:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface-1: #13161b;
  --surface-2: #1a1e25;
  --surface-3: #232831;
  --line: #2a303a;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8b8f98;
  --accent: #3987e5;          /* overridden by the club's kit colour */
  --accent-ink: #ffffff;
  --us: #3987e5;              /* series 1 — our club */
  --them: #d95926;            /* series 2 — opponents */
  --good: #2fb37a;
  --bad: #e66767;
  --warn: #c98500;
  --neutral: #6b7280;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Barlow Condensed", "Inter", sans-serif;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f4f1; --surface-1: #fcfcfb; --surface-2: #f1f1ee; --surface-3: #e6e6e1; --line: #dcdcd6;
    --text-primary: #0b0b0b; --text-secondary: #52514e; --text-muted: #73726c;
    --us: #2a78d6; --them: #eb6834; --good: #12804f; --bad: #c93a3a; --warn: #a66d00;
    --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 18px rgba(0,0,0,.05);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f1; --surface-1: #fcfcfb; --surface-2: #f1f1ee; --surface-3: #e6e6e1; --line: #dcdcd6;
  --text-primary: #0b0b0b; --text-secondary: #52514e; --text-muted: #73726c;
  --us: #2a78d6; --them: #eb6834; --good: #12804f; --bad: #c93a3a; --warn: #a66d00;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 18px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text-primary); font: 14px/1.5 var(--font); }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px 80px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* Top bar ---------------------------------------------------------------- */
.topbar { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; }
.logo { font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: .02em; text-decoration: none; white-space: nowrap; }
.logo b { color: var(--accent); }
.search { position: relative; flex: 1; max-width: 520px; display: flex; gap: 6px; }
.search input { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; outline: none; }
.search input:focus { border-color: var(--accent); }
.search select { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; }
.results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface-1); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 420px; overflow: auto; z-index: 50; }
.results button { display: flex; width: 100%; justify-content: space-between; gap: 10px; padding: 10px 14px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; }
.results button:hover, .results button:focus { background: var(--surface-2); outline: none; }
.results .note { padding: 10px 14px; color: var(--text-muted); font-size: 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; }
.chip { white-space: nowrap; border: 1px solid var(--line); background: var(--surface-1); border-radius: 999px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.chip.active { border-color: var(--accent); }
.iconbtn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; }

/* Hero ------------------------------------------------------------------- */
.hero { margin-top: 20px; border-radius: 20px; padding: 24px; background:
  radial-gradient(600px 300px at 100% 0%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 70%), var(--surface-1);
  border: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; box-shadow: var(--shadow); }
