/* Шашки VK Mini App — премиум-тема: глубокий синий + золото + свечение.
   Тема единая (тёмная) вне зависимости от схемы VK — дизайн-решение. */
:root {
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius: 16px;

    --bg-0: #0a1c4a;
    --bg-1: #050d24;
    --text: #eef3ff;
    --text-dim: #8fa3c8;

    --gold-1: #f6df9c;
    --gold-2: #d4a941;
    --gold-3: #9c7420;

    --blue: #2f7dff;
    --cyan: #45c4ff;

    --panel: rgba(16, 36, 84, .55);
    --panel-2: rgba(20, 44, 100, .75);
    --panel-border: rgba(96, 152, 255, .32);
    --panel-glow: 0 0 18px rgba(47, 125, 255, .18), inset 0 1px 0 rgba(255,255,255,.06);

    --sq-light: #e6cfa4;
    --sq-dark: #22345c;
    --frame: linear-gradient(160deg, #e9c877, #a8791f 55%, #d8b45c);

    --red-1: #ff7466; --red-2: #d63a2b; --red-3: #8f1d13;
    --ivory-1: #fffdf2; --ivory-2: #efdfb8; --ivory-3: #b7a173;

    --sel: rgba(69, 196, 255, .8);
    --hint: rgba(69, 196, 255, .65);
    --cap: rgba(255, 94, 78, .75);
}

* {
    box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent;
    /* Игровое поле: без выделения текста/каллаута — иначе тап/свайп по доске триггерит
       системное выделение или контекстное меню (требования Яндекс Игр п. 1.6.1.8/1.6.2.7). */
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior-y: none; }
body {
    font-family: var(--font);
    color: var(--text);
    font-size: 15px; line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
    touch-action: pan-x pan-y;
    background:
        radial-gradient(120% 70% at 50% -10%, rgba(63, 118, 255, .28), transparent 60%),
        radial-gradient(90% 60% at 50% 115%, rgba(38, 90, 210, .20), transparent 60%),
        linear-gradient(180deg, var(--bg-0), var(--bg-1) 70%);
    background-attachment: fixed;
}
.hidden { display: none !important; }
/* Фиксируем приложение по визуальному viewport: это исключает двойной скролл
   внутри VK iframe и скачки высоты при появлении мобильных панелей. */
#app {
    width: 100%; height: 100%; height: 100dvh; min-height: 0;
    display: flex; flex-direction: column; overflow: hidden;
}
.screen {
    flex: 1 1 auto; min-width: 0; min-height: 0;
    display: flex; flex-direction: column;
    overflow-x: hidden; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding:
        max(16px, env(safe-area-inset-top))
        max(16px, env(safe-area-inset-right))
        max(16px, env(safe-area-inset-bottom))
        max(16px, env(safe-area-inset-left));
}

/* --- Меню --- */
/* safe center: центрирует, если влезает; при переполнении прижимает к верху (не обрезает, скроллится) */
#screen-menu {
    align-items: center; justify-content: safe center; gap: 8px;
    overscroll-behavior-y: contain;
}
.menu-title {
    font-size: 52px; font-weight: 800; letter-spacing: 1px;
    background: linear-gradient(180deg, var(--gold-1) 20%, var(--gold-2) 62%, var(--gold-3));
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 3px 12px rgba(212, 169, 65, .35));
}
.menu-subtitle {
    font-size: 12px; font-weight: 700; letter-spacing: 2.4px; text-transform: uppercase;
    color: var(--text-dim); margin: -2px 0 26px;
    text-align: center;
}

