:root {
  --bg: #f5f2ea;
  --surface: #ffffff;
  --surface-2: #efebe1;
  --ink: #15191c;
  --ink-2: #4c5459;
  --ink-3: #80888d;
  --line: #ddd8cc;
  --turf: #14532d;
  --turf-ink: #ffffff;
  --gold: #e3a90b;
  --good: #1f8a4c;
  --bad: #c2352b;
  --skip: #9aa2a7;
  --stage: #ebe6da;
  --shadow: 0 1px 2px rgb(20 25 28 / .06), 0 8px 24px rgb(20 25 28 / .08);
  --radius: 16px;
  --display: 'Oswald', 'Arial Narrow', Impact, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1311;
    --surface: #161e1b;
    --surface-2: #1d2724;
    --ink: #eef1ee;
    --ink-2: #b4bdb8;
    --ink-3: #7f8a85;
    --line: #2a3531;
    --turf: #2f9e5b;
    --turf-ink: #06120b;
    --gold: #f2bd2c;
    --good: #3fbf72;
    --bad: #f0675b;
    --skip: #6f7975;
    --stage: #d9d3c5;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1311; --surface: #161e1b; --surface-2: #1d2724; --ink: #eef1ee; --ink-2: #b4bdb8; --ink-3: #7f8a85;
  --line: #2a3531; --turf: #2f9e5b; --turf-ink: #06120b; --gold: #f2bd2c; --good: #3fbf72; --bad: #f0675b;
  --skip: #6f7975; --stage: #d9d3c5; --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-left, .topbar-right { display: flex; gap: 2px; }
.topbar-right { justify-content: flex-end; }
.brand { text-decoration: none; color: var(--ink); display: flex; gap: 6px; white-space: nowrap; font-family: var(--display); font-weight: 700; font-size: clamp(17px, 5.2vw, 22px); letter-spacing: .02em; line-height: 1; }
.brand-mark.accent { color: var(--turf); }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 10px; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

main { max-width: 560px; margin: 0 auto; padding: 20px 16px 48px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px; border: 0;
  font-weight: 700; font-size: 16px; letter-spacing: .01em;
  background: var(--turf); color: var(--turf-ink);
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--turf); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Home ---------- */
.hero { text-align: center; padding: 24px 0 8px; }
.hero h1 { font-family: var(--display); font-size: clamp(42px, 12vw, 64px); line-height: .95; margin: 0 0 12px; letter-spacing: .01em; text-transform: uppercase; }
.hero h1 span { color: var(--turf); display: block; }
.hero p { color: var(--ink-2); margin: 0 auto 24px; max-width: 34ch; }
.puzzle-meta { display: inline-flex; gap: 10px; align-items: center; color: var(--ink-3); font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 16px; }
.puzzle-meta i { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-3); }
.home-actions { display: grid; gap: 10px; max-width: 320px; margin: 0 auto; }
.mini-stats { display: flex; justify-content: center; gap: 28px; margin: 32px 0 0; }
.mini-stats div { text-align: center; }
.mini-stats b { display: block; font-family: var(--display); font-size: 28px; line-height: 1.1; }
.mini-stats span { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.beta-banner { background: var(--gold); color: #1a1405; border-radius: 12px; padding: 10px 14px; font-weight: 600; font-size: 14px; margin-bottom: 16px; text-align: center; }

/* ---------- Progress ---------- */
.progress { display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; margin-bottom: 10px; }
.progress span { height: 6px; border-radius: 3px; background: var(--line); }
.progress span.correct { background: var(--good); }
.progress span.wrong { background: var(--bad); }
.progress span.skip { background: var(--skip); }
.progress span.current { background: var(--ink); }
.game-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.game-head b { color: var(--ink); font-family: var(--display); font-size: 20px; }

/* ---------- Question card ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.stage { position: relative; height: 200px; display: grid; place-items: end center; background: var(--stage); overflow: hidden; }
.stage::before { content: ''; position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 100%, var(--team-2) 0%, transparent 62%); opacity: .35; }
.stage::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 46px, rgb(255 255 255 / .35) 46px 48px); opacity: .5; }
.stage svg { position: relative; z-index: 1; width: 230px; height: 190px; }
.stage .pts { position: absolute; z-index: 2; top: 12px; right: 12px; }
.stage .diff { position: absolute; z-index: 2; top: 12px; left: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: rgb(255 255 255 / .85); color: #1d2326; }
.pill .dots { display: inline-flex; gap: 2px; }
.pill .dots i { width: 6px; height: 6px; border-radius: 50%; background: #c9c3b6; }
.pill .dots i.on { background: #1d2326; }
.card-body { padding: 18px 18px 20px; }
.player-name { font-family: var(--display); font-size: clamp(30px, 8vw, 40px); line-height: 1.05; margin: 0; text-transform: uppercase; letter-spacing: .01em; }
.player-meta { margin: 6px 0 0; color: var(--ink-2); font-weight: 500; }
.player-meta .sep { color: var(--ink-3); margin: 0 6px; }
.shared-note { margin-top: 8px; font-size: 13px; color: var(--ink-3); }

/* ---------- Typeahead ---------- */
.answer-zone { margin-top: 16px; }
.combo-field { position: relative; }
.combo input {
  width: 100%; height: 54px; padding: 0 16px 0 46px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--bg); font-size: 17px; font-weight: 500;
}
.combo input:focus { outline: none; border-color: var(--turf); }
.combo .search-ico { position: absolute; left: 15px; top: 50%; translate: 0 -50%; width: 20px; height: 20px; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; }
.suggestions {
  list-style: none; margin: 6px 0 0; padding: 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  max-height: 300px; overflow-y: auto;
}
.suggestions:empty { display: none; }
.suggestions li { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--surface-2); }
.suggestions .swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .15); }
.suggestions .via { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.suggestions .empty { color: var(--ink-3); font-weight: 500; cursor: default; }
.suggestions .empty:hover { background: none; }
.answer-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.hint { font-size: 13px; color: var(--ink-3); }

/* ---------- Reveal ---------- */
.reveal { margin-top: 16px; text-align: center; animation: pop .25s ease; }
.verdict { font-weight: 700; font-size: 15px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.verdict.correct { color: var(--good); }
.verdict.wrong { color: var(--bad); }
.verdict.skip { color: var(--ink-3); }
.college-chip {
  display: inline-block; padding: 10px 22px; border-radius: 12px;
  font-family: var(--display); font-weight: 700; font-size: clamp(26px, 7.5vw, 36px); text-transform: uppercase; letter-spacing: .02em; line-height: 1.15;
  border: 3px solid; box-shadow: var(--shadow);
}
.your-guess { margin-top: 10px; color: var(--ink-3); font-size: 14px; }
.your-guess s { color: var(--ink-2); }
.reveal .btn { margin-top: 18px; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Results ---------- */
.results-head { text-align: center; }
.results-head .label { font-size: 13px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.big-score { font-family: var(--display); font-size: 76px; line-height: 1; margin: 6px 0 2px; color: var(--turf); }
.results-line { color: var(--ink-2); font-weight: 600; }
.grid-result { display: grid; grid-template-columns: repeat(5, 30px); gap: 5px; justify-content: center; margin: 18px 0; }
.grid-result span { width: 30px; height: 30px; border-radius: 6px; background: var(--skip); }
.grid-result .correct { background: var(--good); }
.grid-result .wrong { background: var(--bad); }
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.section { margin-top: 28px; }
.section h2 { font-family: var(--display); text-transform: uppercase; font-size: 22px; letter-spacing: .02em; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: baseline; }
.section h2 small { font-family: var(--body); font-size: 13px; color: var(--ink-3); font-weight: 600; text-transform: none; letter-spacing: 0; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.name-form { display: flex; gap: 8px; }
.name-form input, .field input {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg);
}
.name-form input:focus, .field input:focus { outline: none; border-color: var(--turf); }
.form-error { color: var(--bad); font-size: 14px; margin-top: 8px; min-height: 0; }
.form-error:empty { display: none; }
.muted { color: var(--ink-3); font-size: 14px; }

.lb { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lb th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; padding: 6px 8px; }
.lb td { padding: 10px 8px; border-top: 1px solid var(--line); }
.lb .num { text-align: right; }
.lb .rank { width: 36px; color: var(--ink-3); font-weight: 700; }
.lb tr.me td { background: color-mix(in srgb, var(--turf) 12%, transparent); font-weight: 700; }
.lb tr.gap td { text-align: center; color: var(--ink-3); padding: 4px; border: 0; }
.lb .user { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.countdown { text-align: center; margin-top: 28px; color: var(--ink-2); }
.countdown b { display: block; font-family: var(--display); font-size: 34px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Review list ---------- */
.review { list-style: none; margin: 0; padding: 0; }
.review li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.review li:first-child { border-top: 0; }
.review .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--skip); }
.review .dot.correct { background: var(--good); }
.review .dot.wrong { background: var(--bad); }
.review .who { flex: 1; min-width: 0; }
.review .who b { display: block; }
.review .who span { font-size: 13px; color: var(--ink-3); }
.review .school { font-weight: 700; font-size: 14px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.review .pts { width: 44px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.review .pts.on { color: var(--good); }

/* ---------- Modal ---------- */
dialog {
  border: 0; padding: 0; border-radius: 20px; width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgb(0 0 0 / .35);
}
dialog::backdrop { background: rgb(8 12 10 / .55); backdrop-filter: blur(2px); }
.modal-inner { position: relative; padding: 24px 22px 22px; }
.modal-close { position: absolute; top: 10px; right: 10px; }
dialog h2:focus { outline: none; }
dialog h2 { font-family: var(--display); text-transform: uppercase; font-size: 26px; margin: 0 0 14px; letter-spacing: .02em; }
dialog h3 { font-size: 15px; margin: 18px 0 6px; }
dialog ul { padding-left: 20px; margin: 8px 0; }
dialog li { margin: 6px 0; color: var(--ink-2); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin: 8px 0 4px; }
.stat-grid b { display: block; font-family: var(--display); font-size: 32px; line-height: 1.1; }
.stat-grid span { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); padding: 4px; border-radius: 999px; margin-bottom: 16px; }
.tabs button { border: 0; background: none; border-radius: 999px; padding: 8px; font-weight: 600; color: var(--ink-2); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.example-chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-weight: 700; border: 2px solid; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); translate: -50% 20px;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, translate .2s; z-index: 20;
}
#toast.show { opacity: 1; translate: -50% 0; }

.loading { text-align: center; padding: 80px 0; color: var(--ink-3); }
.error-box { text-align: center; padding: 48px 0; }
.error-box p { color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 380px) {
  .icon-btn { width: 36px; }
  .stage { height: 170px; }
  .stage svg { width: 200px; height: 165px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Social share buttons ---------- */
.social-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 4px; margin-top: 18px; }
.social-btn { display: grid; justify-items: center; gap: 6px; width: 64px; padding: 4px 0; background: none; border: 0; border-radius: 12px; }
.social-btn:hover .social-ico { transform: translateY(-2px); }
.social-ico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; transition: transform .12s ease; }
.social-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.social-ico.x, .social-ico.threads { background: #000; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .18); }
.social-ico.facebook { background: #1877f2; }
.social-ico.instagram { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fd5949 45%, #d6249f 60%, #285aeb 90%); }
.social-ico.whatsapp { background: #25d366; }
.social-ico.sms { background: #34c759; }
.social-ico.copy { background: var(--surface-2); color: var(--ink); }
.social-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }

/* ---------- Archive ---------- */
.archive-banner { background: color-mix(in srgb, var(--turf) 14%, var(--surface)); color: var(--ink); border: 1px solid color-mix(in srgb, var(--turf) 35%, transparent); border-radius: 12px; padding: 10px 14px; font-weight: 600; font-size: 14px; margin-bottom: 8px; text-align: center; }
.home-actions .link-btn { justify-self: center; }
.archive-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.arch-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: transform .1s ease; }
.arch-row:hover { transform: translateY(-1px); }
.arch-num { font-family: var(--display); font-size: 22px; width: 52px; color: var(--ink-3); }
.arch-day { flex: 1; min-width: 0; }
.arch-day b { display: block; }
.arch-day span { font-size: 13px; color: var(--ink-3); }
.arch-status { display: grid; justify-items: end; gap: 2px; text-align: right; }
.arch-score { font-family: var(--display); font-size: 22px; line-height: 1; }
.arch-score small { font-family: var(--body); font-size: 12px; color: var(--ink-3); }
.arch-tag { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.arch-tag.ranked { color: var(--good); }
.arch-play { font-weight: 700; color: var(--turf); }

/* ---------- Discord ---------- */
.discord-card {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center;
  margin-top: 24px; padding: 16px; border-radius: var(--radius);
  background: #5865f2; color: #fff; box-shadow: var(--shadow);
}
.discord-badge { grid-row: span 1; width: 44px; height: 44px; border-radius: 12px; background: rgb(255 255 255 / .16); display: grid; place-items: center; }
.discord-badge .discord-ico { width: 26px; height: 26px; }
.discord-copy b { display: block; font-size: 16px; }
.discord-copy span { font-size: 14px; opacity: .9; }
.discord-btn { grid-column: 1 / -1; margin-top: 8px; background: #fff; color: #404eed; text-decoration: none; }

/* ---------- Footer & text pages ---------- */
.site-footer { max-width: 560px; margin: 0 auto; padding: 8px 16px max(32px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12px; line-height: 1.55; text-align: center; }
.site-footer p { margin: 10px 0; }
.site-footer a { color: var(--ink-2); }
.footer-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 16px; font-weight: 600; }
.prose h1 { font-family: var(--display); text-transform: uppercase; font-size: 34px; margin: 0 0 4px; letter-spacing: .01em; }
.prose h2 { font-size: 18px; margin: 26px 0 6px; }
.prose p, .prose li { color: var(--ink-2); }
.prose ul { padding-left: 20px; }
.prose li { margin: 8px 0; }
.prose a:not(.btn) { color: var(--turf); }
