:root {
  color-scheme: dark;
  --bg: #0e1013;
  --surface: #171a1f;
  --surface-2: #1d2128;
  --surface-3: #252a33;
  --border: #2b313b;
  --border-hi: #3a4250;
  --text: #eceae4;
  --text-2: #b6b3aa;
  --muted: #858279;
  --you: #3987e5;
  --target: #d95926;
  --third: #199e70;
  --good: #46c470;
  --bad: #e66767;
  --warn: #e0a526;
  --coal: #8f8f8f;
  --iron: #d9d4cf;
  --gold: #f2c94c;
  --emerald: #2bd46a;
  --diamond: #5ce1e6;
  --netherite: #a98a9c;
  --radius: 6px;
  --pixel: "Silkscreen", "Courier New", monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(57, 135, 229, .08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(43, 212, 106, .06), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  min-height: 100vh;
}
body::before { /* faint pixel grid */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 16px 16px;
}
a { color: var(--diamond); text-decoration: none; }
a:hover { text-decoration: underline; }
.num, td.t, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ layout */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: rgba(16, 18, 22, .92); border-right: 2px solid var(--border);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.logo-text { font-family: var(--pixel); font-size: 17px; line-height: 1.05; letter-spacing: .5px; }
.logo-text small { display: block; font-size: 10px; color: var(--muted); letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 4px; border: 0; background: transparent;
  color: var(--text-2); font: 500 13.5px var(--sans); cursor: pointer; text-align: left;
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-3); color: var(--text); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 4px; background: var(--emerald);
}
.nav-item svg { width: 18px; height: 18px; flex: none; image-rendering: pixelated; }
.side-foot { margin-top: auto; padding: 14px 8px 0; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.side-foot code { color: var(--text-2); }

.main { min-width: 0; padding: 0 28px 48px; }
.topbar {
  position: sticky; top: 0; z-index: 20; margin: 0 -28px 22px; padding: 12px 28px;
  background: rgba(14, 16, 19, .86); backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
}
.player-chip { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.player-chip .name { font-family: var(--pixel); font-size: 15px; }
.player-chip .sub { color: var(--muted); font-size: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.filter { display: flex; align-items: center; gap: 6px; }
.filter > label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }

.seg-ctl { display: inline-flex; background: var(--surface); border: 2px solid var(--border); border-radius: 5px; padding: 2px; }
.seg-ctl button {
  border: 0; background: transparent; color: var(--text-2); padding: 5px 10px; border-radius: 3px;
  font: 500 12.5px var(--sans); cursor: pointer; white-space: nowrap;
}
.seg-ctl button:hover { color: var(--text); }
.seg-ctl button.on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 -2px 0 var(--emerald); }
select {
  background: var(--surface); color: var(--text); border: 2px solid var(--border); border-radius: 5px;
  padding: 5px 8px; font: 500 12.5px var(--sans); cursor: pointer; max-width: 210px;
}
select:focus, button:focus-visible, input:focus-visible { outline: 2px solid var(--diamond); outline-offset: 1px; }
input[type=range] { accent-color: var(--emerald); width: 140px; }

/* ------------------------------------------------------------------ type */
.page-head { margin: 6px 0 18px; }
.page-head h1 { font-family: var(--pixel); font-weight: 400; font-size: 24px; margin: 0 0 4px; letter-spacing: .5px; }
.page-head p { margin: 0; color: var(--text-2); max-width: 820px; }
h2.card-title { font-family: var(--pixel); font-weight: 400; font-size: 14px; margin: 0 0 4px; letter-spacing: .4px; }
.card-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.muted { color: var(--muted); }
.t2 { color: var(--text-2); }

/* ------------------------------------------------------------------ cards */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-hero { grid-template-columns: minmax(0, 1.25fr) minmax(0, 2fr); }
.span2 { grid-column: span 2; }
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 2px solid var(--border); border-radius: var(--radius); padding: 18px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.035), inset 0 -3px 0 rgba(0,0,0,.28), 0 6px 20px rgba(0,0,0,.25);
  min-width: 0;
}
.stack { display: flex; flex-direction: column; gap: 16px; }
.mt { margin-top: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 2px solid var(--border); border-radius: 5px; padding: 12px 14px; }
.tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
.tile .v { font-family: var(--mono); font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .s { color: var(--text-2); font-size: 12px; margin-top: 2px; }

/* hero */
.hero { display: flex; gap: 18px; align-items: center; }
.hero .badge svg { width: 88px; height: 88px; image-rendering: pixelated; filter: drop-shadow(0 6px 14px rgba(0,0,0,.5)); }
.hero .div-name { font-family: var(--pixel); font-size: 26px; line-height: 1.1; }
.hero .elo { font-family: var(--mono); font-size: 32px; font-weight: 700; }
.hero .elo small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.xp { margin-top: 10px; }
.xp-bar { height: 12px; background: #0b0c0e; border: 2px solid #000; position: relative; image-rendering: pixelated; }
.xp-bar > div { height: 100%; background: repeating-linear-gradient(90deg, #7fe03a 0 10px, #6ac62c 10px 12px); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.xp-lbl { display: flex; justify-content: space-between; color: var(--text-2); font-size: 12px; margin-top: 4px; }

/* focus list */
.focus { display: flex; flex-direction: column; gap: 10px; }
.focus-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border: 2px solid var(--border); border-radius: 5px; padding: 10px 12px; }
.focus-item .rank-n { font-family: var(--pixel); font-size: 18px; color: var(--warn); text-align: center; }
.focus-item .title { font-weight: 600; }
.focus-item .why { color: var(--text-2); font-size: 12.5px; }
.focus-item .loss { font-family: var(--mono); font-weight: 700; color: var(--bad); white-space: nowrap; }

/* plays-like tracks */
.tracks { display: flex; flex-direction: column; gap: 12px; }
.track-row { display: grid; grid-template-columns: 96px 1fr 128px; gap: 12px; align-items: center; }
.track-row .lbl { font-weight: 600; font-size: 13px; }
.track { position: relative; height: 14px; border-radius: 2px; overflow: visible; display: flex; }
.track .band { height: 100%; opacity: .32; }
.track .band:first-child { border-radius: 2px 0 0 2px; }
.track .band:last-child { border-radius: 0 2px 2px 0; }
.track .mark { position: absolute; top: -4px; width: 4px; height: 22px; background: var(--text); border-radius: 1px; box-shadow: 0 0 0 2px var(--surface); transform: translateX(-2px); }
.track .cur { position: absolute; top: -2px; width: 0; height: 18px; border-left: 2px dashed var(--muted); }
.track-row .val { font-size: 12.5px; color: var(--text-2); text-align: right; }
.track-row .val b { color: var(--text); font-weight: 600; }

/* tables */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; position: sticky; top: 0; background: var(--surface-2); }
tbody tr:hover td { background: rgba(255,255,255,.025); }
tr.me td { background: rgba(57,135,229,.10); }
tr.sel td { background: rgba(217,89,38,.10); }
td.t { font-size: 12.5px; }
.d-good { color: var(--good); }
.d-bad { color: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--border-hi); background: var(--surface-3); }
.pill.win { color: var(--good); border-color: rgba(70,196,112,.4); }
.pill.loss { color: var(--bad); border-color: rgba(230,103,103,.4); }
.pill.draw, .pill.ff { color: var(--text-2); }
.rk { display: inline-flex; align-items: center; gap: 6px; }
.rk svg { width: 16px; height: 16px; image-rendering: pixelated; }
.cell-heat { border-radius: 3px; padding: 2px 6px; }

/* charts */
.chart { position: relative; height: 300px; }
.chart.tall { height: 380px; }
.chart.short { height: 220px; }
.chart.mini { height: 150px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.legend i.line { height: 3px; border-radius: 0; }
.legend i.dash { height: 0; border-top: 2px dashed; background: none !important; }
.multiples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.multiples .m { background: var(--surface); border: 2px solid var(--border); border-radius: 5px; padding: 10px 12px; }
.multiples .m h3 { margin: 0 0 4px; font-size: 13px; }
.multiples .m .chart { height: 160px; }

.big-num { font-family: var(--mono); font-size: 40px; font-weight: 700; line-height: 1.1; }
.big-row { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-end; }
.big-row .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
.note { color: var(--muted); font-size: 12px; margin-top: 10px; }
.callout { border-left: 4px solid var(--emerald); background: rgba(43,212,106,.06); padding: 10px 14px; border-radius: 0 5px 5px 0; color: var(--text-2); font-size: 13px; }
.callout b { color: var(--text); }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 2px dashed var(--border); border-radius: 6px; }
.ctl-row { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; margin-bottom: 12px; }
.ctl-row label { color: var(--text-2); font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; color: var(--muted); font-size: 12.5px; }
.btn { background: var(--surface-3); border: 2px solid var(--border-hi); color: var(--text); border-radius: 4px; padding: 4px 12px; font: 500 12.5px var(--sans); cursor: pointer; box-shadow: inset 0 -2px 0 rgba(0,0,0,.3); }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .4; cursor: default; }

/* tooltip-ish (Chart.js renders its own) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1150px) {
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-hero { grid-template-columns: 1fr; }
  .multiples { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; overflow-x: auto; padding: 8px 10px; border-right: 0; border-bottom: 2px solid var(--border); }
  .logo, .side-foot { display: none; }
  .nav-item { width: auto; white-space: nowrap; padding: 7px 10px; }
  .nav-item.active::before { left: 6px; right: 6px; top: auto; bottom: -8px; width: auto; height: 3px; }
  .main { padding: 0 16px 40px; }
  .topbar { position: static; margin: 0 -16px 16px; padding: 12px 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .multiples { grid-template-columns: 1fr; }
  .track-row { grid-template-columns: 80px 1fr; }
  .track-row .val { grid-column: 1 / -1; text-align: left; }
  .hero { flex-direction: column; align-items: flex-start; }
  .big-num { font-size: 32px; }
  .tiles.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile .v { font-size: 19px; }
}
