:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #16181d;
  --ink-2: #4a505c;
  --muted: #6b7280;
  --line: #e4e7ec;
  --accent: #2a6fdb;
  --accent-soft: #e6effc;
  --gold: #c8961e;
  --silver: #8a94a3;
  --bronze: #b0703c;
  --bar: #2a6fdb;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a21; --ink: #eef0f4; --ink-2: #b8bfcc; --muted: #8b93a3;
    --line: #2a2f3a; --accent: #6ea2ff; --accent-soft: #1d2a42; --bar: #6ea2ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a21; --ink: #eef0f4; --ink-2: #b8bfcc; --muted: #8b93a3;
  --line: #2a2f3a; --accent: #6ea2ff; --accent-soft: #1d2a42; --bar: #6ea2ff; color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 12px; }
.brand { color: var(--ink); display: flex; gap: 8px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand:hover { text-decoration: none; }
.logo { font-size: 20px; }
.links { display: flex; gap: 16px; }
.links a { color: var(--ink-2); }

h1 { font-size: 26px; margin: 28px 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 28px 0 12px; }
.lede { color: var(--ink-2); margin: 0 0 20px; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 20px; }
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 4px; overflow-x: auto; max-width: 100%; }
.tabs button {
  border: 0; background: none; color: var(--ink-2); padding: 6px 12px; border-radius: 7px;
  font: inherit; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }
select, input[type="search"] {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 10px; min-width: 0;
}
input[type="search"] { flex: 1 1 180px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 13px; }

.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; margin-bottom: 24px; }
.pod {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 12px; text-align: center; color: var(--ink); display: block;
}
.pod:hover { text-decoration: none; border-color: var(--accent); }
.pod img { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--medal); }
.pod.p1 { padding-top: 28px; --medal: var(--gold); }
.pod.p2 { --medal: var(--silver); }
.pod.p3 { --medal: var(--bronze); }
.pod .place { font-weight: 700; color: var(--medal); }
.pod .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .pts { font-size: 20px; font-weight: 700; }

.board { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 14px; border-top: 1px solid var(--line); color: var(--ink);
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--accent-soft); text-decoration: none; }
.rank { font-weight: 700; color: var(--muted); text-align: center; }
.person { display: flex; gap: 10px; align-items: center; min-width: 0; }
.person img { width: 36px; height: 36px; border-radius: 50%; flex: none; background: var(--line); }
.person .names { min-width: 0; }
.person .login { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12.5px; color: var(--muted); }
.score { text-align: right; }
.score b { font-size: 18px; }
.score .share { height: 4px; background: var(--line); border-radius: 2px; width: 90px; margin-top: 4px; }
.score .share i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

.profile-head { display: flex; gap: 16px; align-items: center; margin: 24px 0 8px; }
.profile-head img { width: 80px; height: 80px; border-radius: 50%; }
.profile-head h1 { margin: 0; }
.ranks { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); }
.chart .bar { fill: var(--bar); }
.chart rect.hit { fill: transparent; }
.chart g:hover .bar { opacity: .75; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; border-top: 0; }
td.r, th.r { text-align: right; }

.rules td:first-child { width: 60%; }
.tip {
  position: fixed; pointer-events: none; z-index: 10; background: var(--ink); color: var(--bg);
  padding: 6px 9px; border-radius: 8px; font-size: 12.5px; white-space: nowrap;
}
.foot { padding: 32px 16px 40px; font-size: 13px; }

@media (max-width: 640px) {
  .two { grid-template-columns: 1fr; }
  .podium { gap: 8px; }
  .pod img { width: 48px; height: 48px; }
  .pod .pts { font-size: 16px; }
  .score .share { width: 60px; }
  .chips .opt { display: none; }
  h1 { font-size: 22px; }
}
