/* ===========================================================================
   killpipe — one stylesheet for the whole site.

   Home and TV defined the canonical look (dark #0E1014 body, accent green
   #22CC77, Inter-style sans-serif). Every page — home, games index, each
   individual game, TV — uses *this* file and only this file. Inline CSS
   in a page is reserved for that page's unique gameplay/board surface
   (the math-path grid, scramble's letter cells, etc.), nothing chrome.

   Token names follow the historical retro.css scheme so existing class
   references keep working. Short aliases (--bg, --text, --accent…)
   resolve to the same values for new code.
   ============================================================================ */

:root {
    /* Surfaces (dark to light) */
    --bg-primary:   #0E1014;
    --bg-surface:   #15181D;
    --bg-elevated:  #1C1E26;
    --bg-raised:    #252830;
    /* Borders */
    --border-dark:    #1B1E25;
    --border-medium:  #2A2E37;
    --border-strong:  #3A3D48;
    --border-light:   #4A4D58;
    /* Text */
    --text-primary:   #FFFFFF;
    --text-secondary: #C8CAD0;
    --text-muted:     #7A7D85;
    /* Accents */
    --accent-green:   #22CC77;
    --accent-gold:    #FFB830;
    --accent-red:     #FF4D4D;
    --accent-blue:    #9BCDFF;
    --accent-purple:  #AA44FF;
    --accent-orange:  #FF6B35;
    /* Misc */
    --radius:    12px;
    --radius-sm: 8px;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    /* Short aliases — same values, easier to type for new code. */
    --bg: var(--bg-primary);
    --surface: var(--bg-surface);
    --surface-2: var(--bg-elevated);
    --text: var(--text-primary);
    --accent: var(--accent-green);
    --warn: var(--accent-gold);
    --error: var(--accent-red);
    --mono-font: var(--mono);
}

/* ---------- reset + base ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}

h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; color: var(--text); margin-bottom: 4px; }
h2 { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
p  { line-height: 1.6; margin-bottom: 8px; }
a  { color: var(--accent); text-decoration: none; transition: opacity .15s; }
a:hover { opacity: 0.85; }

/* ---------- shared layout ---------- */
/* Single page wrapper used site-wide. Game pages previously declared
 * a separate .container with no top padding — that made the topnav sit
 * higher on game screens than on home/games-index/tv/stats. Same rules
 * now mean the nav lands at the exact same y on every page. */
.page, .container {
    max-width: 480px;
    margin: 0 auto;
    padding: 24px 20px 36px;
}

/* Top navigation: KILLPIPE / Home / Games / TV. Standardized across
 * every page — one HTML pattern (.topnav .brand .links), one set of
 * styles. align-items: baseline pins the brand bottom and the link
 * bottoms to the same line even though they use different font sizes
 * (13px vs 11px). */
.topnav {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 14px 0 22px;
    -webkit-tap-highlight-color: transparent;
}
.topnav .brand {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--text);
    text-decoration: none;
    transition: opacity .15s;
}
.topnav .brand:hover { opacity: .8; }
.topnav .links { display: flex; align-items: baseline; gap: 22px; }
/* Topnav links use the canonical .tab class below. Anchors get
 * class="tab" / class="tab active" so the underline + colors come from
 * the single shared rule — no per-component duplicates. */

/* ─── Canonical tab component ───────────────────────────────────────
 * One class for every "uppercase link with optional active underline":
 *   - topnav links (.topnav .links a.tab)
 *   - TV category tabs (.tabs .tab)
 *   - games index tabs (.tabs .tab)
 *
 * Two rules: (1) the tab itself stays text-only height; (2) the active
 * underline is absolutely positioned below the text so it can never
 * push the text up or change the tab's box height. That last bit is
 * the whole reason this lives in one place — it was getting reinvented
 * (and reintroducing the bug) every time a new tab strip was added. */
.tab {
    position: relative;
    display: inline-block;
    /* Strip every flavour of native button chrome. Without these, Safari
     * renders <button class="tab"> with its rounded gray native look and
     * ignores our background/border declarations — the whole "looks like
     * a button, not a tab" bug. */
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    background-color: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    outline: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-decoration: none;
    text-transform: uppercase;
    white-space: nowrap;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
}
.tab:hover,
.tab.active { color: var(--text); }
.tab.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -5px;
    height: 1px;
    background: var(--accent);
}

/* Container for a horizontal tab strip. .tabs--scroll allows overflow
 * so long strips (TV categories, 7+ items) horizontally scroll on
 * narrow viewports without breaking the layout. */
.tabs {
    display: flex;
    align-items: baseline;
    gap: 22px;
    margin-bottom: 16px;
}
.tabs--scroll {
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs--scroll::-webkit-scrollbar { display: none; }

/* Share card (Wordle-style result preview).
   /js/share.js renders into a host element (typically #shareSection).
   The grid is the visualisation of the user's run, then a scoreline,
   streak chip, and Share / Copy buttons. */
.ks-share {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius);
    padding: 22px 20px 18px;
    margin: 18px 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.ks-share .ks-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ks-share .ks-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}
.ks-share .ks-puz {
    font-family: var(--mono);
    color: var(--text);
    font-weight: 800;
    letter-spacing: 0;
}
.ks-share .ks-pb {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.5px;
    background: var(--accent);
    color: #000;
    padding: 2px 6px;
    border-radius: 999px;
    text-transform: uppercase;
}
.ks-share .ks-score {
    font-family: var(--mono);
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
    line-height: 1.1;
    margin: 2px 0;
}
.ks-share .ks-sub {
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}
.ks-share .ks-grid {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 18px;
    line-height: 1.15;
    margin: 10px 0;
    color: var(--text);
    background: none;
    padding: 0;
    white-space: pre;
    user-select: text;
    /* Emoji on most platforms have their own metrics — letter-spacing
       a bit tighter so the grid reads as a block, not isolated cells. */
    letter-spacing: -0.5px;
}
.ks-share .ks-streak {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--accent);
    padding: 4px 12px;
    background: rgba(34, 204, 119, 0.10);
    border: 1px solid rgba(34, 204, 119, 0.35);
    border-radius: 999px;
    text-transform: uppercase;
}
.ks-share .ks-streak-num {
    font-family: var(--mono);
    font-weight: 800;
    color: var(--text);
}
.ks-share .ks-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    width: 100%;
    max-width: 320px;
}
.ks-share .ks-btn {
    flex: 1;
    background: none;
    border: 1px solid var(--border-strong);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .1s;
}
.ks-share .ks-btn:hover:not(:disabled) {
    background: var(--bg-raised);
    border-color: var(--border-light);
}
.ks-share .ks-btn:active:not(:disabled) { transform: scale(0.98); }
.ks-share .ks-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}
.ks-share .ks-btn.primary:hover { filter: brightness(1.08); }
.ks-share .ks-status {
    min-height: 16px;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--accent);
    opacity: 0;
    transition: opacity .2s;
}
.ks-share .ks-status.show { opacity: 1; }

/* Streak chip — injected into .topnav .links by /js/streak-chip.js.
   Always present so navigation doesn't flicker the chrome; styles
   change based on whether the user has an active streak. */
.streak-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1;
    transition: background .15s, border-color .15s, transform .15s, opacity .2s;
}
.streak-chip .flame {
    font-size: 12px;
    line-height: 1;
    /* Emoji glyphs sit ~1px above the text baseline on most platforms,
       so the chip's "🔥 N" looks lopsided without an explicit nudge. */
    display: inline-flex;
    transform: translateY(0.5px);
}
.streak-chip .num {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}
/* Chip lives inside .topnav .links which has a fairly specific rule
   for its anchors (0,2,1). To win the cascade we scope these with the
   same parent prefix (0,3,0). is-on/is-off rather than active/idle so
   we don't collide with the topnav's .active class on the current-page
   link. */
.topnav .links .streak-chip.is-on {
    background: rgba(34, 204, 119, 0.10);
    border: 1px solid rgba(34, 204, 119, 0.35);
    color: var(--accent);
}
.streak-chip.is-on .num { color: var(--text); }
.streak-chip.is-on .flame { animation: streak-flicker 1.5s ease-in-out infinite; }
.topnav .links .streak-chip.is-on:hover {
    background: rgba(34, 204, 119, 0.18);
    border-color: var(--accent);
    transform: translateY(-1px);
}
/* "Off" state — no streak yet. Dim, grayscale flame, no animation. */
.topnav .links .streak-chip.is-off {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-dark);
    color: var(--text-muted);
}
.streak-chip.is-off .flame { filter: grayscale(1); opacity: 0.55; }
.streak-chip.is-off .num { color: var(--text-muted); }
.topnav .links .streak-chip.is-off:hover {
    border-color: var(--border-medium);
    color: var(--text-secondary);
}

@keyframes streak-flicker {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25%      { transform: scale(1.08) rotate(-3deg); }
    50%      { transform: scale(1) rotate(0deg); }
    75%      { transform: scale(1.08) rotate(3deg); }
}

/* "Back to games" link used on each game page */
.back-link {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
    transition: opacity .15s;
}
.back-link:hover { opacity: .8; }

/* Floating "?" help button next to back-link, injected by tutorial.js */
.help-btn {
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 16px;
    font-weight: bold;
    width: 32px; height: 32px;
    cursor: pointer;
    margin-left: 12px;
    vertical-align: middle;
    line-height: 1;
    padding: 0;
    transition: color .15s, border-color .15s;
}
.help-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Hero / page header (home + TV use this; games' .header is similar) */
.hero {
    margin-bottom: 14px;
    padding-bottom: 14px;
}
.hero-date {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}
.hero-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.4px;
    color: var(--text);
}
.hero-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.header { text-align: left; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border-dark); }
.header h1, h1.page-title { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; color: var(--text); margin-bottom: 4px; }
.puzzle-number, .subtitle { font-size: 12px; color: var(--text-muted); letter-spacing: 1px; }

