/* SportsNerd: the daily case book. Paper, ink, a penalty-flag yellow, and rubber stamps. */
:root {
  --paper: #f2ede1;
  --paper-2: #e9e3d4;
  --sheet: #fbf8f1;
  --ink: #141414;
  --ink-2: #3b3a36;
  --muted: #77736a;
  --rule: rgba(20, 20, 20, 0.14);
  --grid: rgba(20, 20, 20, 0.045);
  --flag: #ffcc00;
  --flag-ink: #141414;
  --good: #17703f;
  --bad: #c8321b;
  --display: "Archivo", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --text: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121211;
    --paper-2: #1b1b19;
    --sheet: #181816;
    --ink: #eee8d8;
    --ink-2: #c9c3b3;
    --muted: #8c877b;
    --rule: rgba(238, 232, 216, 0.16);
    --grid: rgba(238, 232, 216, 0.035);
    --flag: #ffcc00;
    --flag-ink: #141414;
    --good: #4cc07c;
    --bad: #ff6a4d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font: 400 16px/1.5 var(--text);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
a { color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter; }
svg .fill { fill: currentColor; stroke: none; }
::selection { background: var(--flag); color: var(--flag-ink); }

.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px calc(32px + env(safe-area-inset-bottom));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Masthead */
.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 18px 0 12px;
  border-bottom: 3px solid var(--ink);
  position: relative;
}
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -7px; border-bottom: 1px solid var(--ink); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; justify-self: start; }
.mark {
  width: 20px; height: 26px; border: 1.5px solid var(--ink); border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 3.5px, transparent 3.5px 7px);
}
.word {
  font-family: var(--display); font-stretch: 62%; font-weight: 850; font-size: 30px; line-height: 1;
  text-transform: uppercase; letter-spacing: 0.005em;
}
.top-meta { font: 500 12px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.top-actions { justify-self: end; display: flex; gap: 4px; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  background: none; border: 1.5px solid transparent; border-radius: 2px; color: var(--ink);
}
.icon-btn svg { stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; width: 20px; height: 20px; }
.icon-btn:hover { border-color: var(--ink); }

/* Progress: five boxes like a score line */

main { flex: 1; padding-top: 16px; }

/* The page: a sheet from the case book */
.page {
  position: relative;
  background: var(--sheet);
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  box-shadow: 6px 6px 0 var(--ink);
  padding: 26px 26px 24px;
}
@media (max-width: 460px) { .page { padding: 20px 18px 20px; box-shadow: 4px 4px 0 var(--ink); } }

.kicker {
  display: flex; justify-content: space-between; gap: 12px;
  font: 500 11.5px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
  padding-bottom: 12px; border-bottom: 1px dashed var(--rule);
}

/* Intro */
.intro h1 {
  font-family: var(--display); font-stretch: 62%; font-weight: 900; text-transform: uppercase;
  font-size: clamp(56px, 15vw, 96px); line-height: 0.86; letter-spacing: -0.005em; margin: 22px 0 16px;
}
.intro h1::after { content: ""; display: block; width: 72px; height: 10px; margin-top: 18px; background: var(--flag); }
.lede { font-size: 17.5px; line-height: 1.5; color: var(--ink-2); margin: 0 0 22px; }
.specs { display: grid; grid-template-columns: repeat(3, 1fr); border: 1.5px solid var(--ink); border-radius: 2px; }
.specs div { padding: 12px 14px 10px; }
.specs div + div { border-left: 1.5px solid var(--ink); }
.specs b { display: block; font-family: var(--display); font-stretch: 62%; font-weight: 800; font-size: 40px; line-height: 1; }
.specs span { font: 500 10.5px/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.hint { font: 400 12px/1.4 var(--mono); color: var(--muted); text-align: center; margin: 14px 0 0; }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; margin-top: 18px; padding: 15px 18px; cursor: pointer;
  background: var(--ink); color: var(--paper); border: 1.5px solid var(--ink); border-radius: 2px;
  font-family: var(--display); font-stretch: 85%; font-weight: 750; font-size: 17px; text-transform: uppercase; letter-spacing: 0.04em;
  transition: transform 0.08s, box-shadow 0.08s, background 0.12s;
}
.btn:hover { background: var(--flag); color: var(--flag-ink); box-shadow: 3px 3px 0 var(--ink); transform: translate(-2px, -2px); }
.btn:active { transform: none; box-shadow: none; }
.btn:focus-visible { outline: 3px solid var(--flag); outline-offset: 2px; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--flag); color: var(--flag-ink); }
.btn svg { width: 20px; height: 20px; flex: none; }

