/* Единая геометрия существующих компонентов. Подключать после стилей страницы.
   Палитры игр — --sp-*, независимый каркас — --bx-*. Токены — spatial.css.
   Круглыми остаются аватары, маркеры, индикаторы и дорожки прогресса. */
:where(button, input, select, textarea, summary, a) { -webkit-tap-highlight-color: transparent; }
:where(button, [role="button"], input, select, textarea) { box-sizing: border-box; }
:where(button, a, input, select, textarea, summary):focus-visible {
    outline: 2px solid var(--accent-secondary); outline-offset: 3px;
}
:where(button, [role="button"], input, select, textarea, summary) {
    transition: var(--sp-t);
}
:where(button:disabled, input:disabled, select:disabled, textarea:disabled, [aria-disabled="true"]) {
    opacity: .45; cursor: not-allowed;
}
:where(button, [role="button"]):is(:disabled, [aria-disabled="true"], [aria-busy="true"], .is-loading) {
    transform: none; box-shadow: none;
}
:where([aria-busy="true"], .is-loading) { cursor: progress; }

/* Три варианта кнопок доступны обычному HTML и React Button. */
/* display — в :where(): прежние правила скрытия (display:none, [hidden]) остаются сильнее */
:where(.sp-btn, .bx-btn, .auth-btn, .game-cta, .db-more, .dbs-map, .dbs-rnd, .db-tt-go, .cp.db .db-mapgo) { display: inline-flex; }
.sp-btn, .bx-btn, .auth-btn, .game-cta, .db-more, .dbs-map, .dbs-rnd, .db-tt-go, .cp.db .db-mapgo {
    align-items: center; justify-content: center; gap: var(--space-2);
    min-height: var(--control-height); height: var(--control-height); padding: 0 var(--space-5);
    border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
    background: var(--bg-elevated); color: var(--text-primary);
    font-size: 14px; font-weight: 600; line-height: 1.25; text-decoration: none;
    transition: var(--sp-t);
}
.sp-btn:hover, .bx-btn:hover, .auth-btn:hover, .game-cta:hover {
    background: color-mix(in srgb, var(--bg-elevated) 92%, var(--text-primary));
    border-color: var(--accent-secondary); box-shadow: var(--shadow-card); transform: translateY(-1px);
}
.sp-btn.sp-primary, .bx-btn-primary {
    background: var(--accent-primary); color: var(--text-on-accent); border-color: transparent; box-shadow: none;
}
.sp-btn.sp-primary:hover, .bx-btn-primary:hover {
    background: color-mix(in srgb, var(--accent-primary) 92%, white);
    color: var(--text-on-accent); border-color: transparent; box-shadow: var(--glow-lime); transform: translateY(-1px);
}
.sp-btn.sp-ghost, .bx-head-link, .auth-btn.logout {
    background: transparent; color: var(--text-secondary); border-color: transparent; border-radius: var(--radius-lg);
}
.sp-btn.sp-ghost:hover, .bx-head-link:hover, .auth-btn.logout:hover { background: var(--bg-elevated); }
:where(.sp-btn.sp-icon, .sp-btn.sp-round, .bx-round, .bx-icon-btn, .bx-actions .bp-install, .game-fav, .recent-dismiss, .db-lb-nav, .db-lb-x, .db-top, .db-tt-x) { display: inline-grid; }
.sp-btn.sp-icon, .sp-btn.sp-round, .bx-round, .bx-icon-btn, .bx-actions .bp-install, .game-fav, .recent-dismiss, .db-lb-nav, .db-lb-x, .db-top, .db-tt-x {
    place-items: center; width: var(--icon-size); height: var(--icon-size);
    min-width: var(--icon-size); min-height: var(--icon-size); flex: none; padding: 0; border-radius: var(--radius-lg);
}
:is(.sp-icon, .bx-round, .bx-icon-btn, .game-fav, .recent-dismiss) svg { width: 20px; height: 20px; }
.bx-social-btn { border-radius: var(--radius-lg); }
.bx-rail-item, .bx-head-link, .auth-info, .bx-donate { border-radius: var(--radius-lg); }
.auth-info { height: var(--control-height); }
.bx-dialog { border-radius: var(--radius-2xl); padding: var(--space-6); }
.bx-dialog[open] { animation-duration: var(--motion-duration); }
.bx-find-list { border-radius: var(--radius-lg); }
.bx-find-list a { min-height: var(--control-height); border-radius: var(--radius-sm); }
.bx-search {
    height: var(--control-height); gap: var(--space-2); padding-inline: 14px;
    border-radius: var(--radius-lg); background: var(--bg-input); border-color: var(--border-strong);
}
.bx-search input { font-size: 14px; color: var(--text-primary); }
.bx-search input::placeholder { color: var(--text-muted); }
.bx-search:focus-within { border-color: var(--accent-secondary); box-shadow: var(--sp-focus-ring); }

