
        /* ----- Settings bar (difficulty) ----- */
        .settings-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-bottom: 0.6rem; max-width: 480px; }
        .setting-group { display: flex; align-items: center; gap: 0.3rem; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.16); border-radius: 30px; padding: 0.25rem 0.4rem; }
        .setting-label { font-family: 'Orbitron', monospace; font-size: 0.5rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.7); padding-left: 0.4rem; }
        .setting-btn { padding: 0.3rem 0.7rem; border: none; border-radius: 20px; font-family: inherit; font-size: 0.7rem; font-weight: 600; cursor: pointer; background: transparent; color: rgba(255,255,255,0.85); transition: all 0.18s; }
        .setting-btn.active { background: linear-gradient(135deg, #f472b6, #a855f7); color: #fff; box-shadow: 0 2px 10px rgba(168,85,247,0.5); }
        .setting-btn:hover:not(.active):not(:disabled) { background: rgba(168,85,247,0.18); }
        .setting-btn:disabled { opacity: 0.4; cursor: not-allowed; }

        /* ----- Canvas container + overlays ----- */
        .game-container {
            position: relative;
            /* Hug the canvas (htFitSize makes a portrait board narrower than the
               old width:100% box on desktop → it sat left with dead space on the
               right and the absolute HUD detached). fit-content + margin:auto
               wraps + centers the board. */
            width: fit-content;
            max-width: min(900px, 96vw);
            margin: 0 auto;
            border-radius: 18px;
            overflow: hidden;
            box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 3px rgba(168,85,247,0.18) inset;
        }
        #canvas2d {
            display: block;
            border-radius: 18px;
            touch-action: none;
            cursor: none;
            background: radial-gradient(ellipse at top, #1a0b2e 0%, #0f0820 60%, #050310 100%);
        }
        /* Show cursor when overlays are visible */
        .game-container:has(.overlay.active) #canvas2d { cursor: pointer; }
        .overlay { cursor: pointer; }
        .overlay-btn, .start-cta, .hud-pause-btn { cursor: pointer; }

        /* Top HUD bar */
        .game-hud {
            position: absolute; inset: 0; pointer-events: none;
        }
        .hud-top {
            position: absolute; top: 10px; left: 10px; right: 10px;
            display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
        }
        .hud-stack { display: flex; flex-direction: column; gap: 6px; }
        .hud-score-box {
            pointer-events: none;
            background: rgba(13, 10, 20, 0.65);
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
            border: 1px solid rgba(255,255,255,0.16);
            color: #fff;
            border-radius: 14px;
            padding: 6px 12px;
            font-family: 'Orbitron', monospace;
            display: flex;
            align-items: baseline;
            gap: 6px;
        }
        .hud-score-label {
            font-size: 0.56rem;
            letter-spacing: 0.18em;
            text-transform: uppercase;
            color: rgba(255,255,255,0.6);
        }
        .hud-score-value {
            font-size: 1.2rem;
            font-weight: 800;
            color: #fff;
            text-shadow: 0 2px 8px rgba(168,85,247,0.5);
        }
        .hud-best {
            margin-left: 4px;
            font-size: 0.62rem;
            color: rgba(244,114,182,0.95);
            letter-spacing: 0.06em;
        }
        .hud-meta-row { display: flex; gap: 6px; }
        .hud-pill {
            pointer-events: none;
            background: rgba(13, 10, 20, 0.65);
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
            border: 1px solid rgba(255,255,255,0.16);
            color: #fff;
            border-radius: 11px;
            padding: 4px 9px;
            font-family: 'Orbitron', monospace;
            font-size: 0.65rem;
            letter-spacing: 0.05em;
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }
        .hud-pill .pill-label {
            font-size: 0.5rem;
            text-transform: uppercase;
            letter-spacing: 0.14em;
            color: rgba(255,255,255,0.55);
        }
        .hud-pill .pill-value {
            font-weight: 800;
            color: #fcd663;
        }
        .hud-pause-btn {
            pointer-events: auto;
            width: 40px; height: 40px;
            border-radius: 12px;
            background: rgba(13, 10, 20, 0.65);
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
            border: 1px solid rgba(255,255,255,0.16);
            color: #fff;
            font-size: 1.1rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: transform 0.15s, background 0.15s;
        }
        .hud-pause-btn:hover { background: rgba(168,85,247,0.45); transform: scale(1.05); }
        .hud-pause-btn[hidden] { display: none; }

        /* Power-up status bar */
        .powerup-status {
            position: absolute; bottom: 10px; left: 10px; right: 10px;
            display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
            pointer-events: none;
        }
        .pu-chip {
            background: rgba(13, 10, 20, 0.72);
            backdrop-filter: blur(4px);
            border: 1px solid rgba(255,255,255,0.2);
            color: #fff;
            border-radius: 11px;
            padding: 4px 9px;
            font-family: 'Orbitron', monospace;
            font-size: 0.65rem;
            display: inline-flex;
            align-items: center;
            gap: 5px;
            animation: chipIn 0.25s ease-out;
        }
        .pu-chip .pu-icon { font-size: 0.85rem; }
        .pu-chip .pu-time { color: #fcd663; font-weight: 700; }
        @keyframes chipIn {
            from { opacity: 0; transform: translateY(8px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* Start / pause / gameover overlays */
        .overlay {
            position: fixed;
            inset: 0;
            z-index: 10000;
            pointer-events: none;
            display: none;
            align-items: center;
            justify-content: center;
            background: linear-gradient(180deg, rgba(10, 5, 25, 0.35), rgba(10, 5, 25, 0.75));
            text-align: center;
            color: #fff;
            font-family: 'Orbitron', monospace;
            padding: 24px;
            backdrop-filter: blur(3px);
            -webkit-backdrop-filter: blur(3px);
        }
        .overlay.active { display: flex; }
        .overlay-box, .start-cta, .overlay-btn { pointer-events: auto; }
        .overlay-box {
            background: rgba(13, 10, 20, 0.78);
            border: 1px solid rgba(168,85,247,0.35);
            border-radius: 22px;
            padding: 30px 30px 26px;
            min-width: 260px;
            max-width: 380px;
            box-shadow: 0 0 60px rgba(168,85,247,0.25) inset;
        }
        .overlay-title {
            font-size: 1.5rem;
            font-weight: 900;
            letter-spacing: 0.04em;
            margin: 0 0 6px;
            background: linear-gradient(135deg, #f472b6, #a855f7);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 0 2px 30px rgba(168,85,247,0.5);
        }
        .overlay-sub {
            margin: 0 0 18px;
            color: rgba(255,255,255,0.78);
            font-family: -apple-system, sans-serif;
            font-size: 0.92rem;
            line-height: 1.5;
        }
        .overlay-btn-row {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            justify-content: center;
        }
        .overlay-btn {
            padding: 11px 20px;
            border-radius: 99px;
            border: 0;
            cursor: pointer;
            font-family: 'Orbitron', monospace;
            font-size: 0.78rem;
            font-weight: 800;
            letter-spacing: 0.1em;
            text-transform: uppercase;
            transition: transform 0.15s, box-shadow 0.15s;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
        }
        .overlay-btn-primary {
            background: linear-gradient(135deg, #f472b6, #a855f7);
            color: #fff;
        }
        .overlay-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(168,85,247,0.55); }
        .overlay-btn-ghost {
            background: rgba(255,255,255,0.08);
            border: 1px solid rgba(255,255,255,0.25);
            color: #fff;
        }
        .overlay-btn-ghost:hover { background: rgba(255,255,255,0.15); }

        /* Game-over stats grid */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 6px;
            margin: 12px 0 18px;
        }
        .stat-cell {
            padding: 9px 4px;
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(255,255,255,0.12);
            border-radius: 10px;
        }
        .stat-cell-label {
            font-size: 0.5rem;
            letter-spacing: 0.12em;
            color: rgba(255,255,255,0.55);
            margin-bottom: 4px;
        }
        .stat-cell-value {
            font-size: 0.98rem;
            font-weight: 800;
            color: #f472b6;
        }

        /* Countdown big number */
        .countdown {
            font-size: 5rem;
            font-weight: 900;
            color: #fff;
            text-shadow: 0 4px 30px rgba(168,85,247,0.6);
            animation: countdownPulse 1s ease-out;
        }
        @keyframes countdownPulse {
            0% { transform: scale(0.6); opacity: 0; }
            40% { transform: scale(1.2); opacity: 1; }
            100% { transform: scale(1); opacity: 0.95; }
        }

        /* Start CTA */
        .start-cta {
            background: linear-gradient(135deg, #f472b6, #a855f7);
            color: #fff;
            padding: 16px 38px;
            border-radius: 99px;
            font-family: 'Orbitron', monospace;
            font-weight: 800;
            font-size: 1.05rem;
            letter-spacing: 0.16em;
            text-transform: uppercase;
            border: 0;
            box-shadow: 0 14px 36px rgba(168,85,247,0.55);
            animation: startPulse 1.6s ease-in-out infinite;
            cursor: pointer;
        }
        @keyframes startPulse {
            0%, 100% { transform: scale(1); box-shadow: 0 14px 36px rgba(168,85,247,0.55); }
            50% { transform: scale(1.06); box-shadow: 0 18px 44px rgba(168,85,247,0.75); }
        }
        .start-sub {
            display: block;
            margin-top: 14px;
            font-size: 0.84rem;
            color: rgba(255,255,255,0.85);
            font-weight: 500;
            letter-spacing: 0.06em;
            font-family: -apple-system, sans-serif;
            text-shadow: 0 2px 8px rgba(0,0,0,0.5);
        }

        /* Level-up banner */
        .level-banner {
            background: rgba(13, 10, 20, 0.85);
            border: 1px solid rgba(168,85,247,0.5);
            border-radius: 16px;
            padding: 18px 32px;
            text-align: center;
            box-shadow: 0 0 60px rgba(168,85,247,0.3);
            animation: levelBannerIn 0.4s ease-out;
        }
        @keyframes levelBannerIn {
            from { opacity: 0; transform: scale(0.85); }
            to { opacity: 1; transform: scale(1); }
        }
        .level-banner h2 {
            margin: 0 0 4px;
            font-family: 'Orbitron', monospace;
            font-size: 1.6rem;
            font-weight: 900;
            background: linear-gradient(135deg, #fcd663, #f472b6, #a855f7);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            letter-spacing: 0.08em;
        }
        .level-banner p {
            margin: 0;
            color: rgba(255,255,255,0.75);
            font-family: -apple-system, sans-serif;
            font-size: 0.85rem;
        }

        /* Help + history panels */
        .help-toggle, .history-toggle {
            display: block; margin: 0.7rem auto 0; padding: 0.4rem 1.1rem; background: none; border: 1px solid rgba(168,85,247,0.4);
            color: #f0e6ff; border-radius: 20px; font-family: 'Orbitron', monospace; font-size: 0.66rem; cursor: pointer; letter-spacing: 0.12em; text-transform: uppercase;
        }
        .help-toggle:hover, .history-toggle:hover { background: rgba(168,85,247,0.18); }
        .help-panel, .history-panel {
            display: none; max-width: 480px; margin: 0.8rem auto 0; padding: 1rem 1.2rem;
            background: rgba(13, 10, 20, 0.7); border: 1px solid rgba(168,85,247,0.3); border-radius: 14px;
            color: rgba(255,255,255,0.92); font-family: -apple-system, sans-serif; font-size: 0.86rem; line-height: 1.55;
        }
        .help-panel.active, .history-panel.active { display: block; }
        .help-panel h3 { margin: 0 0 6px; font-family: 'Orbitron', monospace; font-size: 0.85rem; color: #f472b6; }
        .help-panel ul { margin: 0 0 10px; padding-left: 20px; }
        .help-panel li { margin: 3px 0; }
        .help-panel .pu-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
        .help-panel .pu-emoji { font-size: 1.15rem; }
        .history-title { font-family: 'Orbitron', monospace; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; color: #f472b6; text-align: center; margin-bottom: 8px; }
        .history-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: rgba(168,85,247,0.12); border-radius: 8px; font-size: 0.78rem; margin-bottom: 4px; }
        .history-score { font-family: 'Orbitron', monospace; font-weight: 700; color: #fcd663; }
        .history-meta { color: rgba(255,255,255,0.6); font-size: 0.72rem; }
        .history-empty { text-align: center; color: rgba(255,255,255,0.4); font-size: 0.84rem; padding: 12px; }

        .pause-icon::before { content: '⏸'; }
        .play-icon::before { content: '▶'; }

        /* Theme variables (dark gradient theme for breakout) */
        body.game-page {
            --t-bg: #0f0820;
            --t-bg-grad: radial-gradient(ellipse at top, #1a0b2e 0%, #0f0820 60%, #050310 100%);
            --t-text: #f0e6ff;
            --t-text-muted: rgba(255,255,255,0.7);
            --t-primary: #a855f7;
            --t-primary-mid: #c084fc;
            --t-primary-dark: #7c3aed;
            --t-card-bg: rgba(13, 10, 20, 0.7);
            --t-card-border: rgba(168,85,247,0.3);
            --t-btn-grad: linear-gradient(135deg, #f472b6, #a855f7);
        }
        body.game-page .game-name,
        body.game-page .score-value {
            background: linear-gradient(135deg, #f472b6, #a855f7) !important;
            -webkit-background-clip: text !important;
            background-clip: text !important;
            -webkit-text-fill-color: transparent !important;
            color: transparent !important;
        }

        /* ============================================================
           DESKTOP FILL LAYOUT — board grows to use the viewport HEIGHT;
           the leftover horizontal space is consumed by a side rail that
           holds difficulty / live stats / recent games / how-to. The
           tall portrait board (ASPECT 1.45) used to float small + centered
           with dead space on both sides; the rail eats that space.
           Overlays are CONFINED to the board on desktop so the rail's
           difficulty selectors stay clickable (previously the full-screen
           start & game-over overlays buried them — you could never start a
           new game at a different difficulty).
           ============================================================ */
        .game-layout {
            display: flex; gap: 22px; align-items: flex-start;
            justify-content: center; width: 100%;
            max-width: 1400px; margin: 0 auto; padding: 0 18px;
        }
        .game-main {
            position: relative; display: flex; flex-direction: column;
            align-items: center; min-width: 0; max-width: 100%;
        }
        /* Board hugs the canvas; sits at the left of .game-main (no auto margin
           pushing it around). It already has no backdrop-filter so the
           position:fixed mobile overlays aren't trapped to it. */
        .game-container { margin: 0; max-width: 100%; }

        .game-rail {
            width: 340px; flex-shrink: 0;
            display: flex; flex-direction: column; gap: 14px;
        }
        .rail-card {
            background: rgba(168,85,247,0.08);
            border: 1px solid rgba(168,85,247,0.28);
            border-radius: 16px; padding: 14px 16px;
            backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
        }
        .rail-card-title {
            font-family: 'Orbitron', monospace; font-size: 0.6rem;
            text-transform: uppercase; letter-spacing: 0.14em;
            color: #f472b6; margin-bottom: 10px;
        }
        /* Settings + best stack full-width inside 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; }
        /* Recent games + help live open in the rail, full-width */
        .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;
        }
        /* Best-score readout in the rail */
        .rail-best { display: flex; justify-content: space-between; align-items: baseline; }
        .rail-best-label { font-family: 'Orbitron', monospace; font-size: 0.56rem; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(255,255,255,0.6); }
        .rail-best-value { font-family: 'Orbitron', monospace; font-weight: 800; font-size: 1.05rem; color: #fcd663; }

        /* Overlays: confine to the board (was full-screen `fixed`). The
           container is position:relative + overflow:hidden, so the overlay
           clips to the rounded board and scrolls internally if needed. */
        .overlay {
            position: absolute;
            z-index: 20;
            overflow-y: auto;
            border-radius: 18px;
        }
        .overlay .overlay-box, .overlay .level-banner { margin: auto; }

        /* In-overlay difficulty re-pick — MOBILE only (desktop uses the
           always-visible rail). Lets the start + end screens launch a new
           run at a different difficulty without hunting for a panel. */
        .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 the start / end screens get the whole viewport. */
            .overlay { position: fixed; border-radius: 0; }
            .overlay-settings {
                display: flex; flex-wrap: wrap; gap: 8px;
                justify-content: center; margin: 4px 0 14px;
            }
        }
