:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --border: #e6e1d8;
  --text: #1d1b18;
  --muted: #6f6a61;
  --accent: #d9480f;
  --accent-soft: #fff0e6;
  --up: #2b8a3e;
  --down: #c92a2a;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312;
    --surface: #1e1c1a;
    --border: #33302c;
    --text: #f1ede6;
    --muted: #a09a8f;
    --accent: #ff8a4c;
    --accent-soft: #33221a;
    --up: #69db7c;
    --down: #ff8787;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 760px; margin: 0 auto; padding: 48px 16px 80px; }

header h1 { margin: 0; font-size: 2.25rem; letter-spacing: -0.03em; }
header h1 span { color: var(--accent); }
header p { margin: 6px 0 0; color: var(--muted); }

h2 {
  margin: 40px 0 12px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Matchup */
.matchup { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: stretch; }
.contender {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.contender:focus-visible, .contender:active {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}
/* Hover only where there is a real pointer, so it doesn't stick after a tap. */
@media (hover: hover) {
  .contender:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-2px);
  }
}
.contender .name { display: block; font-size: 1.2rem; font-weight: 650; }
.contender .tag { display: block; color: var(--muted); font-size: 0.9rem; }
.contender .about { display: block; margin-top: 10px; color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.vs { align-self: center; color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.matchup-actions { margin-top: 10px; text-align: center; }

button.link {
  background: none; border: none; padding: 4px 8px;
  color: var(--muted); font: inherit; font-size: 0.9rem;
  cursor: pointer; text-decoration: underline;
}
button.link:hover { color: var(--text); }

/* Leaderboard */
.board {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.row:first-child { border-top: none; }
.rank { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.row:nth-child(-n+3) .rank { color: var(--accent); }
.row .name { font-weight: 600; }
.row .tag { color: var(--muted); font-size: 0.85rem; }
.record { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.record .up { color: var(--up); }
.record .down { color: var(--down); }
.score { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 3.2em; text-align: right; }

.board-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 40px; }
.board-head h2 { margin: 0; }
#total { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.board-note { margin: 4px 0 12px; color: var(--muted); font-size: 0.85rem; }

header { text-align: center; }
nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
nav a {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 600;
}
nav a:hover { color: var(--text); }
nav a[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.arrow {
  width: 0.95em; height: 0.95em; margin-right: 2px; vertical-align: -0.12em;
  fill: none; stroke: currentColor; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round;
}
.record .up, .record .down { font-weight: 650; }
#skip { color: color-mix(in srgb, var(--text) 65%, var(--muted)); }
#skip:hover { color: var(--text); }
.question { text-align: center; }

.row > div { min-width: 0; overflow-wrap: anywhere; }
.contender .name { overflow-wrap: anywhere; }

/* Phones */
@media (max-width: 520px) {
  main {
    padding: 28px max(16px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  header h1 { font-size: 1.9rem; }
  header p { font-size: 0.95rem; }
  h2 { margin-top: 28px; }

  nav a { padding: 10px 14px; }

  .matchup { grid-template-columns: 1fr; gap: 6px; }
  .vs { justify-self: center; }
  .contender { padding: 20px 16px; }
  #skip { padding: 12px 20px; font-size: 1rem; }

  /* Votes move under the name instead of taking their own column.
     The rank column is wide enough for three digits: the problems board has more than 99 rows. */
  .row {
    grid-template-columns: 32px 1fr auto;
    grid-template-areas: "rank info score" "rank record score";
    gap: 2px 10px;
    padding: 12px;
  }
  .row .rank { grid-area: rank; }
  .row > div { grid-area: info; }
  .row .record { grid-area: record; }
  .row .score { grid-area: score; min-width: 0; }

  .board-head { margin-top: 28px; }
}
[hidden] { display: none !important; }
#notice { margin: 6px 0 0; min-height: 1.5em; color: var(--muted); font-size: 0.9rem; }

/* Progress timeline */
#timeline h2 { margin: 32px 0 12px; font-size: 1rem; letter-spacing: 0.04em; color: var(--text); }
#timeline h2:first-child { margin-top: 16px; }
/* The notice is empty unless the timeline fails to load, so it takes no room. */
.board-head + #notice:empty { display: none; }
/* The left border is the line; each entry hangs a dot on it. */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.event {
  position: relative;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.event:last-child { margin-bottom: 0; }
.event.is-solved { border-color: color-mix(in srgb, var(--up) 55%, var(--border)); }
@media (hover: hover) {
  .event { transition: border-color 0.15s; }
  .event:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
}
/* The dot is 18px wide with its ring, and its middle sits on the middle of the 2px line. */
.event::before {
  content: ""; position: absolute; left: -29px; top: 16px;
  box-sizing: border-box; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg);
}
.event-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sep { margin: 0 7px; color: var(--muted); opacity: 0.8; }
.event-meta { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.event-title { margin-top: 6px; overflow-wrap: anywhere; }
.event-title .name { font-size: 1.05rem; font-weight: 650; }
.event p { margin: 6px 0 0; }
.event-summary { line-height: 1.45; }
.event-by, .event-links { color: var(--muted); font-size: 0.85rem; }
/* A larger gap above the credit line parts the description from the details. */
.event .event-by { margin-top: 12px; }
.event-by .by { font-weight: 650; color: var(--text); }
.event.ai .event-by .by { color: var(--accent); }
.event-links a { color: var(--accent); font-weight: 600; text-decoration: none; }
.event-links a:hover { text-decoration: underline; }
.status {
  padding: 1px 8px; border: 1px solid currentColor; border-radius: 999px;
  font-size: 0.7rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.status.solved { color: var(--up); }
.status.verified { color: var(--accent); }
.status.claimed { color: var(--muted); }

/* Humans vs AIs score, above the timeline */
.scoreboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: stretch; }
.scoreboard .side {
  display: flex; flex-direction: column; min-width: 0; padding: 12px 8px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.scoreboard .count { display: block; font-size: 1.9rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--accent); }
.scoreboard .name { display: block; font-weight: 650; }
/* Each counter takes the colour of its dots on the timeline. */
.scoreboard .name::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 50%;
  background: var(--accent);
}
.scoreboard .human .name::before { background: var(--muted); }
.scoreboard .both .name::before { background: linear-gradient(90deg, var(--muted) 50%, var(--accent) 50%); }
.scoreboard .human .count { color: var(--text); }
/* One colour between the two, so the number does not look broken in half. */
.scoreboard .both .count { color: color-mix(in srgb, var(--text) 50%, var(--accent)); }
.scoreboard .tag { display: block; margin-top: auto; color: var(--muted); font-size: 0.85rem; }
/* Entries by humans get a grey dot, entries by AIs keep the accent dot, and shared ones get half of each. */
.event.human::before { background: var(--muted); }
.event.both::before { background: linear-gradient(90deg, var(--muted) 50%, var(--accent) 50%); }

/* One bar in three parts between the tabs and the score: doom, nothing happens, bloom.
   The block sets --doom, --none and --bloom; they give the widths of the bar and of the labels above it. */
.odds {
  padding: 12px 18px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
/* Each number stands over its own part of the bar. */
.odds-items {
  display: grid; align-items: end;
  grid-template-columns: calc(var(--doom) * 1%) calc(var(--none) * 1%) calc(var(--bloom) * 1%);
}
.odd { min-width: 0; text-align: center; }
.odd.doom { text-align: left; white-space: nowrap; }
.odd-value { display: block; font-size: 1.5rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.odd-label { display: block; margin-top: 2px; font-size: 0.75rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.doom .odd-value { color: var(--down); }
.none .odd-value { color: var(--muted); }
.bloom .odd-value { color: var(--up); }
/* One bar: the three colours touch, and only the ends of the bar are round. */
.odds-bar { display: flex; height: 12px; margin-top: 8px; border-radius: 999px; overflow: hidden; }
.odds-bar .doom { width: calc(var(--doom) * 1%); background: var(--down); }
.odds-bar .none { width: calc(var(--none) * 1%); background: color-mix(in srgb, var(--muted) 55%, var(--surface)); }
.odds-bar .bloom { width: calc(var(--bloom) * 1%); background: var(--up); }
.odds-note { margin: 8px 0 0; color: var(--muted); font-size: 0.85rem; line-height: 1.45; text-align: center; }
/* On a phone the first part of the bar is too narrow for its label, so the labels go left, middle and right. */
@media (max-width: 520px) {
  .odds-items { grid-template-columns: 1fr 2fr 1fr; gap: 8px; }
  .odd.bloom { text-align: right; }
  .odd-value { font-size: 1.35rem; }
  .odd-label { font-size: 0.68rem; letter-spacing: 0.03em; }
}

/* Progress page on a phone: "Humans & AI" stays on one line, and the cards use less padding. */
@media (max-width: 520px) {
  .scoreboard { gap: 8px; }
  .scoreboard .side { padding: 12px 4px; }
  .scoreboard .count { font-size: 1.7rem; }
  .scoreboard .name { font-size: 0.82rem; white-space: nowrap; }
  .scoreboard .name::before { width: 7px; height: 7px; margin-right: 5px; }
  .scoreboard .tag { font-size: 0.78rem; }
  .odds { padding: 12px 14px 12px; }
  .timeline { padding-left: 14px; }
  .event { padding: 14px; margin-bottom: 16px; }
  .event::before { left: -25px; top: 14px; }
}

/* Very narrow phones: the counter labels get smaller and lose their dot, so "Humans & AI" stays inside its tile. */
@media (max-width: 360px) {
  .scoreboard .name { font-size: 0.74rem; }
  .scoreboard .name::before { display: none; }
}