/* A situation */
.case-head { display: flex; align-items: center; gap: 12px; }
.sit { display: flex; align-items: baseline; gap: 6px; }
.sit .num { font-family: var(--display); font-stretch: 62%; font-weight: 900; font-size: 46px; line-height: 0.8; }
.sit .of { font: 500 12px/1 var(--mono); color: var(--muted); }
.tag {
  font: 600 11px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
  background: var(--flag); color: var(--flag-ink); padding: 6px 8px 5px; border-radius: 1px;
}
.clock {
  margin-left: auto; font: 600 30px/1 var(--mono); letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
  min-width: 2.2ch; text-align: right;
}
.clock.low { color: var(--bad); }
.clock.paused { font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.stripes { height: 12px; margin: 16px 0 20px; border: 1.5px solid var(--ink); border-radius: 1px; overflow: hidden; }
.stripes div {
  height: 100%; width: 100%; transform-origin: left;
  background: repeating-linear-gradient(-45deg, var(--ink) 0 6px, var(--sheet) 6px 12px);
}
.stripes div.low { background: repeating-linear-gradient(-45deg, var(--bad) 0 6px, var(--flag) 6px 12px); }

.lbl {
  display: inline-block; vertical-align: 0.18em; margin-right: 10px;
  font: 600 10.5px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
  border: 1.5px solid currentColor; padding: 4px 6px 3px; border-radius: 1px;
}
.play { font-size: 21px; line-height: 1.45; font-weight: 450; margin: 0 0 20px; letter-spacing: -0.005em; }
@media (max-width: 460px) { .play { font-size: 19px; } }

.choices { display: grid; gap: 8px; }
.choice {
  display: grid; grid-template-columns: 34px 1fr; align-items: stretch;
  width: 100%; padding: 0; text-align: left; cursor: pointer; line-height: 1.35;
  background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 2px;
  transition: transform 0.08s, box-shadow 0.08s, background 0.1s;
}
.choice .key {
  display: grid; place-items: center; background: var(--ink); color: var(--sheet);
  font: 600 14px/1 var(--mono);
}
.choice .txt { padding: 12px 14px; }
.choice:hover:not(:disabled) { background: var(--flag); color: var(--flag-ink); box-shadow: 3px 3px 0 var(--ink); transform: translate(-2px, -2px); }
.choice:focus-visible { outline: 3px solid var(--flag); outline-offset: 2px; }
.choice:disabled { cursor: default; }
.choice.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--sheet)); }
.choice.right .key { background: var(--good); color: #fff; }
.choice.wrong { border-color: var(--bad); }
.choice.wrong .key { background: var(--bad); color: #fff; }
.choice.wrong .txt { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--bad); color: var(--muted); }
.choice:disabled:not(.right):not(.wrong) { opacity: 0.4; }

/* Rubber stamp */
.stamp {
  position: absolute; top: 18px; right: 22px; z-index: 2; pointer-events: none;
  font-family: var(--display); font-stretch: 70%; font-weight: 900; font-size: 34px; line-height: 1;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 14px 6px;
  border: 4px double currentColor; border-radius: 4px; transform: rotate(-9deg);
  background: color-mix(in srgb, var(--sheet) 70%, transparent);
  animation: thunk 0.32s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.stamp.right { color: var(--good); }
.stamp.wrong { color: var(--bad); }
.stamp.static { position: static; animation-delay: 0.15s; font-size: 30px; white-space: nowrap; }
@keyframes thunk { from { opacity: 0; transform: rotate(-9deg) scale(1.8); } to { opacity: 0.92; transform: rotate(-9deg) scale(1); } }

.ruling { margin-top: 20px; padding-top: 18px; border-top: 1.5px solid var(--ink); animation: rise 0.22s ease-out; }
.ruling p { margin: 0; font-size: 16.5px; color: var(--ink-2); }
.cite {
  display: flex; gap: 10px; align-items: baseline; margin-top: 14px;
  font: 400 12.5px/1.45 var(--mono); color: var(--muted);
}
.cite .ref { font-weight: 600; color: var(--ink); text-transform: uppercase; letter-spacing: 0.08em; flex: none; }
.cite a { text-decoration: underline; text-decoration-color: var(--flag); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.cite a:hover { background: var(--flag); color: var(--flag-ink); }

.next-row { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.next-row .btn { margin-top: 0; flex: 1; }
.pts { font-family: var(--display); font-stretch: 62%; font-weight: 900; font-size: 38px; line-height: 1; min-width: 72px; color: var(--muted); }
.pts.right { color: var(--good); }

/* Scorecard */
.tally { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 20px 0 22px; }
.total b { display: block; font-family: var(--display); font-stretch: 62%; font-weight: 900; font-size: clamp(76px, 22vw, 112px); line-height: 0.82; letter-spacing: -0.01em; }
.total span { font: 500 11px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.grid { width: 100%; border-collapse: collapse; table-layout: fixed; border: 1.5px solid var(--ink); }
.grid th, .grid td { border: 1px solid var(--ink); text-align: center; padding: 8px 4px; }
.grid th { font: 600 11px/1 var(--mono); background: var(--ink); color: var(--sheet); padding: 7px 4px; }
.grid .marks td { height: 54px; }
.grid .marks svg { width: 28px; height: 28px; stroke-width: 3; }
.grid .marks .right { color: var(--good); }
.grid .marks .wrong { color: var(--bad); }
.grid .sports td { font: 500 10px/1.2 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid .nums td { font: 600 14px/1 var(--mono); font-variant-numeric: tabular-nums; }
.line-stats {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; margin-top: 14px;
  font: 400 12px/1.4 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
}
.line-stats b { color: var(--ink); font-weight: 600; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Sheets */
.sheet {
  width: min(540px, calc(100vw - 28px)); max-height: calc(100vh - 40px);
  background: var(--sheet); color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 2px; box-shadow: 8px 8px 0 var(--ink);
  padding: 28px 26px 24px;
}
.sheet::backdrop { background: color-mix(in srgb, var(--paper) 70%, transparent); backdrop-filter: blur(3px); }
.sheet[open] { animation: rise 0.18s ease-out; }
.sheet:focus { outline: none; }
.sheet-close { position: absolute; top: 14px; right: 14px; margin: 0; }
.sheet-close button { width: 34px; height: 34px; display: grid; place-items: center; border: 1.5px solid var(--ink); background: none; border-radius: 2px; cursor: pointer; }
.sheet-close button:hover { background: var(--flag); color: var(--flag-ink); }
.sheet h2 {
  font-family: var(--display); font-stretch: 62%; font-weight: 900; font-size: 44px; line-height: 0.9;
  text-transform: uppercase; margin: 0 0 18px; padding-bottom: 14px; border-bottom: 3px solid var(--ink);
}
.sheet ol { list-style: none; counter-reset: n; padding: 0; margin: 0 0 18px; }
.sheet ol li { counter-increment: n; display: grid; grid-template-columns: 34px 1fr; gap: 6px; padding: 9px 0; border-bottom: 1px dashed var(--rule); color: var(--ink-2); }
.sheet ol li::before { content: "0" counter(n); font: 600 13px/1.5 var(--mono); color: var(--ink); }
.sheet p { color: var(--ink-2); margin: 0 0 12px; }
.sheet .small { font: 400 12px/1.5 var(--mono); color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1.5px solid var(--ink); margin-bottom: 20px; }
.stat-grid div { padding: 12px 8px 10px; text-align: center; }
.stat-grid div + div { border-left: 1.5px solid var(--ink); }
.stat-grid b { display: block; font-family: var(--display); font-stretch: 62%; font-weight: 900; font-size: 38px; line-height: 1; }
.stat-grid span { font: 500 9.5px/1.25 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); display: block; margin-top: 4px; }
.dist { display: grid; gap: 6px; }
.dist div { display: grid; grid-template-columns: 52px 1fr; white-space: nowrap; align-items: center; gap: 8px; font: 500 12px/1 var(--mono); color: var(--muted); }
.dist i { display: block; height: 22px; background: var(--paper-2); border: 1.5px solid var(--ink); min-width: 26px; font: 600 12px/19px var(--mono); font-style: normal; color: var(--ink); padding: 0 6px; text-align: right; border-radius: 1px; }
.dist i.today { background: var(--flag); color: var(--flag-ink); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--flag); color: var(--flag-ink); border: 1.5px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  padding: 10px 16px; border-radius: 2px; font: 600 13px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.06em;
  animation: toast-in 0.18s ease-out; z-index: 10;
}

.foot { margin-top: 30px; font: 400 11.5px/1.5 var(--mono); color: var(--muted); text-align: center; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (hover: none) { .hint { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Fixes after first look */
html, body { overflow-x: clip; }
.case.done .clock { visibility: hidden; }
.btn-row .btn { justify-content: center; font-size: 15px; padding: 14px 10px; }
@media (max-width: 460px) {
  .top-meta { display: none; }
  .top { grid-template-columns: 1fr auto; }
  .word { font-size: 26px; }
  .stamp { font-size: 28px; top: 14px; right: 14px; }
  .stamp.static { font-size: 20px; padding: 6px 10px 4px; border-width: 3px; }
  .tally { gap: 10px; }
}

/* Rounding the bases */
.progress { display: flex; align-items: center; gap: 14px; padding: 14px 0 2px; min-height: 92px; }
.diamond { width: 78px; height: 78px; flex: none; overflow: visible; }
.diamond .path { fill: color-mix(in srgb, var(--flag) 10%, transparent); stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 3 3; }
.diamond .stn { fill: var(--sheet); stroke: var(--ink); stroke-width: 2; transition: fill 0.25s; }
.diamond .stn.now { fill: var(--flag); }
.diamond .stn.right { fill: var(--good); stroke: var(--good); }
.diamond .stn.wrong { fill: var(--bad); stroke: var(--bad); }
.diamond .runner { fill: var(--ink); stroke: var(--paper); stroke-width: 2.5; transition: transform 0.6s cubic-bezier(0.5, 0, 0.3, 1); }
.diamond .runner.home { fill: var(--flag); stroke: var(--ink); stroke-width: 2; }
.where { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.where b { font-family: var(--display); font-stretch: 62%; font-weight: 900; font-size: 30px; line-height: 0.9; text-transform: uppercase; }
.where span { font: 500 11px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.sofar { margin-left: auto; text-align: right; }
.sofar b { display: block; font-family: var(--display); font-stretch: 62%; font-weight: 900; font-size: 40px; line-height: 0.85; }
.sofar span { font: 500 10.5px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* Crowd split on each choice */
.choice { position: relative; overflow: hidden; grid-template-columns: 34px 1fr auto; }
.choice .txt, .choice .key, .choice .share-pct { position: relative; z-index: 1; }
.choice .fill { position: absolute; left: 34px; top: 0; bottom: 0; width: 0; background: color-mix(in srgb, var(--ink) 9%, transparent); transition: width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); z-index: 0; }
.choice.right .fill { background: color-mix(in srgb, var(--good) 22%, transparent); }
.choice.wrong .fill { background: color-mix(in srgb, var(--bad) 16%, transparent); }
.choice .share-pct { align-self: center; padding-right: 14px; font: 600 13px/1 var(--mono); font-variant-numeric: tabular-nums; opacity: 0; transition: opacity 0.3s 0.3s; }
.choice.show-crowd .share-pct { opacity: 1; }
.choice.show-crowd:disabled:not(.right):not(.wrong) { opacity: 0.7; }

.crowd { display: flex; align-items: center; gap: 14px; margin-top: 18px; padding: 12px 14px; border: 1.5px solid var(--ink); background: var(--flag); color: var(--flag-ink); border-radius: 2px; animation: rise 0.25s ease-out; }
.crowd-n { font-family: var(--display); font-stretch: 62%; font-weight: 900; font-size: 44px; line-height: 0.85; min-width: 64px; }
.crowd-n small { font-size: 0.55em; }
.crowd-t { font-size: 15px; font-weight: 600; line-height: 1.3; }
.crowd-t em { display: block; font: 400 11px/1.4 var(--mono); font-style: normal; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 3px; opacity: 0.75; }

/* You vs the field */
.total b small { font-size: 0.45em; color: var(--muted); }
.vs { border: 1.5px solid var(--ink); background: var(--flag); color: var(--flag-ink); padding: 16px; margin-bottom: 18px; border-radius: 2px; animation: rise 0.25s ease-out; }
.vs-head { display: flex; align-items: center; gap: 14px; }
.vs-head b { font-family: var(--display); font-stretch: 62%; font-weight: 900; font-size: 58px; line-height: 0.85; flex: none; }
.vs-head span { font-size: 15px; font-weight: 500; line-height: 1.35; }
.bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; align-items: end; height: 96px; margin-top: 16px; }
.bar { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; }
.bar i { display: block; background: color-mix(in srgb, var(--flag-ink) 22%, transparent); border: 1.5px solid var(--flag-ink); border-radius: 1px; transition: height 0.6s; }
.bar.you i { background: var(--flag-ink); }
.bar span { font: 600 11px/1 var(--mono); text-align: center; margin-top: 5px; }
.bar em { position: absolute; top: -2px; left: 50%; transform: translateX(-50%); font: 700 9.5px/1 var(--mono); font-style: normal; text-transform: uppercase; letter-spacing: 0.06em; background: var(--flag-ink); color: var(--flag); padding: 3px 4px; border-radius: 1px; }
.bars-note, .grid-note { font: 400 10.5px/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; margin: 8px 0 0; opacity: 0.75; }
.grid-note { color: var(--muted); opacity: 1; }
@media (max-width: 460px) {
  .where b { font-size: 25px; }
  .diamond { width: 66px; height: 66px; }
  .vs-head b { font-size: 46px; }
}

/* Pass 2 */
.diamond { width: 104px; height: 104px; }
.diamond .runner { r: 7px; }
.specs span { line-height: 1.35; display: block; margin-top: 4px; }
@media (max-width: 460px) {
  .diamond { width: 86px; height: 86px; }
  .case.done .tag { visibility: hidden; }
  .case .stamp { top: 16px; right: 12px; font-size: 24px; padding: 6px 10px 4px; border-width: 3px; }
}

.sofar b small { font-size: 0.5em; color: var(--muted); }
.diamond .stn.box { fill: none; stroke-dasharray: 2 2; }
.sofar span { white-space: nowrap; }
