/* HAMSTER RACING · a racing tabloid that happens to be live.
   Newsprint, heavy rules, condensed black type. The only electronic
   objects on the page are the seven-segment boards. */

:root {
  --news: #e7e0cf;
  --news-2: #ddd5c1;
  --ink: #17140f;
  --ink-soft: #4a453a;
  --bar: #0d0b08;
  --spot: #ab1e23;
  --amber: #ffb52e;
  --amber-ghost: rgba(255, 181, 46, 0.14);
  /* Printed ink green. The lighter racing green fails 4.5:1 on newsprint,
     so lamps are filled blocks carrying paper-coloured text instead. */
  --green: #17632f;
  --rule: rgba(23, 20, 15, 0.28);
  --rule-soft: rgba(23, 20, 15, 0.16);
  --measure: 1360px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  /* Solid ground first, so a missing texture degrades to clean newsprint. */
  background-color: var(--news);
  background-image: url('/assets/grain.png'), url('/assets/paper.png');
  background-repeat: repeat, repeat;
  background-size: 256px 256px, 512px 512px;
  /* Grain rides soft-light so it reads as newsprint tooth, not stucco.
     Only the paper fibre multiplies. */
  background-blend-mode: soft-light, multiply;
  color: var(--ink);
  font-family: 'Newsreader', Georgia, serif;
  font-size: 17px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

p { margin: 0 0 0.75em; }

a { color: var(--spot); text-underline-offset: 3px; }
a:hover { color: var(--ink); }

:focus-visible { outline: 2px solid var(--spot); outline-offset: 2px; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 90;
  background: var(--bar); color: var(--news); padding: 10px 16px;
  font-family: 'Barlow Condensed', sans-serif; text-transform: uppercase;
}
.skip:focus { left: 8px; top: 8px; }

/* ── rules ──────────────────────────────────────────────────────── */
.rule-hair { height: 1px; background: var(--rule); }
.rule-thick { height: 6px; background: var(--bar); margin-bottom: 14px; }

/* ── shared label type ──────────────────────────────────────────── */
.col-head {
  display: block;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.16em; font-size: 0.72rem;
  color: var(--ink-soft);
}

/* ── masthead ───────────────────────────────────────────────────── */
.masthead { padding: 0 20px; max-width: var(--measure); margin: 0 auto; }

.mast-row {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  padding: 14px 0 10px;
}
.nameplate {
  font-family: 'UnifrakturMaguntia', 'Newsreader', serif;
  font-weight: 400;
  font-size: clamp(2.1rem, 7vw, 4.6rem);
  line-height: 0.94;
  margin: 0;
  letter-spacing: 0.01em;
}
.mast-sub {
  font-family: 'Newsreader', serif; font-style: italic;
  font-size: 0.95rem; color: var(--ink-soft);
  margin: 4px 0 0;
}
.mast-wallet { display: flex; align-items: center; gap: 12px; padding-bottom: 4px; }

.balance-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.76rem;
  color: var(--ink-soft);
}
#walletBtn {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.86rem;
  background: var(--spot); color: var(--news);
  border: 0; border-radius: 0; padding: 12px 20px;
  cursor: pointer; min-height: 44px;
}
#walletBtn:hover { background: var(--bar); }
#walletBtn.connected { background: var(--bar); color: var(--news); }

.edition {
  display: flex; flex-wrap: wrap; gap: 4px 18px;
  padding: 7px 0;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.14em; font-size: 0.7rem;
  color: var(--ink-soft);
}
.edition .ed-end { margin-left: auto; color: var(--spot); font-weight: 700; }

