/*
  Name the Roster house style. One neutral look for every team: no team colors, no logos.
  Palette: Ink & Cream. Type: Bebas Neue (scoreboard numerals, headings) + Source Sans 3 (body).
*/
:root {
  --ink: #1A1A18;
  --cream: #F5F0E8;
  --surface: #FDFAF4;
  --red: #B52A2A;
  --green: #1F6B3A;
  --bar: #1A1A18;
  --bar-text: #F5F0E8;
  --muted: #5F5A50;
  --rule: #D9D1C3;
  --slot: #ECE5D8;
  --focus: #B52A2A;
  --display: 'Bebas Neue', 'Arial Narrow', sans-serif;
  --body: 'Source Sans 3', 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #F2ECE0;
    --cream: #141412;
    --surface: #1D1C19;
    --red: #E0736B;
    --green: #6CC58A;
    --bar: #262520;
    --bar-text: #F2ECE0;
    --muted: #B3AB9C;
    --rule: #3A3832;
    --slot: #26251F;
    --focus: #E0736B;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #F2ECE0;
  --cream: #141412;
  --surface: #1D1C19;
  --red: #E0736B;
  --green: #6CC58A;
  --bar: #262520;
  --bar-text: #F2ECE0;
  --muted: #B3AB9C;
  --rule: #3A3832;
  --slot: #26251F;
  --focus: #E0736B;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 400 17px/1.45 var(--body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main:focus-visible { outline: none; }
main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px 48px; outline: none; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--cream); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Masthead */
.masthead {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  max-width: 980px; width: 100%; margin: 0 auto; padding: 18px 16px 10px;
  border-bottom: 2px solid var(--ink);
}
.wordmark { display: inline-flex; align-items: center; gap: 10px; font: 400 30px/1 var(--display); letter-spacing: 0.04em; text-decoration: none; }
.wordmark img { flex: 0 0 auto; transform: translateY(-1px); }
.wordmark .wm { white-space: nowrap; }
.wordmark .wm span { color: var(--red); }
.masthead nav a, .theme-toggle { white-space: nowrap; }
.masthead nav { display: flex; align-items: center; gap: 14px; }
.masthead nav a { font-weight: 600; font-size: 15px; text-decoration: none; border-bottom: 1px solid var(--rule); }
.theme-toggle {
  min-height: 36px; padding: 0 10px; border: 1px solid var(--rule); background: transparent; border-radius: 2px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; color: var(--muted);
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }

