:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --border: #e4e4e0;
  --grid: #ececea;
  --text: #191919;
  --text-2: #666666;
  --accent: #2370cd;
  --s1: #257de0; /* blue */
  --s2: #f47230; /* orange */
  --s3: #00b894; /* aqua */
  --win: #f2a600; /* yellow */
  --muted: #a6a6a6;
  --up: #1d7a33;
  --down: #c2410c;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111111;
    --surface: #191919;
    --border: #2c2c2c;
    --grid: #262626;
    --text: #efefef;
    --text-2: #9c9c9c;
    --accent: #6aabf1;
    --s1: #338ced;
    --s2: #e76624;
    --s3: #00a888;
    --win: #d28e05;
    --muted: #6b6b6b;
    --up: #4ade80;
    --down: #fb923c;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
main { max-width: 1120px; margin: 0 auto; padding: 24px 20px 40px; }
footer { text-align: center; color: var(--text-2); font-size: 13px; padding: 0 0 32px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 4px; }
small { display: block; color: var(--text-2); font-size: 12px; }
small.inline { display: inline; }
.notice { padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text-2); }
.back { display: inline-block; font-size: 14px; margin-bottom: 12px; }

/* home */
.home { max-width: 620px; margin: 10vh auto 0; }
.home h1 { font-size: 36px; }
.lede { color: var(--text-2); font-size: 17px; }
.search input {
  width: 100%; font: inherit; font-size: 18px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.results { list-style: none; padding: 0; margin: 8px 0; background: var(--surface); border-radius: 10px; overflow: hidden; }
.results:empty { display: none; }
.results li { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); }
.results li:last-child { border-bottom: 0; }
.results a { flex: 1; padding: 10px 14px; color: var(--text); }
.results a:hover { background: var(--bg); text-decoration: none; }
.results span { padding: 10px 14px; color: var(--text-2); }
.results .none { padding: 10px 14px; color: var(--text-2); }
.hint { color: var(--text-2); font-size: 13px; }

/* player header */
.who { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.who img, .who .initials { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; }
.who .initials { display: grid; place-items: center; background: var(--border); font-weight: 600; color: var(--text-2); }
.who p { margin: 2px 0 0; color: var(--text-2); }
.progress { margin: 0 0 16px; }
.progress .bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: var(--s1); transition: width 0.4s; }
.progress p { font-size: 13px; color: var(--text-2); margin: 6px 0 0; }

.filters { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; font-size: 14px; color: var(--text-2); }
.filters select { font: inherit; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg button { font: inherit; border: 0; background: none; padding: 5px 12px; border-radius: 6px; color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--bg); color: var(--text); font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.tile .label { font-size: 13px; color: var(--text-2); }
.tile .value { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.tile .note { font-size: 12px; color: var(--text-2); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card .sub { color: var(--text-2); font-size: 13px; margin: 0 0 10px; max-width: 760px; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.find { font: inherit; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); min-width: 260px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols .card { margin-bottom: 0; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }
.td-name { font-size: 22px; margin: 0 0 12px; }

/* tables */
.scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 7px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data .n { text-align: right; white-space: nowrap; }
table.data tr.link { cursor: pointer; }
table.data tr.link:hover td, table.data tbody tr:hover td { background: var(--bg); }
table.data td.date { white-space: nowrap; color: var(--text-2); }
table.data tr.won td:first-child { box-shadow: inset 3px 0 var(--win); }
.trend.up { color: var(--up); }
.trend.down { color: var(--down); }
td.none, li.none { color: var(--text-2); }
.sparkcell { width: 130px; }
.spark path { fill: none; stroke: var(--s1); stroke-width: 1.5; stroke-linejoin: round; }
.spark circle { fill: var(--s1); }
.spark .mid { stroke: var(--grid); }

.moves { padding-left: 20px; margin: 4px 0 16px; font-size: 14px; }
.moves li { margin-bottom: 6px; }
.moves li span { float: right; color: var(--text-2); margin-left: 8px; }
.moves.up b { color: var(--up); }
.moves.down b { color: var(--down); }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .grid text, .chart .axis-title { fill: var(--text-2); font-size: 11px; }
.chart .axis-title { font-size: 12px; }
.chart .empty { fill: var(--text-2); }
.chart .trend { fill: none; stroke: var(--text); stroke-opacity: 0.55; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .diag { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .dot { fill: var(--s1); fill-opacity: 0.75; stroke: var(--surface); stroke-width: 1.5; transition: r 0.1s; }
.chart .dot.hover { r: 7; fill-opacity: 1; }
.chart .dot.won { fill: var(--win); fill-opacity: 1; }
.chart .dot.climbed { fill: var(--s1); }
.chart .dot.dropped { fill: var(--s2); }
.chart .dot.same, .chart .dot.other { fill: var(--muted); }
.chart .dot.loc1 { fill: var(--s1); }
.chart .dot.loc2 { fill: var(--s2); }
.chart .dot.loc3 { fill: var(--s3); }
.tip {
  position: absolute; pointer-events: none; z-index: 2; max-width: 320px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; line-height: 1.4; box-shadow: 0 4px 16px rgb(0 0 0 / 0.12);
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); margin-top: 8px; }
.k { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; background: var(--muted); }
.k.dot, .k.climbed, .k.loc1 { background: var(--s1); }
.k.won { background: var(--win); }
.k.dropped, .k.loc2 { background: var(--s2); }
.k.loc3 { background: var(--s3); }
.k.line { width: 16px; height: 2px; border-radius: 1px; background: var(--text); opacity: 0.55; vertical-align: 3px; }
.k.diag { width: 16px; height: 0; border-radius: 0; background: none; border-top: 1.5px dashed var(--muted); vertical-align: 3px; }