/* Section header (home's "TODAY'S GAMES", "LATEST" rows) */
.sec-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 18px 0 10px;
}
.sec-head + .rows { margin-top: 0; }
.sec-head .h {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-transform: uppercase;
}
.sec-head .meta {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* Row list (home, games-index, TV).
   .row is used both as <a> (home/games) and <button> (TV channels), so the
   rule has to neutralise the generic button defaults (filled background,
   border on every side, rounded corners) — otherwise TV's live grid
   renders as a stack of pill buttons instead of a clean list. */
.rows { display: flex; flex-direction: column; }
.row {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 14px 0;
    border: 0;
    border-top: 1px solid var(--border-dark);
    border-radius: 0;
    background: none;
    text-decoration: none;
    color: inherit;
    text-align: left;
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: padding-left .15s, color .15s;
}
.row:last-child { border-bottom: 1px solid var(--border-dark); }
.row:hover { padding-left: 4px; }
.row:hover .row-name { color: var(--accent); }
.row.active .row-num { color: var(--accent); }
.row.done   .row-num { color: var(--accent); }
.row-num {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-align: center;
}
.row-body { min-width: 0; }
.row-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.row-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.row-meta { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.row-pb { font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: .5px; }
.row-time { font-size: 11px; color: var(--text-muted); letter-spacing: .5px; }
.row-mark { font-size: 14px; font-weight: 700; color: var(--border-medium); width: 14px; text-align: center; }
.row.done .row-mark { color: var(--accent); }
/* TV "LIVE" badge: red text + pulsing red dot. The badge is a .row-tag
   inside the channel button; .row-tag.upcoming (defined further down in
   the TV block) overrides this for upcoming-broadcast countdowns. */
.row-tag {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent-red);
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.live-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent-red);
    box-shadow: 0 0 6px rgba(255, 77, 77, 0.55);
    animation: pulse 1.6s infinite;
}

/* Stats row (games' top stats) */
.stats {
    display: flex;
    align-items: center;
    margin: 4px 0 18px;
    padding: 0;
    background: none;
}
.stat + .stat {
    border-left: 1px solid var(--border-dark);
    padding-left: 14px;
}
.stat { text-align: left; padding: 0 14px 0 0; }
.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.stat-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    font-family: var(--mono);
}
.stat-value.score, .stat-value.green { color: var(--accent); }
.stat-value.time { color: var(--warn); }
.stat-value.time.urgent { color: var(--error); }
.stat-value.mode { color: var(--text-secondary); font-size: 14px; font-family: inherit; }

/* Buttons */
button {
    background: var(--bg-raised);
    border: 1px solid var(--border-strong);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    transition: background .15s, border-color .15s, transform .1s;
    -webkit-tap-highlight-color: transparent;
}
button:hover:not(:disabled) { background: var(--border-medium); }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.3; cursor: not-allowed; }
button.primary,
button[type="submit"], button.start, .start-btn, .play-btn, .play-button {
    background: var(--accent);
    color: #000;
    border: none;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 14px 26px;
}
button.primary:hover:not(:disabled),
button[type="submit"]:hover:not(:disabled),
button.start:hover:not(:disabled), .start-btn:hover:not(:disabled),
.play-btn:hover:not(:disabled), .play-button:hover:not(:disabled) {
    filter: brightness(1.08);
    background: var(--accent);
}

/* Form inputs */
.kp-input, .answer-input, input[type="text"], input[type="number"], input[type="search"] {
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 18px;
    padding: 14px 16px;
    width: 100%;
    transition: border-color .15s;
}
.kp-input:focus, .answer-input:focus,
input[type="text"]:focus, input[type="number"]:focus, input[type="search"]:focus {
    outline: none;
    border-color: var(--accent);
}

/* Panels (used by game-over screens, modals) */
.panel, .puzzle-content, .completion-modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    padding: 18px;
    margin: 14px 0;
}
.game-over h2, .completion-modal h2 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--text);
}
.final-score, .result-score {
    font-size: 36px;
    font-weight: 900;
    color: var(--accent);
    text-align: center;
    margin: 6px 0 14px;
    font-family: var(--mono);
}

/* Footer */
.footer {
    margin-top: 28px;
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 1px;
}
.footer a { color: var(--text-secondary); font-weight: 600; text-decoration: none; }
.footer a:hover { color: var(--text); }
.footer .sep { margin: 0 8px; opacity: .5; }

/* Utility classes */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-gold   { color: var(--warn); }
.text-error  { color: var(--error); }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

