/* Baseline Engine — shared light site styles.
   Used by the public-facing pages: index, play, game, docs.
   Keeps DOM hooks (.game-layout, .game-container, .input-area, #commandInput,
   #output, #storyList, etc.) so JS that drives those pages keeps working. */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #ffffff;
    --bg-soft: #fafafa;
    --bg-soft-2: #f3f3f1;
    --text: #1a1a1a;
    --text-soft: #2a2a2a;
    --muted: #6b6b6b;
    --muted-2: #8a8a8a;
    --border: #e8e8e8;
    --border-strong: #d4d4d4;
    --link: #1d4eaa;
    --link-hover: #0a2f7a;
    --accent: #b91c1c;
    --accent-soft: #fef2f2;
    --code-bg: #f7f5f0;
    --code-border: #e6e1d4;

    /* Game terminal: kept on this clean theme but with the visual cues of a
       prompt (mono, cursor, soft inset). No CRT scanlines or glow. */
    --term-bg: #ffffff;
    --term-text: #1a1a1a;
    --term-muted: #6b6b6b;
    --term-prompt: var(--accent);

    --serif: 'Source Serif Pro', Charter, 'Iowan Old Style', Georgia, 'Times New Roman', serif;
    --sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    --radius: 6px;
    --radius-lg: 10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.06);

    --maxw: 1040px;
}

/* Dark theme: override the colour palette only — every component reads from
   these tokens so the layout stays identical. */
body.dark-theme {
    --bg: #0e1014;
    --bg-soft: #141821;
    --bg-soft-2: #1b2030;
    --text: #e8eaed;
    --text-soft: #cfd2d8;
    --muted: #8d93a3;
    --muted-2: #6b7180;
    --border: #232936;
    --border-strong: #2f3645;
    --link: #7fa9ff;
    --link-hover: #a6c1ff;
    --accent: #ff6b6b;
    --accent-soft: #2a1818;
    --code-bg: #1a1f2b;
    --code-border: #2a3142;

    --term-bg: #0e1014;
    --term-text: #e8eaed;
    --term-muted: #8d93a3;
    --term-prompt: var(--accent);

    color-scheme: dark;
}
body.dark-theme .nav { background: rgba(14,16,20,0.92); }
body.dark-theme ::selection { background: #4a3b00; color: #fff; }

html { font-size: 17px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
}
::selection { background: #fff3a3; color: var(--text); }
a { color: var(--link); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--link-hover); }
img { max-width: 100%; height: auto; display: block; }

/* ============================================================ */
/* SITE NAV                                                     */
/* ============================================================ */
.nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.nav-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.nav-logo {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    font-family: var(--mono);
}
.nav-logo:hover { color: var(--accent); }
.nav-logo .bracket { color: var(--accent); }
.nav-logo .slash { color: #c9c9c9; }

.nav-menu { display: flex; align-items: center; gap: 22px; }
.nav-menu a { font-size: 0.88rem; color: var(--muted); font-weight: 500; }
.nav-menu a:hover, .nav-menu a.active { color: var(--text); }
.nav-menu a.active { color: var(--accent); }
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text);
}
.nav-tools { display: flex; align-items: center; gap: 10px; }

/* Light/dark toggle (lives in nav and game header). */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.18s, color 0.18s, background 0.18s;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
body.dark-theme .theme-toggle .icon-sun { display: block; }
body.dark-theme .theme-toggle .icon-moon { display: none; }

/* ============================================================ */
/* HERO (landing)                                               */
/* ============================================================ */
.hero {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 64px 24px 40px;
}
.hero h1 {
    font-family: var(--serif);
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin-bottom: 14px;
}
.hero .eyebrow {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 14px;
}
.hero-deck {
    font-family: var(--serif);
    font-size: 1.18rem;
    font-style: italic;
    color: var(--muted);
    line-height: 1.55;
    margin-bottom: 28px;
    max-width: 640px;
}
.hero-ctas { display: flex; gap: 12px; flex-wrap: wrap; }

/* ============================================================ */
/* BUTTONS                                                      */
/* ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    font-family: var(--sans);
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: var(--text);
    color: #fff;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.12s;
    text-decoration: none;
}
.btn:hover { background: #000; color: #fff; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); background: transparent; transform: translateY(-1px); }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: #8c1414; }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================================ */
/* SECTIONS                                                     */
/* ============================================================ */
.section {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 56px 24px;
    border-top: 1px solid var(--border);
}
.section-eyebrow {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 14px;
}
.section-title {
    font-family: var(--serif);
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.015em;
    margin-bottom: 14px;
}
.section-deck {
    font-family: var(--serif);
    font-size: 1.08rem;
    font-style: italic;
    color: var(--muted);
    line-height: 1.5;
    max-width: 640px;
    margin-bottom: 36px;
}