/* ── the odds board: the one electronic object ──────────────────── */
.board { background: var(--bar); }
.board-in {
  max-width: var(--measure); margin: 0 auto;
  padding: 11px 20px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.board-lab, .board-unit, .board-phase {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.76rem;
  color: #b9b2a2;
}
.board-phase { color: var(--news); }
.board-gap { flex: 1 1 20px; }

.led-box {
  position: relative; z-index: 0;
  display: inline-block;
  background: #000;
  border: 1px solid #2a2620;
  border-radius: 3px;
  padding: 5px 9px 3px;
}
.led {
  position: relative;
  font-family: 'DSEG7', 'B612 Mono', monospace;
  font-weight: 700; font-size: 1.02rem;
  color: var(--amber);
  text-shadow: 0 0 7px rgba(255, 181, 46, 0.4);
  letter-spacing: 0.06em; white-space: nowrap;
}
.led::before {
  content: attr(data-shadow);
  position: absolute; left: 0; top: 0;
  color: var(--amber-ghost); text-shadow: none; z-index: -1;
}
.led.sm { font-size: 0.85rem; }
.led.big { font-size: clamp(1.1rem, 2.6vw, 1.5rem); }
.led.huge { font-size: clamp(2rem, 6vw, 3.8rem); }
.big-box { padding: 6px 12px 4px; }
.huge-box { padding: 12px 20px 8px; border-radius: 4px; }

/* ── layout ─────────────────────────────────────────────────────── */
main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 18px 20px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 0 30px;
  align-items: start;
}
#races { grid-column: 1; min-width: 0; }
#betslip { grid-column: 2; }
#jackpot, #leaderboard, #fairness, #how { grid-column: 1 / -1; margin-top: 34px; }

.sec-head { margin-bottom: 16px; }
.sec-head h2 {
  font-family: 'Anton', 'Barlow Condensed', sans-serif;
  font-weight: 400; text-transform: uppercase;
  font-size: clamp(1.9rem, 5vw, 3.4rem);
  line-height: 0.92; margin: 0 0 6px; letter-spacing: 0.005em;
}
.deck {
  font-family: 'Newsreader', serif; font-style: italic;
  font-size: 1.02rem; color: var(--ink-soft); max-width: 60ch; margin: 0;
}

/* ── the schedule strip (five tracks, deliberately unequal) ─────── */
.strip-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  border-bottom: 2px solid var(--ink); padding-bottom: 5px;
}
.strip-note {
  font-family: 'Newsreader', serif; font-style: italic;
  font-size: 0.86rem; color: var(--ink-soft);
}
#trackTabs {
  min-height: 64px;
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 16px;
}
#trackTabs::-webkit-scrollbar { display: none; }