/* Главная: обложки, карточки и раскрытие списка карт. */
.bx-hero { border-radius: var(--radius-3xl); }
.bx-hero-title { font-size: clamp(36px, 4vw, 48px); line-height: 1.1; }
.bx-hero-lead { font-size: 16px; }
.bx-stage-frame, .recent-item, .game-dropdown, .game-suggest-banner { border-radius: var(--radius-xl); }
.bx-badge, .game-new { border-radius: var(--radius-sm); }
.bx-latest { border-radius: var(--radius-lg); gap: var(--space-2); }
.games-container { gap: var(--space-4); }
.game-dropdown { padding: var(--space-3); transition: var(--sp-t); }
.game-banner, .is-list .game-banner { border-radius: var(--radius-lg); }
.game-info { padding: var(--space-3) 0 0; gap: var(--space-3); }
.game-title, .db-game b { font-size: 16px; font-weight: 600; line-height: 1.3; }
.game-dropdown:hover, .game-dropdown[open] {
    transform: translateY(-3px); border-color: var(--accent-secondary); box-shadow: var(--shadow-hover);
}
.game-dropdown:hover .game-banner-art, .db-game:hover .db-game-art { transform: none; }
.game-dropdown:hover .game-cta, .game-dropdown[open] .game-cta { box-shadow: none; }
.game-fav:hover { transform: translateY(-1px); }
.game-fav { top: var(--space-5); right: var(--space-5); background: var(--bg-base); }
/* «Список»: баннер узкий (168 px) — звёздочка в нижний правый угол, чтобы не наезжать на плашку «Скоро · дата» слева сверху */
.is-list .game-fav { top: auto; bottom: var(--space-2); right: var(--space-2); width: 30px; height: 30px; min-width: 30px; min-height: 30px; }
.is-list .game-fav svg { width: 16px; height: 16px; }
.recent-dismiss { top: var(--space-2); right: var(--space-2); }
.recent-item { padding: var(--space-4) 60px var(--space-4) var(--space-4); }
.maps-list { border-radius: var(--radius-lg); padding: var(--space-1); }
.map-link { min-height: var(--control-height); border-radius: var(--radius-sm); }
.is-list .game-info { padding: 0 0 0 var(--space-4); gap: var(--space-4); }
.is-list .game-dropdown > summary { gap: 0; }
.is-list .maps-list { margin: 0; }
.lib-sort button, .view-toggle button {
    height: var(--filter-height); border-radius: var(--radius-md); padding-inline: var(--space-3); font-size: 14px;
}
.view-toggle { padding: var(--space-1); gap: var(--space-1); }
.view-toggle button { width: 36px; padding: 0; }
.bx-cta { border-radius: var(--radius-2xl); }