/* Feature grid (landing) */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.feature {
    background: var(--bg);
    padding: 22px 22px;
}
.feature h3 {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 8px;
}
.feature p { font-size: 0.95rem; color: var(--text-soft); line-height: 1.55; }

/* Hub cards (landing) */
.hub-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
.hub-card {
    display: block;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg);
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
    color: var(--text);
}
.hub-card:hover {
    border-color: var(--accent);
    color: var(--text);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.hub-card-eyebrow {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
}
.hub-card h3 {
    font-family: var(--serif);
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin-bottom: 8px;
}
.hub-card p {
    font-size: 0.95rem;
    color: var(--muted);
    line-height: 1.55;
    margin-bottom: 14px;
}
.hub-card-arrow { font-size: 0.85rem; font-weight: 600; color: var(--accent); }

/* Info box (callout) */
.callout {
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    padding: 14px 18px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin: 20px 0;
}
.callout strong { color: var(--accent); }
.callout--muted { border-left-color: var(--border-strong); background: var(--bg-soft); }
.callout--muted strong { color: var(--text); }

/* ============================================================ */
/* FOOTER                                                       */
/* ============================================================ */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 36px 24px;
    background: var(--bg-soft);
}
.footer-inner { max-width: var(--maxw); margin: 0 auto; }
.footer-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 18px;
}
.footer-links { display: flex; gap: 18px; font-size: 0.85rem; color: var(--muted); flex-wrap: wrap; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }
.footer-note {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.6;
}

/* ============================================================ */
/* LANDING — HERO ANIMATION (kept verbatim animation, themed)   */
/* ============================================================ */
.hero-anim {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 80px 24px 64px;
}
.hero-anim-inner {
    max-width: 760px;
    margin: 0 auto;
    text-align: left;
}
.hero-anim .main-title {
    font-family: var(--serif);
    font-size: clamp(1.5rem, 4.5vw, 2.2rem);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.15;
    margin-bottom: 24px;
    transition: opacity 0.5s ease;
}
.hero-anim .hero-dialogue {
    font-family: var(--mono);
    font-size: 1.05rem;
    line-height: 1.85;
    margin-bottom: 24px;
    min-height: 8em;
    color: var(--text-soft);
}
.hero-anim .user-line { color: var(--accent); }
.hero-anim .user-line::before { content: '› '; opacity: 0.6; }
.hero-anim .game-line { color: var(--text); padding-left: 12px; }
.hero-anim .hero-question {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.4rem;
    color: var(--muted);
    margin: 18px 0;
    transition: opacity 0.8s ease;
}
.hero-anim .hero-cta-container {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
    transition: opacity 0.8s ease;
}
.hero-anim .hero-cta-container .btn { min-width: 120px; justify-content: center; }
.hero-anim .scroll-indicator {
    margin-top: 36px;
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    color: var(--muted);
    text-transform: uppercase;
    transition: opacity 0.8s ease;
}
.hero-anim .scroll-indicator span {
    display: inline-block;
    width: 1px; height: 14px;
    background: var(--muted);
    margin-right: 8px;
    vertical-align: middle;
    animation: scrollPulse 1.6s ease-in-out infinite;
}
@keyframes scrollPulse {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(3px); }
}

/* ============================================================ */
/* STATS MODAL                                                  */
/* ============================================================ */
.modal {
    position: fixed; inset: 0;
    background: rgba(20, 20, 20, 0.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 1100;
    padding: 20px;
    backdrop-filter: blur(4px);
}
.modal-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px rgba(0,0,0,0.18);
    width: 100%;
    max-width: 540px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.modal-head h2 {
    font-family: var(--serif);
    font-size: 1.15rem;
    font-weight: 700;
}
.modal-close {
    background: none; border: 0;
    font-size: 1.3rem; color: var(--muted); cursor: pointer;
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-soft); color: var(--text); }
.modal-body { padding: 18px 22px 22px; }
.stat-group { margin-bottom: 16px; }
.stat-group h3 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    margin-bottom: 8px;
}
.stat-group--alt h3 { color: var(--muted); }
.stat-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    font-size: 0.92rem;
    padding: 6px 0;
    border-top: 1px dashed var(--border);
}
.stat-row:first-of-type { border-top: 0; }
.stat-row .v { font-family: var(--mono); font-weight: 600; color: var(--text); }
.modal-foot {
    font-size: 0.75rem; color: var(--muted);
    text-align: center;
    padding: 12px 22px 18px;
    border-top: 1px solid var(--border);
}

