    :root {
        --bg: #0b0e14;
        --bg-2: #0e1320;
        --panel: #141a26;
        --panel-2: #1c2332;
        --border: #252e40;
        --text: #e6edf3;
        --muted: #8b949e;
        --accent: #58a6ff;
        --accent-2: #ff7eb6;
        --accent-bg: #1a2f4d;
        --chip-bg: #232b3c;
        --chip-text: #adbac7;
        --spark: #fff;            /* ambient starfield + logo sparkle color */
        --tile-base: #0d1117;     /* base color the Top Picks tiles tint over */
        --tile-border: #3a4862;   /* Top Picks tile border */

        /* Per-category accent + translucent fill, applied via --cat-color / --cat-bg
              CSS vars set on chips/tiles/row headers at build time. */
        --cat-arcade:  #58a6ff;   --cat-arcade-bg:  rgba(88,166,255,.18);
        --cat-shooter: #ff7eb6;   --cat-shooter-bg: rgba(255,126,182,.18);
        --cat-puzzle:  #bb86fc;   --cat-puzzle-bg:  rgba(187,134,252,.18);
        --cat-board:   #f7c948;   --cat-board-bg:   rgba(247,201,72,.18);
        --cat-strategy:#2dd4bf;   --cat-strategy-bg:rgba(45,212,191,.18);
        --cat-sports:  #4ade80;   --cat-sports-bg:  rgba(74,222,128,.18);
        --cat-physics: #fb7185;   --cat-physics-bg: rgba(251,113,133,.18);
        --cat-construction: #ff9744; --cat-construction-bg: rgba(255,151,68,.18);
        --cat-frankforce: #22d3ee; --cat-frankforce-bg: rgba(34,211,238,.18);
        --cat-extra: #94a3b8; --cat-extra-bg: rgba(148,163,184,.18);
    }
    /* Light theme — overrides the surface/text palette only; the bright
          category + accent hues carry over (they read fine on light too). */
    :root[data-theme="light"] {
        --bg: #dde1e8;
        --bg-2: #e6e9ef;
        --panel: #ffffff;
        --panel-2: #eef1f6;
        --border: #d0d6e0;
        --text: #1b2230;
        --muted: #5a6573;
        --accent: #2f7ad6;
        --accent-2: #d6488f;
        --accent-bg: #dbe8fb;
        --chip-bg: #e6eaf1;
        --chip-text: #3c4658;
        --spark: #2f7ad6;
        --tile-base: #ffffff;
        --tile-border: #d0d6e0;
    }
    * { box-sizing: border-box; }
    /* `height: 100%` on iOS measures the layout viewport (which extends behind
          the browser URL bar in portrait), pushing fixed elements off-screen at
          the top. `100dvh` measures the dynamic visible viewport — correct on
          iOS, falls back to 100% on browsers that don't understand dvh. */
    html, body { margin: 0; padding: 0; height: 100%; height: 100dvh; overflow: hidden; }
    body {
        background: var(--bg);
        color: var(--text);
        font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        display: flex;
        /* Disable text selection on the launcher chrome — every clickable element
              launches a game, so accidental selections just get in the way. The
              iframe content is in its own document and is unaffected. */
        user-select: none;
        -webkit-user-select: none;
    }
    /* …but keep text inputs selectable, obviously. */
    input, textarea { user-select: text; -webkit-user-select: text; }
    button { font: inherit; color: inherit; cursor: pointer; }

    /* ===================== Sidebar ===================== */
    /* Sidebar = the in-game game-switcher, hidden on the welcome floor.
          NON-TOUCH: a persistent side panel that appears beside the game in-game
          (the game fills the remaining space) — no overlay, no dim, no toggle.
          TOUCH: an overlay drawer slid in by the game's Library button, dimming
          the rest of the screen (the original mobile behavior). */
    #sidebar {
        width: 300px;
        flex: 0 0 300px;
        background: var(--panel);
        border-right: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    /* Non-touch: no sidebar on the welcome floor (the base rule shows it in-game). */
    body:not(.touch):not(.in-game) #sidebar { display: none; }
    /* Non-touch: the persistent side panel can be collapsed for more game space
          via the game's Library button (toggles body.sidebar-collapsed); the
          stage flexes to fill the freed width. Touch uses the slide-in drawer
          instead, so this only applies to non-touch. */
    body:not(.touch).in-game.sidebar-collapsed #sidebar { display: none; }
    /* Touch: overlay drawer at all widths, hidden off-screen until opened. */
    body.touch #sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 320px;
        max-width: 85vw;
        flex: none;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .25s ease-out;
        box-shadow: 4px 0 24px rgba(0, 0, 0, .5);
    }
    body.touch #sidebar.open { transform: translateX(0); }
    #sidebar-header { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }

    /* Sidebar logo — clickable "home" button */
    #sidebar-logo-wrap {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 12px;
        cursor: pointer;
        /* One-time entrance pop lives on the wrapper so hover state changes on
              the logo never replay it. */
        animation: splat .55s cubic-bezier(.34, 1.56, .64, 1);
    }
    /* Breathing glow lives on the logo's own drop-shadow (no separate halo). */
    @keyframes logo-breathe {
        0%, 100% { filter: drop-shadow(0 3px 8px rgba(88, 166, 255, .35))
                           drop-shadow(0 0 12px rgba(255, 126, 182, .15)); }
        50%      { filter: drop-shadow(0 3px 13px rgba(88, 166, 255, .6))
                           drop-shadow(0 0 22px rgba(255, 126, 182, .32)); }
    }
    /* Gentle left/right wobble on hover — keeps the hover scale baked in so it
          isn't overridden by the transform animation. */
    @keyframes logo-wobble {
        0%, 100% { transform: scale(1.05) rotate(0deg); }
        25%      { transform: scale(1.05) rotate(-4deg); }
        75%      { transform: scale(1.05) rotate(4deg); }
    }
    #sidebar-logo-title {
        margin-top: 6px;
        font-size: 12px;
        font-weight: 600;
        letter-spacing: 1.2px;
        text-transform: uppercase;
        color: var(--accent);
        text-align: center;
        text-shadow: 0 0 10px rgba(88, 166, 255, .55),
                     0 0 18px rgba(255, 126, 182, .3);
        transition: color .15s, text-shadow .15s;
    }
    #sidebar-logo-wrap:hover #sidebar-logo-title {
        color: var(--accent-2);
        text-shadow: 0 0 12px rgba(255, 126, 182, .65),
                     0 0 22px rgba(88, 166, 255, .35);
    }
    #sidebar-logo {
        height: 64px;
        width: auto;
        filter: drop-shadow(0 3px 10px rgba(88, 166, 255, .45))
                drop-shadow(0 0 16px rgba(255, 126, 182, .2));
        transition: transform .15s, filter .15s;
        animation: logo-breathe 4s ease-in-out infinite;
    }
    #sidebar-logo-wrap:hover #sidebar-logo {
        animation: logo-breathe 4s ease-in-out infinite,
                   logo-wobble 2.5s linear infinite;
    }

    #search {
        width: 100%;
        padding: 7px 10px;
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 6px;
        color: var(--text);
        font: inherit;
        outline: none;
    }
    #search:focus { border-color: var(--accent); }

    #filter-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        margin-top: 10px;
    }
    .chip-filter {
        background: var(--chip-bg);
        color: var(--chip-text);
        border: 1px solid transparent;
        padding: 3px 9px;
        border-radius: 11px;
        font-size: 11px;
        text-transform: lowercase;
        letter-spacing: .3px;
        transition: background .1s, color .1s, border-color .1s;
    }
    .chip-filter:hover { background: var(--panel-2); color: var(--text); }
    .chip-filter.active {
        background: var(--cat-bg, var(--accent-bg));
        color: var(--text);
        border-color: var(--cat-color, var(--accent));
    }

    /* overflow-anchor: none disables Chrome's scroll-anchoring at the list
          bottom. Without it, hovering the last card expands its body, which
          grows scrollHeight, which the browser "corrects" by shifting scrollTop —
          and that shift moves the card out from under the cursor, triggering a
          hover-collapse-anchor-expand oscillation loop. */
    #list { flex: 1; overflow-y: auto; padding: 6px 0; overflow-anchor: none; }
    #list::-webkit-scrollbar { width: 10px; }
    #list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
    /* Suppress hover during scroll — otherwise each card under the cursor
          briefly expands as the list slides by, causing visible flicker.
          Gated to hover-capable (mouse) devices: on touch there's no hover to
          suppress, and pointer-events:none would block the finger from grabbing
          the list to stop its momentum scroll until the glide settled on its own. */
    @media (hover: hover) {
        #list.scrolling { pointer-events: none; }
    }

    .card {
        /* Rendered as a <button> for keyboard access — strip the native button
              chrome so it looks identical to the old div. font/color are picked
              up from the global `button` rule above. */
        appearance: none;
        -webkit-appearance: none;
        display: block;
        width: 100%;
        text-align: left;
        background: none;
        border: 0;
        border-left: 3px solid transparent;
        border-radius: 0;
        padding: 8px 14px;
        cursor: pointer;
        user-select: none;
        transition: background .08s;
    }
    .card:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
    .card:hover { background: var(--panel-2); }
    .card.selected {
        background: var(--accent-bg);
        border-left-color: var(--accent);
    }
    .card .title {
        font-weight: 500;
        font-size: 14px;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    /* Fixed-width emoji slot so titles line up regardless of glyph width. */
    .card .title .emoji {
        font-size: 18px;
        line-height: 1;
        flex: 0 0 22px;
        text-align: center;
    }
    .card .title .name { flex: 1; min-width: 0; }
    .card .body {
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height .15s, opacity .15s, margin-top .15s;
    }
    .card:hover .body, .card.selected .body {
        max-height: 200px;
        opacity: 1;
        margin-top: 6px;
    }
    .card .desc { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
    .chips { display: flex; flex-wrap: wrap; gap: 4px; }
    .chip {
        background: var(--chip-bg);
        color: var(--chip-text);
        padding: 1px 7px;
        border-radius: 10px;
        font-size: 10.5px;
        text-transform: lowercase;
        letter-spacing: .3px;
    }
    /* Touch only: floor / recently-played / top-pick tiles drop their tag chips
       (incl. 🎮 + ↗ off-site) so the grid reads cleaner on cramped screens.
       Non-touch keeps the chips on the tiles — there's room for them there. Tags
       also show in the featured hero cabinet and the sidebar card on any device. */
    body.touch .tile .chips { display: none; }
    .empty { padding: 20px 16px; color: var(--muted); font-size: 13px; text-align: center; }

    /* High-score badge — gold accent, used on tiles + sidebar cards. */
    .score-badge {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        background: rgba(247, 201, 72, .14);
        color: #f7c948;
        border: 1px solid rgba(247, 201, 72, .35);
        padding: 1px 7px;
        border-radius: 8px;
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: .2px;
        line-height: 1.3;
    }
    .card .body .score-badge { margin-bottom: 6px; }
    .tile .score-badge {
        align-self: flex-start;
        justify-self: start;
        margin: 2px 0 4px;
    }

    /* Subtle divider that separates "main" games from under-construction ones
          at the bottom of the sidebar list. */
    .list-divider {
        margin: 14px 14px 4px;
        padding-top: 10px;
        border-top: 1px dashed var(--border);
        color: var(--cat-construction);
        font-size: 10.5px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 1.2px;
    }

    /* Sidebar footer — controls live here so they never overlap the game */
    #sidebar-footer {
        padding: 10px 14px;
        border-top: 1px solid var(--border);
        display: flex;
        gap: 6px;
    }
    #sidebar-footer .btn {
        flex: 1;
        text-align: center;
        background: var(--bg);
        color: var(--text);
        border: 1px solid var(--border);
        padding: 7px 10px;
        border-radius: 6px;
        font-size: 12px;
        text-decoration: none;
        transition: background .1s, border-color .1s, opacity .1s;
    }
    #sidebar-footer .btn:hover:not(.disabled) {
        background: var(--accent-bg);
        border-color: var(--accent);
    }
    #sidebar-footer .btn.disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }

    /* ===================== Stage ===================== */
    #stage {
        flex: 1;
        position: relative;
        overflow: hidden;
        /* gradient base lives on the stage so the starfield canvas can paint
              transparent on top without losing the welcome backdrop. */
        background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
    }
    #frame { width: 100%; height: 100%; border: 0; display: block; position: relative; z-index: 2; }
    #starfield { position: absolute; inset: 0; pointer-events: none; z-index: 0; }

    /* ===================== Welcome screen ===================== */
    #welcome {
        position: absolute;
        inset: 0;
        overflow-y: auto;
        z-index: 1;
        background:
            radial-gradient(ellipse at 50% 0%, rgba(88, 166, 255, .12) 0%, transparent 55%),
            radial-gradient(ellipse at 80% 100%, rgba(255, 126, 182, .08) 0%, transparent 50%);
        padding: 40px 48px 60px;
    }
    #welcome::-webkit-scrollbar { width: 10px; }
    #welcome::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }

    #welcome-hero {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 32px;
    }
    #welcome-logo {
        width: min(220px, 30vw);
        height: auto;
        filter: drop-shadow(0 8px 28px rgba(88, 166, 255, .45))
                        drop-shadow(0 0 40px rgba(255, 126, 182, .2));
        animation: splat .7s cubic-bezier(.34, 1.56, .64, 1),
                              float 5s ease-in-out infinite 1s;
    }
    #welcome-tagline {
        margin-top: 14px;
        color: var(--muted);
        font-size: 14px;
        letter-spacing: .5px;
    }

    #quick-actions {
        display: flex;
        gap: 12px;
        justify-content: center;
        margin-bottom: 36px;
        flex-wrap: wrap;
    }
    .quick-btn {
        background: linear-gradient(135deg, var(--accent-bg), var(--panel));
        border: 1px solid var(--border);
        color: var(--text);
        padding: 12px 22px;
        border-radius: 10px;
        font-size: 14px;
        font-weight: 500;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        transition: transform .12s, border-color .12s, box-shadow .12s;
    }
    .quick-btn:hover {
        transform: translateY(-2px);
        border-color: var(--accent);
        box-shadow: 0 6px 20px rgba(88, 166, 255, .25);
    }
    .quick-btn.primary {
        background: linear-gradient(135deg, var(--accent), #2978d3);
        border-color: var(--accent);
    }
    .quick-btn.primary:hover {
        box-shadow: 0 6px 24px rgba(88, 166, 255, .5);
    }
    .quick-btn .icon { font-size: 16px; }
    .quick-btn .sub {
        color: rgba(255, 255, 255, .7);
        font-size: 12px;
        margin-left: 4px;
    }

    .row { margin-bottom: 32px; max-width: 100%; }
    .row h2 {
        font-size: 13px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 1.5px;
        color: var(--muted);
        margin: 0 0 12px;
        padding-left: 4px;
    }
    .row .tiles {
        display: flex;
        gap: 14px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 12px 4px 14px;     /* top padding gives hover-lift room */
        cursor: grab;
    }
    .row .tiles.dragging { cursor: grabbing; }
    .row .tiles.dragging .tile { pointer-events: none; }

    /* Row header — small colored bar + category emoji */
    .row h2 .row-bar {
        display: inline-block;
        width: 4px;
        height: 14px;
        margin-right: 8px;
        vertical-align: -2px;
        border-radius: 2px;
        background: var(--cat-color, var(--accent));
    }
    .row h2 .row-emoji {
        margin-right: 6px;
        filter: drop-shadow(0 0 6px var(--cat-color, var(--accent)));
    }
    .row .tiles::-webkit-scrollbar { height: 8px; }
    .row .tiles::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

    /* Tiles wrapper hosts the edge scroll buttons */
    .tiles-wrap { position: relative; }

    /* Edge buttons — full-height columns at left/right that combine the
          fade gradient and the click target. Chevron sits inside the fade. */
    .edge-scroll {
        position: absolute;
        top: 0;
        bottom: 12px;               /* clear the horizontal scrollbar */
        width: 64px;
        border: 0;
        padding: 0 14px;
        display: flex;
        align-items: center;
        font-size: 30px;
        line-height: 1;
        color: var(--text);
        opacity: .55;
        z-index: 2;
        transition: opacity .15s;
        text-shadow: 0 0 6px var(--bg), 0 0 12px var(--bg);
    }
    .edge-scroll:hover { opacity: 1; }
    .edge-scroll[hidden] { display: none; }
    .edge-scroll.left {
        left: 0;
        background: linear-gradient(to right, var(--bg) 25%, transparent);
        justify-content: flex-start;
    }
    .edge-scroll.right {
        right: 0;
        background: linear-gradient(to left, var(--bg) 25%, transparent);
        justify-content: flex-end;
    }

    .tile {
        /* Rendered as a <button> for keyboard access — reset native chrome that
              the rules below don't already override (text-align + appearance). */
        appearance: none;
        -webkit-appearance: none;
        text-align: left;
        flex: 0 0 auto;
        position: relative;
        background: linear-gradient(135deg, var(--panel) 0%, var(--panel-2) 100%);
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 14px;
        padding-left: 18px;            /* room for the category color stripe */
        cursor: pointer;
        overflow: hidden;
        transition: transform .15s, border-color .15s, box-shadow .15s;
        display: flex;
        gap: 12px;
    }
    .tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    /* Category color stripe down the left edge */
    .tile::before {
        content: '';
        position: absolute;
        left: 0; top: 0; bottom: 0;
        width: 4px;
        background: var(--cat-color, var(--border));
    }
    .tile:hover {
        transform: translateY(-4px) scale(1.02);
        border-color: var(--cat-color, var(--accent));
        box-shadow: 0 10px 28px rgba(0, 0, 0, .45),
                                0 0 0 1px var(--cat-color, rgba(88, 166, 255, .3));
    }
    .tile .emoji {
        font-size: 32px;
        line-height: 1;
        flex: 0 0 auto;
        filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .5));
    }
    .tile .info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
    }
    .tile .name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
    .tile .desc {
        color: var(--muted);
        font-size: 12px;
        line-height: 1.35;
        flex: 1;
    }
    .tile .chips { margin-top: 8px; }
    .tiles.top .tile .emoji { font-size: 44px; }

    /* Top picks — larger tiles with a gradient face. Hue is tinted by the
          game's category color via color-mix; darkness is kept consistent so the
          row reads as a set rather than a rainbow. */
    .tiles.top .tile {
        width: 220px;
        min-height: 140px;
        background: linear-gradient(135deg,
            color-mix(in srgb, var(--cat-color, #58a6ff) 20%, var(--tile-base)) 0%,
            color-mix(in srgb, var(--cat-color, #58a6ff) 9%, var(--tile-base)) 100%);
        border-color: var(--tile-border);
    }
    .tiles.top .tile .name { font-size: 16px; }
    .tiles.top .tile .desc { font-size: 12.5px; }

    /* Top tile: emoji + name on top row, rest spans full width below. */
    .tiles.top .tile {
        display: grid;
        grid-template-columns: auto 1fr;
        column-gap: 12px;
        row-gap: 6px;
        align-items: start;
    }
    .tiles.top .tile .emoji { align-self: center; }
    .tiles.top .tile .info { display: contents; }
    .tiles.top .tile .info .name {
        align-self: center;
        margin-bottom: 0;
    }
    .tiles.top .tile:has(.score-badge) .emoji { grid-row: 1 / span 2; }
    .tiles.top .tile .info .score-badge {
        grid-column: 2;
        margin: 0;
    }
    .tiles.top .tile .info .desc,
    .tiles.top .tile .info .chips {
        grid-column: 1 / -1;
        margin: 0;
    }

    /* Standard category tiles */
    .row:not(.row-top) .tile { width: 170px; min-height: 100px; }

    /* About blurb at the bottom of the welcome screen */
    #about {
        margin-top: 24px;
        padding-top: 20px;
        border-top: 1px solid var(--border);
        color: var(--muted);
        font-size: 13px;
        line-height: 1.6;
        text-align: center;
    }
    #about a { color: var(--accent); text-decoration: none; }
    #about a:hover { text-decoration: underline; }

    @keyframes splat {
        0%   { transform: scale(0) rotate(-6deg); opacity: 0; }
        60%  { transform: scale(1.12) rotate(2deg); opacity: 1; }
        100% { transform: scale(1) rotate(0); }
    }
    @keyframes float {
        0%, 100% { transform: translateY(0); }
        50%      { transform: translateY(-8px); }
    }

    /* ===================== Theme toggle (top-right of the launcher) ===================== */
    #theme-toggle {
        position: fixed;
        top: 12px;
        right: 22px;
        z-index: 100;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        background: var(--panel-2);
        border: 1px solid var(--border);
        border-radius: 8px;
        font-size: 18px;
        line-height: 1;
        color: var(--text);
        transition: background .15s, border-color .15s, transform .15s;
    }
    #theme-toggle:hover { border-color: var(--accent); transform: scale(1.08); }
    /* Hide while a game is loaded — the iframe owns the view there. */
    body.in-game #theme-toggle { display: none; }

    /* ===================== Library toggle (top-right, beside theme toggle) ===================== */
    #hamburger {
        display: flex;             /* always shown (mobile + desktop) */
        position: fixed;
        /* Sits in the top-right, just left of #theme-toggle (40px wide + 8px gap). */
        top: 12px;
        right: 70px;
        z-index: 100;
        width: 40px;
        height: 40px;
        background: var(--panel-2);
        border: 1px solid var(--border);
        border-radius: 8px;
        color: var(--text);
        align-items: center;
        justify-content: center;
        cursor: pointer;
        padding: 0;
        transition: background .15s, border-color .15s, transform .15s;
    }
    #hamburger:hover { border-color: var(--accent); transform: scale(1.08); }
    /* Looks identical whether the panel is open or closed — it just toggles it. */
    /* Hide while a game is loaded — same as the theme toggle. */
    body.in-game #hamburger { display: none; }

    /* iOS top-URL-bar browsers (see the ios-topbar script) overlap fixed top
       content in PORTRAIT (in landscape Chrome hides its bar, so no offset).
       Drop the top buttons clear of the bar there. Desktop/Safari unaffected. */
    @media (orientation: portrait) {
        html.ios-topbar #theme-toggle,
        html.ios-topbar #hamburger { top: 48px; }
    }

    /* 2×2 grid icon — clearly "library / apps", and doesn't collide with the
          hamburger pattern many games use for their own pause menus. */
    #hamburger .grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr;
        gap: 3px;
        width: 20px;
        height: 20px;
    }
    #hamburger .grid span {
        background: var(--text);
        border-radius: 2px;
    }
    /* Backdrop dims the screen behind the TOUCH drawer (it only covers the side,
          so we dim the rest) and catches an outside tap to close. Touch-only —
          the non-touch side panel is in-flow and never overlays the game. */
    #backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .55);
        z-index: 50;
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s;
    }
    body.touch #backdrop { display: block; }
    #backdrop.show { opacity: 1; pointer-events: auto; }

    /* ===================== Polish: stagger + wiggle + dice + sparkle ===================== */

    /* Tile entrance — staggered fade+rise. --i is set per-tile in makeTile,
          capped so wide rows don't take forever to finish populating. */
    .tile {
        animation: tile-enter .3s ease-out backwards;
        animation-delay: calc(var(--i, 0) * 25ms);
    }
    @keyframes tile-enter {
        from { opacity: 0; transform: translateY(10px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    /* Emoji wiggle on tile hover — fires once per hover-in, doesn't loop. */
    .tile:hover .emoji { animation: emoji-wiggle .5s ease-in-out; }
    @keyframes emoji-wiggle {
        0%, 100% { transform: rotate(0) scale(1); }
        25%      { transform: rotate(-14deg) scale(1.15); }
        60%      { transform: rotate(10deg)  scale(1.08); }
    }

    /* Random-button die roll — quick tumble before navigating. */
    .quick-btn .icon { display: inline-block; }
    .quick-btn .icon.rolling { animation: dice-roll .28s ease-out; }
    @keyframes dice-roll {
        0%   { transform: rotate(0)      scale(1); }
        50%  { transform: rotate(180deg) scale(1.3); }
        100% { transform: rotate(360deg) scale(1); }
    }

    /* Logo idle sparkles — small white square that rotates while floating up. */
    .sparkle {
        position: absolute;
        pointer-events: none;
        background: var(--spark, #fff);
        border-radius: 1px;
        box-shadow: 0 0 8px rgba(255, 255, 255, .8),
                                0 0 14px rgba(180, 220, 255, .4);
        z-index: 3;
        animation: sparkle-float 1.3s ease-out forwards;
    }
    @keyframes sparkle-float {
        0%   { opacity: 0; transform: translateY(0)    rotate(0)      scale(.3); }
        18%  { opacity: 1; transform: translateY(-10px) rotate(140deg) scale(1);  }
        100% { opacity: 0; transform: translateY(-60px) rotate(540deg) scale(.4); }
    }

    /* Respect OS-level "reduce motion" preference — kill the playful animations
          that aren't required for understanding the page. Starfield + sparkle JS
          loops are skipped in setupStarfield / setupSparkles for the same reason. */
    @media (prefers-reduced-motion: reduce) {
        .tile,
        .tile:hover .emoji,
        .quick-btn .icon.rolling,
        .sparkle,
        #welcome-logo,
        #sidebar-logo-wrap,
        #sidebar-logo { animation: none !important; }
        .tile { opacity: 1; transform: none; }
    }

    /* ===================== Mobile / narrow viewport ===================== */
    @media (max-width: 720px) {
        /* Sidebar drawer behavior is handled by the touch rules above (not by
              width), so there are no sidebar/backdrop overrides here. */

        /* Welcome screen tweaks — extra top padding so the top buttons don't
              overlap the logo, smaller side padding for more content width. */
        #welcome { padding: 60px 16px 40px; }
        #welcome-hero { margin-bottom: 24px; }
        #welcome-tagline { font-size: 13px; }

        /* Bigger touch targets + readable text inside the drawer. */
        #sidebar-header { padding: 14px 14px 12px; }
        #search { padding: 11px 12px; font-size: 15px; }
        .card { padding: 12px 14px; }
        .card .title { font-size: 16px; }
        .card .title .emoji { font-size: 22px; flex-basis: 28px; }
        .card .desc { font-size: 13.5px; }
        .chip { padding: 2px 8px; font-size: 11.5px; }

        /* Hide the category filter chips and the footer buttons on mobile —
              the drawer is cramped enough already; leave just the logo, search,
              and game list. (Footer actions are still reachable from the welcome
              screen or via the iframe game's own UI / OS share.) */
        #filter-chips { display: none; }
        #sidebar-footer { display: none; }

        /* Welcome tiles — slightly bigger text so they're readable on phones. */
        .tile .name { font-size: 15px; }
        .tile .desc { font-size: 12.5px; }
        .tiles.top .tile { width: 200px; min-height: 130px; }
        .row:not(.row-top) .tile { width: 160px; min-height: 96px; }
        .row h2 { font-size: 14px; }

        /* Quick-action buttons big enough to tap comfortably. */
        .quick-btn { padding: 14px 22px; font-size: 15px; }
    }

/* ---- second style block (was index.html 857-1034) ---- */

    /* ===================== Arcade Floor ===================== */

    /* Third top-right icon: About (?). Right of hamburger, left of theme. */
    #about-btn {
        position: fixed; top: 12px; right: 70px; z-index: 100;
        width: 40px; height: 40px;
        display: flex; align-items: center; justify-content: center;
        padding: 0; background: var(--panel-2); border: 1px solid var(--border);
        border-radius: 8px; font-size: 20px; font-weight: 700; line-height: 1;
        color: var(--accent);
        transition: background .15s, border-color .15s, transform .15s;
    }
    #about-btn:hover { border-color: var(--accent); transform: scale(1.08); }
    /* The launcher's own library toggle is retired — each game's top-right
          toolbar now carries the Library button (on touch AND desktop, via the
          menus.js handshake), so there's nothing for this to do. */
    #hamburger { display: none; }
    body.in-game #about-btn { display: none; }
    @media (orientation: portrait) { html.ios-topbar #about-btn { top: 48px; } }

    /* Fourth top-right icon: Fullscreen (⛶). Left of about. Toggles the whole
          page in/out of fullscreen on the welcome screen; hidden in-game (the
          game's own toolbar owns fullscreen there, like the theme/about icons). */
    #fullscreen-toggle {
        position: fixed; top: 12px; right: 118px; z-index: 100;
        width: 40px; height: 40px;
        display: flex; align-items: center; justify-content: center;
        padding: 0; background: var(--panel-2); border: 1px solid var(--border);
        border-radius: 8px; font-size: 19px; line-height: 1;
        color: var(--text);
        transition: background .15s, border-color .15s, transform .15s;
    }
    #fullscreen-toggle:hover { border-color: var(--accent); transform: scale(1.08); }
    body.in-game #fullscreen-toggle { display: none; }
    /* Touch devices: browser fullscreen is unreliable on mobile, so hide it
          (matches the game toolbar's hideOnTouch fullscreen button). */
    body.touch #fullscreen-toggle { display: none; }
    @media (orientation: portrait) { html.ios-topbar #fullscreen-toggle { top: 48px; } }

    /* ---- Hero attract cabinet: 16:9 screen + side info/controls panel ---- */
    /* The cabinet itself is NOT a button — only the screen and the PLAY NOW
          button launch the game (see .hero-screen / .hero-coin below). So no
          whole-cabinet cursor:pointer or hover highlight. */
    #hero-cabinet {
        display: flex; align-items: stretch; margin: 0 auto 28px; max-width: 1100px;
        border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
        background: var(--panel);
        box-shadow: 0 10px 40px rgba(0,0,0,.5), 0 0 0 1px rgba(88,166,255,.15);
    }
    /* The screen holds the attract iframe at a locked 16:9 aspect ratio. It is
          one of the two play surfaces (with PLAY NOW) — clicking it launches
          the game, so it gets the pointer cursor + a hover ring. */
    .hero-screen { position: relative; flex: 0 0 62%; aspect-ratio: 16 / 9; background: #000; border-right: 1px solid var(--border); cursor: pointer; }
    /* Accent ring on hover, layered above the iframe (an inset shadow on the
          screen itself would be hidden behind the frame). Pointer-events off so
          it never eats the click. Gated to hover-capable devices so it can't
          stick after a tap on touch. */
    .hero-screen::after {
        content: ''; position: absolute; inset: 0; pointer-events: none;
        box-shadow: inset 0 0 0 2px var(--accent); opacity: 0; transition: opacity .15s;
    }
    @media (hover: hover) { .hero-screen:hover::after { opacity: 1; } }
    /* The attract iframe is purely visual — pointer-events off so it never
          handles input. Starts transparent and fades in once the attract is
          clean (no white flash, no menu flicker). */
    #hero-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; background: #000; opacity: 0; transition: opacity .35s ease; }
    /* Transparent hit layer ON TOP of the iframe. Catches the launch tap/click,
          and — crucially on real mobile — keeps the touch from ever reaching the
          iframe (which can swallow drag-to-scroll gestures there despite the
          iframe's pointer-events:none). A plain div scrolls the page on drag and
          fires click on tap, so the hero scrolls like the rest of the page. */
    .hero-hit { position: absolute; inset: 0; cursor: pointer; appearance: none; -webkit-appearance: none; background: none; border: 0; padding: 0; }
    .hero-hit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
    /* Info + controls panel beside the screen, like a cabinet marquee. */
    .hero-bar {
        flex: 1; min-width: 0;
        display: flex; flex-direction: column; justify-content: center; gap: 9px;
        padding: 20px 22px; color: var(--text);
        background: linear-gradient(135deg, var(--panel) 0%, var(--panel-2) 100%);
    }
    .hero-now { font-size: 10px; letter-spacing: 1.5px; color: var(--muted); }
    .hero-name { font-size: 30px; font-weight: 800; line-height: 1.1; color: var(--text); }
    .hero-bar .hero-score { align-self: flex-start; }
    .hero-bar .hero-score[hidden] { display: none; }
    /* PLAY NOW is a real button (the other play surface besides the
          screen) — it takes pointer events, a pointer cursor, and a hover lift. */
    .hero-coin {
        align-self: flex-start; margin-top: 4px;
        background: linear-gradient(135deg, var(--accent), #2978d3); border: 1px solid var(--accent);
        color: #fff; font-weight: 700; font-size: 14px; padding: 10px 18px; border-radius: 9px;
        box-shadow: 0 4px 16px rgba(88,166,255,.4); white-space: nowrap; cursor: pointer;
        transition: filter .12s, box-shadow .12s, transform .12s;
    }
    .hero-coin:hover { filter: brightness(1.08); box-shadow: 0 6px 22px rgba(88,166,255,.55); transform: translateY(-1px); }
    .hero-coin:active { transform: translateY(0); }
    .hero-shuffle {
        align-self: flex-start; margin-top: 2px;
        background: rgba(127,127,127,.10); border: 1px solid var(--border);
        color: var(--muted); padding: 7px 12px; border-radius: 8px; font-size: 12px;
        transition: border-color .12s, background .12s, color .12s;
    }
    .hero-shuffle:hover { border-color: var(--accent); background: rgba(127,127,127,.20); color: var(--text); }
    /* Touch: drop the "show a different game" button (cycling is glitchy there). */
    body.touch .hero-shuffle { display: none; }
    /* While the auto-advance counts down, the NOW PLAYING / FEATURED line shows it. */
    .hero-now.counting { color: var(--accent-2); }
    /* Narrow viewports: stack the screen above the panel. */
    @media (max-width: 720px) {
        #hero-cabinet { flex-direction: column; }
        .hero-screen { flex: 0 0 auto; width: 100%; border-right: 0; border-bottom: 1px solid var(--border); }
        .hero-bar { padding: 16px 18px; }
        .hero-name { font-size: 24px; }
    }
    /* Short viewports (phones in landscape): keep the logo + hero compact so
          they don't eat the whole screen before the grid. */
    @media (max-height: 520px) {
        #welcome-hero { margin-bottom: 14px; }
        #welcome-logo { width: min(120px, 22vw); }
    }

    /* ---- Floor controls + responsive grid ---- */
    .floor-section { max-width: 1320px; margin: 0 auto; }
    .floor-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 14px; }
    .floor-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
    .floor-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
    .floor-search { width: 210px; max-width: 60vw; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font: inherit; outline: none; }
    .floor-search:focus { border-color: var(--accent); }
    .floor-chips { display: flex; flex-wrap: wrap; gap: 5px; }
    .floor-chip { position: relative; background: var(--chip-bg); color: var(--chip-text); border: 1px solid transparent; padding: 5px 12px 5px 18px; border-radius: 13px; font-size: 12px; transition: background .1s, color .1s, border-color .1s; }
    /* Category color bar on the left — mirrors the stripe on the game tiles, so a
       filter chip's color maps 1:1 to its category. 'All' has no category color, so
       it falls back to a neutral bar (same fallback the tile stripe uses). */
    .floor-chip::before { content: ''; position: absolute; left: 7px; top: 5px; bottom: 5px; width: 4px; border-radius: 2px; background: var(--cat-color, var(--border)); }
    .floor-chip:hover { background: var(--panel-2); color: var(--text); }
    .floor-chip.on { background: var(--cat-bg, var(--accent-bg)); color: var(--text); border-color: var(--cat-color, var(--accent)); }

    .floor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 14px; padding-bottom: 36px; }
    /* Narrow phones (e.g. iPhone SE): smaller min column so two cards fit per row. */
    @media (max-width: 480px) {
        .floor-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    }
    /* Reuse the existing .tile look, but let it flex to the grid cell width. */
    .floor-grid .tile { width: auto; min-height: 104px; }
    /* Full-width divider before the Under Construction section (mirrors sidebar). */
    .floor-grid .floor-divider {
        grid-column: 1 / -1;
        margin: 22px 0 2px; padding-top: 14px;
        border-top: 1px dashed var(--border);
        color: var(--cat-construction);
        font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.2px;
    }

    /* ---- About modal ---- */
    #about-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
    #about-modal[hidden] { display: none; }
    .about-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
    .about-panel {
        position: relative; z-index: 1; width: min(560px, 92vw); max-height: 88vh; overflow-y: auto;
        background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
        padding: 30px 30px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.6); text-align: center;
    }
    .about-close { position: absolute; top: 16px; right: 14px; background: none; border: 0; color: var(--muted); font-size: 24px; line-height: 1; }
    .about-close:hover { color: var(--text); }
    .about-logo { width: 120px; height: auto; filter: drop-shadow(0 4px 16px rgba(88,166,255,.4)); margin-bottom: 4px; }
    .about-panel h2 { margin: 6px 0 4px; font-size: 20px; color: var(--text); }
    .about-panel h3 { margin: 18px 0 6px; font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--accent); }
    .about-panel p { margin: 0 auto 8px; color: var(--muted); font-size: 13.5px; line-height: 1.6; max-width: 46ch; }
    .about-panel code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 12px; color: var(--text); }
    .about-links { display: flex; flex-direction: column; gap: 8px; margin: 8px auto; max-width: 420px; }
    .about-links a { display: block; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 10px 14px; color: var(--text); text-decoration: none; font-size: 13.5px; text-align: left; transition: border-color .12s, background .12s; }
    .about-links a:hover { border-color: var(--accent); background: var(--accent-bg); }
    .about-links a .sub { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
    .about-credit { margin-top: 16px; font-size: 12px; color: var(--muted); }
    @media (max-width: 720px) {
        .about-panel { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; padding-top: 58px; }
    }