/* Карты: одни и те же контролы для всех игровых палитр. */
html[data-game] :is(.btn-group button, .io-row button, .add-marker-btn, .auth-mini-btn, .bp-suggest-actions button),
html[data-game] .leaflet-popup :is([class*="-done-btn"], [class*="-link-btn"], [class*="-del-btn"]) {
    min-height: var(--control-height); border-radius: var(--radius-lg); gap: var(--space-2);
    font-size: 14px; font-weight: 600; line-height: 1.25; padding: var(--space-2) var(--space-3);
    transition: var(--sp-t);
}
html[data-game] :is(.map-select, .region-select),
html[data-game] #sidebar input:is([type="text"], [type="search"], [type="number"]),
html[data-game] :is(.bp-note textarea, .bp-suggest textarea) {
    min-height: var(--control-height); border: 1px solid var(--sp-edge); border-radius: var(--radius-lg);
    padding-inline: 14px; color: var(--sp-text); background-color: var(--sp-card); box-shadow: none;
}
html[data-game] :is(input, textarea)::placeholder { color: var(--sp-muted); opacity: 1; }
html[data-game] #sidebar input:focus-visible, html[data-game] :is(select, textarea):focus-visible {
    outline: 2px solid var(--accent-secondary); outline-offset: 2px; box-shadow: var(--sp-focus-ring);
}
html[data-game] :is(.filter-locate, .bp-focus-btn, .bp-layers-btn, .bp-search-clear),
html[data-game] .leaflet-popup a.leaflet-popup-close-button,
html[data-game] .bp-tr > .bp-focus-btn {
    border-radius: var(--radius-lg); width: var(--icon-size); height: var(--icon-size);
    min-width: var(--icon-size); min-height: var(--icon-size); padding: 0; flex-shrink: 0;
}
html[data-game] :is(.progress-card, .auth-mini-box) { border-radius: var(--radius-lg); }
html[data-game] :is(.bp-more-menu, .search-results, .bp-layers-panel), .marker-stack { border-radius: var(--radius-lg); }
html[data-game] .leaflet-popup .leaflet-popup-content-wrapper,
html[data-game] :is(.bp-keys-box, .bp-suggest-box) { border-radius: var(--radius-2xl); }
html[data-game] .leaflet-popup :is([class$="-popup-img"], .bp-pop-body img) { border-radius: var(--radius-lg); }
html[data-game] .leaflet-popup h3 { padding-right: var(--space-12); }
html[data-game] .leaflet-popup [class$="-tags"] > span { border-radius: var(--radius-sm); }
html[data-game] :is(.filter-item, .search-item) { border-radius: var(--radius-md); }
.bp-chip, html[data-game] :is(.map-switch-btn, .zone-btn), .bp-seg a, .bp-seg span {
    min-height: var(--filter-height); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); gap: var(--space-2);
}
.bp-chip[aria-pressed="true"] { background: var(--sp-accent); color: var(--sp-base); }
.bp-seg { border-radius: var(--radius-lg); }
.bp-back-db { border-radius: var(--radius-lg); }

/* База: карточки, каталог, поиск, переключатели и всплывающие панели. */
.cp.db :is(.db-game, .db-card, .db-tal, .db-shots figure) { border-radius: var(--radius-xl); }
.db-game { transition: var(--sp-t); }
.db-game:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.cp.db :is(.db-facts, .db-flavor, .db-fpanel, .db-link, .db-plate, .db-mm) { border-radius: var(--radius-lg); }
.cp.db :is(.db-tag, .db-vcount, .db-fbadge) { border-radius: var(--radius-sm); }
.db-tt, .db-ltt, .db-sug, .db-toast { border-radius: var(--radius-lg); }
.cp.db :is(.db-search, .db-sort), .dbx-search, .dbs-search {
    min-height: var(--control-height); border-radius: var(--radius-lg); border: 1px solid var(--sp-edge);
    background-color: var(--sp-card); color: var(--sp-text);
}
.dbx-search { padding: 0 14px; }
.dbx-search .db-search, .cp.db .dbx-search .db-search, .dbs-search input { min-height: 0; height: 42px; border: 0; border-radius: 0; background: transparent; padding: 0; box-shadow: none; }
.dbx-search:focus-within, .dbs-search:focus-within { box-shadow: var(--sp-focus-ring); }
.cp.db :is(.db-chips button, .db-tabs a, .db-view button, .db-seg button, .db-fbtn, .db-onvar, .db-freset), .dbs-tabs a {
    min-height: var(--filter-height); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); font-size: 14px;
}
.cp.db :is(.db-view, .db-seg) { border-radius: var(--radius-lg); padding: var(--space-1); }
.cp.db .db-chips button.is-on, .cp.db .db-tabs a[aria-selected="true"],
.cp.db .db-view button[aria-pressed="true"], .lib-sort button[aria-pressed="true"] {
    background: var(--accent-primary); color: var(--text-on-accent); box-shadow: none;
}
.cp.db :is(.db-search, input)::placeholder { color: var(--sp-muted); opacity: 1; }
.cp.db .db-shots img { border-radius: var(--radius-lg); }

