/* Sports day.
   A committed dark theme - this is a scoreboard, it should look like one on a
   phone in a field and on a television in a marquee. Condensed display face
   for anything that is a name or a number, tabular figures everywhere so
   columns of points line up, and one loud accent used sparingly enough that it
   still means something when it appears. */

:root {
  --bg: #0a0c10;
  --bg-2: #0f131a;
  --panel: #141922;
  --panel-2: #1a202b;
  --line: #242c3a;
  --line-soft: #1c2330;

  --ink: #eef2f8;
  --ink-2: #a7b2c4;
  --ink-3: #6d7a8d;

  --accent: #ccff33;
  --accent-ink: #0a0c10;
  --live: #ff3b5c;

  --gold: #ffc84a;
  --silver: #c8d2e0;
  --bronze: #d98b4a;

  --ok: #3ddc84;
  --miss: #ff5a6e;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 48px rgba(0, 0, 0, .55);

  --display: 'Barlow Condensed', 'Oswald', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* The `hidden` attribute only sets `display: none` at user-agent weight, so any
   rule here that sets display beats it. Several things toggled with .hidden are
   flex containers - the guess form once the quiz closes, the scoring fields
   that do not apply - and they would otherwise stay on screen. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 50% -10%, #1a2333 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 42%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, .display { font-family: var(--display); font-weight: 700; letter-spacing: .01em; margin: 0; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

.shell { max-width: 1120px; margin: 0 auto; padding: 0 16px 72px; }

/* ---- header ------------------------------------------------------------- */

.topbar {
  position: relative;
  padding: 26px 0 18px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 20px;
}

.eyebrow {
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}

.title {
  font-family: var(--display);
  font-size: clamp(34px, 7vw, 58px);
  line-height: .94;
  text-transform: uppercase;
  letter-spacing: .005em;
}

.title em { font-style: normal; color: var(--accent); }

.subtitle { color: var(--ink-2); margin-top: 7px; font-size: 14px; }

.topbar-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.pill.is-live { border-color: rgba(255, 59, 92, .45); color: #ffdbe1; }
.pill.is-live .dot { background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }

@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.78); } }

@media (prefers-reduced-motion: reduce) {
  .pill.is-live .dot { animation: none; }
}

/* ---- tabs --------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 22px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--display);
  font-size: 16px;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected='true'] { background: var(--accent); color: var(--accent-ink); }

.tabs.sub { background: transparent; border: 0; padding: 0; gap: 8px; margin-bottom: 18px; }
.tabs.sub .tab {
  flex: 0 0 auto; font-size: 14px; padding: 6px 14px;
  border: 1px solid var(--line); background: var(--panel);
}
.tabs.sub .tab[aria-selected='true'] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---- panels ------------------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent);
}

.panel-head h2 { font-size: 20px; text-transform: uppercase; letter-spacing: .08em; }
.panel-head .hint { color: var(--ink-3); font-size: 12px; }

.section-title {
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 30px 0 12px;
}

/* ---- leaderboard -------------------------------------------------------- */

.lb { display: flex; flex-direction: column; }

.lb-row {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  position: relative;
}
.lb-row:last-child { border-bottom: 0; }

/* A faint bar behind each row, scaled to the leader. Reads instantly from the
   back of a marquee in a way a column of numbers does not. */
.lb-row::before {
  content: '';
  position: absolute; inset: 0 auto 0 0;
  width: var(--bar, 0%);
  background: linear-gradient(90deg, rgba(204, 255, 51, .12), rgba(204, 255, 51, 0));
  pointer-events: none;
}

.lb-row.is-me { background: rgba(204, 255, 51, .05); }
.lb-row.is-me .lb-name { color: var(--accent); }

.lb-rank {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.lb-row[data-rank='1'] .lb-rank { color: var(--gold); }
.lb-row[data-rank='2'] .lb-rank { color: var(--silver); }
.lb-row[data-rank='3'] .lb-rank { color: var(--bronze); }

.lb-name {
  font-family: var(--display);
  font-size: 23px;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: .02em;
  min-width: 0;
  overflow-wrap: anywhere;
}

.lb-sub { font-size: 11px; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; margin-top: 1px; }

.lb-total {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  line-height: 1;
}
.lb-total span { font-size: 11px; color: var(--ink-3); display: block; letter-spacing: .14em; text-transform: uppercase; font-family: var(--body); font-weight: 600; }

/* ---- events ------------------------------------------------------------- */

.events { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.event-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.event-head { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); }
.event-head h3 { font-size: 19px; text-transform: uppercase; letter-spacing: .06em; }
.event-head .meta { font-size: 11px; color: var(--ink-3); letter-spacing: .06em; margin-top: 3px; }
.event-head .note { font-size: 12px; color: var(--ink-2); margin-top: 5px; }

.st-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}
.st-row:last-child { border-bottom: 0; }
.st-row.is-me { background: rgba(204, 255, 51, .05); color: var(--accent); }