h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: 0.02em; line-height: 0.95; margin: 0; }
h1 { font-size: clamp(48px, 13vw, 104px); }
h2 { font-size: 34px; }
h3 { font-size: 24px; }
.kicker { font-weight: 700; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.lede { font-size: 19px; max-width: 34ch; margin: 14px 0 0; }
.muted { color: var(--muted); }
.loading { padding: 40px 0; color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border: 2px solid var(--ink); border-radius: 2px;
  background: var(--ink); color: var(--cream); font-weight: 700; font-size: 17px;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--red); border-color: var(--red); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { border-color: var(--red); color: var(--red); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Home */
.hero { padding: 36px 0 24px; display: grid; gap: 8px; }
.hero h1 { max-width: 12ch; }
.search { margin-top: 22px; max-width: 520px; position: relative; }
.search label { display: block; font-weight: 700; margin-bottom: 6px; }
.search input, .entry input, .field input {
  width: 100%; min-height: 54px; padding: 0 16px; background: var(--surface);
  border: 2px solid var(--ink); border-radius: 2px; font-size: 19px;
}
.search ul { list-style: none; margin: 0; padding: 0; border: 2px solid var(--ink); border-top: 0; background: var(--surface); }
.search li a { display: flex; justify-content: space-between; padding: 12px 16px; text-decoration: none; }
.search li a:hover, .search li a:focus { background: var(--slot); }
.home-team {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 8px 0 0; padding: 16px; border-left: 6px solid var(--red); background: var(--surface);
}
.section { margin-top: 40px; }
.section > header { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--rule); padding-bottom: 8px; margin-bottom: 14px; }
.rivals { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0; border-top: 1px solid var(--rule); }
.rivals a { display: flex; align-items: baseline; gap: 10px; padding: 14px 4px; border-bottom: 1px solid var(--rule); text-decoration: none; font: 400 26px/1 var(--display); letter-spacing: 0.03em; }
.rivals a .vs { font: 700 13px/1 var(--body); color: var(--red); letter-spacing: 0.1em; }
.rivals a:hover { color: var(--red); }
.divisions { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 26px 28px; }
.divisions h3 { font-size: 20px; color: var(--muted); margin-bottom: 6px; }
.divisions ul { list-style: none; margin: 0; padding: 0; }
.divisions li a { display: block; padding: 7px 0; text-decoration: none; border-bottom: 1px dotted var(--rule); }
.divisions li a:hover { color: var(--red); }

/* Sport tabs and league chips */
.tabs {
  display: flex; gap: 0; margin: 30px -16px 0; padding: 0 16px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 2px solid var(--ink); position: sticky; top: 0; z-index: 4; background: var(--cream);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: 0 0 auto; padding: 14px 16px 10px; font: 400 26px/1 var(--display); letter-spacing: 0.04em;
  text-decoration: none; color: var(--muted); border-bottom: 5px solid transparent; margin-bottom: -2px;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.chips a {
  display: inline-flex; align-items: baseline; gap: 6px; min-height: 44px; padding: 9px 14px;
  border: 2px solid var(--rule); background: var(--surface); text-decoration: none; font-weight: 600; font-size: 15px;
}
.chips a:hover { border-color: var(--ink); }
.chips a[aria-current="page"] { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.chips a.soon { color: var(--muted); }
.chips a small { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.home-team { margin-top: 20px; }
.coming { border-top: 2px solid var(--ink); padding-top: 18px; }
.coming .lede { max-width: 46ch; }
.team-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 28px; }
.team-grid li a { display: block; padding: 9px 0; text-decoration: none; border-bottom: 1px dotted var(--rule); }
.team-grid li a:hover { color: var(--red); }

/* Team page */
.team-head { padding: 32px 0 8px; }
.team-head .city { font: 700 15px/1 var(--body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.facts { display: flex; flex-wrap: wrap; gap: 0; margin: 22px 0; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); }
.facts div { flex: 1 1 120px; padding: 12px 14px 12px 0; }
.facts dt { font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 2px 0 0; font: 400 34px/1 var(--display); }
fieldset.clocks { border: 0; padding: 0; margin: 22px 0; }
fieldset.clocks legend { font-weight: 700; margin-bottom: 8px; }
.clock-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 560px; }
.clock-options label { display: block; cursor: pointer; }
.clock-options input { position: absolute; opacity: 0; }
.clock-options span { display: block; padding: 12px 10px; border: 2px solid var(--rule); background: var(--surface); min-height: 86px; }
.clock-options strong { display: block; font: 400 28px/1 var(--display); }
.clock-options small { display: block; font-size: 14px; color: var(--muted); margin-top: 4px; }
.clock-options input:checked + span { border-color: var(--ink); box-shadow: inset 0 -5px 0 var(--red); }
.clock-options input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.note { font-size: 15px; color: var(--muted); margin-top: 10px; }

/* Game */
/* The scoreboard, the entry box and the feedback line stay pinned together, so the box
   is always in view while the board scrolls under it. */
.play-head { position: sticky; top: 0; z-index: 5; background: var(--cream); margin: 0 -16px; padding: 0 16px; }
.scorebar {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 18px;
  margin: 0 -16px; padding: 8px 16px; min-height: 56px; background: var(--bar); color: var(--bar-text);
}
.scorebar .team { font: 400 24px/1 var(--display); letter-spacing: 0.03em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scorebar .stat { text-align: right; position: relative; }
.scorebar .stat small { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.72; }
.scorebar .stat b { font: 400 40px/0.9 var(--display); font-variant-numeric: tabular-nums; display: inline-block; }
.scorebar .stat.late b { color: #FF8A80; animation: pulse 1s steps(1) infinite; }
@keyframes pulse { 0% { transform: scale(1.06); } 15% { transform: scale(1); } }
.meter { height: 4px; margin: 0 -16px; background: var(--slot); }
.meter span { display: block; height: 100%; width: 0; background: var(--green); transition: width 200ms ease-out; }
.plus-one { position: absolute; right: 0; top: -2px; font: 700 15px/1 var(--body); color: #8FE0A8; pointer-events: none; animation: float-up 400ms ease-out forwards; }
@keyframes float-up { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-16px); opacity: 0; } }
.streak { margin-left: 8px; padding: 2px 6px; font: 700 11px/1.2 var(--body); letter-spacing: 0.08em; text-transform: uppercase; background: var(--bar-text); color: var(--bar); vertical-align: middle; }
.entry { padding: 12px 0 4px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.entry label { grid-column: 1 / -1; font-weight: 700; font-size: 15px; }
.entry input { transition: border-color 120ms; }
.entry input.right { border-color: var(--green); box-shadow: 0 0 0 2px var(--green); }
.entry input.wrong { animation: shake 160ms ease-in-out; }
@keyframes shake { 25% { transform: translateX(-3px); } 50% { transform: translateX(3px); } 75% { transform: translateX(-3px); } }
.feedback { min-height: 24px; margin: 0; padding: 2px 0 10px; font-weight: 600; font-size: 16px; border-bottom: 2px solid var(--ink); }
.feedback.good { color: var(--green); }
.feedback.bad { color: var(--muted); }
.feedback.bonus { color: var(--ink); }
.countdown {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: color-mix(in srgb, var(--cream) 88%, transparent);
  font: 400 160px/1 var(--display); color: var(--ink); pointer-events: none;
}
.countdown span { animation: count-in 600ms ease-out; }
@keyframes count-in { from { transform: scale(1.4); opacity: 0; } 40% { opacity: 1; } to { transform: scale(1); } }
.board { display: grid; gap: 22px; margin-top: 10px; }
.group header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--ink); padding-bottom: 4px; margin-bottom: 8px; }
.group header b { font: 400 22px/1 var(--display); font-variant-numeric: tabular-nums; }
.slots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
.slots li {
  display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 4px 8px;
  background: var(--slot); font-size: 15px;
}
.slots li .pos { font: 700 12px/1 var(--body); letter-spacing: 0.06em; color: var(--muted); min-width: 28px; }
.slots li.got { background: var(--ink); color: var(--cream); animation: drop 260ms ease-out; }
.slots li.got .pos { color: var(--cream); opacity: 0.7; }
.slots li.missed { background: transparent; border: 1px dashed var(--red); }
@keyframes drop { from { transform: translateY(-6px); opacity: 0.2; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .slots li.got { animation: none; } }
.bonus-list { margin-top: 18px; font-size: 15px; }
.bonus-list ul { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.bonus-list li { border: 1px dashed var(--muted); padding: 3px 8px; }
.end-row { margin-top: 26px; display: flex; justify-content: flex-end; }

/* Results */
.result-head { padding: 28px 0 8px; display: grid; gap: 4px; }
.big-score { font: 400 clamp(72px, 22vw, 150px)/0.85 var(--display); font-variant-numeric: tabular-nums; }
.big-score small { font-size: 0.4em; color: var(--muted); }
.tier-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; font-size: 18px; }
.tier-badge { font: 400 30px/1 var(--display); color: var(--red); letter-spacing: 0.04em; }
.status { font-size: 15px; padding: 10px 12px; border-left: 4px solid var(--muted); background: var(--surface); margin: 14px 0; }
.status.verified { border-left-color: var(--green); }
/* The tier lands like a rubber stamp on a ticket stub. */
.stamp {
  display: inline-block; margin: 14px 0 4px; padding: 6px 14px 2px; border: 3px solid var(--red); color: var(--red);
  font: 400 44px/1 var(--display); letter-spacing: 0.06em; text-transform: uppercase; transform: rotate(-6deg);
  animation: stamp 240ms cubic-bezier(.2, 1.4, .4, 1) 200ms both;
}
.stamp.small { font-size: 22px; border-width: 2px; padding: 3px 8px 1px; margin: 0 0 0 10px; vertical-align: middle; animation: none; }
@keyframes stamp { from { transform: rotate(-6deg) scale(1.6); opacity: 0; } 80% { transform: rotate(-6deg) scale(.98) translateY(2px); opacity: 1; } to { transform: rotate(-6deg) scale(1); opacity: 1; } }
.versus { display: grid; grid-template-columns: 1fr 1fr; gap: 0; max-width: 420px; margin: 16px 0; border: 2px solid var(--ink); }
.versus div { padding: 10px 14px; }
.versus div + div { border-left: 1px solid var(--rule); }
.versus small { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.versus b { font: 400 34px/1 var(--display); font-variant-numeric: tabular-nums; }
.versus .lost b { color: var(--muted); }
.again { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 0; padding: 12px 14px; border-left: 6px solid var(--red); background: var(--surface); text-decoration: none; }
.again b { font: 400 24px/1 var(--display); letter-spacing: 0.03em; }
@media (prefers-reduced-motion: reduce) {
  .stamp, .plus-one, .entry input.wrong, .countdown span, .scorebar .stat.late b { animation: none; }
}
.ticket {
  margin: 22px 0; max-width: 420px; background: var(--surface); border: 2px solid var(--ink);
  padding: 16px 18px; position: relative;
}
.ticket::before, .ticket::after {
  content: ''; position: absolute; top: 50%; width: 18px; height: 18px; margin-top: -9px;
  background: var(--cream); border: 2px solid var(--ink); border-radius: 50%;
}
.ticket::before { left: -11px; clip-path: inset(0 0 0 50%); }
.ticket::after { right: -11px; clip-path: inset(0 50% 0 0); }
.ticket pre { margin: 0; font: 600 16px/1.5 var(--body); white-space: pre-wrap; word-break: break-word; }
.field { max-width: 420px; margin: 8px 0 14px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; }
.field input { min-height: 48px; font-size: 17px; }

/* Sign-up: an inline card, then a bottom sheet. Never a wall, never during a round. */
.signup-card { margin: 22px 0 0; max-width: 520px; padding: 16px 18px; border: 1px solid var(--ink); background: var(--surface); }
.signup-card p { margin: 0 0 12px; }
.signup-card.done { border-left: 6px solid var(--green); }
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(20, 20, 18, 0.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--cream); color: var(--ink);
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border-top: 4px solid var(--ink); animation: sheet-up 220ms ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.sheet-top p { margin: 4px 0 0; font-size: 15px; }
.sheet .field input { font-size: 17px; min-height: 48px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; margin: 4px 0 12px; border: 2px solid var(--ink); max-width: 420px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 11px 8px; font-weight: 700; }
.seg input:checked + span { background: var(--ink); color: var(--cream); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
.help { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.err { margin: 4px 0 0; font-size: 15px; font-weight: 600; color: var(--red); }
.consent { display: flex; gap: 10px; align-items: flex-start; max-width: 460px; margin: 6px 0 14px; font-size: 14px; line-height: 1.4; color: var(--muted); }
.consent input { width: 22px; height: 22px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--ink); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.wide { width: 100%; max-width: 420px; min-height: 52px; }
.fine { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
body.sheet-open { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

/* Results: the challenge button comes right after the stamp. */
.share-row { display: grid; gap: 8px; max-width: 520px; margin: 14px 0 6px; }
.share-row input { min-height: 48px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 2px; background: var(--surface); font-size: 17px; }
.share-row .btn { min-height: 56px; font-size: 18px; }
.big-score { font-weight: 400; }
.rules { margin: 14px 0 0; font-size: 17px; max-width: 46ch; }
.masthead nav a, .theme-toggle { min-height: 44px; display: inline-flex; align-items: center; }
.footer a { display: inline-block; padding: 6px 0; }

/* Challenge landing */
.challenge { padding: 40px 0 16px; }
.challenge h1 { font-size: clamp(44px, 12vw, 92px); max-width: 12ch; }
.challenge .turn { color: var(--red); }

/* Terms and privacy */
.legal { max-width: 720px; padding-top: 28px; }
.legal h1 { margin-bottom: 8px; }
.legal h2 { font-size: 28px; margin: 30px 0 8px; }
.legal p { max-width: 66ch; }

/* Profile */
table.tiers { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 16px; }
table.tiers th, table.tiers td { text-align: left; padding: 10px 8px 10px 0; border-bottom: 1px solid var(--rule); }
table.tiers th { font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.footer { border-top: 1px solid var(--rule); padding: 18px 16px 28px; max-width: 980px; width: 100%; margin: 0 auto; font-size: 14px; color: var(--muted); }
.footer p { margin: 0 0 6px; max-width: 70ch; }
.footer .maker { margin-top: 10px; font: 400 18px/1 var(--display); letter-spacing: 0.06em; color: var(--ink); }
.noscript { padding: 16px; }

@media (max-width: 520px) {
  .wordmark { font-size: 24px; gap: 8px; }
  .wordmark img { width: 28px; height: 28px; }
  .masthead { gap: 10px; }
  .masthead nav { gap: 8px; }
  .tabs a { font-size: 22px; padding: 12px 12px 9px; }
  .scorebar { gap: 12px; }
  .scorebar .team { font-size: 20px; }
  .scorebar .stat b { font-size: 34px; }
  #start-form .btn[type=submit] { width: 100%; min-height: 56px; }
  .slots { grid-template-columns: repeat(2, 1fr); }
  .clock-options span { min-height: 96px; }
}

@media (max-width: 360px) {
  .wordmark { font-size: 21px; gap: 6px; }
  .wordmark img { width: 24px; height: 24px; }
  .theme-toggle { padding: 0 6px; font-size: 11px; }
  .masthead nav a { font-size: 14px; }
}