/* Нажатие не меняет размеры, отключённые действия не приподнимаются. */
:is(.sp-btn, .bx-btn, .auth-btn, .game-cta, .bx-round, .bx-icon-btn, .game-fav):active { transform: translateY(0); box-shadow: none; }
:is(.sp-btn, .bx-btn, .auth-btn, .bx-round, .bx-icon-btn):is(:disabled, [aria-disabled="true"], .is-loading) { transform: none; box-shadow: none; }

@media (max-width: 860px) {
    .bx-head h2 { font-size: 20px; }
    .bx-hero { padding: var(--space-6); gap: var(--space-6); }
    .bx-hero-title { font-size: 32px; }
}
@media (max-width: 560px) {
    /* компактный первый экран телефона (остальное — css/home-neo.css, тот же брейкпоинт) */
    .bx-hero { padding: 16px 14px; gap: 14px; }
    .bx-hero-title { font-size: 25px; }
    .bx-hero-cta { width: 100%; }
    .bx-hero-cta .bx-btn { flex: 1 1 0; }
    /* вид «Список» на телефоне — строка ~100 px: миниатюра 16:9 слева (баннер целиком, логотип не обрезается), текст и прогресс, справа стрелка раскрытия;
       большая обложка и широкая «Выбрать карту» — только в «Плитке» */
    .games-container.is-list { gap: 10px; }
    .is-list .game-dropdown { padding: 14px 12px; }
    .is-list .game-dropdown > summary { flex-wrap: nowrap; align-items: center; gap: 12px; }
    .is-list .game-banner { width: 120px; height: 68px; aspect-ratio: auto; flex: none; border-radius: var(--radius-md); }
    .is-list .game-new { top: 4px; left: 4px; height: auto; min-height: 18px; padding: 2px 6px; font-size: 10px; line-height: 1.15; border-radius: 6px; white-space: nowrap; }
    .is-list .game-new.is-soon { flex-direction: column; align-items: flex-start; }
    .is-list .game-new-sep { display: none; }
    .is-list .game-fav {
        top: 4px; right: 4px; width: 26px; height: 26px; min-width: 26px; min-height: 26px; border-radius: 8px;
        background: color-mix(in srgb, var(--bg-base) 70%, transparent);
    }
    .is-list .game-fav svg { width: 14px; height: 14px; }
    .is-list .game-info { flex: 1; min-width: 0; width: auto; padding: 0; gap: 8px; flex-direction: row; flex-wrap: nowrap; align-items: center; }
    .is-list .game-title-block { flex: 1; gap: 2px; }
    .is-list .game-title { font-size: 15px; line-height: 1.2; overflow-wrap: anywhere; }
    .is-list .game-meta { flex-direction: column; align-items: flex-start; font-size: 12px; line-height: 1.35; }
    .is-list .game-meta i { display: none; }
    .is-list .game-progress { gap: 8px; margin-top: 4px; }
    .is-list .game-progress strong { font-size: 11px; }
    .is-list .game-cta { width: 40px; height: 40px; }
    .cp.db .db-fpanel { border-radius: var(--radius-2xl) var(--radius-2xl) 0 0; }
}
@media (pointer: coarse) {
    :root { --icon-size: 44px; --filter-height: 44px; }
    .view-toggle button { width: 44px; }
    :where(.bx-head-link, .bx-social-btn, .bx-footer-links a, .bx-footer-links button) { display: inline-flex; }
    .bx-head-link, .bx-social-btn, .bx-footer-links a, .bx-footer-links button { min-height: 44px; align-items: center; }
    html[data-game] .filter-item { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto !important; }
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
    .game-dropdown:hover, .game-dropdown[open], .db-game:hover { transform: none; }
}