.st-place {
  font-family: var(--display); font-size: 17px; font-weight: 700;
  color: var(--ink-3); text-align: center; font-variant-numeric: tabular-nums;
}
.st-row[data-place='1'] .st-place { color: var(--gold); }
.st-row[data-place='2'] .st-place { color: var(--silver); }
.st-row[data-place='3'] .st-place { color: var(--bronze); }

.st-name { min-width: 0; overflow-wrap: anywhere; }
.st-extra {
  display: block;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-top: 1px;
}
.st-pts { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }

.empty { padding: 22px 18px; color: var(--ink-3); font-size: 13px; text-align: center; }

/* ---- countdown ---------------------------------------------------------- */

.cd-wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
  padding: 16px 18px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
}

.cd-label { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }

.cd { display: flex; gap: 8px; align-items: flex-start; }

.cd-seg { text-align: center; min-width: 54px; }
.cd-seg b {
  display: block;
  font-family: var(--display);
  font-size: clamp(30px, 8vw, 44px);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.cd-seg i {
  font-style: normal; font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-3);
}

.cd.is-urgent .cd-seg b { color: var(--live); }
.cd.is-over .cd-seg b { color: var(--ink-3); }

.score-big { text-align: right; }
.score-big b {
  font-family: var(--display); font-size: clamp(34px, 9vw, 48px); font-weight: 700;
  line-height: 1; font-variant-numeric: tabular-nums; display: block;
}
.score-big b em { font-style: normal; color: var(--ink-3); font-size: .55em; }
.score-big i { font-style: normal; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }

/* ---- quiz input --------------------------------------------------------- */

.guess-wrap { position: sticky; top: 0; z-index: 5; padding: 12px 0; background: linear-gradient(180deg, var(--bg) 72%, transparent); }

.guess {
  display: flex; gap: 8px;
}

.guess input {
  flex: 1;
  background: var(--panel-2);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 17px;
  outline: none;
  transition: border-color .12s, background .12s;
  min-width: 0;
}
.guess input::placeholder { color: var(--ink-3); }
.guess input:focus { border-color: var(--accent); }
.guess input:disabled { opacity: .5; }

.guess.is-ok input { border-color: var(--ok); background: rgba(61, 220, 132, .1); }
.guess.is-miss input { border-color: var(--miss); animation: shake .3s; }
.guess.is-dupe input { border-color: var(--gold); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
@media (prefers-reduced-motion: reduce) { .guess.is-miss input { animation: none; } }

.guess-msg { min-height: 20px; margin-top: 7px; font-size: 13px; color: var(--ink-2); }
.guess-msg.ok { color: var(--ok); }
.guess-msg.miss { color: var(--miss); }
.guess-msg.dupe { color: var(--gold); }

/* ---- league jump strip -------------------------------------------------- */

.league-jump {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 0 14px;
  scrollbar-width: none;
}
.league-jump::-webkit-scrollbar { display: none; }

.jump {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 74px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink-2);
  cursor: pointer;
}
.jump:hover { border-color: var(--ink-3); }
.jump b { font-family: var(--display); font-size: 16px; letter-spacing: .1em; color: var(--ink); }
.jump span { font-size: 12px; font-variant-numeric: tabular-nums; }
.jump.done { border-color: var(--accent); }
.jump.done b, .jump.done span { color: var(--accent); }

/* ---- quiz board --------------------------------------------------------- */

.leagues { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }

