/* Shared gameplay chrome. Individual boards keep their own visual language. */
.game-layout {
    --game-surface: #191b1b;
    --game-inset: #121414;
    --game-border: #343737;
    --game-muted: #a6abab;
    min-width: 0;
    width: 100%;
    max-width: 1180px;
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding-block: 30px 28px;
    color: #f4f3eb;
}

.game-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 22px 20px;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.back-btn {
    grid-column: 1 / -1;
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 13px;
    border: 1px solid var(--game-border);
    border-radius: 6px;
    background: transparent;
    color: #e3e5df;
    font: inherit;
    font-size: 0.875rem;
    line-height: 1.4;
    text-decoration: none;
}

.back-btn:hover {
    border-color: #727979;
    background: #212424;
    color: #fff;
}

.game-topbar-title { min-width: 0; }
.game-layout .game-topbar-title h2:focus { outline: none; }
.game-topbar-title h2 {
    margin: 0 0 10px;
    font-size: clamp(1.9rem, 3.7vw, 3rem);
    font-weight: 650;
    line-height: 1.12;
    letter-spacing: -0.045em;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
}

.game-topbar-title .subtitle {
    display: block;
    color: var(--game-muted);
    font-size: 0.925rem;
    line-height: 1.65;
    white-space: normal;
    overflow: visible;
}

.topbar-badge,
.game-topbar .badge {
    max-width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--game-border);
    border-radius: 5px;
    background: var(--game-surface);
    color: #d6dbcf;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    white-space: normal;
}

.topbar-badges { gap: 6px; justify-content: flex-end; }

.game-main,
.game-main > * { min-width: 0; max-width: 100%; }
.canvas-layout,
.coin-layout-inner,
.poker-layout-inner,
.sudoku-layout-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 316px;
    align-items: start;
    gap: 24px;
}

.game-sidebar {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--game-border);
    border-radius: 12px;
    background: var(--game-surface);
}

.game-sidebar .info-card {
    min-width: 0;
    padding: 19px 21px;
    border: 0;
    border-bottom: 1px solid var(--game-border);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    animation: none;
    transition: none;
}
.game-sidebar .info-card:last-child { border-bottom: 0; }
.game-sidebar .score-card { order: -1; }
#snake-screen .game-layout { max-width: 1040px; }
#snake-screen .game-sidebar .info-card:has(> .btn.sm) {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    min-height: 76px;
}
#snake-screen .game-sidebar .info-card:has(> .btn.sm) :is(.info-label, p) { margin: 0; }
#snake-screen .game-sidebar .info-card:has(> .btn.sm) p { font-size: 0.8125rem; }
#snake-screen .game-sidebar .info-card:last-child {
    display: grid;
    grid-template-columns: 66px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}
