:root {
  color-scheme: light;
  --ground: #fcfcfb;
  --surface: #ffffff;
  --surface-2: #f4f3ee;
  --line: #e5e4de;
  --line-soft: #efeee9;
  --ink: #16150f;
  --ink-2: #56554d;
  --ink-3: #8a887d;
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, .14);
  --official: #eb6834;
  --form: #1baf7a;
  --good: #1baf7a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #1a1a19;
    --surface: #212120;
    --surface-2: #2a2a27;
    --line: #35352f;
    --line-soft: #2c2c28;
    --ink: #f6f5ef;
    --ink-2: #c3c2b7;
    --ink-3: #8d8b80;
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, .20);
    --official: #d95926;
    --form: #199e70;
    --good: #199e70;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #1a1a19;
  --surface: #212120;
  --surface-2: #2a2a27;
  --line: #35352f;
  --line-soft: #2c2c28;
  --ink: #f6f5ef;
  --ink-2: #c3c2b7;
  --ink-3: #8d8b80;
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, .20);
  --official: #d95926;
    --form: #199e70;
  --good: #199e70;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: Archivo, "IBM Plex Sans", sans-serif; margin: 0; text-wrap: balance; }
h1 { font-size: 27px; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
.n { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 80px; }

/* ---------------------------------------------------------------- header */
.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top-in {
  max-width: 1080px; margin: 0 auto; padding: 16px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.brand a { color: var(--ink); }
.brand .tag {
  font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3);
}
.top .src { font-size: 13px; color: var(--ink-2); }
.themer {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  border-radius: 5px; padding: 5px 10px; font-size: 12.5px; cursor: pointer;
  font-family: inherit;
}
.themer:hover { color: var(--ink); }

/* ------------------------------------------------------------- summary */
.hero { padding: 28px 0 22px; display: flex; flex-direction: column; gap: 12px; }
.hero p { color: var(--ink-2); max-width: 68ch; }
.facts { display: flex; flex-wrap: wrap; gap: 7px; }
.facts span {
  font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--ink-2);
  background: var(--surface-2); border-radius: 3px; padding: 4px 9px;
}

/* --------------------------------------------------------------- toolbar */
.tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.tools input[type="search"] {
  flex: 1 1 240px; min-width: 0; padding: 9px 12px; font: inherit;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
}
.tools label {
  display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--ink-2);
  user-select: none; cursor: pointer;
}
.count { font-size: 13px; color: var(--ink-3); margin-left: auto; }