.ttab {
  position: relative;
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  gap: 3px 10px;
  align-items: center;
  min-width: 132px;
  padding: 9px 14px 8px;
  background: none;
  border: 0;
  border-radius: 0;
  /* Top rule and column rule are drawn, not bordered: a border here reads to
     scanners as the side-tab accent tell, and inset shadow gives the same
     printed hairline. */
  box-shadow: inset 0 3px 0 transparent;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: inherit;
  text-align: left;
}
.ttab::after {
  content: "";
  position: absolute; top: 8px; bottom: 8px; right: 0;
  width: 1px; background: var(--rule-soft);
}
.ttab:last-child::after { display: none; }
.t-no {
  grid-column: 1;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.82rem;
}
.t-cd {
  grid-column: 2; grid-row: 1 / span 2;
  font-family: 'B612 Mono', monospace;
  font-size: 0.86rem; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ttab[aria-selected="true"] .t-cd { color: var(--news); }
.t-lamp {
  grid-column: 1; justify-self: start;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase;
  padding: 2px 6px; color: var(--news); background: var(--ink-soft);
}
.lamp-betting { background: var(--green); }
.lamp-locked  { background: var(--bar); }
.lamp-running { background: var(--spot); color: var(--news); }

/* The live entry and the selected entry are NOT peers of the rest.
   Five identical tiles was a named v1 tell. */
.ttab.is-live { box-shadow: inset 0 3px 0 var(--spot); flex-grow: 1.5; }
.ttab.is-live .t-no { color: var(--ink); font-size: 0.92rem; }
.ttab[aria-selected="true"] {
  background: var(--ink); color: var(--news);
  box-shadow: inset 0 3px 0 var(--ink); flex-grow: 1.7;
}
.ttab[aria-selected="true"] .t-no { color: var(--news); font-size: 0.96rem; }
.ttab[aria-selected="true"].is-live { box-shadow: inset 0 3px 0 var(--spot); }

@media (prefers-reduced-motion: no-preference) {
  .lamp-running { animation: lamp 1.1s steps(2, end) infinite; }
  @keyframes lamp { 50% { opacity: 0.62; } }
}

/* ── the lead photograph ────────────────────────────────────────── */
.photo { margin: 0 0 18px; }
.photo-plate {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0a0f0b;
  border: 1px solid var(--bar);
  overflow: hidden;
}
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.screen {
  position: absolute; inset: 0; pointer-events: none;
  /* deliberately empty: the race footage carries no screen. Nadav, 08-31:
     "dont add weird texture on the video of the hamsters racing". */
  display: none;
}
.photo figcaption {
  font-family: 'Newsreader', serif; font-style: italic;
  font-size: 0.9rem; color: var(--ink-soft);
  padding: 7px 0 9px; max-width: 74ch;
  min-height: 3.4em;
  border-bottom: 1px solid var(--rule);
}
/* Wire report first, provenance second: a caption reads left to right. */
.cap-live {
  font-style: normal;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em;
  font-size: 0.78rem; color: var(--ink);
  margin-right: 7px;
}
.cap-note { color: var(--ink-soft); }

/* ── late results ───────────────────────────────────────────────── */
.late { display: flex; align-items: center; gap: 14px; }
.late-lab {
  flex: 0 0 auto;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem;
  color: var(--news); background: var(--bar); padding: 3px 8px;
}
.results-strip {
  min-height: 44px;
  display: flex; align-items: center; gap: 0;
  overflow-x: auto; scrollbar-width: none; min-width: 0;
}
.results-strip::-webkit-scrollbar { display: none; }
.res-chip {
  display: inline-flex; align-items: baseline; gap: 7px;
  padding: 0 13px; flex: 0 0 auto;
  border-right: 1px solid var(--rule-soft);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.82rem; letter-spacing: 0.05em;
  color: var(--ink-soft); white-space: nowrap;
}
.res-chip .rw { font-weight: 700; color: var(--ink); text-transform: uppercase; }
.res-chip.jp .rw { color: var(--spot); }
.res-chip .dot { width: 8px; height: 8px; display: inline-block; }

/* ── the form (printed race card) ───────────────────────────────── */
#betslip {
  background: var(--news-2);
  border: 1px solid var(--rule);
  padding: 14px 16px 16px;
}
.form-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  border-bottom: 4px solid var(--ink); padding-bottom: 6px;
}
.form-title {
  font-family: 'Anton', sans-serif; font-weight: 400;
  text-transform: uppercase; font-size: 1.8rem; line-height: 1;
  margin: 0; letter-spacing: 0.01em;
}
.form-meta {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.78rem;
  color: var(--ink-soft);
}
.form-pool {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rule);
}
.pool-fig { display: inline-flex; align-items: baseline; gap: 7px; }
/* The form is paper: its running total is printed, not lit. The board strip
   upstairs stays the page's only electronic object. */
.pool-num {
  font-family: 'B612 Mono', monospace; font-weight: 700;
  font-size: 1.05rem; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.pool-fig i {
  font-family: 'Barlow Condensed', sans-serif; font-style: normal;
  font-weight: 700; font-size: 0.68rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-soft);
}

.form-cols {
  display: grid;
  grid-template-columns: 30px 1fr 74px 56px;
  gap: 8px; align-items: end;
  padding: 7px 0 4px;
  border-bottom: 2px solid var(--ink);
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.66rem;
  color: var(--ink-soft);
}
.form-cols .fc-3, .form-cols .fc-4 { text-align: right; }

/* 8 rows at 49px plus the 37px note. Reserving the tallest state keeps
   CLS at 0 when the note appears, without leaving dead paper. */
