:root {
  --bg: #f6f1e7;
  --bg-2: #efe7d6;
  --ink: #1c1a17;
  --ink-soft: #5b554c;
  --paper: #fffdf8;
  --line: #e3d9c5;
  --green: #0a7d4f;
  --green-soft: #d6efe1;
  --gold: #c8911f;
  --gold-soft: #f6e7c3;
  --red: #c0392b;
  --red-soft: #f7ddd8;
  --shadow: 0 18px 40px -22px rgba(40, 30, 10, 0.45);
  --radius: 20px;
  --maxw: 620px;
  font-synthesis: none;
}

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

/* the [hidden] attribute must always win over class display rules below */
[hidden] { display: none !important; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg-2), transparent 60%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px) 16px 80px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.shell { width: 100%; max-width: var(--maxw); position: relative; }

/* ---------- screens ---------- */
.screen { display: none; animation: pop .35s cubic-bezier(.2,.9,.3,1.2); }
.screen.is-active { display: block; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }

/* ---------- typography ---------- */
.kicker {
  font-size: .72rem; letter-spacing: .18em; text-transform: uppercase;
  font-weight: 700; color: var(--green);
}
.title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 800; font-size: clamp(2.7rem, 11vw, 4.4rem);
  line-height: .95; letter-spacing: -.02em; margin: .35rem 0 .8rem;
}
.title-accent { color: var(--green); font-style: italic; }
.tagline { font-size: 1.08rem; color: var(--ink-soft); max-width: 30em; }
.tagline em { color: var(--ink); font-style: italic; }

/* ---------- start screen ---------- */
.how {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.3rem; margin: 1.6rem 0 1.2rem;
  box-shadow: var(--shadow);
}
.how h2 { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: .6rem; }
.how ol { padding-left: 1.2rem; display: grid; gap: .35rem; }
.how li { font-size: .98rem; }
.fine { margin-top: .8rem; font-size: .88rem; color: var(--ink-soft); font-style: italic; }

.namefield { display: block; margin: 0 0 1.1rem; }
.namefield span { display: block; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: .35rem; }
.namefield input {
  width: 100%; font: inherit; font-size: 1.05rem; padding: .7rem .9rem;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink);
}
.namefield input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }

.cta-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.rounds-note { margin-top: 1rem; font-size: .85rem; color: var(--ink-soft); }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 999px;
  padding: .8rem 1.4rem; border: 1.5px solid transparent; transition: transform .08s ease, box-shadow .15s ease, background .15s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 10px 22px -10px rgba(10,125,79,.7); }
.btn-primary:hover { background: #0b6e47; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--paper); }

/* ---------- HUD ---------- */
.hud { display: flex; justify-content: space-between; align-items: center; font-size: .92rem; color: var(--ink-soft); margin-bottom: .6rem; }
.hud b { color: var(--ink); }
.hud-left { display: flex; gap: .8rem; align-items: center; }
.hud-streak { background: var(--gold-soft); color: #8a6310; padding: .2rem .6rem; border-radius: 999px; font-size: .82rem; }
.hud-score b { font-variant-numeric: tabular-nums; }

/* ---------- timer ---------- */
.timerbar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 1rem; }
.timerbar-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); transform-origin: left; }
.timerbar-fill.run { transition: transform linear; transform: scaleX(0); }
.timerbar-fill.danger { background: var(--red); }