/* ============================================================ */
/* PLAY (story select)                                          */
/* ============================================================ */
.page-head {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 48px 24px 24px;
}
.page-head h1 {
    font-family: var(--serif);
    font-size: clamp(1.8rem, 5vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}
.page-head p { color: var(--muted); font-family: var(--serif); font-style: italic; font-size: 1.05rem; }

.filter-bar {
    max-width: var(--maxw);
    margin: 0 auto 24px;
    padding: 0 24px;
    display: grid;
    grid-template-columns: 1fr 180px 180px;
    gap: 10px;
}
.filter-input, .filter-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s;
}
.filter-input:focus, .filter-select:focus { border-color: var(--accent); }
.filter-input::placeholder { color: var(--muted-2); }

.story-grid {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 24px 64px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}
.story-card {
    display: flex;
    flex-direction: column;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg);
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
    color: var(--text);
}
.story-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.story-card .story-meta-row {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.story-card .story-meta-row .badge {
    border: 1px solid var(--border-strong);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
}
.story-card .story-title {
    font-family: var(--serif);
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 8px;
}
.story-card .story-desc {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 14px;
    flex-grow: 1;
}
.story-card .story-author { font-size: 0.82rem; color: var(--muted-2); margin-bottom: 12px; }
.story-card .story-card-actions { display: flex; gap: 12px; align-items: center; }
.story-card .story-share-link {
    font-size: 0.8rem;
    color: var(--muted);
    border-bottom: 1px solid transparent;
}
.story-card .story-share-link:hover { color: var(--accent); border-bottom-color: var(--accent); }
.story-card .lock-icon-container {
    color: var(--muted);
    display: inline-flex; align-items: center;
}

.progress-container {
    max-width: 320px;
    margin: 0 auto 24px;
    height: 6px;
    background: var(--bg-soft-2);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}
.progress-fill {
    position: absolute; inset: 0 100% 0 0;
    background: var(--accent);
    border-radius: 999px;
    animation: progFill 0.9s ease-out forwards;
}
@keyframes progFill { to { inset: 0 0 0 0; } }
.progress-text {
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-top: 8px;
}

.loading-text {
    text-align: center;
    color: var(--muted);
    font-family: var(--mono);
    margin: 24px 0;
}
.loading-text .cursor {
    display: inline-block;
    width: 2px; height: 1em;
    background: var(--accent);
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: blinkCursor 0.7s step-end infinite;
}
@keyframes blinkCursor { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* ============================================================ */
/* DOCS                                                         */
/* ============================================================ */
.docs-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 40px;
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 24px 96px;
}
.docs-toc {
    position: sticky;
    top: 76px;
    align-self: start;
    max-height: calc(100dvh - 96px);
    overflow-y: auto;
    padding: 14px 0 14px 4px;
    border-right: 1px solid var(--border);
}
.docs-toc h3 {
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    color: var(--accent);
    margin: 0 0 12px;
    text-transform: uppercase;
    font-weight: 600;
}
.docs-toc ol { list-style: none; padding: 0; margin: 0; counter-reset: docnum; }
.docs-toc li { margin: 0; counter-increment: docnum; }
.docs-toc a {
    display: block;
    padding: 6px 12px 6px 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.4;
    border-left: 2px solid transparent;
    padding-left: 12px;
    margin-left: -2px;
}
.docs-toc a:hover { color: var(--text); border-left-color: var(--border-strong); }
.docs-toc a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

.docs-content { max-width: 720px; }
.docs-content h1 {
    font-family: var(--serif);
    font-size: clamp(2rem, 5vw, 2.6rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 18px;
}
.docs-content > p { font-size: 1.08rem; color: var(--text-soft); line-height: 1.7; margin: 14px 0; }
.docs-content h2 {
    font-family: var(--serif);
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin-top: 56px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.docs-content h3 {
    font-family: var(--sans);
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 28px;
    margin-bottom: 8px;
    letter-spacing: -0.005em;
}
.docs-content p, .docs-content ul, .docs-content ol {
    line-height: 1.7;
    margin: 12px 0;
}
.docs-content ul, .docs-content ol { padding-left: 22px; }
.docs-content li { margin: 4px 0; }
.docs-content code {
    background: var(--code-bg);
    padding: 1px 6px;
    border: 1px solid var(--code-border);
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 0.88em;
    color: var(--accent);
}
.docs-content pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: var(--radius);
    padding: 16px 18px;
    overflow-x: auto;
    font-size: 0.86rem;
    line-height: 1.55;
    margin: 16px 0;
    font-family: var(--mono);
}
.docs-content pre code {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--text);
}
.docs-content .note {
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    padding: 12px 16px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin: 16px 0;
}
.docs-content .note strong { color: var(--accent); }
.docs-content a {
    color: var(--link);
    border-bottom: 1px solid var(--border-strong);
}
.docs-content a:hover { color: var(--link-hover); border-bottom-color: var(--link-hover); }
.docs-content strong { color: var(--text); font-weight: 700; }

.docs-toc-button {
    display: none;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1050;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 0;
    background: var(--text);
    color: #fff;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    cursor: pointer;
    font-size: 1.1rem;
}
.docs-toc-button:active { transform: scale(0.96); }

/* ============================================================ */
/* GAME (clean light terminal — preserves --app-height for soft */
/* keyboards; preserves all DOM hooks the JS expects)           */
/* ============================================================ */
body.game-page {
    background: var(--term-bg);
    overflow: hidden;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
}
.game-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    height: var(--app-height, 100dvh);
    width: 100%;
}
.game-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}
.game-header .back-link {
    font-size: 0.82rem;
    color: var(--muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.game-header .back-link:hover { color: var(--accent); }
.game-header .engine-link {
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}
.game-header .engine-link:hover { color: var(--accent); }
.game-header .spacer { flex: 1; }
.game-header .game-status-bar {
    font-size: 0.75rem;
    color: var(--muted);
    font-family: var(--mono);
}
.game-header select.filter-select {
    padding: 6px 8px;
    font-size: 0.78rem;
    border-radius: 4px;
}
.game-header .mute-button {
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.78rem;
    color: var(--text);
    cursor: pointer;
    font-family: var(--mono);
}
.game-header .mute-button:hover { border-color: var(--accent); color: var(--accent); }
.game-header .cat-icon {
    font-family: var(--mono);
    font-size: 0.7rem;
    line-height: 1;
    color: var(--muted);
    white-space: pre;
    display: none;
}
@media (min-width: 720px) {
    .game-header .cat-icon { display: block; }
}
.cat-eyes { color: var(--accent); }

.game-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    width: 100%;
    max-width: 820px;
    padding: 20px 24px 16px;
    margin: 0 auto;
    box-sizing: border-box;
    overflow: hidden;
}
.output-area {
    flex-grow: 1;
    overflow-y: auto;
    white-space: pre-wrap;
    margin-bottom: 14px;
    font-family: var(--mono);
    font-size: 1.02rem;
    line-height: 1.7;
    padding-right: 8px;
    color: var(--text);
}
.output-area::-webkit-scrollbar { width: 8px; }
.output-area::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.output-area::-webkit-scrollbar-track { background: transparent; }
.input-area {
    display: flex;
    align-items: center;
    border-top: 1px solid var(--border);
    padding: 12px 0 6px;
}
.input-area .prompt {
    margin-right: 10px;
    font-family: var(--mono);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--term-prompt);
}
.input-area input[type="text"],
.game-input {
    background: transparent;
    border: none;
    color: var(--text);
    font-family: var(--mono);
    font-size: 1.05rem;
    flex-grow: 1;
    outline: none;
    caret-color: var(--accent);
}
.latency-counter {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--muted);
    text-align: right;
    margin-bottom: 4px;
}
.log-entry.story { margin-bottom: 18px; color: var(--text); }
.log-entry.user { color: var(--muted); font-style: italic; margin-bottom: 10px; }
.log-entry.user::before { content: '› '; color: var(--accent); font-style: normal; }
.log-entry.error { color: var(--accent); }
.log-entry.system { color: var(--muted); font-size: 0.88rem; margin-bottom: 10px; }