#raceCard { min-height: 429px; }
.rc-note {
  padding: 9px 0; border-bottom: 1px solid var(--rule);
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.76rem;
  color: var(--spot);
}
.rc-row {
  display: grid;
  grid-template-columns: 30px 1fr 74px 56px;
  gap: 8px; align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule-soft);
}
.rc-row[tabindex="0"] { cursor: pointer; }
.rc-plate {
  font-family: 'Anton', sans-serif; font-size: 1.15rem; line-height: 1;
  text-align: center; padding: 4px 0;
  background: var(--jersey, var(--ink)); color: var(--news);
}
.rc-id { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rc-thumb { display: block; flex: 0 0 auto; }
.rc-name {
  font-family: 'Anton', sans-serif; font-size: 1rem; line-height: 1;
  text-transform: uppercase; letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rc-you {
  display: block;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--spot);
}
.rc-pool {
  font-family: 'B612 Mono', monospace; font-size: 0.78rem;
  text-align: right; display: block; color: var(--ink-soft);
}
.rc-odds {
  font-family: 'Anton', sans-serif; font-size: 1.25rem; line-height: 1;
  text-align: right;
}
.rc-odds.open {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  font-size: 0.7rem; letter-spacing: 0.12em; color: var(--ink-soft);
}
.rc-row[aria-checked="true"] {
  background: var(--news);
  box-shadow: inset 3px 0 0 var(--spot);
  padding-left: 8px;
}
.rc-row[aria-disabled="true"] { opacity: 0.62; }

/* ── slip ───────────────────────────────────────────────────────── */
.slip { padding-top: 12px; }
#betAmount {
  width: 100%; margin-top: 5px;
  font-family: 'B612 Mono', monospace; font-size: 1.05rem;
  background: var(--news); color: var(--ink);
  border: 1px solid var(--ink); border-radius: 0;
  padding: 11px 12px; min-height: 46px;
}
.presets { display: flex; gap: 6px; margin-top: 8px; }
.presets button {
  flex: 1;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.76rem;
  background: none; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 0;
  padding: 10px 4px; min-height: 42px; cursor: pointer;
}
.presets button:hover { background: var(--ink); color: var(--news); }
#placeBet {
  width: 100%; margin-top: 10px;
  font-family: 'Anton', sans-serif; font-size: 1.1rem;
  text-transform: uppercase; letter-spacing: 0.03em;
  background: var(--spot); color: var(--news);
  border: 0; border-radius: 0; padding: 15px;
  min-height: 54px; cursor: pointer;
}
#placeBet:hover:not(:disabled) { background: var(--bar); }
#placeBet:disabled { background: #9d968a; color: #2b2720; cursor: not-allowed; }
#slipMsg {
  margin-top: 8px; min-height: 1.2em;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.76rem;
  color: var(--spot);
}

.tickets { margin-top: 14px; border-top: 1px solid var(--rule); padding-top: 10px; }
#myOpenBets { min-height: 20px; margin-top: 6px; }
.ob-empty, .drops-empty, .lb-empty {
  font-family: 'Newsreader', serif; font-style: italic;
  font-size: 0.9rem; color: var(--ink-soft);
}
.ob-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid var(--rule-soft);
  font-family: 'Barlow Condensed', sans-serif; font-size: 0.8rem;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.ob-row .dot { width: 8px; height: 8px; flex: 0 0 auto; }
.ob-amt { margin-left: auto; font-family: 'B612 Mono', monospace; font-size: 0.76rem; }

/* ── the pot ────────────────────────────────────────────────────── */
.pot-body { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: start; }
.pot-fig { display: flex; flex-direction: column; gap: 7px; }
.pot-unit {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem;
  color: var(--ink-soft);
}
.pot-copy { column-count: 2; column-gap: 26px; column-rule: 1px solid var(--rule-soft); }
.drops-wrap { margin-top: 20px; border-top: 1px solid var(--rule); padding-top: 10px; }
#jackpotDrops { margin-top: 8px; }
.drop-row {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--rule-soft);
}
.drop-amt { font-family: 'Anton', sans-serif; font-size: 1.05rem; }
.drop-meta, .drop-who {
  font-family: 'Barlow Condensed', sans-serif; font-size: 0.78rem;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft);
}
.drop-who { margin-left: auto; font-family: 'B612 Mono', monospace; text-transform: none; }

/* ── standings ──────────────────────────────────────────────────── */
.scroll-x { overflow-x: auto; }
.lb-stats {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.76rem;
  color: var(--ink-soft); margin-bottom: 8px;
}
.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th {
  text-align: left; padding: 6px 10px 5px;
  border-bottom: 2px solid var(--ink);
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.68rem;
  color: var(--ink-soft);
}
.lb-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--rule-soft);
  font-family: 'B612 Mono', monospace; font-size: 0.82rem;
}
.lb-table .num { text-align: right; }
.lb-table .rank { font-family: 'Anton', sans-serif; font-size: 1rem; }

