:root {
  --bg: #11151f; --panel: #1a2030; --ink: #f1f3f7; --muted: #a7afc0; --line: #2b3346;
  --accent: #f2c230; --blue: #4aa3ff; --red: #e0565c;
  --t0: #a7afc0; --t1: #58b368; --t2: #4aa3ff; --t3: #b07cf0; --t4: #f2c230;
  --pixel: 'Press Start 2P', ui-monospace, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 Inter, system-ui, sans-serif; }
.game { max-width: 960px; margin: 0 auto; padding: 12px 16px 24px; }
/* The field keeps its 16:9 shape, so its width sets its height. On a short window (a laptop at 100%
   zoom) the page narrows until the title, field, score strip and the answer box or result fit on one
   screen: about 350px of the height goes to everything but the field (36px is the page padding and
   the field's border). It never gets narrower than 560px; below that the page scrolls instead. */
@media (min-width: 601px) { .game { max-width: clamp(560px, calc((100vh - 350px) * 16 / 9 + 36px), 960px); } }
.masthead { padding: 2px 0 8px; }
.brand { margin: 0; color: var(--accent); font: 16px/1 var(--pixel); letter-spacing: 1px; }
/* Broadcast score strip attached to the bottom edge of the field. */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; background: #000; border: 2px solid #000; border-top: 0; font-family: var(--pixel); }
.board > * { background: #07080c; padding: 8px 10px; }
.cell span { display: block; color: var(--muted); font-size: 8px; margin-bottom: 6px; }
.cell b { font-size: 12px; font-weight: normal; white-space: nowrap; }
.clock b { color: var(--accent); }
/* Comeback: YOU, OPP, BALL, SNAP, CLOCK, NET YDS on one row (two rows of three on a phone). */
.board.comeback { grid-template-columns: repeat(6, 1fr); }
.board.comeback #c-clock { order: 5; } .board.comeback #c-yards { order: 6; }
.score b { color: #fff; font-size: 14px; }
#c-opp b { color: var(--muted); }
.choices-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.choices-row button { flex: 1 1 220px; line-height: 1.5; }
.share { font: 13px/1.5 ui-monospace, monospace; white-space: pre-wrap; background: #121725; border: 1px solid var(--line); padding: 8px 10px; margin: 0 0 12px; }
.clock.low b { color: var(--red); }
.stage { container-type: inline-size; position: relative; border: 2px solid #000; background: #3d8b3a; line-height: 0; overflow: hidden; }
canvas { width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
/* The result banner sits over the crowd along the top sideline, on a solid black box, so the players
   and the ball stay in view below it. The stands are the top 21% of the field image. */
/* Sizes follow the field's width (cqw) so the banner fits the stands at any field size. */
.gain { position: absolute; left: 50%; top: 2%; transform: translateX(-50%); font: clamp(12px, 2.6cqw, 24px)/1.25 var(--pixel); color: #fff;
  background: #000; border: 3px solid #fff; padding: clamp(5px, 1.2cqw, 12px) clamp(8px, 1.7cqw, 16px); white-space: nowrap; pointer-events: none; text-align: center; max-width: calc(100% - 16px); }
.gain small { display: block; font-size: clamp(9px, 1.4cqw, 11px); margin-top: clamp(4px, .8cqw, 8px); color: var(--accent); }
.gain small:empty { display: none; }
/* The flag sits beside the call, keeping the banner short enough to stay over the stands. */
.gain .flag { display: inline-block; margin: 0 12px 0 0; vertical-align: 3px; background: #f2c230; color: #000; font-size: clamp(9px, 1.3cqw, 12px); padding: clamp(3px, .6cqw, 6px) clamp(5px, 1cqw, 10px); }
.gain.pop { animation: pop .5s steps(5) both; }
@keyframes pop { from { transform: translate(-50%, 20%) scale(.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
.panel { background: var(--panel); border: 2px solid #000; border-top: 0; padding: 20px; min-height: 230px; }
.kicker { font: 9px/1.6 var(--pixel); color: var(--accent); margin: 0 0 10px; letter-spacing: .5px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 10px; }
h2 { font-size: 22px; line-height: 1.3; margin: 0 0 6px; }
.note { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.tiers { list-style: none; padding: 0; margin: 14px 0 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; }
.tiers li { background: #121725; border: 1px solid var(--line); padding: 6px 10px; font-size: 13px; }
.tiers b { font-family: var(--pixel); font-size: 10px; font-weight: normal; }
.timer { height: 6px; background: #0b0e16; margin: 6px 0 14px; }
.timer div { height: 100%; background: var(--accent); transform-origin: left; }
form { display: flex; gap: 8px; flex-wrap: wrap; }
input { flex: 1 1 240px; min-width: 0; font: inherit; font-size: 18px; padding: 10px 12px; border: 2px solid #000; background: #f5f6f8; color: #11151f; }
input:disabled { opacity: .6; }
button { font: 10px/1 var(--pixel); padding: 12px 14px; border: 2px solid #000; cursor: pointer; background: #2b3346; color: var(--ink); }
button.primary { background: var(--accent); color: #11151f; box-shadow: 3px 3px 0 #000; }
button.primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
button.quiet { background: transparent; border-color: var(--line); color: var(--muted); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: default; }
.feedback { min-height: 24px; margin: 10px 0 0; }
#choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tier-line { font: 11px/1.6 var(--pixel); margin: 10px 0 16px; }
.results { padding: 0; list-style: none; margin: 0 0 14px; }
.results li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.results .q { color: var(--muted); grid-column: 1 / -1; font-size: 13px; }
.seasons { font: 9px/1.6 var(--pixel); color: var(--blue); margin: -6px 0 10px; }
.results .recap { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.results .recap b { font-weight: 600; }
.results .y { font-family: var(--pixel); font-size: 10px; align-self: center; }
.credit { color: var(--muted); font-size: 12px; margin-top: 14px; }
.credit a { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.penalty { color: var(--accent); }
.t0 { color: var(--t0); } .t1 { color: var(--t1); } .t2 { color: var(--t2); } .t3 { color: var(--t3); } .t4 { color: var(--t4); }
@media (max-width: 600px) {
  .game { padding: 0 0 16px; }
  .masthead { padding: 8px 14px; } .brand { font-size: 12px; }
  .cell { padding: 6px 8px; } .cell b { font-size: 11px; } .cell span { font-size: 7px; margin-bottom: 4px; }
  .board.comeback { grid-template-columns: repeat(3, 1fr); } .score b { font-size: 12px; }
    .gain { border-width: 2px; top: 3px; } .gain .flag { margin-right: 6px; vertical-align: 1px; }
  h1 { font-size: 21px; } h2 { font-size: 18px; }
  .panel { padding: 14px; }
  input { font-size: 17px; padding: 8px 10px; flex-basis: 100%; }
  form button { flex: 1; }
  .credit { padding: 0 14px; }
  /* While typing, the keyboard takes about half the screen: shrink the field to a strip around the
     line of scrimmage so the question, answer box and clock stay in view together. */
  body.typing .stage { height: 84px; }
  body.typing .stage canvas { position: relative; top: 50%; transform: translateY(-58%); }
  body.typing #note, body.typing #ask .kicker, body.typing .masthead { display: none; }
  body.typing .timer { margin: 4px 0 8px; }
  body.typing .feedback { min-height: 0; margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) { .gain.pop { animation: none; } }

/* Stats: tiles reuse the tier list's grid. */
.stats b { font-family: var(--pixel); font-size: 11px; }
#history .results .recap { font-size: 12px; }

/* Today's leaderboard: rank, player, finish; the player's own row highlighted. */
.board-box { margin: 6px 0 18px; }
.place { font: 11px/1.6 var(--pixel); color: var(--ink); margin: 0 0 4px; }
.leaders { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.leaders th { font: 8px/1.6 var(--pixel); color: var(--muted); text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); font-weight: normal; }
.leaders td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
.leaders td:first-child { font-family: var(--pixel); font-size: 10px; width: 2.5em; }
.leaders td.name { overflow-wrap: break-word; }
.leaders tr.you td { background: #2a2a1a; color: var(--accent); }
.leaders tr.you td.name b { font-weight: 800; }
.leaders .you-apart tr:first-child td { border-top: 2px dashed var(--line); }
.name-form { margin-top: 10px; }
.name-form div { display: flex; gap: 8px; flex-wrap: wrap; }
.name-form input { flex: 1 1 160px; min-width: 0; }
@media (max-width: 600px) {
  .leaders { font-size: 13px; }
  .leaders th, .leaders td { padding: 6px 4px; }
}