.install-btn {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text);
    border-radius: var(--radius);
    padding: 8px 14px;
    cursor: pointer;
    margin-top: 10px;
    align-self: flex-end;
    font-family: var(--mono);
    font-size: 0.82rem;
}
.install-btn:hover { border-color: var(--accent); color: var(--accent); }

/* The challenge button used by terminal.js */
.challenge-btn {
    display: inline-block;
    margin-left: 10px;
    cursor: pointer;
    color: var(--accent);
    font-weight: 700;
    transition: transform 0.18s;
}
.challenge-btn:hover { transform: scale(1.05); }
.transmission-tag {
    color: var(--muted-2);
    font-size: 0.7rem;
    margin-left: 10px;
    font-family: var(--mono);
}

/* In-game modal (intents list etc) */
.modal-content {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    color: var(--text);
    font-family: var(--sans);
    box-shadow: 0 18px 50px rgba(0,0,0,0.18);
}
.modal-header {
    font-family: var(--serif);
    font-size: 1.15rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    margin-bottom: 14px;
}
.intent-option {
    padding: 10px 12px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}
.intent-option:hover {
    background: var(--bg-soft);
    border-color: var(--accent);
}

/* ============================================================ */
/* MOBILE                                                       */
/* ============================================================ */
@media (max-width: 820px) {
    html { font-size: 16px; }
    .nav-menu { display: none; }
    .nav-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 38px; height: 38px;
        position: relative; z-index: 1200;
        padding: 0;
        background: none;
        border: 1px solid var(--border-strong);
        border-radius: 6px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .nav-toggle:hover { border-color: var(--accent); }
    .nav-toggle .bars { display: inline-block; width: 18px; height: 12px; position: relative; }
    .nav-toggle .bars::before,
    .nav-toggle .bars::after,
    .nav-toggle .bars span {
        content: ''; position: absolute; left: 0; right: 0; height: 2px;
        background: var(--text); border-radius: 1px;
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
    }
    .nav-toggle .bars::before { top: 0; }
    .nav-toggle .bars span { top: 5px; }
    .nav-toggle .bars::after { bottom: 0; }
    .nav.open .nav-toggle .bars::before { transform: translateY(5px) rotate(45deg); }
    .nav.open .nav-toggle .bars span { opacity: 0; transform: scaleX(0.4); }
    .nav.open .nav-toggle .bars::after { transform: translateY(-5px) rotate(-45deg); }
    .nav-menu {
        position: fixed; left: 0; right: 0; top: 0;
        width: 100%; height: 100vh; height: 100dvh;
        background: var(--bg);
        z-index: 999;
        pointer-events: none;
        opacity: 0;
        transform: translateY(-12px);
        transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1),
                    transform 0.36s cubic-bezier(0.16, 1, 0.3, 1);
        display: flex; flex-direction: column; align-items: flex-start; gap: 0;
        padding: 88px 28px 28px;
    }
    .nav-menu a {
        font-family: var(--serif);
        font-size: 1.7rem;
        font-weight: 700;
        letter-spacing: -0.015em;
        line-height: 1.2;
        color: var(--text);
        padding: 14px 0;
        width: 100%;
        border-bottom: 1px solid var(--border);
    }
    .nav-menu a:hover, .nav-menu a.active { color: var(--accent); }
    .nav.open .nav-menu { pointer-events: auto; opacity: 1; transform: translateY(0); }
    body.nav-locked { overflow: hidden; }

    .hero, .section { padding: 40px 20px; }
    .hero-anim { padding: 56px 20px 40px; }
    .hub-grid { grid-template-columns: 1fr; }
    .filter-bar { grid-template-columns: 1fr; padding: 0 20px; }
    .story-grid { padding: 0 20px 56px; grid-template-columns: 1fr; }
    .page-head { padding: 32px 20px 16px; }

    /* Docs: collapse sidebar into a drawer triggered by floating button */
    .docs-shell { grid-template-columns: 1fr; padding: 20px 18px 80px; gap: 0; }
    .docs-toc {
        position: fixed;
        top: 0; right: 0;
        height: 100dvh;
        width: min(320px, 88%);
        background: var(--bg);
        border-left: 1px solid var(--border);
        border-right: 0;
        padding: 76px 18px 28px;
        max-height: none;
        z-index: 1100;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: -18px 0 40px rgba(0,0,0,0.08);
    }
    body.docs-toc-open .docs-toc { transform: translateX(0); }
    body.docs-toc-open::before {
        content: '';
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.35);
        z-index: 1099;
    }
    .docs-toc-button { display: inline-flex; align-items: center; justify-content: center; }
    .docs-content { max-width: 100%; }
    .docs-content h2 { margin-top: 40px; }
    .docs-content pre { font-size: 0.78rem; }

    /* Game on mobile */
    .game-header { padding: 10px 14px; gap: 10px; flex-wrap: nowrap; }
    .game-header .engine-link { display: none; }
    .game-header .game-status-bar { display: none; }
    .game-container { padding: 14px 16px 12px; }
    .output-area { font-size: 1rem; }
    .input-area input[type="text"], .game-input { font-size: 16px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
