
        /* ===============================================================
           2048 — Nyza Games
           Polished tile-slide build with absolutely-positioned tiles,
           CSS transform animation, undo budget, pause, celebration.
           =============================================================== */

        /* ---- Settings panel (difficulty / grid) ---- */
        .settings-bar {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            justify-content: center;
            margin-bottom: 0.5rem;
            max-width: 460px;
        }
        .setting-group {
            display: flex;
            align-items: center;
            gap: 0.3rem;
            background: var(--t-card-bg);
            border: 1px solid var(--t-card-border);
            border-radius: 30px;
            padding: 0.3rem 0.45rem;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 3px 12px rgba(0,0,0,0.06);
        }
        .setting-label {
            font-family: 'Orbitron', monospace;
            font-size: 0.5rem;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            color: var(--t-text-muted);
            padding-left: 0.4rem;
        }
        .setting-btn {
            padding: 0.32rem 0.7rem;
            border: none;
            border-radius: 20px;
            font-family: inherit;
            font-size: 0.7rem;
            font-weight: 600;
            cursor: pointer;
            background: transparent;
            color: var(--t-text);
            transition: all 0.18s;
        }
        .setting-btn.active {
            background: linear-gradient(135deg, #f59563, #f67c5f);
            color: #fff;
            box-shadow: 0 2px 10px rgba(245,124,95,0.4);
        }
        .setting-btn:hover:not(.active):not(:disabled) { background: rgba(245,124,95,0.12); }
        .setting-btn:disabled { opacity: 0.4; cursor: not-allowed; }

        /* ---- Action buttons ---- */
        .action-bar {
            display: flex;
            gap: 0.5rem;
            justify-content: center;
            margin-bottom: 0.5rem;
            flex-wrap: wrap;
        }
        .action-btn {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            padding: 0.5rem 0.95rem;
            border: 1px solid var(--t-glass-border);
            border-radius: 30px;
            background: var(--t-card-bg);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            font-family: inherit;
            font-size: 0.75rem;
            font-weight: 600;
            color: var(--t-text);
            cursor: pointer;
            transition: all 0.18s;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 3px 10px rgba(0,0,0,0.06);
        }
        .action-btn:hover:not(:disabled) {
            transform: translateY(-1px);
            background: rgba(245,124,95,0.12);
            border-color: rgba(245,124,95,0.35);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.45), 0 5px 14px rgba(245,124,95,0.18);
        }
        .action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
        .action-btn svg { width: 14px; height: 14px; }
        .undo-count {
            display: inline-block;
            min-width: 18px;
            padding: 1px 6px;
            background: linear-gradient(135deg, #f59563, #f67c5f);
            color: #fff;
            border-radius: 99px;
            font-family: 'Orbitron', monospace;
            font-size: 0.55rem;
            font-weight: 800;
        }

        /* ---- Stats row ---- */
        .stats-row {
            display: flex;
            gap: 0.5rem;
            justify-content: center;
            margin-bottom: 0.5rem;
            flex-wrap: wrap;
        }
        .stat {
            text-align: center;
            padding: 0.4rem 0.9rem;
            background: var(--t-card-bg);
            border: 1px solid var(--t-card-border);
            border-radius: 12px;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 2px 8px rgba(0,0,0,0.06);
            min-width: 70px;
        }
        .stat-label {
            font-family: 'Orbitron', monospace;
            font-size: 0.5rem;
            text-transform: uppercase;
            letter-spacing: 0.13em;
            color: var(--t-text-muted);
        }
        .stat-value {
            font-family: 'Orbitron', monospace;
            font-size: 1rem;
            font-weight: 700;
            color: var(--t-text);
            margin-top: 0.15rem;
        }

        /* ---- Score popup ---- */
        .score-popup {
            position: absolute;
            font-family: 'Orbitron', monospace;
            font-weight: 800;
            font-size: 1.1rem;
            color: #d4a017;
            pointer-events: none;
            text-shadow: 0 0 10px rgba(237,194,46,0.6), 0 2px 4px rgba(0,0,0,0.2);
            animation: scoreFloat 0.95s ease-out forwards;
            z-index: 30;
        }
        @keyframes scoreFloat {
            0%   { transform: translate(-50%, 0) scale(0.7); opacity: 0; }
            18%  { transform: translate(-50%, -6px) scale(1.2); opacity: 1; }
            100% { transform: translate(-50%, -46px) scale(1); opacity: 0; }
        }
        @keyframes scoreNumPop {
            0%   { transform: scale(1); }
            45%  { transform: scale(1.18); color: #d4a017; }
            100% { transform: scale(1); }
        }
        .score-value.pop { animation: scoreNumPop 0.35s ease-out; }

        /* ---- Board (absolute-tile build) ---- */
        .board-wrap {
            position: relative;
            /* MOBILE / narrow base: board fills the width left after the page
               chrome, also capped by viewport height so board + on-screen chrome
               fit with no scroll. The horizontal chrome is FIXED (body 1rem×2 +
               .game-layout 0.75rem×2 = 56px), so a flat 92vw overshot it and the
               board overflowed sideways a few px; subtract the real 56px instead.
               dvh handles mobile browser chrome; the cap feeds through width (not
               max-height) so aspect-ratio:1 keeps it square and tiles auto-scale. */
            width: min(640px, calc(100vw - 56px), calc(100dvh - 300px));
            max-width: 640px;
            aspect-ratio: 1;
            touch-action: none;
        }
        /* DESKTOP fill-the-screen: the board grows to fill the viewport HEIGHT
           while the 340px rail consumes the leftover horizontal space. Width is
           the min of (a) the height-bound square and (b) the horizontal budget
           after the rail+gaps+page padding. Capped at 900px for huge monitors. */
        @media (min-width: 900px) {
            .board-wrap {
                width: min(
                    900px,
                    calc(100dvh - 130px),
                    calc(100vw - 340px - 22px - 36px)
                );
                max-width: 900px;
            }
        }
        .board {
            position: relative;
            width: 100%;
            height: 100%;
            padding: var(--gap);
            background: rgba(187,173,160,0.85);
            border-radius: 14px;
            box-shadow:
                inset 0 2px 8px rgba(0,0,0,0.18),
                inset 0 -1px 4px rgba(255,255,255,0.08),
                0 14px 44px rgba(0,0,0,0.22),
                0 0 0 6px rgba(187,173,160,0.45);
            box-sizing: border-box;
            transition: opacity 0.3s, filter 0.3s;
            --gap: 10px;
        }
        .board::before {
            content: '';
            position: absolute;
            inset: 0;
            border-radius: 14px;
            background: radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.06) 0%, transparent 70%);
            pointer-events: none;
        }
        .board.paused {
            filter: blur(6px) brightness(0.6);
            pointer-events: none;
        }
        .board.no-transition .tile { transition: none !important; }
        .board.flashing::after {
            content: '';
            position: absolute;
            inset: 0;
            border-radius: 14px;
            background: radial-gradient(ellipse at 50% 50%, rgba(255,235,128,0.95) 0%, rgba(245,196,80,0.6) 30%, transparent 75%);
            animation: boardFlash 0.9s ease-out;
            pointer-events: none;
            z-index: 5;
        }
        @keyframes boardFlash {
            0%   { opacity: 0; transform: scale(0.5); }
            25%  { opacity: 1; transform: scale(1.1); }
            100% { opacity: 0; transform: scale(1.4); }
        }

        /* Static grid cells (background) */
        .cell {
            position: absolute;
            border-radius: 8px;
            background: rgba(238,228,218,0.35);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), inset 0 -1px 2px rgba(0,0,0,0.06);
        }

        /* Tile pool — absolutely positioned at (0,0); slides come from animating
           transform: translate(--tx, --ty) which is transitioned. */
        .tile {
            position: absolute;
            left: 0;
            top: 0;
            --tx: 0px;
            --ty: 0px;
            transform: translate(var(--tx), var(--ty));
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            font-family: 'Orbitron', monospace;
            font-weight: 800;
            user-select: none;
            transition: transform 160ms cubic-bezier(0.22, 0.61, 0.36, 1);
            will-change: transform;
            z-index: 2;
            box-shadow:
                inset 0 1px 0 rgba(255,255,255,0.55),
                inset 0 -2px 4px rgba(0,0,0,0.12),
                0 2px 6px rgba(0,0,0,0.12);
        }
        .tile::after {
            content: '';
            position: absolute;
            inset: 0;
            border-radius: 8px;
            background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.22) 0%, transparent 55%);
            pointer-events: none;
        }
        .tile-inner {
            position: relative;
            z-index: 1;
            line-height: 1;
        }
        /* Spawn animation — scale layered on top of the translate position. */
        .tile.spawn { animation: tileSpawn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1); }
        @keyframes tileSpawn {
            0%   { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
            60%  { transform: translate(var(--tx), var(--ty)) scale(1.12); opacity: 1; }
            100% { transform: translate(var(--tx), var(--ty)) scale(1); opacity: 1; }
        }
        /* Merge animation — runs AFTER the slide finishes */
        .tile.merged { z-index: 3; animation: mergePulse 0.28s cubic-bezier(0.34, 1.56, 0.64, 1); }
        @keyframes mergePulse {
            0%   { transform: translate(var(--tx), var(--ty)) scale(1); filter: brightness(1); }
            40%  { transform: translate(var(--tx), var(--ty)) scale(1.22); filter: brightness(1.45); }
            70%  { transform: translate(var(--tx), var(--ty)) scale(0.96); filter: brightness(1.15); }
            100% { transform: translate(var(--tx), var(--ty)) scale(1); filter: brightness(1); }
        }
        /* Color per value */
        .tile[data-val="2"]    { background: #eee4da; color: #776e65; box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -2px 4px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.12); }
        .tile[data-val="4"]    { background: #ede0c8; color: #776e65; box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -2px 4px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.12); }
        .tile[data-val="8"]    { background: linear-gradient(160deg, #f4c094 0%, #f2b179 60%, #ec9c5f 100%); color: #fff; }
        .tile[data-val="16"]   { background: linear-gradient(160deg, #f9a87c 0%, #f59563 60%, #ef7e44 100%); color: #fff; }
        .tile[data-val="32"]   { background: linear-gradient(160deg, #fb9476 0%, #f67c5f 60%, #ee5e3a 100%); color: #fff; }
        .tile[data-val="64"]   { background: linear-gradient(160deg, #fb7a55 0%, #f65e3b 60%, #e3431b 100%); color: #fff; }
        .tile[data-val="128"]  { background: linear-gradient(160deg, #f4dd8a 0%, #edcf72 60%, #d8b54e 100%); color: #fff;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.65), inset 0 -2px 4px rgba(0,0,0,0.15), 0 0 14px rgba(237,194,46,0.45), 0 2px 6px rgba(0,0,0,0.15);
        }
        .tile[data-val="256"]  { background: linear-gradient(160deg, #f4db7d 0%, #edcc61 60%, #d4ad3c 100%); color: #fff;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), inset 0 -2px 4px rgba(0,0,0,0.18), 0 0 18px rgba(237,194,46,0.55), 0 2px 8px rgba(0,0,0,0.18);
        }
        .tile[data-val="512"]  { background: linear-gradient(160deg, #f5d96c 0%, #edc850 60%, #d2aa2c 100%); color: #fff;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.75), inset 0 -2px 4px rgba(0,0,0,0.2), 0 0 22px rgba(237,194,46,0.6), 0 2px 10px rgba(0,0,0,0.2);
        }
        .tile[data-val="1024"] { background: linear-gradient(160deg, #f5d75b 0%, #edc53f 60%, #cfa61c 100%); color: #fff;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), inset 0 -2px 4px rgba(0,0,0,0.22), 0 0 28px rgba(237,194,46,0.7), 0 2px 12px rgba(0,0,0,0.22);
        }
        .tile[data-val="2048"] {
            background: linear-gradient(135deg, #fde68a 0%, #f6d63a 35%, #edc22e 65%, #b8a423 100%);
            color: #fff;
            box-shadow:
                inset 0 1px 0 rgba(255,255,255,0.9),
                inset 0 -3px 6px rgba(0,0,0,0.25),
                0 0 38px rgba(237,194,46,0.9),
                0 0 18px rgba(255,215,90,0.7),
                0 4px 16px rgba(0,0,0,0.25);
            animation: goldPulse 2.4s ease-in-out infinite;
        }
        .tile[data-val="4096"] {
            background: linear-gradient(135deg, #c084fc 0%, #6b3fb0 50%, #4c1d95 100%);
            color: #fff;
            box-shadow:
                inset 0 1px 0 rgba(255,255,255,0.5),
                inset 0 -3px 6px rgba(0,0,0,0.35),
                0 0 40px rgba(168,85,247,0.7),
                0 0 22px rgba(192,132,252,0.55),
                0 4px 16px rgba(0,0,0,0.3);
            animation: purplePulse 2.4s ease-in-out infinite;
        }
        .tile[data-val="8192"], .tile[data-val="16384"] {
            background: linear-gradient(135deg, #ec4899 0%, #4a1a8a 50%, #0a0420 100%);
            color: #fff;
            box-shadow:
                inset 0 1px 0 rgba(255,255,255,0.45),
                inset 0 -3px 6px rgba(0,0,0,0.4),
                0 0 46px rgba(236,72,153,0.85),
                0 0 24px rgba(168,85,247,0.6),
                0 4px 18px rgba(0,0,0,0.35);
            animation: purplePulse 2s ease-in-out infinite;
        }
        @keyframes goldPulse {
            0%, 100% { filter: brightness(1) saturate(1); }
            50%      { filter: brightness(1.15) saturate(1.1); }
        }
        @keyframes purplePulse {
            0%, 100% { filter: brightness(1); }
            50%      { filter: brightness(1.18); }
        }

        /* ---- Confetti ---- */
        .confetti {
            position: absolute;
            top: -20px;
            width: 10px;
            height: 14px;
            opacity: 0;
            border-radius: 2px;
            pointer-events: none;
            z-index: 15;
            animation: confettiFall 2.6s ease-out forwards;
        }
        @keyframes confettiFall {
            0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
            100% { transform: translateY(520px) rotate(720deg); opacity: 0; }
        }

        /* ---- Particle burst (merges 256+) ---- */
        .burst {
            position: absolute;
            width: 8px; height: 8px;
            border-radius: 50%;
            pointer-events: none;
            z-index: 20;
            animation: burst 0.7s ease-out forwards;
        }
        @keyframes burst {
            0%   { opacity: 1; transform: translate(0,0) scale(1); }
            100% { opacity: 0; transform: var(--burst-end) scale(0.3); }
        }

        /* ---- Overlays — fixed-position viewport modals ---- */
        .overlay {
            position: fixed;
            inset: 0;
            display: none;
            align-items: center;
            justify-content: center;
            text-align: center;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            z-index: 10000;
            padding: 20px;
        }
        .overlay.active { display: flex; }
        .overlay-pause { background: rgba(12,10,14,0.7); }
        .overlay-pause .pause-text {
            font-family: 'Orbitron', monospace;
            font-size: 1.7rem;
            font-weight: 800;
            letter-spacing: 0.14em;
            background: linear-gradient(135deg, var(--t-primary), var(--t-primary-dark));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .overlay-win {
            background: radial-gradient(ellipse at 50% 40%, rgba(255,235,128,0.55) 0%, rgba(13,10,14,0.7) 65%);
            flex-direction: column;
            gap: 0.9rem;
        }
        .win-title {
            font-family: 'Orbitron', monospace;
            font-size: 1.6rem;
            font-weight: 900;
            letter-spacing: 0.04em;
            color: #fcd663;
            text-shadow: 0 4px 18px rgba(0,0,0,0.5), 0 0 20px rgba(255,215,90,0.6);
        }
        .win-sub {
            font-size: 0.86rem;
            color: #fff;
            max-width: 280px;
            line-height: 1.45;
            opacity: 0.95;
        }
        .win-btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

        .overlay-gameover {
            background: rgba(13, 10, 20, 0.8);
            flex-direction: column;
            padding: 28px;
        }
        .gover-title {
            font-family: 'Orbitron', monospace;
            font-size: 1.4rem;
            font-weight: 900;
            letter-spacing: 0.04em;
            margin-bottom: 0.3rem;
            color: #fff;
        }
        .gover-title.win-flavor {
            background: linear-gradient(135deg, #fde68a, #f59e0b);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .gover-sub {
            color: rgba(255,255,255,0.78);
            font-size: 0.85rem;
            margin-bottom: 1rem;
            max-width: 320px;
            line-height: 1.45;
        }
        .gover-stats {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 0.5rem;
            margin-bottom: 1rem;
            width: 100%;
            max-width: 280px;
        }
        .gover-stat {
            padding: 0.55rem 0.4rem;
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(255,255,255,0.14);
            border-radius: 10px;
        }
        .gover-stat-label {
            font-family: 'Orbitron', monospace;
            font-size: 0.5rem;
            letter-spacing: 0.16em;
            color: rgba(255,255,255,0.55);
            text-transform: uppercase;
        }
        .gover-stat-value {
            font-family: 'Orbitron', monospace;
            font-size: 1rem;
            font-weight: 800;
            color: #fcd663;
            margin-top: 0.18rem;
        }
        .gover-stat-value.highlight { color: #a7f3d0; }
        .gover-btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

        /* Override game-btn for overlays (whiter look on dark overlay) */
        .overlay .game-btn {
            padding: 0.65rem 1.2rem;
            font-family: 'Orbitron', monospace;
            font-size: 0.78rem;
            font-weight: 800;
            letter-spacing: 0.1em;
            text-transform: uppercase;
            border-radius: 99px;
            border: 0;
            cursor: pointer;
            background: linear-gradient(135deg, #f59563, #f67c5f);
            color: #fff;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            transition: transform 0.15s, box-shadow 0.15s;
        }
        .overlay .game-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(245,124,95,0.4); }
        .overlay .game-btn-secondary {
            background: rgba(255,255,255,0.08);
            border: 1px solid rgba(255,255,255,0.25);
            color: #fff;
        }
        .overlay .game-btn-secondary:hover { background: rgba(255,255,255,0.15); }

        /* ---- Help & history panels ---- */
        .help-toggle, .history-toggle {
            display: block;
            margin: 0.6rem auto 0;
            padding: 0.4rem 1rem;
            background: var(--t-card-bg);
            border: 1px solid var(--t-glass-border);
            color: var(--t-text-muted);
            border-radius: 20px;
            font-family: 'Orbitron', monospace;
            font-size: 0.62rem;
            cursor: pointer;
            letter-spacing: 0.12em;
            text-transform: uppercase;
            transition: color 0.18s, background 0.18s;
        }
        .help-toggle:hover, .history-toggle:hover { color: var(--t-primary); background: rgba(245,124,95,0.08); }
        .help-panel, .history-panel {
            display: none;
            max-width: 440px;
            margin: 0.7rem auto 0;
            padding: 1rem 1.2rem;
            background: var(--t-card-bg);
            border: 1px solid var(--t-card-border);
            border-radius: 14px;
            color: var(--t-text);
            font-size: 0.84rem;
            line-height: 1.55;
        }
        .help-panel.active, .history-panel.active { display: block; }
        .help-panel h3 {
            margin: 0 0 0.4rem;
            font-family: 'Orbitron', monospace;
            font-size: 0.72rem;
            text-transform: uppercase;
            letter-spacing: 0.12em;
            color: var(--t-primary-dark);
        }
        .help-panel ul { margin: 0 0 0.7rem; padding-left: 1.1rem; }
        .help-panel li { margin: 3px 0; font-size: 0.82rem; }
        .help-panel p { font-size: 0.82rem; margin: 0.3rem 0; }
        .history-title {
            font-family: 'Orbitron', monospace;
            font-size: 0.66rem;
            text-transform: uppercase;
            letter-spacing: 0.12em;
            color: var(--t-primary-dark);
            text-align: center;
            margin-bottom: 0.5rem;
        }
        .history-list {
            display: flex;
            flex-direction: column;
            gap: 0.3rem;
            max-height: 240px;
            overflow-y: auto;
        }
        .history-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0.5rem 0.7rem;
            background: rgba(0,0,0,0.04);
            border: 1px solid rgba(0,0,0,0.06);
            border-radius: 8px;
            font-size: 0.74rem;
            gap: 0.6rem;
        }
        .history-score {
            font-family: 'Orbitron', monospace;
            font-weight: 700;
            color: var(--t-primary-dark);
        }
        .history-meta { color: var(--t-text-muted); font-size: 0.68rem; }
        .history-empty { text-align: center; color: var(--t-text-muted); font-size: 0.82rem; padding: 0.8rem; }

        .controls-hint {
            margin-top: 0.5rem;
            font-size: 0.72rem;
            color: var(--t-text-subtle);
            text-align: center;
            font-weight: 500;
        }

        /* ---- Desktop vertical-fit: tighten chrome so board + essential
           controls + play hint fit one viewport (no scroll). Scoped here so
           the shared games.css base rules are untouched. The mobile @media
           block below is unaffected (these are base/desktop values and the
           board cap uses min(92vw, ...) so narrow-tall phones ignore it). ---- */
        .game-score-bar { margin-bottom: 0.5rem; }
        /* Vertical padding only — leave horizontal padding to games.css so the
           mobile @media (max-width:480px) 1rem rule still governs width and we
           don't push the board past 100vw on narrow phones. */
        .game-container { padding-top: 1rem; padding-bottom: 1rem; }
        .help-toggle, .history-toggle { margin-top: 0.4rem; }

        /* ============================================================
           DESKTOP FILL-THE-SCREEN LAYOUT (mirrors snake.html)
           The board grows to fill the viewport HEIGHT and the leftover
           HORIZONTAL space is consumed by a side rail (score / setup /
           stats / recent games / how-to-play). Previously the board
           floated as a small square in a sea of empty desktop space.
           ============================================================ */
        .game-layout {
            display: flex; gap: 22px; align-items: flex-start;
            justify-content: center; width: 100%;
            max-width: 1400px; margin: 0 auto; padding: 0 18px;
            box-sizing: border-box;
        }
        .game-main {
            position: relative; display: flex; flex-direction: column;
            align-items: center; min-width: 0; max-width: 100%;
        }
        /* The board container hugs the board (no empty strip beside it).
           backdrop-filter is dropped so a `position:fixed` overlay (mobile)
           is positioned relative to the viewport, not trapped to this box. */
        .game-main .game-container {
            width: fit-content; max-width: 100%; margin: 0;
            backdrop-filter: none; -webkit-backdrop-filter: none;
        }

        .game-rail {
            width: 340px; flex-shrink: 0;
            display: flex; flex-direction: column; gap: 14px;
        }
        .rail-card {
            background: var(--t-card-bg);
            border: 1px solid var(--t-card-border);
            border-radius: 16px; padding: 14px 16px;
            backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 3px 12px rgba(0,0,0,0.06);
        }
        .rail-card-title {
            font-family: 'Orbitron', monospace; font-size: 0.6rem;
            text-transform: uppercase; letter-spacing: 0.14em;
            color: var(--t-primary-dark); margin-bottom: 10px;
        }
        /* Score bar fills the rail card. */
        .game-rail .game-score-bar { margin: 0; }
        /* Settings stack full-width in the rail. */
        .game-rail .settings-bar {
            flex-direction: column; align-items: stretch;
            gap: 10px; margin: 0; max-width: none;
        }
        .game-rail .setting-group { justify-content: space-between; flex-wrap: wrap; }
        /* Stats fill the rail row. */
        .game-rail .stats-row { margin: 0; gap: 8px; }
        .game-rail .stat { flex: 1; min-width: 0; }
        /* Action buttons fill the rail. */
        .game-rail .action-bar { margin: 0; }
        /* Recent games + help live in the rail. */
        .game-rail .history-toggle, .game-rail .help-toggle {
            display: block; width: 100%; margin: 0; text-align: left;
        }
        .game-rail .history-panel, .game-rail .help-panel {
            max-width: none; margin: 10px 0 0; background: none;
            border: none; padding: 0;
        }
        .game-rail .controls-hint { margin: 0; text-align: left; }

        /* Overlays confined to the board on desktop (was full-screen `fixed`),
           so the rail (difficulty re-pick) stays clickable behind the end
           screen. .game-main is the position:relative, NON-filtered ancestor. */
        .game-main .overlay {
            position: absolute;
            z-index: 20;
            overflow-y: auto;
            border-radius: 14px;
        }

        /* In-overlay difficulty re-pick — MOBILE only (desktop uses the
           always-visible rail selector). Lets the end/start screen launch a
           new run at a different difficulty without hunting for the rail. */
        .overlay-settings { display: none; }

        @media (max-width: 899px) {
            .game-layout { flex-direction: column; align-items: center; gap: 14px; padding: 0 12px; }
            .game-rail { width: 100%; max-width: 480px; }
            .game-rail .settings-bar { flex-direction: row; flex-wrap: wrap; justify-content: center; }
            .game-rail .setting-group { justify-content: center; }
            /* Mobile: overlays go full-screen (no rail beside the board to
               preserve), so end / start screens get the whole viewport. */
            .game-main .overlay { position: fixed; border-radius: 0; }
            .overlay-settings {
                display: flex; flex-wrap: wrap; gap: 8px;
                justify-content: center; margin: 4px 0 14px;
            }
            .overlay-settings .setting-btn {
                border: 1px solid rgba(255,255,255,0.25);
                background: rgba(255,255,255,0.06);
                color: #fff;
            }
            .overlay-settings .setting-btn.active {
                background: linear-gradient(135deg, #f59563, #f67c5f);
                border-color: transparent;
            }
        }

        /* ===== 2048 theme palette ===== */
        body.game-page {
            --t-bg: #faf8ef;
            --t-bg-grad: radial-gradient(ellipse at 50% -20%, #faf8ef 0%, #ede4d3 70%);
            --t-text: #2d2620;
            --t-text-muted: #5c4a3a;
            --t-text-subtle: #8a7560;
            --t-primary: #edc22e;
            --t-primary-mid: #f59563;
            --t-primary-dark: #f67c5f;
            --t-glass-bg: rgba(238,228,218,0.5);
            --t-glass-border: rgba(186,166,135,0.4);
            --t-card-bg: rgba(238,228,218,0.5);
            --t-card-border: rgba(186,166,135,0.35);
            --t-btn-grad: linear-gradient(135deg, #f59563, #f67c5f);
        }
        body.game-page .game-name,
        body.game-page .score-value { color: #f67c5f !important; -webkit-text-fill-color: #f67c5f !important; background: none !important; }

        @media (max-width: 480px) {
            .board { --gap: 8px; }
            .stat { padding: 0.35rem 0.6rem; min-width: 60px; }
            .stat-value { font-size: 0.9rem; }
            .action-btn { padding: 0.45rem 0.75rem; font-size: 0.7rem; }
            .gover-title { font-size: 1.2rem; }
        }