/* Visible focus rings for keyboard users only */
button:focus-visible, a:focus-visible, input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Animations */
.pulse { animation: pulse 2s infinite; }
.pop { animation: pop 0.2s ease-out; }
.shake { animation: shake 0.3s ease; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

/* Score / time-display monospace */
.score, .time-display, .timer, .countdown,
.digit, .number-display { font-family: var(--mono); }

/* ===========================================================================
   TV — formerly /tv/tv.css. Lives here because the user wants one CSS file.
   These selectors are page-unique (.tv-tabs, .tv-player, .mode-pills,
   .digest-filters, etc.) so they coexist with the rest without scoping.
   ============================================================================ */
        /* TV page-specific layout: full-viewport with fixed top + scrolling grid */
        .page.tv {
            height: 100vh;
            height: 100dvh;
            padding-bottom: 0;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        .tv > .topnav,
        .tv > .hero,
        .tv > .tv-tabs,
        .tv > .tv-player { flex-shrink: 0; }
        .tv > .hero { margin-bottom: 14px; padding-bottom: 14px; }
        /* Title on the left, mode pills baseline-aligned on the right.
           hero-sub stays alone on the second line so the pills don't
           visually compete with the live count. */
        .tv .hero-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            min-width: 0;
        }
        .tv .hero-row .hero-title { min-width: 0; }
        .tv .hero-row .mode-pills { margin: 0; flex-shrink: 0; }

        /* Category tabs share the canonical .tab / .tabs styles. The
         * old .tv-tab rules used to live here — see .tab in this
         * stylesheet for the canonical implementation. */

        /* Player */
        .tv-player { margin-bottom: 16px; }
        .tv-player[hidden] { display: none; }
        .tv-player .frame {
            position: relative;
            width: 100%;
            margin: 0 auto;
            aspect-ratio: 16 / 9;
            /* Cap by viewport height so player + grid both stay visible. */
            max-width: calc(38vh * 16 / 9);
            max-width: calc(38dvh * 16 / 9);
            background: #000;
            overflow: hidden;
        }
        .tv-player .frame iframe {
            position: absolute; inset: 0;
            width: 100%; height: 100%;
            border: none;
        }
        /* Top bar (above iframe): audio + close on the right */
        .tv-player .top-bar {
            display: flex; align-items: center; justify-content: flex-end;
            gap: 4px;
            padding: 6px 0 8px;
        }
        /* Bottom bar (below iframe): name+status on the left, tag on the right */
        .tv-player .bar {
            display: flex; align-items: center; justify-content: space-between;
            padding: 10px 0;
            border-bottom: 1px solid #1B1E25;
        }
        .tv-player .bar .left { display: flex; align-items: center; gap: 12px; min-width: 0; }
        .tv-player .bar .right { display: flex; align-items: center; gap: 8px; }
        .tv-player .bar .name {
            font-size: 13px; font-weight: 700; letter-spacing: 1.5px; color: #fff;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }
        .tv-player .bar .live {
            display: inline-flex; align-items: center; gap: 5px;
            font-size: 9px; font-weight: 700; letter-spacing: 2px; color: #FF4D4D;
        }
        .tv-player .bar .live::before {
            content: '';
            width: 6px; height: 6px; border-radius: 50%;
            background: #FF4D4D;
            animation: pulse 1.6s infinite;
        }
        .tv-player .bar .close {
            background: none; border: none; cursor: pointer;
            font: inherit;
            font-size: 11px; font-weight: 600; letter-spacing: 2px;
            color: var(--text-muted);
            padding: 4px 0; margin-left: 12px;
            transition: color .15s;
            -webkit-tap-highlight-color: transparent;
            text-transform: uppercase;
        }
        .tv-player .bar .close:hover { color: var(--text-primary); }

        /* Grid scroll area */
        .tv > .rows {
            flex: 1;
            overflow-y: auto;
            padding-bottom: 24px;
            -webkit-overflow-scrolling: touch;
        }
        /* On TV, rows are slightly tighter than on home/games */
        .tv .row { padding: 12px 0; }

        /* Empty state when category has no live channels */
        .tv-empty {
            padding: 32px 0;
            text-align: center;
            color: var(--text-muted);
            font-size: 12px;
        }
        .tv-empty .label {
            font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
            margin-bottom: 6px; color: #2A2E37;
        }

        /* Mode toggle — segmented control with a sliding green thumb.
           Two halves of equal width; the thumb is a pseudo-element on
           the container that translates between them via [data-mode]. */
        .mode-pills {
            position: relative;
            display: flex;
            padding: 3px;
            background: rgba(255,255,255,0.04);
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 999px;
            width: fit-content;
            isolation: isolate;
        }
        .mode-pills::before {
            content: "";
            position: absolute;
            top: 3px; bottom: 3px;
            left: 3px;
            width: calc(50% - 3px);
            background: var(--accent-green);
            border-radius: 999px;
            transition: transform .25s cubic-bezier(.4, 0, .2, 1);
            z-index: 0;
        }
        /* Pills are now ordered [Digests, Live]. Thumb sits over the
         * first pill (Digests) by default; slides right when Live is
         * active. Invert this if the pill order ever swaps back. */
        .mode-pills[data-mode="live"]::before {
            transform: translateX(100%);
        }
        .mode-pill {
            position: relative;
            z-index: 1;
            flex: 1 1 0;
            background: none; border: none; cursor: pointer;
            font: inherit;
            font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
            color: var(--text-muted); text-transform: uppercase;
            padding: 6px 18px;
            border-radius: 999px;
            transition: color .2s ease;
            -webkit-tap-highlight-color: transparent;
            text-align: center;
            min-width: 64px;
        }
        .mode-pill:hover { color: var(--text-primary); }
        .mode-pill.active { color: #000; }
        .mode-pill .count {
            font-size: 9px;
            opacity: .7;
            margin-left: 4px;
            font-weight: 600;
        }

        /* Latest items (digests) */
        .latest-row {
            display: grid;
            grid-template-columns: 28px 1fr auto;
            gap: 14px;
            align-items: center;
            padding: 12px 0;
            border-top: 1px solid #1B1E25;
            background: none; border-left: none; border-right: none; border-bottom: none;
            font: inherit;
            text-align: left;
            cursor: pointer;
            color: inherit;
            transition: padding .15s;
            -webkit-tap-highlight-color: transparent;
        }
        .latest-row:hover { padding-left: 4px; }
        .latest-row:hover .latest-title { color: var(--accent-green); }
        /* Active state matches the live-channel rows: title + num turn green,
           nothing else.  Same look across Live / Digests / Replays. */
        .latest-row.active .latest-title,
        .latest-row.active .latest-num { color: var(--accent-green); }

        /* Digest filter pills (Digests mode only). Stays pinned to the
           top of the scrolling list while the user scrolls. One row,
           horizontal scroll instead of wrapping — feels less crowded and
           visually matches the .tabs strip above it. */
        .digest-filters {
            display: flex;
            flex-wrap: nowrap;
            align-items: center;
            overflow-x: auto;
            scrollbar-width: none;
            gap: 6px;
            padding: 6px 0 10px;
            /* Without this, when the parent flex of .rows applies
             * implicit min-height: 0 the row collapses to the padding-
             * only height. min-height locks in a tappable row. */
            min-height: 38px;
            margin: 0 0 8px;
            border-bottom: 1px solid #1B1E25;
            position: sticky;
            top: 0;
            z-index: 5;
            background: #0E1014;
        }
        .digest-filters::-webkit-scrollbar { display: none; }
        .digest-tag {
            /* appearance: none kills native browser button chrome so the
             * pill shows up with the height we declare instead of being
             * collapsed to a sliver. Same root cause as .tab — same fix.
             * line-height + min-height pin the vertical size so the
             * country pills are actually tappable. */
            appearance: none;
            -webkit-appearance: none;
            display: inline-flex;
            align-items: center;
            flex: 0 0 auto;
            min-height: 22px;
            line-height: 1.4;
            background: rgba(255,255,255,0.04);
            border: 1px solid rgba(255,255,255,0.08);
            color: var(--text-muted);
            padding: 3px 10px;
            border-radius: 999px;
            font: inherit;
            font-size: 10px; font-weight: 600;
            letter-spacing: 0.3px;
            cursor: pointer;
            white-space: nowrap;
            transition: all .15s;
            -webkit-tap-highlight-color: transparent;
        }
        .digest-tag:hover {
            color: #fff;
            background: rgba(255,255,255,0.08);
            border-color: rgba(255,255,255,0.16);
        }
        .digest-tag.active {
            color: #000;
            background: var(--accent-green);
            border-color: var(--accent-green);
        }
        .latest-num {
            font-size: 11px; font-weight: 600;
            color: var(--text-muted);
            font-variant-numeric: tabular-nums;
            letter-spacing: 1px;
        }
        .latest-body { min-width: 0; }
        .latest-title {
            font-size: 13px; font-weight: 600;
            color: var(--text-primary);
            line-height: 1.35;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            transition: color .15s;
        }
        .latest-meta {
            font-size: 10px; color: var(--text-muted);
            margin-top: 4px;
            letter-spacing: 0.5px;
        }
        .latest-meta .channel { color: var(--text-secondary); font-weight: 600; }
        .latest-meta .sep { margin: 0 6px; opacity: .5; }
        .latest-duration {
            font-size: 10px; color: var(--text-muted);
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
        }

        /* === Audio mode overlay ===
           iframe is always mounted; in audio mode this overlay covers it
           with a thumbnail + transport controls floating on top.
           Audio keeps coming from the iframe, so the toggle is instant. */
        .player-content { position: relative; }
        .audio-overlay {
            position: absolute; inset: 0;
            background: #000;
            display: none;
            overflow: hidden;
            user-select: none;
            -webkit-user-select: none;
        }
        .tv-player.audio-only-active .audio-overlay { display: block; }

        .audio-overlay .thumb {
            position: absolute; inset: 0;
            background-size: cover;
            background-position: center;
            background-color: #000;
            transform: scale(1.02);   /* hide thumbnail edges */
            filter: brightness(0.55) saturate(1.1);
        }
        .audio-overlay .scrim {
            position: absolute; inset: 0;
            background:
                radial-gradient(circle at 50% 55%, rgba(0,0,0,0) 35%, rgba(0,0,0,0.45) 70%),
                linear-gradient(180deg, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.05) 30%, rgba(0,0,0,0.7) 100%);
            pointer-events: none;
        }

        .audio-overlay .badge {
            position: absolute; top: 12px; left: 12px;
            display: inline-flex; align-items: center; gap: 6px;
            padding: 5px 10px;
            background: rgba(0,0,0,0.65);
            backdrop-filter: blur(6px);
            border-radius: 4px;
            font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
            color: #fff; text-transform: uppercase;
        }
        .audio-overlay .badge .dot {
            width: 7px; height: 7px; border-radius: 50%;
            background: var(--text-muted);
        }
        .audio-overlay .badge.live .dot {
            background: #FF4D4D;
            box-shadow: 0 0 8px #FF4D4D;
            animation: pulse 1.5s ease-in-out infinite;
        }
        .audio-overlay .badge.upcoming .dot { background: #5BB6FF; }
        .audio-overlay .badge.replay .dot,
        .audio-overlay .badge.digest .dot { background: var(--accent-green); }

        /* Centered transport: <<15 [PLAY/PAUSE big] 15>>  */
        .audio-overlay .transport {
            position: absolute; inset: 0;
            display: flex; align-items: center; justify-content: center;
            gap: 22px;
            pointer-events: none;
        }
        .audio-overlay .transport > * { pointer-events: auto; }
        .audio-overlay .ctrl-btn {
            background: rgba(0,0,0,0.45);
            backdrop-filter: blur(8px);
            border: none;
            color: #fff;
            cursor: pointer;
            width: 44px; height: 44px;
            border-radius: 50%;
            display: inline-flex; align-items: center; justify-content: center;
            padding: 0;
            transition: background .15s, transform .1s;
            -webkit-tap-highlight-color: transparent;
        }
        .audio-overlay .ctrl-btn:hover { background: rgba(0,0,0,0.65); }
        .audio-overlay .ctrl-btn:active { transform: scale(0.94); }
        .audio-overlay .ctrl-btn svg { width: 22px; height: 22px; }
        .audio-overlay .ctrl-btn.play {
            width: 64px; height: 64px;
            background: rgba(255,255,255,0.95);
            color: #000;
        }
        .audio-overlay .ctrl-btn.play:hover { background: #fff; }
        .audio-overlay .ctrl-btn.play svg { width: 32px; height: 32px; }

        /* Bottom seek row */
        .audio-overlay .seek-row {
            position: absolute;
            left: 0; right: 0; bottom: 0;
            padding: 8px 14px 14px;
            display: grid;
            grid-template-columns: minmax(36px, auto) 1fr minmax(36px, auto);
            gap: 10px;
            align-items: center;
            font-variant-numeric: tabular-nums;
        }

        /* Auto-hide controls (YouTube-style): tap player to bring back.
           The badge (channel name / tag / status) stays visible so the
           user can always see what's playing — only transport + seek
           fade away. */
        .audio-overlay .scrim,
        .audio-overlay .transport,
        .audio-overlay .seek-row {
            transition: opacity .25s ease;
        }
        .audio-overlay.hide-ctrl .scrim,
        .audio-overlay.hide-ctrl .transport,
        .audio-overlay.hide-ctrl .seek-row {
            opacity: 0;
            pointer-events: none;
        }
        .audio-overlay { cursor: pointer; }
        .audio-overlay .seek-time {
            font-size: 11px;
            font-weight: 600;
            color: rgba(255,255,255,0.85);
            text-shadow: 0 1px 2px rgba(0,0,0,0.6);
        }
        .audio-overlay .seek-time.dur { text-align: right; }
        .audio-overlay .audio-seek {
            -webkit-appearance: none; appearance: none;
            background: transparent;
            width: 100%;
            min-width: 0;
            height: 16px;
            cursor: pointer;
            margin: 0;
        }
        .audio-overlay .audio-seek::-webkit-slider-runnable-track {
            height: 3px;
            background: rgba(255,255,255,0.25);
            border-radius: 2px;
        }
        .audio-overlay .audio-seek::-moz-range-track {
            height: 3px;
            background: rgba(255,255,255,0.25);
            border-radius: 2px;
        }
        .audio-overlay .audio-seek::-webkit-slider-thumb {
            -webkit-appearance: none; appearance: none;
            width: 12px; height: 12px;
            margin-top: -4.5px;
            border-radius: 50%;
            background: #fff;
            cursor: pointer;
            transition: transform .1s;
        }
        .audio-overlay .audio-seek:hover::-webkit-slider-thumb { transform: scale(1.25); }
        .audio-overlay .audio-seek::-moz-range-thumb {
            width: 12px; height: 12px; border: none;
            border-radius: 50%;
            background: #fff;
            cursor: pointer;
        }
        .audio-overlay .audio-seek.live { opacity: 0.4; pointer-events: none; }

        /* Legacy (pre-overlay) audio styles — no-op now but kept for any HTML
           still referencing them. */
        .audio-placeholder { display: none; }

        .audio-transport {
            display: flex; align-items: center; justify-content: center;
            gap: 14px;
            padding: 14px 16px 6px;
            background: #0A0D11;
        }
        .audio-seek-row {
            padding: 6px 16px 14px;
            background: #0A0D11;
            border-bottom: 1px solid #1B1E25;
        }
        .audio-btn {
            background: rgba(255,255,255,0.06);
            border: none;
            color: #fff;
            cursor: pointer;
            font: inherit;
            width: 40px; height: 40px;
            border-radius: 50%;
            display: inline-flex; align-items: center; justify-content: center;
            padding: 0;
            transition: background .15s, transform .1s;
            -webkit-tap-highlight-color: transparent;
        }
        .audio-btn:hover:not(:disabled) { background: rgba(255,255,255,0.12); }
        .audio-btn:active:not(:disabled) { transform: scale(0.94); }
        .audio-btn:disabled { opacity: 0.35; cursor: default; }
        .audio-btn svg { width: 18px; height: 18px; }

        .audio-btn.play {
            width: 56px; height: 56px;
            background: #fff; color: #000;
        }
        .audio-btn.play svg { width: 26px; height: 26px; }
        .audio-btn.play:hover { background: #f0f0f0; }

        .audio-seek-row {
            display: grid;
            grid-template-columns: minmax(36px, auto) 1fr minmax(36px, auto);
            align-items: center;
            gap: 10px;
            font-variant-numeric: tabular-nums;
        }
        .audio-time {
            font-size: 11px;
            color: var(--text-muted);
        }
        .audio-time.dur { text-align: right; }
        .audio-seek {
            -webkit-appearance: none; appearance: none;
            background: transparent;
            width: 100%;
            min-width: 0;
            height: 16px;
            cursor: pointer;
            margin: 0;
            padding: 0;
        }
        .audio-seek::-webkit-slider-runnable-track {
            height: 3px;
            background: rgba(255,255,255,0.12);
            border-radius: 2px;
        }
        .audio-seek::-moz-range-track {
            height: 3px;
            background: rgba(255,255,255,0.12);
            border-radius: 2px;
        }
        .audio-seek::-webkit-slider-thumb {
            -webkit-appearance: none; appearance: none;
            width: 12px; height: 12px;
            margin-top: -4.5px;
            border-radius: 50%;
            background: #fff;
            cursor: pointer;
            transition: transform .1s;
        }
        .audio-seek:hover::-webkit-slider-thumb { transform: scale(1.2); }
        .audio-seek::-moz-range-thumb {
            width: 12px; height: 12px; border: none;
            border-radius: 50%;
            background: #fff;
            cursor: pointer;
        }
        .audio-seek.live {
            opacity: 0.4; pointer-events: none;
        }

        /* === Top bar: audio toggle + share on the left, close on the right === */
        .tv-player .top-bar {
            display: flex; align-items: center; justify-content: space-between;
            gap: 10px;
            padding: 6px 0 10px;
        }
        .tv-player .top-bar .left-group {
            display: flex; align-items: center; gap: 8px;
            min-width: 0;
        }

        /* Tag chips — neutral dark pill. Tags are proper names (Bay Area,
           Manorama, etc.) so they render in their own case, not uppercased. */
        .tag-chip {
            display: inline-block;
            padding: 2px 8px;
            background: rgba(255, 255, 255, 0.06);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 4px;
            font-size: 10px;
            font-weight: 600;
            letter-spacing: 0.3px;
            color: var(--text-soft, #C8CAD0);
            line-height: 1.4;
            white-space: nowrap;
            vertical-align: 1px;
        }
        .tag-chip + .tag-chip { margin-left: 5px; }
        .latest-meta .tag-chip { margin-left: 0; }
        /* Tag chip inside the player bar (under the iframe) gets a louder
         * treatment so it actually catches the eye against the player
         * chrome. Same shape, beefier colors. */
        .tv-player .bar .right .tag-chip {
            background: rgba(34, 204, 119, 0.12);
            border-color: rgba(34, 204, 119, 0.38);
            color: var(--accent-green, #22CC77);
            font-size: 11px;
            padding: 3px 10px;
            letter-spacing: 0.5px;
        }
        /* Channel-tag chip in the row-desc gets a tiny tweak so the
           description text after it doesn't run into it. */
        .row-desc .tag-chip { margin-right: 8px; }

        /* Toast for share fallback */
        .kp-toast {
            position: fixed; left: 50%; bottom: 32px;
            transform: translateX(-50%);
            padding: 10px 18px;
            background: rgba(0,0,0,0.92);
            border: 1px solid #2A2E37;
            border-radius: 999px;
            color: #fff;
            font-size: 12px; font-weight: 600;
            letter-spacing: 1px;
            box-shadow: 0 4px 18px rgba(0,0,0,0.35);
            z-index: 1000;
            animation: kp-toast 1.8s ease both;
            pointer-events: none;
        }
        @keyframes kp-toast {
            0%   { opacity: 0; transform: translate(-50%, 6px); }
            12%  { opacity: 1; transform: translate(-50%, 0); }
            85%  { opacity: 1; }
            100% { opacity: 0; transform: translate(-50%, -4px); }
        }

        .audio-pill {
            background: rgba(255,255,255,0.04);
            border: 1px solid rgba(255,255,255,0.08);
            color: var(--text-soft, #C8CAD0);
            cursor: pointer;
            display: inline-flex; align-items: center; gap: 8px;
            padding: 7px 14px 7px 11px;
            border-radius: 999px;
            font: inherit;
            font-size: 11px; font-weight: 600;
            letter-spacing: 1.5px; text-transform: uppercase;
            transition: all .18s ease;
            -webkit-tap-highlight-color: transparent;
        }
        .audio-pill:hover {
            background: rgba(255,255,255,0.07);
            border-color: rgba(255,255,255,0.14);
            color: #fff;
        }
        .audio-pill:active { transform: scale(0.98); }
        .audio-pill svg { width: 14px; height: 14px; opacity: 0.85; }
        .audio-pill .switch {
            display: inline-block;
            width: 22px; height: 12px;
            background: rgba(255,255,255,0.12);
            border-radius: 999px;
            position: relative;
            transition: background .18s;
            margin-left: 2px;
        }
        .audio-pill .switch::after {
            content: '';
            position: absolute; top: 1.5px; left: 1.5px;
            width: 9px; height: 9px;
            border-radius: 50%;
            background: #fff;
            transition: transform .18s ease;
        }
        .audio-pill.active {
            background: rgba(34, 204, 119, 0.18);
            border-color: rgba(34, 204, 119, 0.55);
            color: var(--accent-green);
        }
        .audio-pill.active svg { opacity: 1; }
        .audio-pill.active .switch { background: var(--accent-green); }
        .audio-pill.active .switch::after { transform: translateX(10px); }

        /* Round icon button — used for Close (and any future small icon ctrl) */
        .player-icon-btn {
            background: rgba(255,255,255,0.04);
            border: 1px solid rgba(255,255,255,0.06);
            color: var(--text-muted);
            width: 32px; height: 32px;
            border-radius: 50%;
            cursor: pointer; padding: 0;
            display: inline-flex; align-items: center; justify-content: center;
            transition: all .15s;
            -webkit-tap-highlight-color: transparent;
            flex-shrink: 0;
        }
        .player-icon-btn:hover {
            background: rgba(255,255,255,0.1);
            border-color: rgba(255,255,255,0.14);
            color: #fff;
        }
        .player-icon-btn:active { transform: scale(0.94); }
        .player-icon-btn svg { width: 14px; height: 14px; }

        /* (legacy text-pill audio-toggle/close styles removed; replaced by .player-icon-btn) */

        /* Upcoming indicator: stopwatch icon + light-blue countdown text. */
        .row-tag.upcoming {
            color: #5BB6FF;
            font-variant-numeric: tabular-nums;
            text-transform: none;
            letter-spacing: 0.5px;
            font-size: 9px;
            font-weight: 700;
            display: inline-flex;
            align-items: center;
            gap: 5px;
        }
        .row-tag.upcoming .timer-ring {
            width: 11px;
            height: 11px;
            stroke: #5BB6FF;
            fill: none;
            flex-shrink: 0;
        }
        .row.upcoming .row-name { color: #C8CAD0; }

        /* Visible focus rings for keyboard users — invisible on mouse use */
        button:focus-visible,
        a:focus-visible {
            outline: 2px solid #9BCDFF;
            outline-offset: 2px;
            border-radius: 4px;
        }

/* ===== game: sixty ===== */

        body.game-sixty /* Mode Selection */
        .mode-selection{
            background: #1C1E26;
            border: 3px solid #2E3038;
            border-radius: 8px;
            padding: 40px;
            text-align: center;
        }

        body.game-sixty .mode-title{
            font-size: 24px;
            color: #22CC77;
            margin-bottom: 30px;
            letter-spacing: 2px;
        }

        body.game-sixty .mode-buttons{
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        body.game-sixty .mode-button{
            padding: 20px;
            background: #252830;
            border: 2px solid #3A3D48;
            border-radius: 8px;
            color: #FFFFFF;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 18px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            text-transform: uppercase;
            letter-spacing: 2px;
        }

        body.game-sixty .mode-button:hover{
            background: #2E3038;
            border-color: #22CC77;
        }

        body.game-sixty .mode-button.easy:hover{
            border-color: #22CC77;
        }

        body.game-sixty .mode-button.medium:hover{
            border-color: #FFB830;
        }

        body.game-sixty .mode-button.hard:hover{
            border-color: #FF4D4D;
        }

        body.game-sixty .difficulty-label{
            font-size: 14px;
            color: #7A7D85;
            margin-top: 5px;
        }

        body.game-sixty /* Game Area */
        .game-area{
            display: none;
        }

        body.game-sixty .game-area.active{
            display: block;
        }

        body.game-sixty .problem-display{
            background: #1C1E26;
            border: 3px solid #2E3038;
            border-radius: 8px;
            padding: 60px 40px;
            text-align: center;
            margin-bottom: 20px;
            min-height: 180px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        body.game-sixty .problem-text{
            font-size: 48px;
            color: #22CC77;
            font-weight: bold;
            letter-spacing: 4px;
        }

        body.game-sixty .countdown{
            font-size: 72px;
            color: #FFB830;
            font-weight: bold;
        }

        body.game-sixty .input-container{
            margin-bottom: 20px;
        }

        body.game-sixty .answer-input{
            width: 100%;
            padding: 20px;
            background: #1C1E26;
            border: 2px solid #22CC77;
            border-radius: 8px;
            color: #22CC77;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 36px;
            text-align: center;
            font-weight: bold;
        }

        body.game-sixty .answer-input:focus{
            outline: none;
            border-color: #22CC77;
        }

        body.game-sixty .answer-input:disabled{
            opacity: 0.5;
            cursor: not-allowed;
        }

        body.game-sixty .message{
            text-align: center;
            padding: 15px;
            margin-bottom: 20px;
            border: 2px solid #3A3D48;
            border-radius: 8px;
            background: #1C1E26;
            min-height: 50px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            letter-spacing: 2px;
        }

        body.game-sixty .message.success{
            border-color: #22CC77;
            color: #22CC77;
            background: #1C1E26;
        }

        body.game-sixty .message.error{
            border-color: #FF4D4D;
            color: #FF4D4D;
            background: #1C1E26;
        }

        body.game-sixty .problem-counter{
            text-align: center;
            color: #7A7D85;
            font-size: 14px;
            margin-bottom: 15px;
            letter-spacing: 1px;
        }

        body.game-sixty .share-text{
            font-size: 18px;
            margin-bottom: 15px;
            padding: 10px;
            background: #13151A;
            border: 1px solid #3A3D48;
            border-radius: 8px;
        }

        body.game-sixty .final-score{
            font-size: 36px;
            color: #22CC77;
            font-weight: bold;
            margin-bottom: 20px;
        }

        body.game-sixty button{
            padding: 15px;
            background: #252830;
            border: 2px solid #3A3D48;
            border-radius: 8px;
            color: #FFFFFF;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            text-transform: uppercase;
            width: 100%;
            margin-bottom: 10px;
        }

        body.game-sixty button:hover:not(:disabled){
            background: #2E3038;
            border-color: #22CC77;
        }

        body.game-sixty button:disabled{
            opacity: 0.3;
            cursor: not-allowed;
        }

        body.game-sixty button.share{
            background: #1C1E26;
            border-color: #22CC77;
            color: #22CC77;
        }

        body.game-sixty button.share:hover{
            background: #22CC77;
            color: #13151A;
        }

        body.game-sixty .play-buttons{
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
            margin-top: 15px;
        }

        body.game-sixty .play-buttons button{
            margin-bottom: 0;
        }

        body.game-sixty /* Flash effects */
        .flash-correct{
            animation: kp-sixty-flashGreen 0.3s;
        }

        body.game-sixty .flash-incorrect{
            animation: kp-sixty-flashRed 0.3s;
        }

        @keyframes kp-sixty-flashGreen {
            0%, 100% { background: #1C1E26; }
            50% { background: #1a3a2a; }
        }

        @keyframes kp-sixty-flashRed {
            0%, 100% { background: #1C1E26; }
            50% { background: #2a1a1a; }
        }

        body.game-sixty /* Responsive */
        @media (max-width: 768px){
            h1 {
                font-size: 36px;
            }

            .problem-text {
                font-size: 36px;
            }

            .answer-input {
                font-size: 28px;
            }

            .countdown {
                font-size: 56px;
            }
        }
    

    

/* ===== game: flash ===== */

        body.game-flash /* Grid Area */
        .grid-container{
            background: #1C1E26;
            border: 3px solid #2E3038;
            border-radius: 8px;
            padding: 30px;
            margin-bottom: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        body.game-flash .grid{
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 12px;
            width: 100%;
            max-width: 320px;
        }

        body.game-flash .tile{
            aspect-ratio: 1;
            background: #252830;
            border: 2px solid #3A3D48;
            border-radius: 8px;
            cursor: pointer;
            transition: background 0.1s, border-color 0.1s, box-shadow 0.1s;
            min-height: 44px;
            min-width: 44px;
            position: relative;
        }

        body.game-flash .tile:hover{
            border-color: #4A4D58;
        }

        body.game-flash .tile.disabled{
            cursor: default;
            pointer-events: none;
        }

        body.game-flash .tile.flash-active{
            transition: none;
        }

        body.game-flash .tile.correct-flash{
            background: #22CC77 !important;
            border-color: #22CC77 !important;
            box-shadow: 0 0 20px rgba(61, 220, 132, 0.6) !important;
        }

        body.game-flash .tile.wrong-flash{
            background: #FF4D4D !important;
            border-color: #FF4D4D !important;
            box-shadow: 0 0 20px rgba(239, 83, 80, 0.6) !important;
        }

        @keyframes kp-flash-shake {
            0%, 100% { transform: translateX(0); }
            20% { transform: translateX(-6px); }
            40% { transform: translateX(6px); }
            60% { transform: translateX(-4px); }
            80% { transform: translateX(4px); }
        }

        body.game-flash .tile.shake{
            animation: kp-flash-shake 0.4s ease-out;
        }

        body.game-flash /* Status area */
        .status{
            text-align: center;
            padding: 15px;
            margin-bottom: 20px;
            border: 2px solid #3A3D48;
            border-radius: 8px;
            background: #1C1E26;
            min-height: 50px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            letter-spacing: 2px;
        }

        body.game-flash .status.watching{
            border-color: #FFB830;
            color: #FFB830;
        }

        body.game-flash .status.input{
            border-color: #22CC77;
            color: #22CC77;
        }

        body.game-flash .status.success{
            border-color: #22CC77;
            color: #22CC77;
            background: #1C1E26;
        }

        body.game-flash .status.error{
            border-color: #FF4D4D;
            color: #FF4D4D;
            background: #1C1E26;
        }

        @keyframes kp-flash-pulseText {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }

        body.game-flash .status.pulse{
            animation: kp-flash-pulseText 1s infinite;
        }

        body.game-flash /* Buttons */
        button{
            padding: 15px;
            background: #252830;
            border: 2px solid #3A3D48;
            border-radius: 8px;
            color: #FFFFFF;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            text-transform: uppercase;
            width: 100%;
            margin-bottom: 10px;
            letter-spacing: 2px;
        }

        body.game-flash button:hover:not(:disabled){
            background: #2E3038;
            border-color: #22CC77;
        }

        body.game-flash button:disabled{
            opacity: 0.3;
            cursor: not-allowed;
        }

        body.game-flash button.start{
            background: #1C1E26;
            border-color: #22CC77;
            color: #22CC77;
            font-size: 20px;
        }

        body.game-flash button.start:hover{
            background: #22CC77;
            color: #13151A;
        }

        body.game-flash .final-score{
            font-size: 36px;
            color: #22CC77;
            font-weight: bold;
            margin-bottom: 10px;
        }

        body.game-flash .final-round{
            font-size: 18px;
            color: #7A7D85;
            margin-bottom: 20px;
        }

        body.game-flash .share-text{
            font-size: 14px;
            margin-bottom: 15px;
            padding: 10px;
            background: #13151A;
            border: 1px solid #3A3D48;
            border-radius: 8px;
            white-space: pre-line;
            text-align: left;
        }

        body.game-flash button.share{
            background: #1C1E26;
            border-color: #22CC77;
            color: #22CC77;
        }

        body.game-flash button.share:hover{
            background: #22CC77;
            color: #13151A;
        }

        body.game-flash .play-buttons{
            display: grid;
            grid-template-columns: 1fr;
            gap: 10px;
            margin-top: 15px;
        }

        body.game-flash .play-buttons button{
            margin-bottom: 0;
        }

        body.game-flash /* Responsive */
        @media (max-width: 768px){
            h1 {
                font-size: 36px;
            }

            .grid-container {
                padding: 20px;
            }

            .grid {
                gap: 8px;
            }
        }
    

    

/* ===== game: match ===== */

        body.game-match /* Word display area */
        .word-display{
            background: #1C1E26;
            border: 3px solid #2E3038;
            border-radius: 8px;
            padding: 40px 20px;
            text-align: center;
            margin-bottom: 20px;
            min-height: 200px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            transition: background 0.15s;
        }

        body.game-match .color-word{
            font-size: 56px;
            font-weight: bold;
            letter-spacing: 6px;
            margin-bottom: 20px;
            transition: opacity 0.1s;
        }

        body.game-match .prompt-text{
            font-size: 20px;
            color: #7A7D85;
            letter-spacing: 2px;
        }

        body.game-match .prompt-text em{
            font-style: normal;
            color: #22CC77;
            font-weight: bold;
        }

        body.game-match .countdown{
            font-size: 72px;
            color: #FFB830;
            font-weight: bold;
        }

        body.game-match /* Answer buttons */
        .answer-buttons{
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
            margin-bottom: 20px;
        }

        body.game-match .answer-btn{
            padding: 18px 10px;
            background: #252830;
            border: 2px solid #3A3D48;
            border-radius: 8px;
            color: #FFFFFF;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.15s;
            text-transform: uppercase;
            letter-spacing: 2px;
            min-height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-left-width: 5px;
        }

        body.game-match .answer-btn:hover:not(:disabled){
            background: #2E3038;
        }

        body.game-match .answer-btn:active:not(:disabled){
            transform: scale(0.97);
        }

        body.game-match .answer-btn:disabled{
            opacity: 0.3;
            cursor: not-allowed;
        }

        body.game-match /* Flash effects */
        .flash-correct{
            animation: kp-match-flashGreen 0.3s;
        }

        body.game-match .flash-incorrect{
            animation: kp-match-flashRed 0.3s;
        }

        @keyframes kp-match-flashGreen {
            0%, 100% { background: #1C1E26; }
            50% { background: #1a3a2a; border-color: #22CC77; }
        }

        @keyframes kp-match-flashRed {
            0%, 100% { background: #1C1E26; }
            50% { background: #2a1a1a; border-color: #FF4D4D; }
        }

        @keyframes kp-match-shake {
            0%, 100% { transform: translateX(0); }
            20% { transform: translateX(-8px); }
            40% { transform: translateX(8px); }
            60% { transform: translateX(-6px); }
            80% { transform: translateX(6px); }
        }

        body.game-match .shake{
            animation: kp-match-shake 0.3s;
        }

        body.game-match .final-score{
            font-size: 36px;
            color: #22CC77;
            font-weight: bold;
            margin-bottom: 10px;
        }

        body.game-match .final-accuracy{
            font-size: 18px;
            color: #7A7D85;
            margin-bottom: 20px;
        }

        body.game-match .share-text{
            font-size: 14px;
            margin-bottom: 15px;
            padding: 10px;
            background: #13151A;
            border: 1px solid #3A3D48;
            border-radius: 8px;
            white-space: pre-line;
            text-align: left;
        }

        body.game-match button{
            padding: 15px;
            background: #252830;
            border: 2px solid #3A3D48;
            border-radius: 8px;
            color: #FFFFFF;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            text-transform: uppercase;
            width: 100%;
            margin-bottom: 10px;
        }

        body.game-match button:hover:not(:disabled){
            background: #2E3038;
            border-color: #22CC77;
        }

        body.game-match button:disabled{
            opacity: 0.3;
            cursor: not-allowed;
        }

        body.game-match button.share{
            background: #1a3a2a;
            border-color: #22CC77;
            color: #22CC77;
        }

        body.game-match button.share:hover{
            background: #22CC77;
            color: #13151A;
        }

        body.game-match .play-buttons{
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
            margin-top: 15px;
        }

        body.game-match .play-buttons button{
            margin-bottom: 0;
        }

        body.game-match /* Responsive */
        @media (max-width: 768px){
            h1 {
                font-size: 36px;
            }

            .color-word {
                font-size: 42px;
            }

            .prompt-text {
                font-size: 16px;
            }

            .countdown {
                font-size: 56px;
            }

            .answer-btn {
                font-size: 14px;
                padding: 16px 8px;
            }
        }
    

    

/* ===== game: scramble ===== */

        body.game-scramble /* Difficulty indicator */
        .difficulty-bar{
            text-align: center;
            margin-bottom: 20px;
            font-size: 16px;
            font-weight: bold;
            letter-spacing: 2px;
        }

        body.game-scramble .difficulty-bar.easy{
            color: #22CC77;
        }

        body.game-scramble .difficulty-bar.medium{
            color: #FFB830;
        }

        body.game-scramble .difficulty-bar.hard{
            color: #FF4D4D;
        }

        body.game-scramble /* Scramble display */
        .problem-display{
            background: #1C1E26;
            border: 3px solid #2E3038;
            border-radius: 8px;
            padding: 40px 20px;
            text-align: center;
            margin-bottom: 20px;
            min-height: 160px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        body.game-scramble .scramble-letters{
            display: flex;
            justify-content: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        body.game-scramble .letter-cell{
            width: 48px;
            height: 56px;
            background: #13151A;
            border: 2px solid #2E3038;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 36px;
            font-weight: bold;
            color: #22CC77;
            text-transform: uppercase;
            transition: all 0.3s;
        }

        body.game-scramble .letter-cell.correct-flash{
            background: #1a3a2a;
            border-color: #22CC77;
        }

        body.game-scramble .countdown{
            font-size: 72px;
            color: #FFB830;
            font-weight: bold;
        }

        body.game-scramble /* Input area */
        .input-row{
            display: flex;
            gap: 10px;
            margin-bottom: 15px;
        }

        body.game-scramble .answer-input{
            flex: 1;
            padding: 16px 20px;
            background: #1C1E26;
            border: 2px solid #22CC77;
            border-radius: 8px;
            color: #22CC77;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 24px;
            text-align: center;
            font-weight: bold;
            text-transform: lowercase;
        }

        body.game-scramble .answer-input:focus{
            outline: none;
            box-shadow: 0 0 20px rgba(61, 220, 132, 0.3);
        }

        body.game-scramble .answer-input:disabled{
            opacity: 0.5;
            cursor: not-allowed;
        }

        body.game-scramble .answer-input.flash-correct{
            animation: kp-scramble-inputFlashGreen 0.4s;
        }

        body.game-scramble .answer-input.flash-incorrect{
            animation: kp-scramble-inputFlashRed 0.3s;
        }

        @keyframes kp-scramble-inputFlashGreen {
            0% { border-color: #22CC77; background: #1C1E26; }
            50% { border-color: #22CC77; background: #1a3a2a; }
            100% { border-color: #22CC77; background: #1C1E26; }
        }

        @keyframes kp-scramble-inputFlashRed {
            0% { border-color: #FF4D4D; background: #1C1E26; }
            50% { border-color: #FF4D4D; background: #2a1a1a; }
            100% { border-color: #22CC77; background: #1C1E26; }
        }

        body.game-scramble .enter-btn{
            padding: 16px 24px;
            background: #1a3a2a;
            border: 2px solid #22CC77;
            border-radius: 8px;
            color: #22CC77;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        body.game-scramble .enter-btn:hover:not(:disabled){
            background: #22CC77;
            color: #13151A;
        }

        body.game-scramble .enter-btn:disabled{
            opacity: 0.3;
            cursor: not-allowed;
        }

        body.game-scramble .skip-btn{
            width: 100%;
            padding: 12px;
            background: #252830;
            border: 2px solid #3A3D48;
            border-radius: 8px;
            color: #7A7D85;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 14px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-bottom: 20px;
        }

        body.game-scramble .skip-btn:hover:not(:disabled){
            background: #2E3038;
            border-color: #7A7D85;
            color: #FFFFFF;
        }

        body.game-scramble .skip-btn:disabled{
            opacity: 0.3;
            cursor: not-allowed;
        }

        body.game-scramble .message{
            text-align: center;
            padding: 15px;
            margin-bottom: 20px;
            border: 2px solid #3A3D48;
            background: #1C1E26;
            border-radius: 8px;
            min-height: 50px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            letter-spacing: 2px;
        }

        body.game-scramble .message.success{
            border-color: #22CC77;
            color: #22CC77;
            background: #1a3a2a;
        }

        body.game-scramble .message.error{
            border-color: #FF4D4D;
            color: #FF4D4D;
            background: #2a1a1a;
        }

        body.game-scramble .word-counter{
            text-align: center;
            color: #7A7D85;
            font-size: 14px;
            margin-bottom: 15px;
            letter-spacing: 1px;
        }

        body.game-scramble .final-score{
            font-size: 36px;
            color: #22CC77;
            font-weight: bold;
            margin-bottom: 10px;
        }

        body.game-scramble .final-breakdown{
            color: #7A7D85;
            font-size: 14px;
            margin-bottom: 20px;
            line-height: 1.8;
        }

        body.game-scramble .final-breakdown span{
            font-weight: bold;
        }

        body.game-scramble .final-breakdown .easy-count{ color: #22CC77; }
        body.game-scramble .final-breakdown .medium-count{ color: #FFB830; }
        body.game-scramble .final-breakdown .hard-count{ color: #FF4D4D; }

        body.game-scramble .share-text{
            font-size: 14px;
            margin-bottom: 15px;
            padding: 10px;
            background: #13151A;
            border: 1px solid #3A3D48;
            border-radius: 8px;
            white-space: pre-line;
            text-align: left;
        }

        body.game-scramble button{
            padding: 15px;
            background: #252830;
            border: 2px solid #3A3D48;
            border-radius: 8px;
            color: #FFFFFF;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            text-transform: uppercase;
            /* Buttons inside the input row stay at content width; full-width
               buttons (start, skip, play-again) declare width: 100% themselves. */
        }

        body.game-scramble button:hover:not(:disabled){
            background: #2E3038;
            border-color: #22CC77;
        }

        body.game-scramble button:disabled{
            opacity: 0.3;
            cursor: not-allowed;
        }

        body.game-scramble button.share{
            width: 100%;
            margin-bottom: 10px;
            background: #1a3a2a;
            border-color: #22CC77;
            color: #22CC77;
        }

        body.game-scramble button.share:hover{
            background: #22CC77;
            color: #13151A;
        }

        body.game-scramble /* Flash effects */
        .flash-correct{
            animation: kp-scramble-flashGreen 0.3s;
        }

        body.game-scramble .flash-incorrect{
            animation: kp-scramble-flashRed 0.3s;
        }

        @keyframes kp-scramble-flashGreen {
            0%, 100% { background: #1C1E26; }
            50% { background: #1a3a2a; }
        }

        @keyframes kp-scramble-flashRed {
            0%, 100% { background: #1C1E26; }
            50% { background: #2a1a1a; }
        }

        body.game-scramble /* Start screen */
        .start-screen{
            background: #1C1E26;
            border: 3px solid #2E3038;
            border-radius: 8px;
            padding: 40px;
            text-align: center;
        }

        body.game-scramble .start-screen .start-title{
            font-size: 24px;
            color: #22CC77;
            margin-bottom: 20px;
            letter-spacing: 2px;
        }

        body.game-scramble .start-screen .start-desc{
            color: #7A7D85;
            font-size: 14px;
            margin-bottom: 30px;
            line-height: 1.6;
        }

        body.game-scramble .start-btn{
            width: 100%;
            padding: 20px;
            background: #1a3a2a;
            border: 2px solid #22CC77;
            border-radius: 8px;
            color: #22CC77;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 20px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            text-transform: uppercase;
            letter-spacing: 3px;
            width: 100%;
        }

        body.game-scramble .start-btn:hover{
            background: #22CC77;
            color: #13151A;
        }

        body.game-scramble /* Game area hidden until start */
        .game-area{
            display: none;
        }

        body.game-scramble .game-area.active{
            display: block;
        }

        body.game-scramble /* Responsive */
        @media (max-width: 768px){
            h1 {
                font-size: 36px;
            }

            .letter-cell {
                width: 40px;
                height: 48px;
                font-size: 28px;
            }

            .answer-input {
                font-size: 20px;
                padding: 14px 16px;
            }

            .countdown {
                font-size: 56px;
            }

            .stats {
                padding: 10px;
            }

            .stat-value {
                font-size: 20px;
            }
        }

        @media (max-width: 400px) {
            .letter-cell {
                width: 34px;
                height: 42px;
                font-size: 24px;
                gap: 4px;
            }

            .scramble-letters {
                gap: 4px;
            }
        }
    

    

/* ===== game: math-path ===== */

        

body.game-math-path .container{
            max-width: 600px;
            width: 100%;
        }
        

        

        

        

        @media (min-width: 460px) {
            .stat { flex: 1 1 0; }
        }
        

        

        

        

        

        
        body.game-math-path .grid{
            display: grid;
            gap: 8px;
            margin-bottom: 20px;
            background: #1C1E26;
            padding: 20px;
            border: 3px solid #2A2E37;
        }
        
        body.game-math-path .pipe{
            aspect-ratio: 1;
            /* Without min-width: 0, the cell's implicit min-content size
               keeps grid columns wider than the container — that's what
               was making the 6x6 grid overflow viewport on mobile. */
            min-width: 0;
            background: #252830;
            border: 2px solid #2A2E37;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            position: relative;
        }
        
        body.game-math-path .pipe:hover:not(.start):not(.end):not(.selected){
            background: #2E3038;
            border-color: #3A3D45;
        }
        
        body.game-math-path .pipe.start{
            background: #0F3A22;
            border: 2px solid #22CC77;
            color: #22CC77;
            cursor: default;
        }

        body.game-math-path .pipe.end{
            background: #3D1112;
            border: 2px solid #FF4D4D;
            color: #FF4D4D;
            cursor: default;
        }

        body.game-math-path .pipe.adjacent{
            border: 2px solid #22CC77;
            animation: kp-math-path-pulse 1.5s infinite;
        }

        body.game-math-path .pipe.selected{
            background: #0F2E1D;
            border: 2px solid #22CC77;
            color: #22CC77;
            cursor: default;
        }

        body.game-math-path .pipe.disabled{
            opacity: 0.3;
            cursor: not-allowed;
        }

        body.game-math-path .pipe.solution{
            background: #0B1E33;
            border: 2px solid #9BCDFF;
            color: #9BCDFF;
        }
        
        body.game-math-path .pipe.winning{
            animation: kp-math-path-winPulse 0.5s;
        }
        
        @keyframes kp-math-path-pulse {
            0%, 100% { box-shadow: 0 0 5px rgba(34, 204, 119, 0.3); }
            50% { box-shadow: 0 0 15px rgba(34, 204, 119, 0.6); }
        }
        
        @keyframes kp-math-path-winPulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.1); box-shadow: 0 0 30px rgba(34, 204, 119, 0.8); }
        }
        
        body.game-math-path .controls{
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }
        
        body.game-math-path button{
            flex: 1;
            padding: 15px;
            background: #252830;
            border: 2px solid #2A2E37;
            color: #e0e0e0;
            font-family: inherit;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            text-transform: uppercase;
        }
        
        body.game-math-path button:hover:not(:disabled){
            background: #2E3038;
            border-color: #22CC77;
        }
        
        body.game-math-path button:disabled{
            opacity: 0.3;
            cursor: not-allowed;
        }
        
        body.game-math-path .message{
            text-align: center;
            padding: 15px;
            margin-bottom: 20px;
            border: 2px solid #2A2E37;
            background: #1C1E26;
            min-height: 50px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        body.game-math-path .message.success{
            border-color: #22CC77;
            color: #22CC77;
        }
        
        body.game-math-path .message.error{
            border-color: #FF4D4D;
            color: #FF4D4D;
        }
        
        body.game-math-path .share-text{
            font-size: 18px;
            margin-bottom: 15px;
            padding: 10px;
            background: #13151A;
            border: 1px solid #2A2E37;
        }
        
        body.game-math-path button.share{
            background: #0F2E1D;
            border-color: #22CC77;
            color: #22CC77;
        }
    

    

/* ===== game: word-cipher ===== */

body.game-word-cipher .container{
            max-width: 700px;
            width: 100%;
        }

        body.game-word-cipher /* Stats bar */

        /* Quote display area */
        .quote-box{
            background: #1C1E26;
            border: 3px solid #2A2E37;
            padding: 24px 20px;
            margin-bottom: 20px;
            line-height: 2.6;
            min-height: 120px;
            position: relative;
        }

        body.game-word-cipher .quote-box.won{
            border-color: #22CC77;
            box-shadow: 0 0 30px rgba(34, 204, 119, 0.2);
        }

        body.game-word-cipher .cipher-char{
            display: inline-block;
            text-align: center;
            cursor: pointer;
            position: relative;
            margin: 0 1px;
            vertical-align: bottom;
        }

        body.game-word-cipher .cipher-letter{
            display: block;
            font-size: 11px;
            color: #666;
            height: 14px;
            line-height: 14px;
        }

        body.game-word-cipher .decoded-letter{
            display: block;
            width: 22px;
            height: 28px;
            line-height: 28px;
            font-size: 18px;
            font-weight: bold;
            border-bottom: 2px solid #2A2E37;
            color: #e0e0e0;
            transition: all 0.15s;
        }

        body.game-word-cipher .cipher-char:hover .decoded-letter{
            border-bottom-color: #22CC77;
            background: #1a2a1a;
        }

        body.game-word-cipher .cipher-char.selected .decoded-letter{
            border-bottom-color: #22CC77;
            background: #002211;
            box-shadow: 0 0 8px rgba(34, 204, 119, 0.3);
        }

        body.game-word-cipher .cipher-char.selected .cipher-letter{
            color: #22CC77;
        }

        body.game-word-cipher .cipher-char.highlighted .decoded-letter{
            border-bottom-color: #22CC77;
            background: #0a1a0f;
        }

        body.game-word-cipher .cipher-char.correct .decoded-letter{
            color: #22CC77;
        }

        body.game-word-cipher .cipher-char.conflict .decoded-letter{
            color: #FFB830;
        }

        body.game-word-cipher .cipher-char.won .decoded-letter{
            color: #22CC77;
            border-bottom-color: #22CC77;
        }

        body.game-word-cipher .space-char{
            display: inline-block;
            width: 12px;
        }

        body.game-word-cipher .punct-char{
            display: inline-block;
            font-size: 18px;
            font-weight: bold;
            line-height: 28px;
            vertical-align: bottom;
            height: 42px;
            padding-top: 14px;
            color: #7A7D85;
        }

        body.game-word-cipher .quote-author{
            display: block;
            text-align: right;
            margin-top: 16px;
            color: #22CC77;
            font-size: 14px;
            font-style: italic;
            opacity: 0;
            transition: opacity 0.5s;
        }

        body.game-word-cipher .quote-author.visible{
            opacity: 1;
        }

        body.game-word-cipher /* Selection indicator */
        .selection-indicator{
            text-align: center;
            margin-bottom: 16px;
            font-size: 18px;
            height: 28px;
            line-height: 28px;
            color: #7A7D85;
        }

        body.game-word-cipher .selection-indicator .cipher-label{
            color: #22CC77;
            font-weight: bold;
        }

        body.game-word-cipher .selection-indicator .arrow{
            color: #3A3D45;
            margin: 0 8px;
        }

        body.game-word-cipher .selection-indicator .decoded-label{
            color: #FFB830;
            font-weight: bold;
        }

        body.game-word-cipher /* Alphabet mapping grid */
        .mapping-grid{
            background: #1C1E26;
            border: 2px solid #2A2E37;
            padding: 16px 8px;
            margin-bottom: 20px;
        }

        body.game-word-cipher .mapping-row{
            display: flex;
            justify-content: center;
            flex-wrap: wrap;
            gap: 4px;
            margin-bottom: 8px;
        }

        body.game-word-cipher .mapping-row:last-child{
            margin-bottom: 0;
        }

        body.game-word-cipher .mapping-cell{
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 36px;
            cursor: pointer;
            transition: all 0.15s;
            padding: 4px 0;
            border-radius: 3px;
        }

        body.game-word-cipher .mapping-cell:hover{
            background: #252830;
        }

        body.game-word-cipher .mapping-cell.selected{
            background: #002211;
            box-shadow: 0 0 8px rgba(34, 204, 119, 0.3);
        }

        body.game-word-cipher .mapping-cell.mapped{
            /* has a player mapping */
        }

        body.game-word-cipher .mapping-cell .mc-cipher{
            font-size: 14px;
            font-weight: bold;
            color: #7A7D85;
            line-height: 20px;
        }

        body.game-word-cipher .mapping-cell.selected .mc-cipher{
            color: #22CC77;
        }

        body.game-word-cipher .mapping-cell .mc-decoded{
            font-size: 16px;
            font-weight: bold;
            color: #e0e0e0;
            line-height: 22px;
            min-height: 22px;
            border-top: 1px solid #2A2E37;
            width: 100%;
            text-align: center;
        }

        body.game-word-cipher .mapping-cell.correct .mc-decoded{
            color: #22CC77;
        }

        body.game-word-cipher .mapping-cell.conflict .mc-decoded{
            color: #FFB830;
        }

        body.game-word-cipher /* On-screen keyboard for mobile */
        .keyboard{
            margin-bottom: 20px;
        }

        body.game-word-cipher .keyboard-label{
            text-align: center;
            font-size: 11px;
            color: #666;
            margin-bottom: 8px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        body.game-word-cipher .keyboard-row{
            display: flex;
            justify-content: center;
            gap: 4px;
            margin-bottom: 4px;
        }

        body.game-word-cipher .key-btn{
            width: 34px;
            height: 44px;
            background: #252830;
            border: 2px solid #2A2E37;
            color: #e0e0e0;
            font-family: 'Courier New', monospace;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.15s;
            padding: 0;
            border-radius: 3px;
        }

        body.game-word-cipher .key-btn:hover{
            background: #2E3038;
            border-color: #22CC77;
        }

        body.game-word-cipher .key-btn:active{
            background: #002211;
        }

        body.game-word-cipher .key-btn.used{
            opacity: 0.4;
        }

        body.game-word-cipher .key-btn.backspace{
            width: 60px;
            font-size: 12px;
        }

        body.game-word-cipher /* Controls */
        .controls{
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }

        body.game-word-cipher button{
            flex: 1;
            padding: 15px;
            background: #252830;
            border: 2px solid #2A2E37;
            color: #e0e0e0;
            font-family: inherit;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            text-transform: uppercase;
        }

        body.game-word-cipher button:hover:not(:disabled){
            background: #2E3038;
            border-color: #22CC77;
        }

        body.game-word-cipher button:disabled{
            opacity: 0.3;
            cursor: not-allowed;
        }

        body.game-word-cipher button.share{
            background: #0F2E1D;
            border-color: #22CC77;
            color: #22CC77;
        }

        body.game-word-cipher button.share:hover{
            background: #22CC77;
            color: #13151A;
        }

        body.game-word-cipher /* Win / Share section */
        .message{
            text-align: center;
            padding: 15px;
            margin-bottom: 20px;
            border: 2px solid #2A2E37;
            background: #1C1E26;
            min-height: 50px;
            display: none;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            letter-spacing: 2px;
        }

        body.game-word-cipher .message.visible{
            display: flex;
        }

        body.game-word-cipher .message.success{
            border-color: #22CC77;
            color: #22CC77;
            background: #001a11;
        }

        body.game-word-cipher .share-text{
            font-size: 16px;
            margin-bottom: 15px;
            padding: 10px;
            background: #13151A;
            border: 1px solid #2A2E37;
            white-space: pre-line;
        }

        body.game-word-cipher /* Win animation */
        @keyframes kp-word-cipher-winGlow{
            0%, 100% { text-shadow: 0 0 10px rgba(34, 204, 119, 0.5); }
            50% { text-shadow: 0 0 30px rgba(34, 204, 119, 0.8); }
        }

        body.game-word-cipher .win-title{
            color: #22CC77;
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 10px;
            animation: kp-word-cipher-winGlow 1.5s infinite;
        }

        body.game-word-cipher /* Responsive */
        @media (max-width: 600px){
            h1 {
                font-size: 28px;
                letter-spacing: 2px;
            }

            .container {
                padding: 0;
            }

            .quote-box {
                padding: 16px 12px;
                line-height: 2.4;
            }

            .cipher-char {
                margin: 0;
            }

            .decoded-letter {
                width: 18px;
                height: 24px;
                line-height: 24px;
                font-size: 15px;
            }

            .cipher-letter {
                font-size: 9px;
                height: 12px;
                line-height: 12px;
            }

            .space-char {
                width: 8px;
            }

            .punct-char {
                font-size: 15px;
                height: 36px;
                padding-top: 12px;
            }

            .mapping-cell {
                width: 28px;
            }

            .mapping-cell .mc-cipher {
                font-size: 12px;
            }

            .mapping-cell .mc-decoded {
                font-size: 13px;
            }

            .key-btn {
                width: 28px;
                height: 40px;
                font-size: 14px;
            }

            .key-btn.backspace {
                width: 48px;
                font-size: 10px;
            }

            .stats {
                padding: 10px;
            }

            .stat-value {
                font-size: 16px;
            }
        }

        @media (max-width: 380px) {
            .mapping-cell {
                width: 24px;
            }

            .key-btn {
                width: 24px;
                height: 38px;
                font-size: 12px;
            }

            .decoded-letter {
                width: 16px;
                font-size: 13px;
            }

            .cipher-letter {
                font-size: 8px;
            }
        }

/* ----- Per-game "About" + cross-links block. Sits below the game UI;
 * gives Google crawlable, keyword-rich body content and gives returning
 * players a one-tap path to the next game. */
.game-about {
    max-width: 720px;
    margin: 48px auto 32px;
    padding: 24px 20px;
    border-top: 1px solid #1B1E25;
    color: var(--text-muted, #A4A8B2);
    line-height: 1.55;
    font-size: 14px;
}
.game-about h2 {
    color: #fff;
    font-size: 18px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    margin: 0 0 12px;
    font-weight: 700;
}
.game-about h3 {
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 28px 0 14px;
    color: var(--text-muted, #A4A8B2);
    font-weight: 700;
}
.game-about p { margin: 0 0 12px; }
.game-about a {
    color: var(--accent-green, #22CC77);
    text-decoration: none;
}
.game-about a:hover { text-decoration: underline; }
.game-about strong { color: #fff; font-weight: 600; }
.ga-more {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}
.ga-link {
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
    background: #13151A;
    border: 1px solid #1B1E25;
    border-radius: 8px;
    color: #fff !important;
    text-decoration: none !important;
    transition: border-color .15s, background .15s;
}
.ga-link:hover {
    background: #181B22;
    border-color: var(--accent-green, #22CC77);
}
.ga-game {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.8px;
}
.ga-skill {
    font-size: 11px;
    color: var(--text-muted, #A4A8B2);
    margin-top: 3px;
    letter-spacing: 0.4px;
}

/* ----- noscript channel index on /tv/. JS users see the dynamic grid;
 * Google sees crawlable channel names + deep-links here. */
.tv-channel-index {
    max-width: 720px;
    margin: 36px auto;
    padding: 0 20px;
    color: var(--text-muted, #A4A8B2);
    font-size: 14px;
    line-height: 1.6;
}
.tv-channel-index h2 {
    color: #fff;
    font-size: 18px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}
.tv-channel-index ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 14px 0 0;
}
.tv-channel-index a {
    color: var(--accent-green, #22CC77);
    text-decoration: none;
}
.tv-channel-index a:hover { text-decoration: underline; }

/* ----- PWA install chip. Quiet persistent option in the topnav after
 * the loud banner is dismissed. One tap installs (or opens the iOS
 * instruction sheet on Safari). */
.install-chip {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    margin-left: 8px;
    background: var(--accent-green, #22CC77);
    color: #0E1014 !important;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none !important;
    transition: opacity .15s;
}
.install-chip.is-on { display: inline-flex; }
.install-chip:hover { opacity: 0.85; }

/* ----- PWA install banner. Lives between the topnav and the hero on
 * every page so it's the first content visitors see, but quiet enough
 * to feel native to the layout: subtle accent-green tint, same border
 * radius as the rest of the cards, single line on desktop. Dismissable
 * via the × on the right; hidden again after install or after 30 days
 * of quiet. */
.install-banner {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin: 4px 0 18px;
    background: rgba(34, 204, 119, 0.06);
    border: 1px solid rgba(34, 204, 119, 0.22);
    border-radius: 10px;
    color: var(--text-secondary, #C8CAD0);
    font-size: 13px;
    line-height: 1.4;
}
.install-banner.is-on { display: flex; }
.install-banner-icon {
    font-size: 18px;
    line-height: 1;
    flex: none;
}
.install-banner-text {
    flex: 1;
    min-width: 0;
}
.install-banner-text strong {
    color: var(--text-primary, #fff);
    font-weight: 700;
}
.install-banner-sub {
    color: var(--text-muted, #A4A8B2);
}
/* Two-class prefix so we beat the per-game body rules
 * (body.game-sixty button { width:100%; ... } etc.) on specificity
 * without resorting to !important. */
.install-banner .install-banner-cta {
    flex: none;
    width: auto;
    margin: 0;
    padding: 7px 14px;
    background: var(--accent-green, #22CC77);
    color: #0E1014;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: opacity .15s;
    white-space: nowrap;
}
.install-banner .install-banner-cta:hover { opacity: 0.85; background: var(--accent-green, #22CC77); }
.install-banner .install-banner-close {
    flex: none;
    width: auto;
    margin: 0;
    background: none;
    border: 0;
    color: var(--text-muted, #A4A8B2);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    transition: color .15s;
}
.install-banner .install-banner-close:hover {
    color: var(--text-primary, #fff);
    background: none;
}
@media (max-width: 560px) {
    /* On narrow screens, drop the sub line entirely — the headline +
     * CTA + × make the whole point on one row without wrapping. */
    .install-banner-sub { display: none; }
    .install-banner { gap: 10px; padding: 10px 12px; }
    .install-banner-icon { font-size: 16px; }
    .install-banner-cta { padding: 6px 11px; font-size: 10px; letter-spacing: 0.6px; }
}

/* iOS instruction sheet — Safari doesn't fire beforeinstallprompt so the
 * chip opens this small "tap Share → Add to Home Screen" walkthrough
 * instead of calling prompt() directly. */
.install-sheet {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 20px;
}
.install-sheet-card {
    position: relative;
    background: var(--bg-elevated, #13151A);
    border: 1px solid var(--border-medium, #2A2D35);
    border-radius: 12px;
    max-width: 380px;
    width: 100%;
    padding: 22px 22px 18px;
    color: var(--text-primary, #fff);
    font-size: 14px;
    line-height: 1.5;
}
.install-sheet-card h3 {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.4px;
}
.install-sheet-card ol {
    margin: 0;
    padding-left: 20px;
    color: var(--text-secondary, #C8CAD0);
}
.install-sheet-card ol li { margin-bottom: 8px; }
.install-sheet-card strong { color: var(--accent-green, #22CC77); font-weight: 700; }
.install-sheet-note {
    margin: 14px 0 0;
    color: var(--text-muted, #A4A8B2);
    font-size: 12px;
}
.install-sheet-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: 0;
    color: var(--text-muted, #A4A8B2);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
}
.install-sheet-close:hover { color: var(--text-primary, #fff); }

/* ----- Global social-proof counter (home + games index). Populated by
 * social-proof.js from /stats/counts. Hidden until we have a number. */
.global-counter {
    display: none;
    text-align: center;
    color: var(--text-muted, #A4A8B2);
    font-size: 12px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    margin: -10px 0 24px;
}
.global-counter.is-on { display: block; }
.global-counter .gc-num {
    color: var(--accent-green, #22CC77);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ----- Wordmark-as-update-affordance.
 *
 * The .brand element (top-left "KILLPIPE") doubles as:
 *   - Easter egg: hold for 3s → force refresh. The letters fade from
 *     white to accent-green over the hold so the user sees something
 *     happening — no hidden gesture, just an undocumented one.
 *   - Update indicator: when a new build lands, JS swaps the text to
 *     "UPDATE" and adds .has-update. The font, weight, letter-spacing
 *     stay identical; only the letters and the colour change. A
 *     normal tap in that state triggers the refresh.
 *
 * Bottom-right chip is gone — both behaviours live on the wordmark.
 */
.topnav .brand {
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Stop iOS Safari from popping the long-press "Open Link / Copy
     * Link Address" callout when the user holds the wordmark — without
     * this, our 3-second hold gesture loses to the system menu. */
    -webkit-touch-callout: none;
    /* Disables the 300ms double-tap-to-zoom delay AND prevents
     * touch-hold gestures from being interpreted as drag/scroll on
     * elements inside scroll containers. */
    touch-action: manipulation;
    transition: color .25s ease;
}
.topnav .brand.kp-holding {
    /* Linear interpolation across the 3-second hold so the user
     * sees the letters slowly turn green. The matching JS timer
     * fires the actual refresh at HOLD_MS. */
    color: var(--accent-green, #22CC77);
    transition: color 3s linear;
}
.topnav .brand.kp-holding::after {
    /* Thin underline that grows from 0% → 100% width over the hold —
     * the progress indicator. */
    content: '';
    position: absolute;
    left: 0; right: auto; bottom: -4px;
    height: 2px;
    width: 100%;
    background: var(--accent-green, #22CC77);
    transform-origin: left center;
    transform: scaleX(0);
    animation: kp-hold-fill 3s linear forwards;
    box-shadow: 0 0 8px rgba(34, 204, 119, 0.5);
}
@keyframes kp-hold-fill {
    to { transform: scaleX(1); }
}

.topnav .brand.has-update {
    color: var(--accent-green, #22CC77);
    text-shadow: 0 0 16px rgba(34, 204, 119, 0.45);
    animation: kp-brand-pulse 1.8s ease-in-out infinite;
}
@keyframes kp-brand-pulse {
    0%, 100% { text-shadow: 0 0 16px rgba(34, 204, 119, 0.45); }
    50%      { text-shadow: 0 0 26px rgba(34, 204, 119, 0.75); }
}
@media (prefers-reduced-motion: reduce) {
    .topnav .brand.has-update { animation: none; }
    .topnav .brand.kp-holding::after { animation-duration: .2s; }
}
