:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #151a24;
  --surface-strong: #1c2330;
  --ink: #f8fafc;
  --muted: #8f9db2;
  --line: #334155;
  --blue: #3b82f6;
  --green: #4ade80;
  --amber: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.site-header, main, footer {
  width: min(calc(100% - 32px), 820px);
  margin-inline: auto;
}

.site-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #263244;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 900; text-decoration: none; }
.brand img { border-radius: 8px; }
.install-link { color: #93c5fd; font-size: .875rem; font-weight: 800; text-decoration: none; }

main { padding: 42px 0 56px; }
.leaderboard { display: grid; gap: 22px; }
.leaderboard-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: .78rem; font-weight: 900; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 2.75rem; line-height: 1.05; max-width: 560px; text-wrap: balance; }
.updated { margin: 0 0 4px; color: var(--muted); font-size: .8rem; white-space: nowrap; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px; border-radius: 8px; background: #0a0e14; border: 1px solid #263244; }
.tab { min-height: 44px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 850; cursor: pointer; }
.tab.active { background: var(--surface-strong); color: var(--ink); }
.tab:focus-visible, button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #60a5fa; outline-offset: 2px; }

.table-shell { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.table-head, .score-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) 110px; align-items: center; }
.table-head { min-height: 42px; padding: 0 18px; color: var(--muted); font-size: .72rem; font-weight: 850; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.table-head span:last-child { text-align: right; }
.score-list { margin: 0; padding: 0; list-style: none; }
.score-row { min-height: 72px; padding: 10px 18px; border-bottom: 1px solid #263244; }
.score-row:last-child { border-bottom: 0; }
.score-row[data-medal="1"] { background: #252112; }
.score-row[data-medal="2"] { background: #1c2129; }
.score-row[data-medal="3"] { background: #241a15; }
.rank-value { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 850; }
.score-row[data-medal="1"] .rank-value { color: var(--amber); }
.player-cell { min-width: 0; display: grid; gap: 4px; }
.player-cell strong, .player-cell small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-cell strong { font-size: .95rem; }
.player-cell small { color: var(--muted); font-size: .75rem; }
.score-value { text-align: right; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.empty-state, .error-state { min-height: 180px; padding: 32px; display: grid; place-content: center; gap: 10px; text-align: center; }
.empty-state span { color: var(--muted); }
.error-state button { min-height: 42px; border: 0; border-radius: 6px; background: var(--blue); color: white; font-weight: 850; cursor: pointer; }

.player-search { display: grid; gap: 8px; }
.player-search label { font-size: .82rem; font-weight: 850; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.search-row input { min-width: 0; height: 48px; padding: 0 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); }
.search-row button { min-width: 90px; border: 0; border-radius: 7px; background: var(--blue); color: white; font-weight: 850; cursor: pointer; }
#search-result { min-height: 20px; margin: 0; color: var(--muted); font-size: .82rem; }

.shared-result { margin-top: 60px; padding-top: 36px; border-top: 1px solid var(--line); text-align: center; }
.shared-result h2 { color: var(--muted); font-size: 1.1rem; }
.result-score { margin: 14px 0 28px; font-size: clamp(4rem, 16vw, 6rem); line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums; }
.result-score small { margin-left: 8px; color: var(--muted); font-size: 1rem; }
.run-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; border-block: 1px solid var(--line); }
.run-stats div { padding: 18px 8px; }
.run-stats div + div { border-left: 1px solid var(--line); }
.run-stats dt { color: var(--muted); font-size: .75rem; }
.run-stats dd { margin: 6px 0 0; font-size: 1.1rem; font-weight: 850; }

footer { padding: 22px 0 36px; color: #66758b; font-size: .75rem; border-top: 1px solid #263244; }
[hidden] { display: none !important; }

@media (max-width: 560px) {
  .site-header, main, footer { width: calc(100% - 24px); max-width: none; }
  main { padding-top: 28px; }
  h1 { font-size: 2rem; }
  .leaderboard-heading { align-items: start; flex-direction: column; gap: 12px; }
  .updated { align-self: flex-end; }
  .leaderboard, .table-shell, .tabs { min-width: 0; max-width: 100%; }
  .tab { min-width: 0; }
  .table-head, .score-row { grid-template-columns: 42px minmax(0, 1fr) 70px; padding-inline: 10px; }
  .player-cell small { font-size: .68rem; }
  .score-value { font-size: .92rem; }
  .search-row { grid-template-columns: 1fr; }
  .search-row button { min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
