:root {
  color-scheme: dark;
  --bg-a: oklch(17% 0.03 325);
  --bg-b: oklch(12% 0.025 325);
  --surface: oklch(21% 0.034 325);
  --surface-raised: oklch(24% 0.038 325);
  --surface-soft: oklch(100% 0 0 / 0.055);
  --surface-hover: oklch(100% 0 0 / 0.09);
  --border: oklch(100% 0 0 / 0.1);
  --gold: oklch(80% 0.14 85);
  --gold-ink: oklch(20% 0.04 85);
  --coral: oklch(72% 0.16 35);
  --text-high: oklch(97% 0.012 85);
  --text: oklch(92% 0.014 85);
  --text-muted: oklch(72% 0.025 315);
  --text-faint: oklch(61% 0.025 315);
  --serif: "Noto Serif", Georgia, serif;
  --sans: "Noto Sans", "Segoe UI", Arial, sans-serif;
  --shadow-card: 0 18px 45px oklch(6% 0.02 325 / 0.32);
  --focus: 0 0 0 3px oklch(80% 0.14 85 / 0.8);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg-b); }
body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -10%, oklch(38% 0.09 325 / 0.28), transparent 36rem),
    radial-gradient(circle at 95% 8%, oklch(42% 0.08 25 / 0.13), transparent 30rem),
    linear-gradient(180deg, var(--bg-a), var(--bg-b));
  font: 400 16px/1.55 var(--sans);
  overflow-x: hidden;
}

button, a { touch-action: manipulation; }
button { color: inherit; font: inherit; }
a { color: inherit; }
button:focus-visible, a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--gold);
  color: var(--gold-ink);
  font-weight: 700;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.leaderboard-topbar {
  width: min(1120px, calc(100% - 32px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.back-link, .brand-mark {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
}
.back-link { padding: 0 8px; margin-left: -8px; color: var(--text-muted); }
.back-link:hover { color: var(--text-high); }
.brand-mark { color: var(--text-high); font: 700 15px/1 var(--serif); }
.brand-mark img { width: 38px; height: 38px; object-fit: contain; }

.leaderboard-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 72px;
  display: grid;
  gap: 22px;
}
.leaderboard-hero { padding: 8px 4px 0; }
.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.3;
  text-transform: uppercase;
}
.leaderboard-hero h1 {
  margin: 6px 0 0;
  color: var(--text-high);
  font: 700 clamp(32px, 6vw, 52px)/1.14 var(--serif);
  letter-spacing: -0.025em;
}
.leaderboard-hero > p:last-child {
  max-width: 58ch;
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 15px;
}
.leaderboard-card {
  min-width: 0;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(145deg, oklch(23% 0.04 325 / .96), oklch(18% 0.028 325 / .96));
  box-shadow: var(--shadow-card);
}
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.section-heading h2 {
  margin: 4px 0 0;
  color: var(--text-high);
  font: 700 24px/1.25 var(--serif);
}
.refresh-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 0 12px;
  border: 1px solid oklch(80% .14 85 / .35);
  border-radius: 11px;
  background: oklch(80% .14 85 / .08);
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.refresh-button > span:first-child { font-size: 20px; line-height: 1; }
.refresh-button:hover { background: oklch(80% .14 85 / .16); }
.refresh-button:disabled { cursor: wait; opacity: .55; }
.privacy-note {
  margin: 14px 0 0;
  color: var(--text-faint);
  font-size: 12px;
}
.leaderboard-status {
  min-height: 20px;
  margin: 20px 0 12px;
  color: var(--text-muted);
  font-size: 12px;
}
.leaderboard-status.is-loading { opacity: .65; }
.leaderboard-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
}
.leaderboard-podium-card {
  min-width: 0;
  min-height: 164px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 18px 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
  text-align: center;
}
.leaderboard-podium-card.place-1 {
  min-height: 196px;
  order: 2;
  border-color: oklch(80% .14 85 / .75);
  background: linear-gradient(180deg, oklch(80% .14 85 / .2), var(--surface-soft));
}
.leaderboard-podium-card.place-2 { order: 1; border-color: oklch(78% .02 260 / .55); }
.leaderboard-podium-card.place-3 { order: 3; border-color: oklch(68% .12 55 / .55); }
.leaderboard-place { color: var(--gold); font-size: 14px; font-weight: 800; }
.place-2 .leaderboard-place { color: oklch(84% .02 260); }
.place-3 .leaderboard-place { color: oklch(75% .13 55); }
.leaderboard-avatar { width: 72px; height: 72px; display: inline-grid; place-items: center; border-radius: 50%; font-size: 34px; line-height: 1; }
.leaderboard-avatar, .leaderboard-row-icon { overflow: hidden; }
.leaderboard-avatar img, .leaderboard-row-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.leaderboard-podium-card strong {
  max-width: 100%;
  color: var(--text-high);
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.leaderboard-podium-card small { color: var(--text-muted); font-size: 11px; line-height: 1.3; }
.leaderboard-list { display: grid; gap: 8px; margin-top: 12px; }
.leaderboard-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-soft);
}
.leaderboard-number { color: var(--text-muted); font-size: 13px; font-weight: 800; }
.leaderboard-row-icon { width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 50%; font-size: 22px; line-height: 1; text-align: center; }
.leaderboard-row-copy { min-width: 0; }
.leaderboard-row-copy strong, .leaderboard-row-copy small { display: block; overflow-wrap: anywhere; }
.leaderboard-row-copy strong { color: var(--text-high); font-size: 14px; line-height: 1.3; }
.leaderboard-row-copy small { margin-top: 2px; color: var(--text-muted); font-size: 12px; }
.leaderboard-xp { color: var(--gold); font-size: 13px; font-weight: 800; white-space: nowrap; }
.return-link {
  width: max-content;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.return-link:hover { color: var(--text-high); }

@media (max-width: 560px) {
  .leaderboard-topbar { width: min(100% - 28px, 1120px); }
  .brand-mark span { display: none; }
  .leaderboard-shell { width: min(100% - 28px, 920px); padding-top: 20px; }
  .leaderboard-hero h1 { font-size: 36px; }
  .leaderboard-hero > p:last-child { font-size: 14px; }
  .leaderboard-card { border-radius: 18px; }
  .section-heading h2 { font-size: 21px; }
  .refresh-button { width: 42px; padding: 0; justify-content: center; }
  .refresh-button > span:last-child { display: none; }
  .leaderboard-podium { gap: 7px; }
  .leaderboard-podium-card { min-height: 132px; padding: 12px 5px; }
  .leaderboard-podium-card.place-1 { min-height: 156px; }
  .leaderboard-avatar { width: 54px; height: 54px; font-size: 27px; }
  .leaderboard-podium-card strong { font-size: 11px; }
  .leaderboard-podium-card small { font-size: 9px; }
  .leaderboard-row { grid-template-columns: 30px 24px minmax(0, 1fr) auto; gap: 7px; padding: 10px 8px; }
  .leaderboard-row-icon { width: 24px; height: 24px; font-size: 18px; }
  .leaderboard-row-copy strong { font-size: 12px; }
  .leaderboard-row-copy small, .leaderboard-xp { font-size: 10px; }
}

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