/* Дополнительные общие элементы: заметки, клавиши, фильтры и кабинет. */
.sp-card { border-radius: var(--radius-xl); }
.sp-field, .cab .sp-field {
    min-height: var(--control-height); padding: var(--space-3) 14px; border-radius: var(--radius-lg);
    border: 1px solid var(--border-strong); background: var(--bg-input); color: var(--text-primary); box-shadow: none;
}
.sp-field::placeholder { color: var(--text-muted); }
.cab .sp-btn { min-height: var(--control-height); height: auto; padding: var(--space-3) var(--space-5); border-radius: var(--radius-lg); font-size: 14px; }
:where(.sp-chip, .cp-chips a) { display: inline-flex; }
.sp-chip, .cp-chips a { min-height: var(--filter-height); border-radius: var(--radius-md); align-items: center; padding: var(--space-2) var(--space-3); }
.fx-kind, .fx-status, .db-meta, .db-spoiler > summary small { border-radius: var(--radius-sm); }
.cp.db :is(.db-back, .db-shot-map, .db-recent-l a, .db-count .db-showvar, .db-also button, .db-copybar button, .db-tree-tabs button) {
    min-height: var(--filter-height); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3);
}
.cp.db :is(.db-fdone, .db-onmap, .dbx-stats a.dbx-map) { min-height: var(--control-height); border-radius: var(--radius-lg); }
.cp.db :is(.db-chips button, .db-seg button, .db-onmap, .db-onvar, .db-fbtn)[aria-pressed="true"] {
    background: var(--accent-primary); color: var(--text-on-accent); box-shadow: none;
}
html[data-game] .marks-filter .mf-chip, html[data-game] .leaflet-popup .bp-flag {
    min-height: var(--filter-height); border-radius: var(--radius-md); gap: var(--space-2); padding: var(--space-2) var(--space-3);
}
html[data-game] .marks-filter .mf-chip.is-on { background: var(--sp-accent); color: var(--sp-base); box-shadow: none; }
html[data-game] .marks-filter .mf-chip.is-on :is(span, b) { color: inherit; }
html[data-game] .leaflet-popup .bp-note button {
    min-height: var(--control-height); border-radius: var(--radius-lg); padding: var(--space-2) var(--space-3); font-size: 14px;
}
html[data-game] :is(.bp-keys-card, .loading-panel, .spl-card) { border-radius: var(--radius-2xl); }
html[data-game] :is(.bp-keys-close, .bp-back-db, .bp-done-panel button) { min-height: var(--control-height); border-radius: var(--radius-lg); }
html[data-game] :is(.bp-only, .search-clear, .bp-more-btn) {
    width: var(--icon-size); height: var(--icon-size); min-width: var(--icon-size); min-height: var(--icon-size);
    border-radius: var(--radius-lg); flex-basis: var(--icon-size); padding: 0;
}
/* У категории две кнопки справа; размер учитывается flex, текст занимает остаток. */
html[data-game] .filter-locate { flex-basis: var(--icon-size); }
html[data-game] .leaflet-popup [class$="-popup-cat"] { padding-right: var(--space-12); }
html[data-game] .bp-tr > .bp-layers-btn { border-radius: var(--radius-lg); }
html[data-game] .leaflet-bar a, html[data-game] .leaflet-bar a:hover {
    width: var(--icon-size); height: var(--icon-size); line-height: var(--icon-size);
}
@media (pointer: coarse) {
    .cp.db :is(.db-tabs a, .db-seg button, .db-chips button) { min-height: 44px; }
}
/* Специфичность совпадает с темами базы, поэтому выбранное состояние читается и в Skyrim/Gothic. */
html[data-game] .cp.db .db-tabs a[aria-selected="true"],
html[data-game] .cp.db :is(.db-chips button, .db-seg button, .db-onmap, .db-onvar, .db-fbtn)[aria-pressed="true"] {
    background: var(--accent-primary); color: var(--text-on-accent); box-shadow: none;
}
/* число под выбранной плиткой раздела — цветом надписи, приглушённо: серый --sp-muted пропадал на акценте игры */
.cp.db .db-tabs a[aria-selected="true"] small { color: inherit; opacity: .72; }
html[data-game] #sidebar input::placeholder { color: var(--sp-muted); opacity: 1; }