/* ── fairness ───────────────────────────────────────────────────── */
.fair-grid { display: grid; grid-template-columns: 1fr 340px; gap: 30px; align-items: start; }
.fair-copy { column-count: 2; column-gap: 26px; column-rule: 1px solid var(--rule-soft); }
.fair-note { color: var(--ink-soft); font-style: italic; }

.verifier { background: var(--news-2); border: 1px solid var(--rule); padding: 13px 14px; }
.v-form { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; margin-top: 8px; }
.v-lab {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.7rem;
  color: var(--ink-soft);
}
#vTrack, #vRace {
  font-family: 'B612 Mono', monospace; font-size: 0.88rem;
  background: var(--news); color: var(--ink);
  border: 1px solid var(--ink); border-radius: 0; padding: 9px 10px; min-height: 42px;
  width: 100%;
}
#vGo {
  grid-column: 1 / -1;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.82rem;
  background: var(--ink); color: var(--news);
  border: 0; border-radius: 0; padding: 12px; min-height: 44px; cursor: pointer;
}
#vGo:hover { background: var(--spot); }
#vOut { margin-top: 10px; }
.v-row {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 600;
  font-size: 0.8rem; letter-spacing: 0.04em;
  padding: 4px 0; border-bottom: 1px solid var(--rule-soft);
}
.v-row.ok { color: var(--green); }
.v-row.bad { color: var(--spot); }
.v-detail { margin-top: 7px; font-size: 0.72rem; }
.v-detail span {
  display: block;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-soft);
}
.v-detail code {
  font-family: 'B612 Mono', monospace; font-size: 0.68rem;
  overflow-wrap: anywhere; display: block; color: var(--ink);
}

/* ── how it works ───────────────────────────────────────────────── */
.how-cols { column-count: 3; column-gap: 28px; column-rule: 1px solid var(--rule-soft); }
.how-cols p { break-inside: avoid; }
.drop-cap {
  float: left; font-family: 'Anton', sans-serif;
  font-size: 3.1em; line-height: 0.76; padding: 0.04em 0.08em 0 0;
}

/* ── footer ─────────────────────────────────────────────────────── */
footer { max-width: var(--measure); margin: 0 auto; padding: 0 20px 40px; }
.foot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.foot-grid p { font-size: 0.92rem; color: var(--ink-soft); margin-top: 5px; }
.colophon {
  margin-top: 20px; padding-top: 10px; border-top: 1px solid var(--rule-soft);
  font-family: 'Newsreader', serif; font-style: italic;
  font-size: 0.82rem; color: var(--ink-soft);
}

/* ── result overlay ─────────────────────────────────────────────── */
#raceResultOverlay {
  position: absolute; inset: 0; z-index: 5;
  background: rgba(13, 11, 8, 0.9);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#raceResultOverlay[hidden] { display: none; }
.podium { text-align: left; max-width: 92%; color: var(--news); }
.p-finish {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem;
  color: #bdb6a6;
}
.p-win { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.p-name {
  font-family: 'Anton', sans-serif; text-transform: uppercase;
  font-size: clamp(1.6rem, 5vw, 2.8rem); line-height: 1;
}
.p-minor { display: flex; gap: 18px; flex-wrap: wrap; }
.p-minor span {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem;
  color: #bdb6a6;
}
.p-pay {
  /* the slip is paper, so the payout is printed ink, not a lit LED */
  font-family: 'Anton', sans-serif; color: var(--spot);
  font-size: clamp(1.5rem, 4.4vw, 2.3rem); margin-top: 10px;
  letter-spacing: 0.01em;
}
.p-jackpot {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.8rem;
  color: var(--spot); margin-top: 8px;
}
.p-close {
  margin-top: 12px;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.78rem;
  background: none; color: var(--ink);
  border: 1px solid var(--ink); border-radius: 0;
  padding: 10px 16px; min-height: 42px; cursor: pointer;
}
.p-close:hover { background: var(--ink); color: var(--news); }

/* ── toasts ─────────────────────────────────────────────────────── */
#toasts { position: fixed; right: 14px; bottom: 14px; display: grid; gap: 8px; z-index: 80; }
.toast {
  background: var(--bar); color: var(--news);
  border: 1px solid #2a2620; border-radius: 0;
  padding: 12px 16px;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.84rem;
  max-width: min(88vw, 340px);
}
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--spot); }
.toast.gold { border-color: var(--amber); color: var(--amber); }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 0.22s ease-out; }
  @keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
}

