:root {
  --night: #0a1430;
  --night-2: #16285a;
  --ink: #f5f7fb;
  --muted: #b9c4dd;
  --card: rgba(12, 22, 52, 0.82);
  --line: rgba(255, 255, 255, 0.16);
  --red: #c8102e;
  --red-2: #e23a52;
  --gold: #f2c14e;
  --green: #2f6b3a;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: linear-gradient(180deg, var(--night) 0%, var(--night-2) 55%, #24407a 100%);
  background-attachment: fixed;
  color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100svh;
}

.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.floodlight {
  position: absolute; top: -12vh; width: 70vw; height: 70vh;
  background: radial-gradient(closest-side, rgba(255, 246, 210, 0.22), rgba(255, 246, 210, 0) 70%);
}
.floodlight.left { left: -25vw; }
.floodlight.right { right: -25vw; }

#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

.pitch {
  position: fixed; left: 0; right: 0; bottom: 0; width: 100%; height: 30vh; max-height: 260px;
  z-index: 0; pointer-events: none;
}

main {
  position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(30vh + 24px);
}

.loading { text-align: center; color: var(--muted); padding-top: 30vh; }

.hero { text-align: center; padding: 18px 0 14px; }
.kicker {
  margin: 0; text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.74rem; font-weight: 700;
  color: var(--gold); text-wrap: balance;
}
h1 {
  margin: 4px 0 0; font-size: clamp(2rem, 9vw, 3rem); line-height: 1.05; letter-spacing: -0.02em;
  font-weight: 900; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
h1 .gold { color: var(--gold); }
.sub { margin: 8px 0 0; color: var(--muted); }
.date { margin: 6px 0 0; font-weight: 700; color: var(--ink); opacity: 0.85; }

.holding { text-align: center; }
.holding .big { font-size: 1.25rem; font-weight: 700; margin-bottom: 16px; }
.whistle { display: grid; place-items: center; height: 70px; margin-bottom: 4px; }
.pulse {
  width: 26px; height: 26px; border-radius: 50%; background: var(--gold);
  box-shadow: 0 0 0 0 rgba(242, 193, 78, 0.6); animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(242, 193, 78, 0.6); }
  100% { box-shadow: 0 0 0 26px rgba(242, 193, 78, 0); }
}

.winner-line { display: flex; align-items: baseline; gap: 8px; margin: -4px 0 10px; font-size: 1.5rem; font-weight: 900; color: var(--gold); }
.winner-line .trophy { font-size: 1.3rem; }
.turnout-card { display: grid; gap: 10px; }
.turnout-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.turnout-head h3 { margin: 0; }
.turnout-n { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.turnout-card .bar-track { display: block; height: 18px; }
.more { margin: 10px 0 0; }
.live-head { margin: 20px 0 0; }
.bar.top .bar-label { color: var(--gold); font-weight: 800; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-top: 4px solid var(--red);
}
.card > :first-child { margin-top: 0; }
.card p { margin: 0 0 12px; }

h2 { margin: 4px 0 6px; font-size: 1.6rem; line-height: 1.15; }
h3 { margin: 0 0 10px; font-size: 1.05rem; }

.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.error {
  color: #ffd6dc; background: rgba(200, 16, 46, 0.25); border: 1px solid rgba(226, 58, 82, 0.6);
  padding: 10px 12px; border-radius: 10px;
}

.award-list { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 10px; }
.award-list li {
  display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.05); border-left: 3px solid var(--gold);
}
.award-list .muted { font-size: 0.92rem; }

.turnout { font-size: 1rem; color: var(--muted); }
.turnout strong { color: var(--gold); font-size: 1.4rem; }

.btn {
  appearance: none; border: 0; border-radius: 999px; padding: 14px 22px;
  font: inherit; font-weight: 800; cursor: pointer; min-height: 50px;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--red); color: #fff; box-shadow: 0 4px 0 #7d0a1c; }
.btn.primary:hover:not(:disabled) { background: var(--red-2); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.card > .btn.primary { width: 100%; margin-top: 6px; font-size: 1.1rem; }
.btn:focus-visible, .name:focus-visible, .link:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 2px;
}

.link {
  appearance: none; background: none; border: 0; color: var(--gold); font: inherit; font-size: 0.9rem;
  text-decoration: underline; cursor: pointer; padding: 4px;
}

.progress { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.dot {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.5);
}
.dot.done { background: #fff; border-color: #fff; }
.dot.current { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 193, 78, 0.3); }
.step-count {
  margin: 0; text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.75rem; color: var(--gold); font-weight: 700;
}

.names {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin: 16px 0 18px;
}
.name {
  appearance: none; font: inherit; font-weight: 700; color: var(--ink); cursor: pointer;
  background: rgba(255, 255, 255, 0.07); border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px; padding: 12px 8px; min-height: 52px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.name:hover { border-color: rgba(255, 255, 255, 0.4); }
.name.picked { background: var(--gold); color: #1b2540; border-color: var(--gold); }

.nav { display: flex; justify-content: space-between; gap: 10px; }
.nav .btn.primary { flex: 1; }

.review { margin: 10px 0 18px; display: grid; gap: 4px; }
.review dt { color: var(--muted); font-size: 0.85rem; margin-top: 8px; }
.review dd {
  margin: 0; display: flex; justify-content: space-between; align-items: center;
  font-weight: 800; font-size: 1.2rem; border-bottom: 1px solid var(--line); padding-bottom: 6px;
}

.charts { display: grid; gap: 12px; margin-top: 14px; }
.chart-card {
  background: rgba(255, 255, 255, 0.05); border-radius: 12px; padding: 14px;
  border-left: 3px solid var(--gold);
}
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.bar { display: grid; grid-template-columns: 78px 1fr 28px; align-items: center; gap: 8px; font-size: 0.9rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar.anon .bar-label { color: var(--muted); }
.bar-track { height: 14px; background: rgba(255, 255, 255, 0.08); border-radius: 999px; overflow: hidden; }
.bar-fill {
  display: block; height: 100%; border-radius: 999px;
  background: repeating-linear-gradient(135deg, var(--red) 0 10px, #fff 10px 20px);
  transition: width 0.6s ease;
}
.bar-n { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Admin */
.admin main { max-width: 760px; }
.admin-grid { display: grid; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toggle { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--red); }
textarea {
  width: 100%; min-height: 260px; font: inherit; color: var(--ink); background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; resize: vertical;
}
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 800;
  background: rgba(255, 255, 255, 0.1);
}
.pill.open { background: #1f7a3c; }
.pill.closed { background: var(--red); }
.note { color: #c8f0d2; font-size: 0.9rem; }
.steps { margin: 6px 0 12px; padding-left: 22px; display: grid; gap: 8px; color: var(--muted); }
.steps li.now { color: var(--ink); }
.steps li.now::marker { color: var(--gold); }
.steps li.done { text-decoration: line-through; opacity: 0.6; }

/* Reveal mode */
.reveal {
  position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; text-align: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 30%, #1d3270 0%, var(--night) 70%);
}
.reveal-inner { max-width: 640px; width: 100%; }
.reveal h2 { font-size: clamp(1.8rem, 7vw, 3rem); }
.reveal .drum { font-size: 1.3rem; color: var(--muted); min-height: 2em; }
.winner {
  font-size: clamp(3rem, 16vw, 6.5rem); font-weight: 900; color: var(--gold); line-height: 1;
  margin: 10px 0; animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.runners { color: var(--muted); }
.reveal .row { justify-content: center; margin-top: 28px; }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .winner, .pulse { animation: none; }
  .bar-fill { transition: none; }
}