/* «Свернуть меню» — только на телефоне (≤480): закреплена внизу боковой панели карты, над ней список растворяется в фон панели.
   Геометрия общая (44 / 12, текст 14/600), цвет — акцент палитры игры (--sp-accent): контур, заливка-оттенок, текст и стрелка.
   .ds-phone — образец в /design/, там кнопка видна на любой ширине. */
.sidebar-collapse-mobile { display: none; }
@media (max-width: 480px) { html[data-game] .sidebar-collapse-mobile { display: flex; } }
.ds-phone .sidebar-collapse-mobile { display: flex; }
:is(html[data-game], .ds-phone) .sidebar-collapse-mobile {
    position: sticky; bottom: var(--space-3); z-index: 3; isolation: isolate; flex: none;
    align-items: center; justify-content: center; gap: var(--space-2);
    /* ширина явно: в Skyrim/Oblivion кнопка лежит в обычном блоке свитка, где <button> с width:auto сжимается по тексту */
    box-sizing: border-box; width: calc(100% - 2 * var(--space-3)); align-self: center; min-height: var(--control-height); height: var(--control-height); margin: auto var(--space-3) var(--space-3); padding: 0 var(--space-5);
    border: 0; border-radius: var(--radius-lg); background: none; color: var(--sp-accent); box-shadow: none;
    font: 600 14px/1.25 var(--font-ui, var(--bx-font)); letter-spacing: normal; text-transform: none; text-shadow: none;
    cursor: pointer; -webkit-tap-highlight-color: transparent; transition: var(--sp-t);
}
/* фон панели под кнопкой: список уходит под неё плавно, а не обрезается полосой */
:is(html[data-game], .ds-phone) .sidebar-collapse-mobile::before {
    content: ""; position: absolute; z-index: -1; left: calc(-1 * var(--space-3)); right: calc(-1 * var(--space-3));
    top: -28px; bottom: calc(-1 * var(--space-3)); pointer-events: none;
    background: linear-gradient(to top, var(--sp-base) 62%, color-mix(in srgb, var(--sp-base) 0%, transparent));
}
:is(html[data-game], .ds-phone) .sidebar-collapse-mobile::after {
    content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
    border: 1px solid color-mix(in srgb, var(--sp-accent) 50%, transparent);
    background: color-mix(in srgb, var(--sp-accent) 14%, var(--sp-base)); box-shadow: var(--shadow-card); transition: var(--sp-t);
}
:is(html[data-game], .ds-phone) .sidebar-collapse-mobile svg {
    width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
}
:is(html[data-game], .ds-phone) .sidebar-collapse-mobile:hover::after { border-color: var(--sp-accent); }
:is(html[data-game], .ds-phone) .sidebar-collapse-mobile:active::after { background: color-mix(in srgb, var(--sp-accent) 24%, var(--sp-base)); box-shadow: none; }
:is(html[data-game], .ds-phone) .sidebar-collapse-mobile:focus-visible { outline: 2px solid var(--sp-accent); outline-offset: 2px; }