#snake-screen .game-sidebar .info-card:last-child :is(.info-label, p) { margin: 0; }
.info-label {
    margin-bottom: 10px;
    color: #c8cdca;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}
.info-card p { margin: 0 0 6px; line-height: 1.55; }
.info-card p:last-child { margin-bottom: 0; }
.info-card .big-num,
.big-num {
    margin: 5px 0 8px;
    color: var(--accent, #d9fa71);
    font-size: 2.5rem;
    line-height: 1;
    font-weight: 650;
    letter-spacing: -0.045em;
    font-variant-numeric: tabular-nums;
    text-shadow: none;
}
.game-layout .muted-sm,
.game-layout .muted { color: var(--game-muted); font-size: 0.8125rem; line-height: 1.65; }

.game-layout .btn,
.game-layout .game-select,
.game-layout .game-input {
    min-height: 40px;
    max-width: 100%;
    border: 1px solid #424848;
    border-radius: 6px;
    background: #202424;
    color: #f4f3eb;
    box-shadow: none;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.4;
    transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}
.game-layout .btn { padding: 9px 14px; }
.game-layout .btn.sm,
.game-layout .btn.small { min-height: 36px; padding: 7px 10px; font-size: 0.75rem; }
.game-layout .btn:hover:not(:disabled) { background: #2c3230; border-color: #6a746d; transform: none; box-shadow: none; }
.game-layout .btn.primary,
.game-layout .btn-group .btn.active {
    border-color: var(--accent, #d9fa71);
    background: var(--accent, #d9fa71);
    color: #152008;
    font-weight: 650;
    box-shadow: none;
}
.game-layout .btn.primary:hover:not(:disabled),
.game-layout .btn-group .btn.active:hover:not(:disabled) { background: var(--accent, #d9fa71); filter: brightness(1.08); }
.game-layout .btn.primary::after { content: none; }
.game-layout .btn.ghost { background: transparent; }
.game-layout .btn:active:not(:disabled) { transform: translateY(1px); }
.game-layout .btn:disabled { opacity: 0.42; cursor: not-allowed; }
.game-layout :is(button, input, select, [tabindex]):focus-visible {
    outline: 2px solid var(--accent, #d9fa71);
    outline-offset: 3px;
    box-shadow: none;
}
.game-layout .btn-group { gap: 7px; margin-top: 6px; }
.game-select,
.game-input { width: 100%; padding: 9px 10px; }
.game-select option { background: #1b1f1c; color: #f4f3eb; }
.game-layout input[type="range"] { accent-color: var(--accent, #d9fa71); min-width: 0; }
.field-row { min-width: 0; flex-wrap: wrap; gap: 8px; margin: 9px 0; }
.field-row > label { flex: 0 0 66px; }
.field-row > .game-select { flex: 1 1 145px; width: auto; }
.checkbox-row { line-height: 1.5; }
.checkbox-row input[type="checkbox"] { flex: 0 0 17px; width: 17px; height: 17px; }
.tag-list { gap: 6px; }
.tag-list li { padding: 4px 7px; border-radius: 4px; background: #252b27; }

/* Frames stay quiet so the board itself receives attention. */
#snake-canvas,
.board-canvas-wrap,
.tetris-board-wrap,
.shooter-board-wrap,
.board-2048,
.sudoku-board,
.coin-stage,
.poker-table,
.merge10-stage,
.ten-helper-panel {
    border: 1px solid var(--game-border);
    border-radius: 12px;
    box-shadow: none;
    animation: none;
}
.board-canvas-wrap,
.tetris-board-wrap,
.shooter-board-wrap { background: #0e1111; }
#snake-canvas,
.board-canvas-wrap canvas,
#tetris-canvas,
#shooter-canvas,
#gomoku-canvas,
#xiangqi-canvas,
#chess-canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    box-shadow: none;
    animation: none;
}
.board-canvas-wrap { width: min(100%, 720px); justify-self: center; }
#snake-canvas { width: 100%; max-width: 720px; justify-self: center; }
.tetris-board-wrap { width: min(100%, 380px); justify-self: center; }
.shooter-board-wrap { width: min(100%, 520px); justify-self: center; }
.board-2048 { width: min(100%, 340px); height: auto; aspect-ratio: 1; justify-self: center; }
.sudoku-layout-inner > .sudoku-board-wrap { flex: none; width: min(100%, 564px); justify-self: center; }
.sudoku-board {
    width: 100%;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    grid-template-rows: none;
    padding: 12px;
}
.sudoku-cell { min-width: 0; aspect-ratio: 1; }
.sudoku-board::before { content: none; }
.sudoku-pad { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
.game-layout .sudoku-pad .btn { min-width: 0; padding-inline: 3px; }
.game-layout .sudoku-pad .sudoku-erase { grid-column: auto; }

.board-overlay,
.board-2048-overlay,
.tetris-overlay,
.shooter-overlay,
.sudoku-overlay {
    background: rgba(12, 15, 13, 0.9);
    backdrop-filter: blur(4px);
    border-radius: inherit;
}
.overlay-card {
    max-width: 100%;
    padding: 22px;
    border: 1px solid #464d47;
    border-radius: 10px;
    background: #1a1f1b;
    box-shadow: none;
}
.overlay-title { margin-bottom: 10px; font-size: 1.65rem; letter-spacing: -0.025em; color: #f4f3eb; }
.overlay-desc { color: #bdc4bc; font-size: 0.875rem; line-height: 1.6; }
.overlay-actions { flex-wrap: wrap; gap: 9px; }

.coin-stage,
.poker-table,
.merge10-stage,
.ten-helper-panel { background: var(--game-inset); }
.coin-stage { min-height: 550px; justify-content: center; padding: 32px 24px; gap: 25px; }
.coin-predict-btn { min-height: 40px; border-radius: 6px; }
.coin-actions { flex-wrap: wrap; justify-content: center; }
.coin-history { margin-bottom: 0; }
.coin-history li { background: #232823; border-radius: 5px; }
.poker-table { padding: 24px; }
.poker-table::before { content: none; }
.poker-row { gap: 12px; }
.poker-row-label { color: #c9ceca; }
.poker-results { gap: 16px; }
.poker-stat-card { border-color: var(--game-border); border-radius: 8px; box-shadow: none; background: #1b211c; }
.poker-deck { max-width: 100%; overflow-x: auto; scrollbar-width: thin; padding-bottom: 6px; }
.poker-deck-row { min-width: 382px; }
.poker-card-slot { box-shadow: none; }
.poker-card-slot.selected { outline: 2px solid var(--accent, #d9fa71); outline-offset: 2px; }
.poker-card-btn { min-height: 32px; }
.equity-ring { animation: none; box-shadow: none; }
.tetris-mini { background: #111612; border-color: var(--game-border); }
.tetris-energy-bar { background: #2d352d; border-radius: 4px; }
.tetris-energy-fill { background: var(--accent, #d9fa71); box-shadow: none; }
.move-history { color: #b9c2b9; font-size: 0.8125rem; }

.merge10-stage { padding: 22px; }
.ten-helper-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.ten-helper-panel { padding: 22px; }
.ten-helper-panel-head { flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.ten-helper-panel-head h3 { font-size: 1rem; font-weight: 600; }
.ten-helper-controls label { text-transform: none; letter-spacing: 0; font-size: 0.8rem; font-weight: 500; }
.ten-helper-summary { border-color: var(--game-border); background: #1a201b; border-radius: 6px; }
.ten-ocr-card { border: 1px dashed #434d45; background: #1a201b; border-radius: 8px; padding: 12px; margin-bottom: 18px; }
.ten-ocr-canvas { max-width: 100%; }
.ten-ocr-canvas[hidden] { display: none; }
.ten-helper-grid { max-width: 100%; }
.ten-helper-grid input { font-size: 1rem; }

@media (max-width: 1000px) {
    .canvas-layout,
    .coin-layout-inner,
    .poker-layout-inner,
    .sudoku-layout-inner { grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; }
    .game-sidebar .info-card { padding: 17px; }
    .poker-results { grid-template-columns: minmax(0, 1fr); }
    .ten-helper-panel { padding: 16px; }
}

@media (max-width: 760px) {
    .game-layout { padding-block: 25px 38px; gap: 23px; }
    .game-topbar { gap: 20px 12px; }
    .game-topbar-title h2 { font-size: clamp(1.85rem, 6.5vw, 2.5rem); }
    .game-topbar-title .subtitle { font-size: 0.8125rem; }
    .game-topbar > .topbar-badge,
    .game-topbar > .topbar-badges { grid-column: 1 / -1; justify-self: start; margin-top: -8px; }
    .topbar-badges { justify-content: flex-start; }
    .game-topbar-title { grid-column: 1 / -1; }
    .canvas-layout,
    .coin-layout-inner,
    .poker-layout-inner,
    .sudoku-layout-inner,
    .ten-helper-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .game-sidebar { width: 100%; }
    .game-sidebar .info-card { padding: 18px; }
    .game-layout .btn { min-height: 42px; }
    .game-layout .btn.sm,
    .game-layout .btn.small { min-height: 38px; }
    .game-layout .game-select,
    .game-layout .game-input { min-height: 42px; font-size: 1rem; }
    .coin-stage { min-height: 440px; padding: 26px 16px; }
    .coin-particles { width: min(320px, 85vw); height: min(320px, 85vw); }
    .poker-table { padding: 18px; }
    .poker-results { grid-template-columns: minmax(0, 1fr); }
    .poker-slot-row.board { gap: 5px; }
    .poker-card-slot.small { width: clamp(38px, 10.4vw, 62px); height: clamp(57px, 15.5vw, 88px); border-radius: 6px; }
    .poker-card-slot.small .poker-card-rank { font-size: 1rem; }
    .poker-card-slot.small .poker-card-suit { font-size: 1.2rem; }
    .poker-card-slot { width: 74px; height: 104px; }
    .merge10-stage,
    .ten-helper-panel { padding: 12px; }
    .ten-helper-grid,
    .merge10-board { gap: 3px; }
    .ten-helper-grid input { font-size: 1rem; }
    .ten-helper-controls { grid-template-columns: minmax(0, 1fr); }
    .ten-ocr-actions { gap: 8px; }
    .sudoku-board { padding: 6px; border-radius: 9px; }
    .sudoku-cell { font-size: clamp(0.9rem, 3.9vw, 1.35rem); }
    .sudoku-cell.has-cage-sum::before { font-size: 0.45rem; left: 2px; top: 1px; }
    .sudoku-notes { font-size: 0.45rem; gap: 0; padding: 1px; }
    .overlay-card { padding: 18px 14px; }
    .overlay-title { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
    .game-layout *,
    .game-layout *::before,
    .game-layout *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