.crest { width: 76px; height: 76px; border-radius: 20px; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 30px; border: 3px solid; }
.hero > div { min-width: 0; }
.hero h1 { margin: 0; font-family: var(--display); font-size: clamp(30px, 5vw, 46px); line-height: 1; letter-spacing: .01em; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tag { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.hero-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.btn { border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--text-muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn:disabled { opacity: .55; cursor: progress; }
.sync { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; }
.dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.form { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
.form span { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; }
.W { background: var(--good); } .D { background: var(--neutral); } .L { background: var(--bad); }
.tW { color: var(--good); } .tD { color: var(--text-muted); } .tL { color: var(--bad); }

/* Filters & tabs --------------------------------------------------------- */
.toolbar { position: sticky; top: 57px; z-index: 30; background: var(--bg); padding: 12px 0 0; }
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.tabs button.active { color: var(--text-primary); border-color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 8px; cursor: pointer; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.seg button.active { background: var(--surface-3); color: var(--text-primary); }
.filters label { font-size: 12px; color: var(--text-muted); display: inline-flex; gap: 6px; align-items: center; }
.filters select { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; }

/* Layout ----------------------------------------------------------------- */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }
.card .sub { margin: 0 0 14px; color: var(--text-muted); font-size: 12px; }
.section-title { font-family: var(--display); font-size: 22px; margin: 26px 0 10px; letter-spacing: .01em; }
.kpi { padding: 14px 16px; }
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.kpi .value { font-family: var(--display); font-size: 34px; line-height: 1.1; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; color: var(--text-secondary); }

/* Insight lists ---------------------------------------------------------- */
.insight { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: start; }
.insight:first-of-type { border-top: 0; }
.insight .icon { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; }
.insight.good .icon { background: var(--good); } .insight.bad .icon { background: var(--bad); } .insight.info .icon { background: var(--neutral); }
.insight .t { font-weight: 600; }
.insight .e { color: var(--text-muted); font-size: 12px; }
.insight .v { font-family: var(--display); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.plan { counter-reset: step; }
.plan .step { position: relative; padding: 12px 0 12px 40px; border-top: 1px solid var(--line); }
.plan .step:first-child { border-top: 0; }
.plan .step::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 12px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.plan .why { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.empty { color: var(--text-muted); font-size: 13px; padding: 8px 0; }

/* Comparison bars -------------------------------------------------------- */
.cmp { display: grid; grid-template-columns: 1fr minmax(120px, 190px) 1fr; gap: 8px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.cmp:first-of-type { border-top: 0; }
.cmp .lab { text-align: center; color: var(--text-secondary); font-size: 12px; }
.cmp .side { display: flex; align-items: center; gap: 8px; }
.cmp .side.left { flex-direction: row-reverse; }
.cmp .bar { height: 8px; border-radius: 4px; min-width: 2px; }
.cmp .left .bar { background: var(--us); } .cmp .right .bar { background: var(--them); }
.cmp .val { font-variant-numeric: tabular-nums; min-width: 42px; }
.cmp .left .val { text-align: right; }
.cmp .win { font-weight: 700; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.meter { height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }

/* Players ---------------------------------------------------------------- */
.pcard { display: flex; flex-direction: column; justify-content: flex-start; cursor: pointer; transition: border-color .15s, transform .15s; text-align: left; width: 100%; color: inherit; }
.pcard:hover { border-color: var(--accent); transform: translateY(-1px); }
.pcard .top { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.pcard .name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .rating { font-family: var(--display); font-size: 30px; font-weight: 600; line-height: 1; }
.pcard .row { display: flex; gap: 10px; font-size: 12px; color: var(--text-secondary); margin: 8px 0 12px; flex-wrap: wrap; }
.pcard .cats { display: grid; grid-template-columns: 90px 1fr 26px; gap: 4px 8px; align-items: center; font-size: 11px; color: var(--text-muted); }
.pcard .pills { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.pill.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; }
.player-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.player-head h2 { font-family: var(--display); font-size: 34px; margin: 0; line-height: 1; }
.back { background: none; border: 0; color: var(--text-muted); cursor: pointer; padding: 0; margin: 14px 0 6px; }

/* Tables ----------------------------------------------------------------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; cursor: default; }
th.sort { cursor: pointer; } th.sort:hover { color: var(--text-primary); }
th:first-child, td:first-child, th.l, td.l { text-align: left; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }

/* Rivalry ---------------------------------------------------------------- */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 12px; align-items: end; }
.podium .spot { text-align: center; padding: 16px 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.podium .spot.first { padding-top: 26px; border-color: var(--accent); }
.podium .medal { font-family: var(--display); font-size: 40px; line-height: 1; }
.podium .pname { font-weight: 700; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; }
.podium .pscore { font-family: var(--display); font-size: 26px; }
.weights { display: grid; grid-template-columns: 110px 1fr 28px; gap: 6px 10px; align-items: center; font-size: 12px; }
.weights input[type=range] { width: 100%; accent-color: var(--accent); }
.award { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.award .badge { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; flex: none; color: #fff; }
.award.good .badge { background: var(--good); } .award.bad .badge { background: var(--bad); }
.award .who { font-weight: 700; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; text-align: center; }
.vs .big { font-family: var(--display); font-size: 44px; line-height: 1; }

/* Matches ---------------------------------------------------------------- */
.match { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); cursor: pointer; }
.match:hover { background: var(--surface-2); }
.match .res { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; color: #fff; }
.match .score { font-family: var(--display); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.match-detail { padding: 6px 12px 18px; background: var(--surface-2); border-top: 1px solid var(--line); }
.session { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.session:first-child { border-top: 0; }
.grade { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-family: var(--display); font-size: 24px; font-weight: 700; background: var(--surface-3); }
.grade.A { color: var(--good); } .grade.D { color: var(--bad); }

.chart { position: relative; height: 260px; }
.chart.tall { height: 320px; }
.chart.short { height: 200px; }
.notice { border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); border-radius: 12px; padding: 12px 14px; margin-top: 14px; font-size: 13px; }
.notice.bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); z-index: 100; font-size: 13px; }
.loading { padding: 80px 0; text-align: center; color: var(--text-muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
code, .code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; }
.bookmarklet { display: inline-block; padding: 8px 14px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; cursor: grab; }
.tip { position: fixed; pointer-events: none; z-index: 120; background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 12px; box-shadow: var(--shadow); max-width: 260px; }

@media (max-width: 980px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .wrap { padding: 0 16px 60px; }
  .topbar .wrap { flex-wrap: wrap; }
  .search { max-width: none; order: 3; flex-basis: 100%; }
  .chips { display: none; }
  .hero { grid-template-columns: auto 1fr; padding: 18px; }
  .hero-actions { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .toolbar { top: 100px; }
  .crest { width: 56px; height: 56px; font-size: 22px; border-radius: 14px; }
  .cmp { grid-template-columns: 1fr 100px 1fr; }
  .podium { gap: 6px; }
  .match { grid-template-columns: 30px 1fr auto; }
  .match .when { display: none; }
}

/* Who is better: bold = slightly, green = clearly (12%+), green chip with ▲▲ = far better (35%+) */
.val.win { font-weight: 700; }
.val.win.lv1 { color: var(--good); }
.val.win.lv2 { color: var(--good); background: color-mix(in srgb, var(--good) 18%, transparent); border-radius: 6px; padding: 1px 6px; }
.val .mark { font-size: 9px; margin-right: 3px; letter-spacing: -1px; }
.sup-legend { font-size: 11px; color: var(--text-muted); }
.sup-legend .val { min-width: 0; }
td.cell-best { color: var(--good); font-weight: 700; }
td.cell-best.lv2 { background: color-mix(in srgb, var(--good) 14%, transparent); }
td.cell-worst { color: var(--bad); }

/* Match report */
.report { padding-top: 8px; }
.verdict { border-left: 4px solid var(--neutral); background: var(--surface-1); border-radius: 10px; padding: 12px 14px; }
.verdict.W { border-color: var(--good); } .verdict.L { border-color: var(--bad); }
.verdict p { margin: 4px 0 0; line-height: 1.55; }
.match-detail .card { box-shadow: none; }

/* League */
table.league td { vertical-align: middle; }
table.league tr.top1 td:first-child, table.league tr.top2 td:first-child, table.league tr.top3 td:first-child { font-size: 16px; }
table.league .pts { font-family: var(--display); font-size: 18px; }
.fchip { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 4px; margin-right: 3px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.fchip.good { background: color-mix(in srgb, var(--good) 22%, transparent); color: var(--good); }
.fchip.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
tr.breakdown td { background: var(--surface-2); text-align: left; white-space: normal; }
tr.breakdown:hover { background: none; }
.bchips { display: flex; flex-wrap: wrap; gap: 6px; }
.bchip { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-1); color: var(--text-secondary); }
.bchip b { color: var(--text-primary); }
.bchip.good b { color: var(--good); } .bchip.bad b { color: var(--bad); }
.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 18px; }
.rule { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.rule input { width: 64px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; text-align: right; }

/* Staging marker (never shown on the live site). */
.env-badge { flex: none; font-size: 11px; font-weight: 800; letter-spacing: .08em; color: #1a1300; background: #f5b400; border-radius: 6px; padding: 3px 7px; }
