:root {
  color-scheme: dark;
  --bg: #0f1213;
  --bg-2: #13171a;
  --panel: #171b1d;
  --panel-2: #1d2326;
  --line: #2b3236;
  --line-2: #3a4348;
  --ink: #ece6d6;
  --ink-2: #bdb6a4;
  --muted: #8d8779;
  --accent: #ff9a3c;
  --accent-ink: #1a1005;
  --smoke: #e5484d;
  --zone: #4db3ff;
  --gold: #f2c94c;
  --silver: #c9d1d6;
  --good: #46c08a;
  --grid: #252b2f;
  --radius: 10px;
  --display: 'Black Ops One', 'Impact', system-ui, sans-serif;
  --ui: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 600 16px/1.45 var(--ui);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--zone); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 6px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }

/* ---------- backdrop: topo lines + the shrinking blue zone ---------- */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.topo {
  position: absolute; inset: 0; opacity: .5;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255,154,60,.10), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(77,179,255,.08), transparent 50%),
    repeating-radial-gradient(circle at 70% 30%, transparent 0 38px, rgba(236,230,214,.035) 38px 39px),
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 80px 80px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 80px 80px;
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0,0,0,.4) 70%, transparent);
}
.zone-ring {
  position: absolute; width: 140vmax; height: 140vmax; left: 50%; top: 30%;
  border-radius: 50%; border: 2px solid rgba(77,179,255,.35);
  box-shadow: 0 0 60px rgba(77,179,255,.15), inset 0 0 120px rgba(77,179,255,.06);
  transform: translate(-50%, -50%) scale(1);
  animation: zone 40s ease-in-out infinite alternate;
}
@keyframes zone { to { transform: translate(-50%, -50%) scale(.55); } }
@media (prefers-reduced-motion: reduce) { .zone-ring { animation: none; transform: translate(-50%, -50%) scale(.7); } html { scroll-behavior: auto; } }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px; justify-content: space-between;
  padding: 10px max(16px, calc((100vw - 1200px) / 2));
  background: rgba(15,18,19,.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.crest { width: 40px; height: 40px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text b { font: 400 24px/1 var(--display); letter-spacing: .04em; }
.brand-text small { color: var(--accent); font-size: 12px; letter-spacing: .3em; text-transform: uppercase; margin-top: 3px; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  text-decoration: none; padding: 8px 12px; border-radius: 6px; white-space: nowrap;
  color: var(--ink-2); text-transform: uppercase; letter-spacing: .08em; font-size: 14px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav a:hover { color: var(--ink); background: var(--panel-2); }
.nav a.active { color: var(--accent-ink); background: var(--accent); }
.nav-admin svg { width: 14px; height: 14px; }
@media (max-width: 760px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 8px; padding-top: 8px; padding-bottom: 6px; }
  .nav { margin: 0 -16px; padding: 0 16px; }
  .nav-admin span { display: none; }
}

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 1232px; margin: 0 auto; padding: 24px 16px 48px; outline: none; }
.footer { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; padding: 18px max(16px, calc((100vw - 1200px) / 2)); color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.loading { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 80px 0; color: var(--ink-2); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin: 4px 0 20px; }
.page-head h1 { margin: 0; font: 400 clamp(28px, 5vw, 40px)/1.05 var(--display); letter-spacing: .03em; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); }
.kicker { color: var(--accent); text-transform: uppercase; letter-spacing: .25em; font-size: 12px; font-weight: 700; }
h2.section { font: 400 20px/1.2 var(--display); letter-spacing: .04em; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
h2.section::before { content: ''; width: 10px; height: 10px; background: var(--accent); transform: rotate(45deg); flex: none; }
h2.section .more { margin-left: auto; font: 700 13px var(--ui); text-transform: uppercase; letter-spacing: .1em; color: var(--zone); text-decoration: none; }
h2.section .more:hover { text-decoration: underline; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.stack { display: grid; gap: 28px; }
.stack > *, .grid > *, form > * { min-width: 0; }

.panel {
  position: relative; background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.panel.notch { clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 0 100%); }
.panel-title { margin: 0 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-2); }
.panel-sub { margin: 0 0 12px; color: var(--muted); font-size: 14px; font-weight: 500; }

/* ---------- hero ---------- */
.hero { position: relative; padding: 28px 0 8px; display: grid; gap: 20px; }
.hero h1 { margin: 0; font: 400 clamp(44px, 10vw, 96px)/.9 var(--display); letter-spacing: .02em; text-shadow: 0 4px 0 rgba(0,0,0,.4); }
.hero h1 span { color: var(--accent); }
.hero .tag { color: var(--ink-2); font-size: 18px; margin: 10px 0 0; }
.hero .tag b { color: var(--ink); }
.callout { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 999px; background: rgba(0,0,0,.25); font-size: 14px; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(70,192,138,.2); flex: none; }
.dot.off { background: var(--muted); box-shadow: none; }

.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tile { background: var(--panel); padding: 14px 16px; min-width: 0; box-shadow: 1px 1px 0 var(--line); }
.tile .v { font: 700 clamp(24px, 4vw, 32px)/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.tile .k { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin-top: 4px; }
.tile .s { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.tile.hot .v { color: var(--gold); }

/* ---------- badges / chips ---------- */
.place {
  display: inline-grid; place-items: center; min-width: 52px; height: 52px; padding: 0 6px;
  border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-2);
  font: 700 20px/1 var(--mono); flex: none;
}
.place small { font: 700 10px/1 var(--ui); letter-spacing: .1em; color: var(--muted); }
.place.win { background: linear-gradient(160deg, #ffe38a, var(--gold) 50%, #c9971d); color: #2a1d00; border-color: #ffe38a; }
.place.win small { color: #4a3600; }
.place.top5 { border-color: var(--accent); color: var(--accent); }
.place.top10 { border-color: var(--zone); color: var(--zone); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 4px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); font-size: 14px; text-decoration: none; white-space: nowrap; }
.chip:hover { border-color: var(--line-2); }
.swatch { width: 14px; height: 14px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; box-shadow: 0 0 0 2px var(--panel); }
.avatar {
  --c: var(--accent);
  width: 44px; height: 44px; border-radius: 10px; flex: none; display: grid; place-items: center;
  font: 400 20px/1 var(--display); color: #fff; background: var(--c);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.25);
}
.avatar.lg { width: 72px; height: 72px; font-size: 34px; border-radius: 14px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-2); }
.pill.ranked { border-color: var(--smoke); color: #ff8f92; }
.pill.sync { border-color: var(--zone); color: var(--zone); }

/* ---------- match cards ---------- */
.matches { display: grid; gap: 10px; }
.match {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel);
  text-decoration: none; transition: border-color .15s, transform .15s;
}
.match:hover { border-color: var(--line-2); transform: translateY(-1px); }
.match.win { border-color: rgba(242,201,76,.45); background: linear-gradient(90deg, rgba(242,201,76,.10), var(--panel) 40%); }
.match .title { font-size: 18px; font-weight: 700; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.match .meta { color: var(--muted); font-size: 14px; font-weight: 500; }
.match .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.match .nums { display: flex; gap: 18px; text-align: right; }
.match .nums div b { display: block; font: 700 18px var(--mono); }
.match .nums div span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
@media (max-width: 640px) {
  .match { grid-template-columns: auto 1fr; }
  .match .nums { grid-column: 1 / -1; justify-content: space-around; text-align: center; border-top: 1px dashed var(--line); padding-top: 8px; }
}

/* ---------- podium ---------- */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 10px; min-height: 250px; }
.podium .spot { display: flex; flex-direction: column; align-items: center; gap: 8px; text-decoration: none; min-width: 0; }
.podium .name { font-weight: 700; font-size: 17px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .block {
  width: 100%; display: grid; place-items: center; gap: 2px; padding: 10px 4px;
  border-radius: 8px 8px 0 0; border: 1px solid var(--line-2); border-bottom: none;
  background: linear-gradient(180deg, var(--panel-2), var(--bg-2));
}
.podium .block b { font: 400 30px/1 var(--display); }
.podium .block span { font: 700 14px var(--mono); color: var(--ink-2); }
.podium .p1 .block { height: 150px; border-color: var(--gold); background: linear-gradient(180deg, rgba(242,201,76,.18), var(--bg-2)); }
.podium .p1 .block b { color: var(--gold); }
.podium .p2 .block { height: 115px; }
.podium .p2 .block b { color: var(--silver); }
.podium .p3 .block { height: 90px; }
.podium .p3 .block b { color: #d98e57; }
.crown { font-size: 22px; line-height: 1; }

/* ---------- fact cards ---------- */
.facts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.fact { display: flex; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); text-decoration: none; }
a.fact:hover { border-color: var(--line-2); border-left-color: var(--accent); }
.fact .icon { font-size: 28px; line-height: 1; flex: none; width: 40px; height: 40px; display: grid; place-items: center; background: var(--bg-2); border-radius: 8px; }
.fact h3 { margin: 0 0 2px; font: 400 16px/1.2 var(--display); letter-spacing: .03em; }
.fact p { margin: 0; color: var(--ink-2); font-weight: 500; font-size: 15px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; background: var(--bg-2); position: sticky; top: 0; }
td.n, th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.025); }
th button { all: unset; cursor: pointer; }
th button:hover, th button.on { color: var(--accent); }
.rank { font: 400 18px var(--display); color: var(--muted); width: 36px; }
.rank.r1 { color: var(--gold); } .rank.r2 { color: var(--silver); } .rank.r3 { color: #d98e57; }
.bar-cell { min-width: 180px; }
.hbar { display: flex; align-items: center; gap: 10px; }
.hbar .track { flex: 1; height: 8px; background: var(--bg-2); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar b { font: 700 15px var(--mono); min-width: 64px; text-align: right; }
.lowsample { opacity: .55; }
.playerlink { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; }
.playerlink:hover { color: var(--accent); }

/* ---------- tabs, buttons, forms ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tab { text-decoration: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); padding: 7px 12px; border-radius: 6px; cursor: pointer; font-weight: 700; font-size: 14px; letter-spacing: .04em; }
.tab:hover { color: var(--ink); border-color: var(--line-2); }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink); padding: 9px 16px; border-radius: 7px; cursor: pointer; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; font-size: 14px; text-decoration: none; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: rgba(229,72,77,.6); color: #ff8f92; background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label, .label { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
input, select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 7px; padding: 8px 10px; font-weight: 600; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--zone); outline: none; box-shadow: 0 0 0 3px rgba(77,179,255,.18); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
input[type="color"] { padding: 2px; height: 38px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.statgrid input { width: 72px; padding: 6px; text-align: right; font-family: var(--mono); }
.statgrid td, .statgrid th { padding: 6px 8px; }
.statgrid tr.off td:not(:first-child) { opacity: .35; }
.error { color: #ff8f92; font-weight: 600; min-height: 1.4em; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.filters .field { width: min(100%, 200px); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; background: var(--c); cursor: pointer; }
.swatches button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg); }

/* ---------- player cards ---------- */
.pcard { display: grid; gap: 14px; text-decoration: none; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(160deg, color-mix(in srgb, var(--c) 16%, var(--panel)), var(--panel) 55%); transition: transform .15s, border-color .15s; }
.pcard:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 60%, var(--line)); }
.pcard .who { display: flex; gap: 12px; align-items: center; }
.pcard .who b { font-size: 20px; display: block; line-height: 1.1; }
.pcard .who small { color: var(--ink-2); font-weight: 500; }
.minis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mini { background: rgba(0,0,0,.22); border-radius: 7px; padding: 8px; text-align: center; }
.mini b { display: block; font: 700 17px var(--mono); }
.mini span { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.rating { font: 400 14px var(--display); color: var(--accent); margin-left: auto; text-align: right; }
.rating b { display: block; font-size: 26px; line-height: 1; }

.profile-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; padding: 20px; border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(120deg, color-mix(in srgb, var(--c) 28%, var(--panel)), var(--panel) 60%); }
.profile-head h1 { margin: 0; font: 400 clamp(30px, 6vw, 44px)/1 var(--display); }

/* ---------- charts ---------- */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font: 600 11px var(--ui); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#areaGrad); }
.chart .pt { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.chart .pt.win { fill: var(--gold); }
.chart .bar { fill: var(--accent); }
.chart .bar.zone { fill: var(--zone); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hl { stroke: var(--ink); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-2); margin-top: 8px; font-weight: 600; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: #0b0d0e; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.5); max-width: 240px; }
.tooltip b { color: var(--ink); }
.tooltip .t { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }

/* ---------- empty + toast ---------- */
.empty { text-align: center; padding: 48px 20px; border: 1px dashed var(--line-2); border-radius: var(--radius); background: rgba(0,0,0,.2); }
.empty .big { font-size: 44px; }
.empty h2 { font: 400 24px var(--display); margin: 8px 0 6px; }
.empty p { color: var(--ink-2); margin: 0 auto 16px; max-width: 520px; font-weight: 500; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 120px); background: var(--panel-2); border: 1px solid var(--line-2); border-left: 4px solid var(--good); padding: 10px 16px; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.5); transition: transform .25s; z-index: 60; max-width: calc(100vw - 32px); }
.toast.show { transform: translate(-50%, 0); }
.toast.err { border-left-color: var(--smoke); }
.scoreboard .mvp { color: var(--gold); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; margin-left: 6px; }
.records { display: grid; gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.records .tile a { text-decoration: none; color: var(--zone); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
details.tableview summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 8px; }