/* ── responsive ─────────────────────────────────────────────────── */
@media (max-width: 1040px) {
  main { grid-template-columns: minmax(0, 1fr); }
  #races, #betslip { grid-column: 1; }
  #betslip { margin-top: 24px; }
  .fair-grid { grid-template-columns: minmax(0, 1fr); }
  .how-cols { column-count: 2; }
}

@media (max-width: 768px) {
  body { font-size: 16px; }
  .photo-plate { aspect-ratio: 4 / 3; }
  #raceCard { min-height: 429px; }
  .pot-body { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .pot-copy, .fair-copy, .how-cols { column-count: 1; }
  .foot-grid { grid-template-columns: minmax(0, 1fr); }
  .mast-row { align-items: flex-start; }
  /* A newspaper is left aligned, and the balance chip is hidden until sign-in,
     so space-between would strand the button on the right. */
  .mast-wallet { width: 100%; justify-content: flex-start; }
  .board-in { gap: 8px; }
  .board-gap { flex-basis: 100%; height: 0; }
}

/* ── MOTION ────────────────────────────────────────────────────────────────
   Mechanical, not smooth. A press stamps, a lamp flickers, a board holds.
   Nothing eases in from below; nothing fades up on scroll. */

/* The result reads as a slip stamped onto the photograph, not a modal. */
#raceResultOverlay { background: rgba(13, 11, 8, 0.82); }
.podium {
  background: var(--news);
  color: var(--ink);
  border: 2px solid var(--bar);
  box-shadow: 0 0 0 1px var(--bar);
  padding: 18px 22px 20px;
  max-width: min(92%, 560px);
  position: relative;
}
.podium::before {
  content: "RESULT";
  position: absolute; top: -11px; left: 18px;
  background: var(--spot); color: var(--news);
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.2em; font-size: 0.68rem;
  padding: 2px 10px;
}
.podium .p-finish { color: var(--ink-soft); }

@media (prefers-reduced-motion: no-preference) {
  /* stamped: overshoot once, land slightly off-true, settle. 190ms total. */
  #raceResultOverlay:not([hidden]) .podium { animation: stamp 190ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  @keyframes stamp {
    0%   { transform: scale(1.14) rotate(-1.4deg); opacity: 0; }
    60%  { opacity: 1; }
    100% { transform: scale(1) rotate(-0.35deg); opacity: 1; }
  }
  /* a real 7-segment board is never perfectly steady */
  .led { animation: led-flicker 7s steps(1, end) infinite; }
  @keyframes led-flicker {
    0%, 96%, 100% { opacity: 1; }
    97%           { opacity: 0.88; }
    98%           { opacity: 1; }
    99%           { opacity: 0.93; }
  }
}

/* ── THE BOOK: career form table ───────────────────────────────────── */
.form-table { width: 100%; border-collapse: collapse; font-family: 'Barlow', sans-serif; }
.form-table thead th {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.7rem;
  color: var(--ink-soft); text-align: left;
  border-bottom: 2px solid var(--bar); padding: 0 10px 6px 0; white-space: nowrap;
}
.form-table td {
  padding: 9px 10px 9px 0; border-bottom: 1px solid var(--rule);
  font-size: 0.92rem; vertical-align: middle;
}
.form-table .num { text-align: right; font-family: 'B612 Mono', monospace; font-size: 0.85rem; }
.fm-name {
  font-family: 'Anton', sans-serif; text-transform: uppercase;
  letter-spacing: 0.02em; font-size: 1rem;
}
.fm-pct { position: relative; min-width: 78px; }
.fm-pct b { position: relative; font-family: 'B612 Mono', monospace; font-weight: 700; }
.fm-bar {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  height: 15px; background: rgba(171, 30, 35, 0.16); z-index: 0;
}
.fm-form { white-space: nowrap; }
.fm-form .fp {
  display: inline-block; min-width: 18px; padding: 1px 0; margin-right: 3px;
  font-family: 'B612 Mono', monospace; font-style: normal; font-size: 0.76rem;
  text-align: center; color: var(--ink-soft); border: 1px solid var(--rule);
}
.fm-form .fp.w { background: var(--spot); color: var(--news); border-color: var(--spot); font-weight: 700; }
.form-note {
  margin: 12px 0 0; max-width: 70ch;
  font-family: 'Newsreader', serif; font-style: italic;
  font-size: 0.9rem; color: var(--ink-soft);
}
@media (max-width: 560px) {
  .form-table thead th:nth-child(5), .form-table td:nth-child(5) { display: none; }
}