/* ---------- card ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem 1.4rem 1.5rem; box-shadow: var(--shadow);
}
.card-top { display: flex; gap: .5rem; margin-bottom: .8rem; flex-wrap: wrap; }
.chip { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: .28rem .6rem; border-radius: 999px; background: var(--green-soft); color: var(--green); }
.chip-muted { background: var(--bg-2); color: var(--ink-soft); }
.card-event { font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: clamp(1.4rem, 5vw, 1.9rem); line-height: 1.12; letter-spacing: -.01em; }
.card-people { color: var(--ink-soft); margin-top: .35rem; font-size: .95rem; }
.ask { margin: 1.3rem 0 .8rem; font-weight: 600; font-size: 1.02rem; }

/* ---------- options ---------- */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
@media (max-width: 420px) { .options { grid-template-columns: 1fr; } }
.opt {
  font: inherit; font-weight: 700; font-size: 1.25rem; font-variant-numeric: tabular-nums;
  cursor: pointer; padding: 1rem .8rem; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink);
  transition: transform .08s, border-color .12s, background .12s; position: relative;
}
.opt:hover:not(:disabled) { border-color: var(--green); transform: translateY(-1px); }
.opt:disabled { cursor: default; }
.opt.correct { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.opt.wrong { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.opt.picked { background: var(--gold-soft); border-color: var(--gold); color: #8a6310; }
.opt.dim { opacity: .5; }

/* ---------- reveal ---------- */
.reveal { margin-top: 1.1rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; box-shadow: var(--shadow); animation: pop .3s ease; }
.reveal-verdict { font-family: "Fraunces", serif; font-weight: 700; font-size: 1.5rem; }
.reveal-verdict.good { color: var(--green); }
.reveal-verdict.bad { color: var(--red); }
.reveal-actual { margin-top: .2rem; font-size: 1.05rem; }
.reveal-actual b { font-variant-numeric: tabular-nums; }
.reveal-narrator { margin-top: .7rem; font-style: italic; color: var(--ink); font-size: 1.02rem; }
.reveal-event { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.reveal-eventhead { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .5rem; }
.reveal-kicker { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: var(--ink-soft); }
.reveal-date { font-size: .85rem; font-weight: 600; color: var(--green); white-space: nowrap; }
.reveal-summary { color: var(--ink-soft); font-size: .92rem; }
.reveal-image { margin: .9rem 0 0; max-width: 320px; }
.reveal-image img { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); box-shadow: var(--shadow); display: block; }
.reveal-links { display: flex; flex-wrap: wrap; gap: 1.2rem; margin-top: .9rem; }
.reveal-link { color: var(--green); font-weight: 600; font-size: .9rem; text-decoration: none; }
.reveal-link:hover { text-decoration: underline; }
.reveal #next-btn { display: block; width: 100%; margin-top: 1.1rem; }

/* ---------- end ---------- */
.endwrap { text-align: center; }
.end-title { font-family: "Fraunces", serif; font-weight: 800; font-size: clamp(2.2rem, 9vw, 3.4rem); line-height: 1; margin: .3rem 0 1.4rem; letter-spacing: -.02em; }
.scoreboard { display: flex; gap: .7rem; justify-content: center; margin-bottom: 1.1rem; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 1rem .6rem; flex: 1; box-shadow: var(--shadow); }
.stat-num { display: block; font-family: "Fraunces", serif; font-weight: 700; font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.end-blurb { color: var(--ink-soft); max-width: 32em; margin: 0 auto 1.6rem; font-size: 1.02rem; }
.end-founders { margin: 0 auto 1.6rem; max-width: 420px; }
.end-founders img { width: 100%; height: auto; border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--shadow); display: block; }
.end-founders figcaption { margin-top: .6rem; font-size: .85rem; font-style: italic; color: var(--ink-soft); }
.submit-row { display: flex; gap: .6rem; align-items: flex-end; max-width: 440px; margin: 0 auto 1rem; text-align: left; }
.submit-row .namefield { flex: 1; margin: 0; }
.submit-status { font-size: .9rem; color: var(--green); margin-bottom: .8rem; }
.submit-status.err { color: var(--red); }
.endwrap .cta-row { justify-content: center; }

/* ---------- leaderboard overlay ---------- */
.overlay { position: fixed; inset: 0; background: rgba(28, 22, 12, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.overlay-card { background: var(--paper); border-radius: var(--radius); padding: 1.4rem; width: 100%; max-width: 460px; max-height: 80vh; overflow: auto; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); }
.overlay-head { display: flex; justify-content: space-between; align-items: center; }
.overlay-head h2 { font-family: "Fraunces", serif; font-size: 1.5rem; }
.iconbtn { border: none; background: var(--bg-2); width: 34px; height: 34px; border-radius: 999px; cursor: pointer; font-size: 1rem; }
.lb-sub { color: var(--ink-soft); font-size: .88rem; font-style: italic; margin: .3rem 0 1rem; }
.lb-list { list-style: none; display: grid; gap: .4rem; }
.lb-list li { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.lb-rank { font-family: "Fraunces", serif; font-weight: 700; width: 1.6em; text-align: center; color: var(--ink-soft); }
.lb-avatar { width: 56px; height: 56px; flex-shrink: 0; border-radius: 50%; object-fit: contain; background: var(--green-soft); }
.lb-list li:nth-child(1) .lb-rank { color: var(--gold); font-size: 1.2rem; }
.lb-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-variant-numeric: tabular-nums; font-weight: 700; }
.lb-acc { font-size: .78rem; color: var(--ink-soft); }
.lb-loading, .lb-empty { justify-content: center; color: var(--ink-soft); font-style: italic; }
.lb-me { border-color: var(--green); background: var(--green-soft); }

/* ---------- relax ---------- */
.relax-btn { position: fixed; top: 14px; right: 14px; z-index: 60; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink-soft); padding: .45rem .8rem; border-radius: 999px; font: inherit; font-weight: 700; font-size: .82rem; cursor: pointer; box-shadow: var(--shadow); }
.relax-btn:hover { color: var(--ink); }
.relax-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.yawn { position: absolute; top: -10vh; font-size: 2.2rem; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(120vh) rotate(220deg); opacity: .85; } }
.head-float { position: absolute; bottom: -22vh; opacity: 0; will-change: transform, opacity; animation-name: floatUp; animation-timing-function: ease-in; animation-fill-mode: forwards; filter: drop-shadow(0 6px 10px rgba(0,0,0,.25)); }
@keyframes floatUp {
  0% { transform: translateY(0) rotate(0); opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { transform: translateY(-135vh) rotate(var(--rot, 40deg)); opacity: 0; }
}

@media (max-width: 480px) {
  .stat-num { font-size: 1.4rem; }
  .submit-row { flex-direction: column; align-items: stretch; }
}