/* ----------------------------------------------------------------- table */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
th:nth-child(2), td:nth-child(2) { text-align: left; white-space: normal; }
thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  font-size: 11.5px; font-weight: 500; color: var(--ink-2); cursor: pointer;
  letter-spacing: .02em;
}
thead th:hover { color: var(--ink); }
thead th .ind { color: var(--accent); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.rank { color: var(--ink-3); width: 52px; }
td.name { font-weight: 500; }
td.rating { font-size: 15.5px; font-weight: 500; }
.band {
  display: inline-block; font-family: "IBM Plex Mono", monospace; font-size: 11px;
  padding: 2px 6px; border-radius: 3px; background: var(--surface-2);
  color: var(--ink-2); border: 1px solid var(--line);
}
.prov { color: var(--ink-3); font-size: 11.5px; }
.rel { display: flex; align-items: center; gap: 7px; justify-content: flex-end; }
.rel .bar { width: 42px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.rel .bar i { display: block; height: 100%; background: var(--accent); }
.up { color: var(--good); }
.down { color: var(--official); }

/* ---------------------------------------------------------------- player */
.back { display: inline-block; font-size: 13.5px; margin: 22px 0 14px; }
.phead { display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: flex-end; margin-bottom: 22px; }
.phead .who { display: flex; flex-direction: column; gap: 4px; }
.phead .big { font-family: "IBM Plex Mono", monospace; font-size: 46px; font-weight: 500; line-height: 1; letter-spacing: -.03em; }
.phead .sub { font-size: 13px; color: var(--ink-3); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 22px; }
.stat { background: var(--surface); padding: 13px 15px; display: flex; flex-direction: column; gap: 3px; }
.stat .k { font-size: 11.5px; color: var(--ink-3); }
.stat .v { font-family: "IBM Plex Mono", monospace; font-size: 19px; font-variant-numeric: tabular-nums; }

.chartbox { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px 16px 8px; position: relative; margin-bottom: 22px; }
.chartbox svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-bottom: 10px; }
.legend b { display: inline-flex; align-items: center; gap: 7px; font-weight: 400; }
.legend i { width: 15px; height: 2.5px; border-radius: 2px; display: block; }
.legend .l4 i { width: 8px; height: 8px; border-radius: 50%; background: var(--form); }
.legend .l1 i { background: var(--accent); }
.legend .l2 i { background: var(--official); height: 0; border-top: 2px dashed var(--official); }
.legend .l3 i { background: var(--accent-soft); height: 9px; border-radius: 2px; }
.grid { stroke: var(--line-soft); }
.ax { fill: var(--ink-3); font-family: "IBM Plex Mono", monospace; font-size: 10px; }
.band-area { fill: var(--accent-soft); }
.line-main { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-off { fill: none; stroke: var(--official); stroke-width: 2; stroke-dasharray: 5 4; }
.dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
/* form on the day: the reading, the line is the claim */
.form-dot { fill: var(--form); stroke: var(--surface); stroke-width: 1.2; }
.form-dot.bound { fill: var(--surface); stroke: var(--form); stroke-width: 1.6; }
.form-stem { stroke: var(--form); stroke-width: 1; opacity: .30; }
.hit { fill: transparent; cursor: pointer; }
.tip {
  position: absolute; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 11px; font-size: 12.5px; box-shadow: var(--shadow); z-index: 5;
  max-width: 260px;
}
.tip .t1 { font-weight: 500; margin-bottom: 3px; }
.tip .t2 { color: var(--ink-2); font-family: "IBM Plex Mono", monospace; font-size: 11.5px; }

/* ----------------------------------------------------- band scale figure */
.scalesec { margin-top: 34px; display: flex; flex-direction: column; gap: 12px; }
.scalefig { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px 14px; }
.scalefig svg { display: block; width: 100%; height: auto; }
.scalefig figcaption { margin-top: 10px; font-size: 12.5px; color: var(--ink-3); line-height: 1.5; max-width: 78ch; }
.hbar { fill: var(--accent); opacity: .55; }
.seg { fill: var(--surface-2); stroke: var(--line); stroke-width: 1; }
.seg.extra { fill: var(--surface-2); }
.hatch { stroke: var(--line); stroke-width: 2.5; }
.seglab { fill: var(--ink-2); font-family: "IBM Plex Mono", monospace; font-size: 12px; font-weight: 500; }
.segcut { fill: var(--ink-3); font-family: "IBM Plex Mono", monospace; font-size: 10px; }
.mark { stroke: var(--official); stroke-width: 2; }
.marklab { fill: var(--official); font-family: "IBM Plex Mono", monospace; font-size: 11.5px; font-weight: 500; }

.note { font-size: 13px; color: var(--ink-3); margin-top: 12px; max-width: 72ch; }
.about { margin-top: 44px; border-top: 1px solid var(--line); padding-top: 26px; display: flex; flex-direction: column; gap: 14px; font-size: 14px; color: var(--ink-2); max-width: 76ch; }
.about b { color: var(--ink); font-weight: 500; }
.about ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.about code { font-family: "IBM Plex Mono", monospace; font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 3px; }

.loading { padding: 60px 0; text-align: center; color: var(--ink-3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (max-width: 640px) {
  .phead .big { font-size: 38px; }
  h1 { font-size: 22px; }
}

/* ------------------------------------------------------------ tournament */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
tr.clickable { cursor: pointer; }
.hint { font-weight: 400; color: var(--ink-3); font-size: 12.5px; }

.ehead { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
.ehead h2 { font-size: 26px; letter-spacing: -.018em; }
.ehead .eyebrow {
  font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3);
}
.champ {
  display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 11px 14px; align-self: flex-start; max-width: 100%;
}
.champ .trophy { font-size: 16px; line-height: 1; }
.champ b { font-weight: 500; color: var(--ink); }
.champ b i { font-style: normal; color: var(--ink-3); margin: 0 3px; }
.champ .cs { font-family: "IBM Plex Mono", monospace; font-size: 12.5px; color: var(--ink-3); margin-left: 6px; }

/* --- tabs --- */
.tabs {
  display: flex; gap: 2px; overflow-x: auto; margin-bottom: 18px;
  border-bottom: 1px solid var(--line); scrollbar-width: thin;
}
.tab {
  flex: 0 0 auto; font: inherit; font-size: 13px; cursor: pointer; position: relative;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--ink-3); padding: 9px 13px; white-space: nowrap; display: flex;
  align-items: baseline; gap: 6px; margin-bottom: -1px;
}
.tab em {
  font-style: normal; font-family: "IBM Plex Mono", monospace; font-size: 10.5px;
  color: var(--ink-3); background: var(--surface-2); border-radius: 8px; padding: 1px 6px;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }
.tab.on em { background: var(--accent-soft); color: var(--accent); }

/* --- final table --- */
.stand {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.srow {
  background: var(--surface); padding: 11px 16px; display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 58px 132px 52px;
  align-items: center; gap: 12px;
}
.srow .pos {
  font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--ink-3);
  text-align: center; width: 26px; height: 26px; line-height: 26px; border-radius: 50%;
}
.srow.podium .pos { background: var(--surface-2); color: var(--ink); font-weight: 500; }
.srow.p1 .pos { background: var(--accent); color: #fff; }
.srow .who { font-size: 14px; min-width: 0; }
.srow.podium .who { font-weight: 500; }
.srow .amp { font-style: normal; color: var(--ink-3); margin: 0 5px; }
.srow .wl { font-size: 13px; color: var(--ink-2); text-align: right; }
.srow .wl i { font-style: normal; color: var(--ink-3); margin: 0 1px; }
.srow .pts { display: flex; align-items: center; gap: 9px; }
.srow .ptsbar { flex: 1; height: 5px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.srow .ptsbar i { display: block; height: 100%; background: var(--accent-soft); }
.srow.podium .ptsbar i { background: var(--accent); opacity: .55; }
.srow .pts b { font-weight: 500; font-size: 13.5px; min-width: 34px; text-align: right; }
.srow .diff { font-size: 12.5px; text-align: right; color: var(--ink-3); }
.legendline { font-size: 12.5px; color: var(--ink-3); margin-top: 10px; max-width: 70ch; }

/* --- rounds --- */
.roundhead { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.roundhead h3 { font-size: 15px; }
.roundhead span { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; color: var(--ink-3); }
.matches {
  display: flex; flex-direction: column; gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.match {
  background: var(--surface); padding: 12px 16px; display: grid;
  grid-template-columns: 52px 1fr 92px 1fr; align-items: center; gap: 12px;
}
.match:hover { background: var(--surface-2); }
.match .court {
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px; color: var(--ink-3);
  letter-spacing: .04em;
}
.match .court:not(:empty)::before { content: 'court '; }
.match .side {
  font-size: 13.5px; color: var(--ink-3); display: flex; align-items: center;
  gap: 8px; min-width: 0; position: relative;
}
.match .side:first-of-type { justify-content: flex-end; text-align: right; }
.match .side .names { min-width: 0; }
.match .side .amp { font-style: normal; color: var(--line); margin: 0 4px; }
.match .side.won { color: var(--ink); }
.match .side.won .names { font-weight: 500; }
.match .dot {
  flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line);
}
.match .side.won .dot { background: var(--accent); border-color: var(--accent); }
.match .score {
  display: flex; align-items: center; justify-content: center; gap: 3px;
  background: var(--surface-2); border-radius: 6px; padding: 5px 8px;
}
.match .score b { font-weight: 500; font-size: 15px; color: var(--ink-3); }
.match .score b.won { color: var(--ink); }
.match .score i { font-style: normal; color: var(--ink-3); opacity: .5; }
.unreg { color: inherit; opacity: .72; border-bottom: 1px dotted var(--line); }

@media (max-width: 720px) {
  .srow { grid-template-columns: 30px minmax(0, 1fr) 52px 46px; gap: 9px; padding: 10px 12px; }
  .srow .pts .ptsbar { display: none; }
  .match { grid-template-columns: 1fr 78px 1fr; padding: 11px 12px; gap: 8px; }
  .match .court { display: none; }
  .match .side { font-size: 12.5px; }
}