/* .rc-plate is a grid item in the race card and inherits its width there.
   In a table cell it has nothing to size against, so state it. */
.form-table .rc-plate {
  display: inline-block; width: 26px; padding: 3px 0;
  font-size: 0.95rem; text-align: center;
}

/* ══ THE WALL AND THE WATCHING STATES ═══════════════════════════════════════
   Five tracks run at once. Showing one of them hid the whole premise, so the
   wall is a bank of board monitors bolted to the paper: dark cells, LED
   countdowns, jersey runners, newsprint only as the surround. */

/* ── stage head: what is happening, and how you want to watch it ─────────── */
.stage-head {
  display: flex; align-items: stretch; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}

.race-status {
  flex: 1 1 260px;
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 7px 12px 7px 16px;
  background: var(--news-2);
  box-shadow: inset 4px 0 0 var(--ink-soft);
  min-height: 38px;
}
.rs-phase {
  font-family: 'Anton', sans-serif; text-transform: uppercase;
  font-size: 1.05rem; line-height: 1; letter-spacing: 0.02em;
}
.rs-meta, .rs-text {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.78rem;
  color: var(--ink-soft);
}
/* PARADE: prices are moving, you can still get on. */
.race-status[data-phase="betting"] { box-shadow: inset 4px 0 0 var(--green); }
.race-status[data-phase="betting"] .rs-phase { color: var(--green); }
/* GATES: five seconds, and it has to read across a room. */
.race-status[data-phase="locked"] {
  background: var(--spot); box-shadow: inset 4px 0 0 var(--bar);
}
.race-status[data-phase="locked"] .rs-phase { color: var(--news); font-size: 1.35rem; }
.race-status[data-phase="locked"] .rs-meta,
.race-status[data-phase="locked"] .rs-text { color: rgba(231, 224, 207, 0.86); }
/* UNDER WAY: the board is live. */
.race-status[data-phase="running"] {
  background: var(--bar); box-shadow: inset 4px 0 0 var(--spot);
}
.race-status[data-phase="running"] .rs-phase { color: var(--news); }
.race-status[data-phase="running"] .rs-meta,
.race-status[data-phase="running"] .rs-text { color: #b9b2a2; }

.view-toggle { display: flex; flex: 0 0 auto; }
.view-toggle button {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.76rem;
  background: none; color: var(--ink-soft);
  border: 1px solid var(--rule); border-radius: 0;
  padding: 9px 16px; min-height: 38px; cursor: pointer;
}
.view-toggle button + button { border-left: 0; }
.view-toggle button[aria-pressed="true"] {
  background: var(--ink); color: var(--news); border-color: var(--ink);
}

/* ── single view: the photograph, and who is winning right now ───────────── */
.stage-single {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 196px;
  gap: 0 18px;
  align-items: start;
}
.order-col { border-left: 1px solid var(--rule); padding-left: 14px; }
.run-order {
  list-style: none; margin: 7px 0 0; padding: 0;
  /* eight rows reserved so the list appearing never shifts the page */
  min-height: 208px;
}
.ro-row {
  display: grid;
  grid-template-columns: 16px 22px minmax(0, 1fr) auto;
  gap: 7px; align-items: center;
  padding: 3px 0;
  border-bottom: 1px solid var(--rule-soft);
}
.ro-pos {
  font-family: 'B612 Mono', monospace; font-size: 0.72rem;
  color: var(--ink-soft); text-align: right;
}
.ro-plate {
  font-family: 'Anton', sans-serif; font-size: 0.8rem; line-height: 1;
  text-align: center; padding: 3px 0;
  background: var(--jersey, var(--ink)); color: var(--news);
}
.ro-name {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.82rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ro-gap {
  font-family: 'B612 Mono', monospace; font-size: 0.7rem;
  color: var(--ink-soft); white-space: nowrap;
}
.ro-row.is-lead { background: var(--news-2); }
.ro-row.is-lead .ro-name { color: var(--ink); }
.ro-row.is-lead .ro-gap {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--spot);
}
.ro-row.is-mine { box-shadow: inset 3px 0 0 var(--spot); padding-left: 6px; }
.ro-empty {
  font-family: 'Newsreader', serif; font-style: italic;
  font-size: 0.88rem; color: var(--ink-soft); padding-top: 4px;
}

/* ── the wall ────────────────────────────────────────────────────────────── */
.stage-wall[hidden] { display: none; }
/* Three over two, so the bank is never five identical tiles. The live cell
   takes the spot rule on top and a lit board. */
.wall-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  min-height: 420px;
}
.wcell:nth-child(-n+3) { grid-column: span 2; }
.wcell:nth-child(n+4)  { grid-column: span 3; }