.menu-actions { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.mode-card {
    display: flex; align-items: center; gap: 14px; text-align: left;
    font-family: var(--font); color: var(--text); cursor: pointer;
    background: var(--panel); border: 1.5px solid var(--panel-border); border-radius: 18px;
    padding: 16px; box-shadow: var(--panel-glow);
    transition: transform .07s ease, border-color .15s ease, box-shadow .15s ease;
}
.mode-card:active { transform: scale(.98); }
.mode-card-primary {
    border-color: rgba(96, 165, 255, .65);
    box-shadow: 0 0 26px rgba(47, 125, 255, .35), inset 0 1px 0 rgba(255,255,255,.08);
    background: linear-gradient(165deg, rgba(41, 84, 190, .55), rgba(16, 36, 84, .6));
}
.mode-icon {
    flex: none; width: 52px; height: 52px; border-radius: 14px;
    background: rgba(8, 18, 44, .6); border: 1px solid var(--panel-border);
    display: flex; align-items: center; justify-content: center;
}
.mode-icon .over { margin-left: -10px; }
.mode-name { display: block; font-size: 17px; font-weight: 800; }
.mode-sub { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

/* Мини-шашки (иконки в меню и панели сбитых) */
.mini-piece {
    display: inline-block; width: 22px; height: 22px; border-radius: 50%;
    box-shadow: inset 0 2px 3px rgba(255,255,255,.45), inset 0 -3px 4px rgba(0,0,0,.35), 0 2px 4px rgba(0,0,0,.45);
    vertical-align: middle;
}
.mini-piece.red { background: radial-gradient(circle at 35% 30%, var(--red-1), var(--red-2) 60%, var(--red-3)); }
.mini-piece.ivory { background: radial-gradient(circle at 35% 30%, var(--ivory-1), var(--ivory-2) 60%, var(--ivory-3)); }
.mini-piece.chip-ai { width: 30px; height: 30px; box-shadow: inset 0 2px 3px rgba(255,255,255,.45), inset 0 -3px 4px rgba(0,0,0,.3), 0 0 12px rgba(69,196,255,.8); }

/* Статистика в меню */
.menu-stats {
    display: flex; align-items: stretch; gap: 4px; margin-top: 26px;
    background: var(--panel); border: 1.5px solid var(--panel-border); border-radius: 14px;
    padding: 12px 8px; box-shadow: var(--panel-glow);
}
.stat-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-item b { font-size: 22px; font-weight: 800; color: var(--gold-1); }
.stat-item span { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.stat-sep { width: 1px; background: var(--panel-border); }

.rules-link {
    margin-top: 20px; background: none; border: none; cursor: pointer;
    color: var(--text-dim); font-family: var(--font); font-size: 14px; font-weight: 600; text-decoration: underline;
}

.btn {
    font-family: var(--font); font-size: 16px; font-weight: 700;
    border: none; border-radius: var(--radius); padding: 15px 18px;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: transform .06s ease, opacity .15s ease;
    color: var(--text);
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary {
    background: linear-gradient(180deg, #3f8bff, #2059d8);
    box-shadow: 0 0 22px rgba(47, 125, 255, .45), inset 0 1px 0 rgba(255,255,255,.25);
    color: #fff;
}
.btn-secondary { background: var(--panel-2); border: 1.5px solid var(--panel-border); box-shadow: var(--panel-glow); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.badge { font-size: 11px; font-weight: 700; background: rgba(96,152,255,.18); color: var(--text-dim); padding: 2px 8px; border-radius: 999px; }

/* --- Сложность --- */
.difficulty { margin-top: 26px; width: 100%; max-width: 380px; text-align: center; }
.difficulty-label { font-size: 12px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 10px; }
.level-list { display: flex; flex-direction: column; gap: 8px; }
.level-item {
    display: flex; align-items: center; gap: 12px; text-align: left;
    background: var(--panel); border: 1.5px solid var(--panel-border); border-radius: 14px;
    padding: 10px 14px; cursor: pointer; font-family: var(--font); color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.level-item .level-ico { font-size: 20px; width: 28px; text-align: center; }
.level-text { flex: 1; display: flex; flex-direction: column; }
.level-text b { font-size: 15px; font-weight: 800; }
.level-text i { font-style: normal; font-size: 12px; color: var(--text-dim); }
.level-check { color: var(--cyan); font-weight: 800; font-size: 17px; opacity: 0; transition: opacity .15s ease; }
.level-item.active {
    border-color: rgba(96, 185, 255, .8);
    box-shadow: 0 0 18px rgba(47, 125, 255, .35), inset 0 1px 0 rgba(255,255,255,.06);
}
.level-item.active .level-check { opacity: 1; }

/* --- Игра --- */
.game-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.icon-btn {
    width: 42px; height: 42px; border-radius: 13px; cursor: pointer;
    border: 1.5px solid var(--panel-border); background: var(--panel); color: var(--text);
    font-size: 22px; display: flex; align-items: center; justify-content: center;
    box-shadow: var(--panel-glow);
}
.status {
    flex: 1; text-align: center; font-weight: 800; font-size: 14px; letter-spacing: .4px;
    background: var(--panel); border: 1.5px solid var(--panel-border); border-radius: 999px;
    padding: 9px 14px; box-shadow: var(--panel-glow);
}

/* Панель соперника над доской */
.opp-bar {
    display: flex; align-items: center; gap: 12px;
    max-width: min(88vw, 454px); width: 100%; margin: 0 auto 12px;
    background: var(--panel); border: 1.5px solid var(--panel-border); border-radius: 16px;
    padding: 8px 14px; box-shadow: var(--panel-glow);
    transition: border-color .2s ease, box-shadow .2s ease;
}
.opp-ava {
    flex: none; width: 40px; height: 40px; border-radius: 50%;
    background: rgba(8, 18, 44, .6); border: 1.5px solid var(--panel-border);
    display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.opp-meta { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.opp-name { font-size: 15px; font-weight: 800; }
.opp-sub { font-size: 12px; color: var(--text-dim); }
.opp-turn { flex: none; }
.turn-dot { display: block; width: 10px; height: 10px; border-radius: 50%; background: #3a4a6b; transition: background .2s ease, box-shadow .2s ease; }
.opp-bar.thinking { border-color: rgba(96, 185, 255, .7); box-shadow: 0 0 18px rgba(47, 125, 255, .3), inset 0 1px 0 rgba(255,255,255,.06); }
.opp-bar.thinking .turn-dot { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); animation: dotPulse 1s ease-in-out infinite; }
@keyframes dotPulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }

.board-wrap { display: flex; justify-content: center; }
.board-frame {
    padding: 7px; border-radius: 22px;
    background: var(--frame);
    box-shadow: 0 14px 40px rgba(3, 8, 24, .6), 0 0 30px rgba(47, 125, 255, .12);
}
.board {
    /* Ограничение И по высоте: иначе на десктопном/ландшафтном фрейме доска высокая
       и нижние кнопки уезжают за экран (замечание модерации). ~300px под шапку/панель/контролы. */
    /* Запас учитывает шапку, панель соперника, сбитые, кнопки И нижний футер с
       отступами. При добавлении блоков под доской его надо увеличивать, иначе низ
       обрежется в невысоком VK-фрейме. */
    width: min(88vw, 440px, calc(100dvh - 320px)); aspect-ratio: 1;
    display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
    border-radius: 15px; overflow: hidden;
    touch-action: manipulation;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.35);
}
.sq { position: relative; display: flex; align-items: center; justify-content: center; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.playable { cursor: pointer; }
.sq.keyboard-action:focus-visible {
    outline: 3px solid #fff;
    outline-offset: -4px;
    z-index: 4;
}

/* Координаты по краям доски */
.coord { position: absolute; font-size: 9px; font-weight: 800; opacity: .55; pointer-events: none; user-select: none; z-index: 1; }
.coord-rank { top: 2px; left: 3px; }
.coord-file { bottom: 1px; right: 3px; }
.sq.light .coord { color: #7a5f34; }
.sq.dark .coord { color: #8ea3cc; }

/* Исчезновение сбитой шашки */
.piece.capfade { position: absolute; width: 78%; height: 78%; z-index: 3; animation: capFade .4s ease-out forwards; pointer-events: none; }
@keyframes capFade { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.4); } }

.piece {
    width: 78%; height: 78%; border-radius: 50%; position: relative;
    box-shadow:
        inset 0 3px 5px rgba(255,255,255,.5),
        inset 0 -5px 7px rgba(0,0,0,.4),
        0 4px 8px rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    transition: transform .12s ease;
}
.piece::before {
    content: ''; position: absolute; inset: 18%;
    border-radius: 50%; border: 2px solid rgba(0,0,0,.18);
    box-shadow: inset 0 1px 2px rgba(255,255,255,.25);
}
.piece.w { background: radial-gradient(circle at 35% 28%, var(--ivory-1), var(--ivory-2) 58%, var(--ivory-3)); }
.piece.b { background: radial-gradient(circle at 35% 28%, var(--red-1), var(--red-2) 58%, var(--red-3)); }
.piece.b::before { border-color: rgba(0,0,0,.28); }
.piece.king::after {
    content: '♛'; position: relative; z-index: 1; font-size: 58%;
    background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.55));
}

.sq.sel::before { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px var(--sel), inset 0 0 16px rgba(69,196,255,.45); z-index: 1; }
.sq.hint::after { content: ''; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: var(--hint); box-shadow: 0 0 12px rgba(69,196,255,.8); z-index: 1; }
.sq.hint.hint-cap::after { width: 84%; height: 84%; background: transparent; box-shadow: inset 0 0 0 3px var(--cap), 0 0 12px rgba(255,94,78,.5); }
/* Подсказка: этой фигурой обязателен бой */
.sq.must::before { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px var(--cap); animation: mustPulse 1.1s ease-in-out infinite; z-index: 1; }
@keyframes mustPulse { 0%,100% { opacity: .3; } 50% { opacity: .9; } }
/* Лучший ход (кнопка «Подсказка») */
.sq.hint-best::before {
    content: ''; position: absolute; inset: 0; z-index: 1;
    box-shadow: inset 0 0 0 3px rgba(246, 223, 156, .95), inset 0 0 18px rgba(212, 169, 65, .55);
    animation: bestPulse .8s ease-in-out infinite;
}
@keyframes bestPulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }

/* --- Панель под доской --- */
.under-board { max-width: min(88vw, 454px); width: 100%; margin: 14px auto 0; display: flex; flex-direction: column; gap: 10px; }
.captured-panel {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    background: var(--panel); border: 1.5px solid var(--panel-border); border-radius: 14px;
    padding: 9px 14px; box-shadow: var(--panel-glow);
}
.captured-label { font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--text-dim); margin-right: 4px; }
.cap-item { display: inline-flex; align-items: center; gap: 7px; font-size: 15px; font-weight: 800; }
.cap-item .mini-piece { width: 20px; height: 20px; }

.actions-row { display: flex; gap: 10px; }
.btn-panel {
    flex: 1; position: relative; padding: 12px 10px; font-size: 14px;
    background: var(--panel-2); border: 1.5px solid var(--panel-border); box-shadow: var(--panel-glow);
}
.count-badge {
    position: absolute; top: -7px; right: -6px; min-width: 20px; height: 20px; border-radius: 999px;
    background: linear-gradient(180deg, #ff6a5e, #d63a2b); color: #fff;
    font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 5px;
    box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

/* Эмодзи-реакции (PvP) */
.react-row { display: flex; justify-content: center; gap: 10px; }
.react-btn {
    width: 46px; height: 46px; border-radius: 50%; font-size: 22px; cursor: pointer;
    background: var(--panel-2); border: 1.5px solid var(--panel-border); box-shadow: var(--panel-glow);
    display: flex; align-items: center; justify-content: center;
    transition: transform .07s ease;
}
.react-btn:active { transform: scale(.9); }
.react-float {
    position: fixed; left: 50%; z-index: 70; pointer-events: none;
    font-size: 54px; transform: translateX(-50%);
    filter: drop-shadow(0 4px 12px rgba(0,0,0,.5));
}
.react-float.mine { bottom: 20%; }
.react-float.opp { top: 16%; }
.react-float.pop { animation: reactPop 1.7s ease-out forwards; }
@keyframes reactPop {
    0% { opacity: 0; transform: translateX(-50%) scale(.4); }
    12% { opacity: 1; transform: translateX(-50%) scale(1.15); }
    22% { transform: translateX(-50%) scale(1); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-40px) scale(.9); }
}

.game-footer { margin-top: 12px; text-align: center; color: var(--text-dim); font-size: 13px; min-height: 20px; }

/* --- Комната PvP --- */
.room-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.room-illus {
    font-size: 60px; margin-bottom: 4px;
    filter: drop-shadow(0 6px 16px rgba(0,0,0,.4));
    animation: roomFloat 2.6s ease-in-out infinite;
}
@keyframes roomFloat { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
.room-code-label { color: var(--text-dim); font-size: 13px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; }
.room-code {
    font-size: 44px; font-weight: 800; letter-spacing: 10px; cursor: pointer;
    background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 2px 10px rgba(212,169,65,.3));
    border: none; font-family: var(--font); padding: 4px 12px;
    transition: transform .07s ease;
}
.room-code:active { transform: scale(.96); }
.room-hint { color: var(--text-dim); font-size: 12.5px; margin-top: -6px; }
.room-status { color: var(--text-dim); font-size: 14px; display: flex; align-items: center; gap: 9px; margin-top: 4px; }
.room-spinner {
    width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid rgba(96,152,255,.3); border-top-color: var(--cyan);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.room-body .btn-primary { min-width: 240px; }

/* Кнопки шеринга на финальном оверлее */
.share-row { display: flex; gap: 10px; }
.share-row .btn { flex: 1; padding: 12px 10px; font-size: 15px; }

/* --- Оверлей --- */
.overlay {
    position: fixed; inset: 0; background: rgba(3, 8, 22, .72); backdrop-filter: blur(3px);
    display: flex; align-items: safe center; justify-content: center; z-index: 50;
    overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding:
        max(20px, env(safe-area-inset-top))
        max(20px, env(safe-area-inset-right))
        max(20px, env(safe-area-inset-bottom))
        max(20px, env(safe-area-inset-left));
}
.overlay-card {
    background: linear-gradient(170deg, rgba(24, 48, 108, .96), rgba(9, 20, 48, .97));
    border: 1.5px solid var(--panel-border);
    border-radius: 22px; padding: 28px 24px; width: 100%; max-width: 330px; text-align: center;
    flex: 0 0 auto; display: flex; flex-direction: column; gap: 12px;
    box-shadow: 0 18px 60px rgba(0,0,0,.55), 0 0 34px rgba(47,125,255,.18);
}
.overlay-emoji { font-size: 56px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.overlay-title {
    font-size: 26px; font-weight: 800; margin-bottom: 6px;
    background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.overlay-score { font-size: 14px; color: var(--text-dim); font-weight: 700; margin-top: -6px; }

/* Кнопка «Сдаться» в PvP */
.resign-btn {
    align-self: center; margin-top: 4px; padding: 8px 20px; cursor: pointer;
    background: none; border: 1px solid var(--panel-border); border-radius: 999px;
    color: var(--text-dim); font-family: var(--font); font-size: 13px; font-weight: 700;
}
.resign-btn:active { transform: scale(.97); }
.rules-card { text-align: left; max-width: 360px; }
.rules-card .overlay-title { text-align: center; }
.rules-list { margin: 4px 0 4px; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; color: var(--text-dim); font-size: 14px; line-height: 1.4; }
.rules-list li { padding-left: 2px; }

/* --- Toast --- */
.toast {
    position: fixed; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%);
    background: rgba(10, 24, 58, .95); color: var(--text);
    border: 1px solid var(--panel-border);
    padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 60;
    box-shadow: 0 4px 16px rgba(0,0,0,.45);
}

/* ================= Десктоп: раскладка в три колонки =================
   VK/Яндекс отдают игре широкое окно, но мобильная колонка оставляла по бокам
   пустое поле. На широком экране раскладываем экран игры как настольный клиент:
   слева соперник, по центру крупная доска, справа сбитые + управление.
   Мобильная раскладка (по умолчанию) не трогается — только min-width. */
/* Брейкпоинт 1024: ниже него две боковые колонки + крупная доска не помещаются
   по горизонтали и лезли бы друг на друга. VK/Яндекс на десктопе дают заметно шире. */
/* ================= Невысокий фрейм: компактное меню =================
   VK-фрейм часто ниже 700px — ужимаем отступы, чтобы меню и низ экрана влезали. */
@media (max-height: 800px) {
    .screen {
        padding:
            max(10px, env(safe-area-inset-top))
            max(16px, env(safe-area-inset-right))
            max(10px, env(safe-area-inset-bottom))
            max(16px, env(safe-area-inset-left));
    }
    #screen-menu { gap: 4px; }
    .menu-title { font-size: 32px; }
    .menu-subtitle { margin: -2px 0 8px; }
    .menu-actions { gap: 8px; }
    .mode-card { padding: 10px 14px; }
    .mode-icon { width: 44px; height: 44px; }
    .difficulty { margin-top: 10px; }
    .difficulty-label { margin-bottom: 6px; }
    .level-list { gap: 6px; }
    .level-item { padding: 6px 14px; }
    .rules-link { margin-top: 10px; }
}
@media (max-height: 650px) {
    .menu-title { font-size: 26px; }
    .menu-subtitle { display: none; }
    .mode-icon { width: 38px; height: 38px; }
    .level-item { padding: 5px 12px; }
}
@media (max-height: 560px) {
    .menu-title { font-size: 22px; }
    .mode-card { padding: 8px 12px; }
    .mode-icon { width: 34px; height: 34px; }
    .level-item { padding: 4px 12px; }
    .difficulty { margin-top: 8px; }
    .rules-link { margin-top: 6px; }
}

/* Порог 900: реальный VK-фрейм на десктопе ~993px — при 1024 он не попадал
   в трёхколоночную раскладку и получал мобильную колонку. */
@media (min-width: 900px) {
    #screen-game {
        display: grid;
        grid-template-columns: minmax(200px, 280px) auto minmax(200px, 280px);
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "header header header"
            "left   board  right";
        align-content: center; justify-content: center;
        column-gap: 32px; row-gap: 20px;
        max-width: 1180px; margin: 0 auto; width: 100%;
    }
    #screen-game > .game-header { grid-area: header; }

    /* Панель соперника — карточка вверху левой колонки. */
    #screen-game > .opp-bar {
        grid-area: left; align-self: start; margin: 0; max-width: none;
    }

    #screen-game > .board-wrap { grid-area: board; align-self: center; }
    /* Доску ограничиваем и высотой окна, и шириной центральной колонки — чтобы на
       узком десктопе (~1024) она не выдавливала боковые панели. */
    /* 66vh, а не больше: в сетке ещё есть шапка, футер и вертикальные отступы —
       на низких фреймах (520px) при 70vh экран переполнялся. */
    #screen-game > .board-wrap .board { width: min(66vh, 44vw, 560px); }

    /* Сбитые + управление — правая колонка, элементы друг под другом. */
    #screen-game > .under-board {
        grid-area: right; align-self: start; margin: 0; max-width: none;
    }
    #screen-game > .under-board .actions-row { flex-direction: column; }

    #screen-game > .game-footer { grid-column: 1 / -1; }
}