.league {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.league-head { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.league-head h3 { font-size: 20px; letter-spacing: .1em; }
.league-head .count { font-family: var(--display); font-size: 17px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.prog { height: 3px; background: var(--line-soft); }
.prog i { display: block; height: 100%; background: var(--accent); transition: width .35s ease; }

.division { padding: 10px 14px 12px; border-bottom: 1px solid var(--line-soft); }
.division:last-child { border-bottom: 0; }
.division h4 {
  margin: 0 0 7px; font-family: var(--display); font-size: 12px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); font-weight: 600;
}

.slots { display: flex; flex-direction: column; gap: 3px; }

.slot {
  font-size: 13px;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink-3);
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.slot.got {
  background: rgba(204, 255, 51, .1);
  color: var(--ink);
  box-shadow: inset 2px 0 0 var(--accent);
}
.slot.got b { font-weight: 600; }
.slot.got .city { color: var(--ink-2); font-weight: 400; }

.slot.missed { background: rgba(255, 90, 110, .08); color: var(--ink-2); box-shadow: inset 2px 0 0 var(--miss); }

.slot.blank::before { content: ''; height: 2px; width: 46px; background: var(--line); border-radius: 2px; }
.slot.hint { font-size: 12px; letter-spacing: .02em; }

.slot.just-in { animation: pop .4s ease; }
@keyframes pop { 0% { transform: scale(.94); background: rgba(204, 255, 51, .35); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .slot.just-in { animation: none; } }

/* ---- live quiz scores --------------------------------------------------- */

.live-row {
  display: grid;
  grid-template-columns: 40px 1fr 84px auto;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.live-row:last-child { border-bottom: 0; }
.live-row.is-me { background: rgba(204, 255, 51, .05); }
.live-row.is-me .live-name { color: var(--accent); }

.live-name { font-family: var(--display); font-size: 20px; text-transform: uppercase; overflow-wrap: anywhere; }
.live-bar { height: 5px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.live-bar i { display: block; height: 100%; background: var(--accent); transition: width .4s ease; }
.live-correct { font-family: var(--display); font-size: 24px; font-variant-numeric: tabular-nums; text-align: right; min-width: 58px; }
.live-correct em { font-style: normal; font-size: .55em; color: var(--ink-3); }

/* ---- name picker / landing --------------------------------------------- */

.picker { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 18px; }
.picker a {
  display: inline-block;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--ink);
  font-family: var(--display);
  font-size: 17px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.picker a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ---- forms and buttons -------------------------------------------------- */

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: border-color .12s, background .12s;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--miss); border-color: rgba(255, 90, 110, .35); }
.btn.danger:hover { background: rgba(255, 90, 110, .12); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.field .help { font-size: 12px; color: var(--ink-3); }

input[type='text'], input[type='password'], input[type='number'], input[type='datetime-local'], select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  outline: none;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 74px; font-family: var(--body); }

.check { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); flex: 0 0 auto; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .row2, .row3 { grid-template-columns: 1fr; } }

.pad { padding: 16px 18px; }

.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- admin tables ------------------------------------------------------- */

.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
.tbl th { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num-cell { text-align: right; font-variant-numeric: tabular-nums; }

.tbl-scroll { overflow-x: auto; }

.link-cell { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--ink-2); }

.place-input { width: 66px; text-align: center; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2);
}
.tag.on { border-color: rgba(61, 220, 132, .4); color: var(--ok); }
.tag.off { border-color: rgba(255, 90, 110, .35); color: var(--miss); }

/* ---- team entry --------------------------------------------------------- */

.label-row {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: 8px;
}

#team-places { margin: 4px 0 16px; }

.team-grid { display: flex; flex-wrap: wrap; gap: 8px; }

.team-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}
.team-chip b {
  font-family: var(--display);
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.team-chip input { width: 62px; text-align: center; }

/* ---- reset rows --------------------------------------------------------- */

.reset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
}
.reset-row:last-child { padding-bottom: 0; }
.reset-row b { display: block; font-size: 14px; font-weight: 600; }
.reset-row .help { display: block; margin-top: 2px; }
.reset-row .btn { flex: 0 0 auto; }

@media (max-width: 560px) {
  .reset-row { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ---- toast -------------------------------------------------------------- */

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow);
  font-size: 14px; z-index: 50; max-width: calc(100% - 32px);
}
.toast.bad { border-color: rgba(255, 90, 110, .5); color: #ffd7dc; }

/* ---- misc --------------------------------------------------------------- */

.center-card { max-width: 380px; margin: 12vh auto 0; }

.loading { padding: 40px 18px; text-align: center; color: var(--ink-3); }

.foot { margin-top: 30px; text-align: center; color: var(--ink-3); font-size: 12px; }

@media (max-width: 560px) {
  .lb-row { grid-template-columns: 38px 1fr auto; padding: 11px 13px; gap: 9px; }
  .lb-name { font-size: 20px; }
  .lb-total { font-size: 25px; }
  .live-row { grid-template-columns: 32px 1fr 60px; padding: 10px 13px; }
  .live-row .live-bar { display: none; }
  .shell { padding: 0 12px 60px; }
}