.wcell {
  display: flex; flex-direction: column;
  background: var(--bar);
  border: 1px solid #2a2620;
  border-radius: 0;
  padding: 7px 9px 8px;
  cursor: pointer;
  min-width: 0;
  box-shadow: inset 0 3px 0 transparent;
}
.wcell:hover { border-color: #4a443a; }
.wcell.is-live { box-shadow: inset 0 4px 0 var(--spot); border-color: #6b6255; }
.wcell.is-gates { box-shadow: inset 0 4px 0 var(--news); border-color: #6b6255; }

.wcell-head {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 6px; border-bottom: 1px solid #2a2620;
}
.wcell-name {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.74rem;
  color: var(--news);
}
.wcell-lamp {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  font-size: 0.58rem; letter-spacing: 0.16em; text-transform: uppercase;
  padding: 2px 6px; color: var(--news); background: var(--ink-soft);
}
/* The countdown sits on a dark board, so here the LED is at home. It must not
   inherit the schedule strip's grid placement. */
.wcell .t-cd {
  grid-column: auto; grid-row: auto;
  margin-left: auto;
  font-family: 'DSEG7', 'B612 Mono', monospace;
  font-size: 0.8rem; color: var(--amber);
  text-shadow: 0 0 6px rgba(255, 181, 46, 0.36);
}
.wcell-canvas {
  display: block; width: 100%; height: 140px;
  margin: 7px 0 6px;
}
.wcell-foot {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  margin-top: auto; padding-top: 5px; border-top: 1px solid #2a2620;
  min-height: 30px;
}
.wcell-order {
  font-family: 'Barlow Condensed', sans-serif; font-size: 0.76rem;
  letter-spacing: 0.05em; text-transform: uppercase; color: #8d8674;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wcell-order b { color: var(--news); font-weight: 700; }
.wcell-order i { font-style: normal; color: var(--spot); }
.wcell-mine {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--news); background: var(--spot); padding: 2px 6px;
  margin-left: auto; white-space: nowrap;
}
.wall-note {
  margin: 12px 0 0; max-width: 68ch;
  font-family: 'Newsreader', serif; font-style: italic;
  font-size: 0.9rem; color: var(--ink-soft);
}

@media (prefers-reduced-motion: no-preference) {
  .wcell.is-gates { animation: gates 1s steps(2, end) infinite; }
  @keyframes gates { 50% { box-shadow: inset 0 3px 0 rgba(231, 224, 207, 0.3); } }
}

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stage-single { grid-template-columns: minmax(0, 1fr); }
  .order-col {
    border-left: 0; border-top: 1px solid var(--rule);
    padding-left: 0; padding-top: 10px; margin-top: 4px;
  }
  /* the order goes two-up when it sits under the photograph */
  .run-order { min-height: 116px; columns: 2; column-gap: 20px; }
  .ro-row { break-inside: avoid; }
}
@media (max-width: 560px) {
  .wall-grid { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .wcell:nth-child(-n+3), .wcell:nth-child(n+4) { grid-column: span 1; }
  .wcell-canvas { height: 124px; }
  .run-order { columns: 1; min-height: 208px; }
  .view-toggle { width: 100%; }
  .view-toggle button { flex: 1; }
}

/* An author `display:` beats the UA rule for [hidden], so a hidden element with
   `display:grid` stays visible. This bit us: toggling to the wall left BOTH
   stages on screen. Global guard rather than per-element, so it cannot recur. */
[hidden] { display: none !important; }
