:root {
  --turf: #0c2a1e;
  --turf-deep: #081d15;
  --line: rgba(236, 242, 226, 0.14);
  --chalk: #eef3e4;
  --muted: #a9bdae;
  --flood: #f6d44b;
  --danger: #ff6b5e;
  --t-bandwagon: #cfd8cb;
  --t-casual: #62b3f0;
  --t-fan: #6fe08f;
  --t-knowledge: #f6d44b;
  --t-scout: #ff9142;
  --display: 'Anton', Impact, 'Arial Narrow', sans-serif;
  --condensed: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Barlow', 'Segoe UI', Arial, sans-serif;
  --gutter: max(16px, env(safe-area-inset-left));
  --content: 1240px;
}

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

html {
  background: var(--turf-deep);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--turf);
  color: var(--chalk);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  touch-action: manipulation;
}

/* Every screen fills the window and sets its own padding, so nothing floats in empty field. */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen { flex: 1; animation: enter 0.22s ease-out; }

@keyframes enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- Shared ---------- */
.kicker, .category, .hud, .lineup span, .stats dt, .board-label {
  font-family: var(--condensed);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.kicker { color: var(--flood); }

.btn {
  min-height: 52px;
  padding: 0 24px;
  border: 2px solid transparent;
  border-radius: 4px;
  font: 700 20px var(--condensed);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.12s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible, input:focus-visible { outline: 3px solid var(--flood); outline-offset: 2px; }
.btn-primary { background: var(--flood); color: var(--turf-deep); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--chalk); }

@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { background: #ffe26b; }
  .btn-ghost:hover { border-color: var(--chalk); }
}

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.actions .btn { flex: 1 1 150px; }

.hint { min-height: 26px; margin-top: 10px; color: var(--flood); font-weight: 500; overflow-wrap: anywhere; }
.hint.is-miss { color: var(--danger); }
.fineprint { margin-top: 12px; color: var(--muted); font-size: 14px; }

.tier-bandwagon { --tier: var(--t-bandwagon); }
.tier-casual { --tier: var(--t-casual); }
.tier-fan { --tier: var(--t-fan); }
.tier-knowledge { --tier: var(--t-knowledge); }
.tier-scout { --tier: var(--t-scout); }

/* ---------- Home ---------- */
.home-intro {
  padding: 20px var(--gutter) 22px;
  background: repeating-linear-gradient(90deg, var(--turf) 0 72px, #0e3023 72px 144px);
}

.home-panel {
  padding: 18px var(--gutter) calc(24px + env(safe-area-inset-bottom));
  background: var(--turf-deep);
}

.logo {
  margin: 6px 0 12px;
  font: 400 clamp(64px, 19vw, 124px) / 0.98 var(--display);
  text-transform: uppercase;
}

.lede { max-width: 34em; font-size: 19px; }
.lede strong { color: var(--flood); font-weight: 600; }

.tier-key {
  display: grid;
  gap: 4px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.tier-chip {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 12px;
  padding: 5px 12px;
  background: var(--turf);
  border-left: 6px solid var(--tier);
  font: 600 18px/1.15 var(--condensed);
}
.tier-chip small { grid-column: 1; color: var(--muted); font: 500 14px/1.15 var(--condensed); }
.tier-chip b { grid-column: 2; grid-row: 1 / span 2; color: var(--tier); font: 400 28px/1.1 var(--display); }

.lineup { color: var(--muted); font-size: 15px; }
.lineup span { display: block; color: var(--chalk); }

.stats { display: flex; gap: 32px; margin-top: 18px; }
.stats dt { color: var(--muted); font-size: 14px; }
.stats dd { margin: 0; font: 400 34px var(--display); }

/* ---------- Timer scoreboard ---------- */
.board {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) var(--gutter) 14px;
  background: #000;
}

.board-side { display: flex; flex-direction: column; min-width: 0; }
.board-right { align-items: flex-end; text-align: right; }
.board-label { color: var(--muted); font-size: 14px; line-height: 1.15; }
.board-value { color: var(--chalk); font: 400 28px/1.15 var(--display); }
.board-value small { color: var(--muted); font-size: 0.6em; }

.clock {
  min-width: 2ch;
  color: var(--flood);
  font: 400 72px/1 var(--display);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.clock.is-urgent { color: var(--danger); animation: pulse 1s ease-in-out infinite; }

@keyframes pulse {
  50% { transform: scale(1.08); }
}

.clock-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 8px;
  background: #1c2a23;
}
.clock-fill { height: 100%; background: var(--flood); }
.clock-fill.is-urgent { background: var(--danger); }

/* ---------- Prompt ---------- */
.play {
  display: flex;
  flex: none;
  flex-direction: column;
  min-height: var(--visible-height, 100vh);
}

.play-body { padding: 0 var(--gutter) 10px; }

/* Takes whatever height the question leaves, so wrong guesses shrink it and never move the input. */
.arena {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.arena canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.arena canvas[hidden] { display: none; }

.category { margin-top: 20px; color: var(--flood); font-size: 18px; }

.prompt-text {
  margin-top: 4px;
  font: 700 clamp(28px, 6.4vw, 44px) / 1.12 var(--condensed);
}

.as-of { margin-top: 6px; color: var(--muted); font-size: 14px; }

.guess { display: flex; gap: 8px; margin-top: 18px; }
.guess input {
  flex: 1;
  min-width: 0;
  height: 56px;
  padding: 0 14px;
  background: var(--chalk);
  border: 0;
  border-radius: 4px;
  color: var(--turf-deep);
  font: 500 20px var(--body);
}
.guess input.is-wrong { animation: shake 0.28s ease-out; }

@keyframes shake {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

.misses {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding: 0;
  list-style: none;
}
.misses li {
  max-width: 100%;
  padding: 2px 10px;
  background: rgba(255, 107, 94, 0.14);
  border-radius: 3px;
  color: #ffb4ad;
  font-size: 15px;
  overflow-wrap: anywhere;
  text-decoration: line-through;
}

.key-hint { display: none; margin-top: 16px; color: var(--muted); font-size: 14px; }
.key-hint kbd {
  padding: 1px 6px;
  border: 1px solid var(--muted);
  border-radius: 3px;
  font: 600 13px var(--body);
}

/* ---------- Reveal ---------- */
.reveal, .results { padding: 16px var(--gutter) calc(24px + env(safe-area-inset-bottom)); }

.hud { display: flex; justify-content: space-between; gap: 12px; font-size: 16px; }
.hud b { color: var(--flood); }

.ladder-bar { position: relative; height: 8px; margin-top: 8px; background: var(--turf-deep); }
.ladder-fill { height: 100%; background: var(--flood); transition: width 0.5s ease-out; }
.ladder-tick { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--muted); }
.ladder-tick.is-passed { background: var(--flood); }

.stage {
  position: relative;
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 0;
  background: #07170f;
  border: 2px solid var(--line);
  border-radius: 4px;
  color: var(--chalk);
  cursor: pointer;
  overflow: hidden;
}
.stage:focus-visible { outline: 3px solid var(--flood); outline-offset: 2px; }
.stage canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}
.stage-caption {
  position: absolute;
  left: 6px;
  bottom: 4px;
  padding: 0 6px;
  background: rgba(4, 16, 9, 0.8);
  font: 700 14px var(--condensed);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stamp {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  padding: 10px 14px;
  background: var(--tier);
  color: var(--turf-deep);
  font: 400 clamp(26px, 6vw, 36px) / 1.15 var(--display);
  text-transform: uppercase;
  animation: stamp 0.26s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.stamp b { font-weight: 400; }
.stamp-miss { background: var(--turf-deep); color: var(--danger); }

@keyframes stamp {
  from { transform: scale(1.06); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.verdict-note { margin-top: 8px; color: var(--muted); overflow-wrap: anywhere; }
.verdict-note strong { color: var(--chalk); font-weight: 600; }

.reveal-prompt { margin-top: 18px; font: 600 22px/1.2 var(--condensed); }

.answers { margin: 12px 0 0; padding: 0; list-style: none; }

.answer {
  display: grid;
  grid-template-columns: minmax(0, 11em) 1fr 2.2em;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px solid var(--line);
  font-size: 15px;
}
.answer.is-mine { color: var(--flood); font-weight: 600; }
.answer-bar { height: 10px; }
.answer-bar::before {
  content: '';
  display: block;
  width: var(--w);
  height: 100%;
  background: var(--tier);
}
.answer-pts { font-family: var(--condensed); font-weight: 700; text-align: right; }

.fact { margin-top: 16px; padding-left: 12px; border-left: 3px solid var(--flood); }

/* Stays reachable above long answer lists on a phone. */
.btn-next {
  position: sticky;
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: 100%;
  margin-top: 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

/* ---------- Results ---------- */
.final-score { margin-top: 6px; font: 400 clamp(84px, 24vw, 132px) / 1 var(--display); }
.final-score small { color: var(--muted); font-size: 0.32em; }
.final-rank { color: var(--flood); font: 400 36px var(--display); text-transform: uppercase; }

.rungs { margin: 16px 0 0; padding: 0; list-style: none; }
.rung {
  display: flex;
  justify-content: space-between;
  padding: 7px 10px;
  border-left: 4px solid var(--line);
  color: var(--muted);
  font: 600 17px var(--condensed);
}
.rung.is-passed { border-left-color: var(--flood); color: var(--chalk); }
.rung.is-current { background: var(--flood); border-left-color: var(--flood); color: var(--turf-deep); }

.results-body { margin-top: 24px; }

.lines { margin: 0; padding: 0; list-style: none; }
.line {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.line-cat { color: var(--muted); font: 700 13px var(--condensed); letter-spacing: 0.08em; text-transform: uppercase; }
.line-guess { grid-column: 1; overflow-wrap: anywhere; }
.line-pts { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--tier); font: 400 26px var(--display); }
.line-pts.tier-miss { color: var(--danger); }

.share-manual { display: block; white-space: pre-line; color: var(--chalk); user-select: all; }

/* ---------- Account and leaderboard ---------- */
.account { margin-top: 18px; }
.account:empty { display: none; }
.account-note { color: var(--muted); font-size: 15px; }
.account-note strong { color: var(--chalk); font-weight: 600; }
.account-links { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; color: var(--muted); font-size: 14px; }
.account-links a, .link-btn {
  padding: 0;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.google-button { min-height: 44px; margin-top: 10px; }

.nickname-form label { display: block; color: var(--muted); font-size: 15px; }
.nickname-row { display: flex; gap: 8px; margin-top: 8px; }
.nickname-row input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  background: var(--chalk);
  border: 0;
  border-radius: 4px;
  color: var(--turf-deep);
  font: 500 18px var(--body);
}

.leaderboard { width: 100%; max-width: 680px; margin: 0 auto; padding: 24px var(--gutter) calc(24px + env(safe-area-inset-bottom)); }
.board-body { margin-top: 16px; }
.board-list { margin: 0; padding: 0; list-style: none; }
.board-row {
  display: grid;
  grid-template-columns: 2.6em 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}
.board-row.is-mine { background: var(--flood); border-top-color: var(--flood); color: var(--turf-deep); }
.board-rank { font: 700 18px var(--condensed); opacity: 0.8; }
.board-name { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.board-score { font: 400 26px var(--display); }
.board-you-label { margin-top: 16px; color: var(--muted); font: 700 14px var(--condensed); letter-spacing: 0.1em; text-transform: uppercase; }

/* ---------- Phones ---------- */
@media (max-width: 560px) {
  body { font-size: 16px; }
  .lede { font-size: 17px; }
  .clock { font-size: 60px; }
  .answer { grid-template-columns: minmax(0, 9em) 1fr 2em; }
  .actions .btn { flex-basis: 100%; }
}

/* ---------- PC ---------- */
@media (min-width: 900px) {
  /* Lines the scoreboard up with the content under it, while its black bar stays full width. */
  .board { padding-left: max(32px, calc((100% - var(--content)) / 2)); padding-right: max(32px, calc((100% - var(--content)) / 2)); }
  .clock { font-size: 88px; }

  .home {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
  }
  .home-intro {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 32px clamp(32px, 4vw, 72px);
  }
  .home-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 32px clamp(32px, 4vw, 72px);
  }
  /* KNOWLEDGE is about 4.4em wide, so this nearly fills the left panel without overflowing. */
  .logo { font-size: min(10.5vw, 24vh); }
  .lede { font-size: clamp(19px, 1.6vw, 24px); }
  .tier-key { flex: 0 1 46vh; grid-auto-rows: 1fr; gap: 6px; margin-bottom: 20px; }
  .tier-chip { padding: 6px 16px; font-size: 22px; }
  .tier-chip small { font-size: 16px; }
  .tier-chip b { font-size: 38px; }
  .lineup { font-size: 17px; }
  .home-panel .btn { min-height: 60px; }

  .play-body {
    width: 100%;
    max-width: calc(var(--content) + 64px);
    margin: 0 auto;
    padding: clamp(14px, 3vh, 32px) 32px 12px;
  }
  .category { margin-top: 0; font-size: 22px; }
  .prompt-text { margin-top: 6px; font-size: clamp(36px, min(4.4vw, 7vh), 72px); }
  .as-of { font-size: 16px; }
  .guess { margin-top: 22px; }
  .guess input { height: 76px; padding: 0 24px; font-size: 30px; }
  .guess .btn { min-height: 76px; padding: 0 56px; font-size: 26px; }
  .hint { font-size: 20px; }
  .misses li { font-size: 18px; }

  .reveal, .results {
    width: 100%;
    max-width: calc(var(--content) + 64px);
    margin: 0 auto;
    padding: 20px 32px 32px;
  }
  .reveal {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    grid-template-rows: auto auto auto auto 1fr;
    column-gap: 40px;
  }
  /* Shrinks with the window height, keeping its 160:72 shape, so Next stays on screen on small laptops. */
  .stage { max-width: max(320px, calc((100vh - 460px) * 2.22)); margin-left: auto; margin-right: auto; }
  .verdict-note { font-size: 18px; }
  .reveal-prompt { font-size: 28px; }
  .fact { font-size: 19px; }
  .reveal-head { grid-column: 1 / -1; }
  .verdict { grid-column: 1; }
  .reveal-prompt { grid-column: 1; }
  .reveal-notes { grid-column: 1; }
  .btn-next {
    position: static;
    grid-column: 1;
    align-self: end;
    min-height: 60px;
    box-shadow: none;
  }
  /* Long lists scroll in place so the verdict and Next stay on screen together. */
  .answers {
    display: grid;
    grid-auto-rows: minmax(min-content, 1fr);
    grid-column: 2;
    grid-row: 2 / span 4;
    max-height: calc(100vh - 80px);
    margin-top: 16px;
    padding-right: 10px;
    overflow-y: auto;
  }
  .answer { padding: 8px 0; font-size: 18px; }
  .answer-bar { height: 14px; }

  .results {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 56px;
  }
  /* Both columns stretch, and their rows share the height. */
  .results-head, .results-body { display: flex; flex-direction: column; }
  .results-body { margin-top: 0; }
  .rungs, .lines { display: grid; flex: 1; grid-auto-rows: minmax(min-content, 1fr); }
  .rung { align-items: center; font-size: 22px; }
  .line { align-content: center; }
  .line-cat { font-size: 15px; }
  .line-guess { font-size: 22px; }
  .line-pts { font-size: 38px; }
}

/* Phone on its side, usually with the keyboard open: keep the clock and input together. */
@media (max-height: 480px) {
  .logo { font-size: 56px; }
  .board { padding-top: 4px; }
  .play-body { padding-top: 0; }
  .arena { display: none; }
  .clock { font-size: 40px; }
  .board-value { font-size: 20px; }
  .category { margin-top: 8px; font-size: 15px; }
  .prompt-text { font-size: 22px; }
  .guess { margin-top: 8px; }
  .guess input, .guess .btn { height: 46px; min-height: 46px; }
  .stage { max-width: 360px; margin-top: 8px; }
}

/* A real keyboard is present. */
@media (hover: hover) and (pointer: fine) {
  .key-hint { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .screen, .stamp, .clock.is-urgent, .guess input.is-wrong { animation: none; }
  .ladder-fill, .btn { transition: none; }
}
