:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --hover: #262624;
  --border: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --s1: #3987e5; /* you */
  --s2: #d95926; /* lane opponent */
  --s3: #199e70; /* rank benchmark */
  --good: #0ca30c;
  --bad: #e66767;
  --warn: #fab219;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text); }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 12px 24px; background: rgba(13, 13, 13, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; letter-spacing: 0.02em; }
.brand span { color: var(--s1); margin-left: 2px; font-weight: 600; }
.search { display: flex; gap: 8px; flex: 1; max-width: 520px; min-width: 0; }
.search input { flex: 1; min-width: 0; }
input, select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; outline: none;
}
input:focus, select:focus { border-color: var(--s1); }
button {
  background: var(--s1); border: 0; border-radius: 8px; padding: 7px 16px;
  font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: default; }
button.ghost { background: var(--surface-2); border: 1px solid var(--border); font-weight: 500; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 24px; }

/* empty / error */
.empty { text-align: center; padding: 72px 16px; color: var(--text-2); }
.empty h1 { color: var(--text); font-size: 28px; margin: 0 0 12px; }
.empty p { max-width: 520px; margin: 0 auto; line-height: 1.5; }
.empty.small { padding: 40px 16px; }
.recent { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }
.recent button { background: var(--surface); border: 1px solid var(--border); font-weight: 500; }
.error {
  border: 1px solid rgba(230, 103, 103, 0.4); background: rgba(230, 103, 103, 0.08);
  color: var(--text); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px;
}

/* profile */
.profile {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.p-icon { width: 64px; height: 64px; border-radius: 12px; background: var(--surface-2); }
.p-main { flex: 1; min-width: 180px; }
.p-name { font-size: 20px; font-weight: 700; }
.p-name .muted { font-weight: 400; margin-left: 4px; }
.p-sub { margin-top: 4px; display: flex; gap: 12px; color: var(--text-2); flex-wrap: wrap; }
.p-sync { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.p-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.progress { width: 220px; height: 4px; background: var(--grid); border-radius: 2px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--s1); transition: width 0.3s; }
.tier { font-weight: 600; color: var(--text); }
.rank-emblem { width: 28px; height: 28px; vertical-align: middle; margin: -6px 4px -6px -2px; }

/* filters */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; margin-bottom: 16px;
}
.filters label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.narrow { width: 140px; }
.tiny { width: 70px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px; flex-wrap: wrap; }
.seg button { background: transparent; color: var(--text-2); font-weight: 500; padding: 5px 12px; border-radius: 6px; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }

/* tier picker (compare to) */
.tier-picker { position: relative; }
.tp-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; font-weight: 400; }
.tp-btn img { width: 26px; height: 26px; margin: -4px -2px; }
.tp-btn .caret { color: var(--muted); font-size: 11px; }
.tp-menu {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: 280px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.tp-head { font-size: 11px; color: var(--muted); padding: 6px 8px 8px; line-height: 1.4; }
.tp-opt { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; width: 100%; background: transparent; border-radius: 6px; padding: 4px 8px; font-weight: 400; text-align: left; }
.tp-opt:hover:not([disabled]) { background: var(--hover); filter: none; }
.tp-opt.on { background: var(--hover); box-shadow: inset 2px 0 0 var(--s1); }
.tp-opt[disabled] { opacity: 0.35; }
.tp-opt img { width: 28px; height: 28px; }
.tp-val { font-variant-numeric: tabular-nums; color: var(--text-2); }
.tp-you { display: flex; justify-content: space-between; align-items: center; margin: 2px 8px; padding: 3px 8px; border-radius: 6px; background: rgba(57, 135, 229, 0.15); color: var(--text); font-size: 12px; }
.tp-you b { font-variant-numeric: tabular-nums; }

/* analysis scope line + tabs */
.scope { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; color: var(--text-2); font-size: 13px; margin: -4px 0 14px; }
.scope b { color: var(--text); font-weight: 600; }
.scope-warn { color: var(--warn); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(57, 135, 229, 0.15); border: 1px solid var(--s1); color: var(--text); border-radius: 999px; padding: 2px 10px 2px 3px; font-weight: 600; font-size: 12px; }
.chip img { width: 20px; height: 20px; border-radius: 50%; }
.chip span { color: var(--text-2); font-size: 14px; margin-left: 2px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.hint { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; cursor: help; }
.tabs button { background: transparent; border-radius: 0; color: var(--text-2); font-weight: 500; padding: 10px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); filter: none; }
.tabs button.on { color: var(--text); border-bottom-color: var(--s1); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 4px; }
.kpi.hero .value { font-size: 40px; }
.kpi.farm-level { display: flex; align-items: center; gap: 12px; }
.kpi.farm-level img { width: 56px; height: 56px; flex: none; }
.kpi .delta { font-size: 12px; margin-top: 2px; color: var(--text-2); }
.up { color: var(--good); }
.down { color: var(--bad); }


/* strengths & weaknesses */
#phases { margin-bottom: 16px; }
.phase-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.phase { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; border-top: 3px solid var(--axis); }
.phase.strength { border-top-color: var(--good); }
.phase.weakness { border-top-color: var(--bad); }
.phase.few { opacity: 0.6; }
.phase-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.phase-name { font-weight: 600; }
.verdict { font-size: 12px; font-weight: 600; margin-top: 6px; color: var(--text-2); }
.phase.strength .verdict { color: var(--good); }
.phase.weakness .verdict { color: var(--bad); }
.phase-value { font-size: 24px; font-weight: 600; margin: 4px 0 10px; }
.pbar { position: relative; height: 6px; border-radius: 3px; background: var(--grid); margin: 0 0 4px; }
.pbar-mid { position: absolute; left: 50%; top: -3px; width: 1px; height: 12px; background: var(--muted); }
.pbar-dot { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--text-2); box-shadow: 0 0 0 2px var(--surface-2); }
.phase.strength .pbar-dot { background: var(--good); }
.phase.weakness .pbar-dot { background: var(--bad); }
.pbar-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-bottom: 8px; }
.phase-sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.insights { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.insights li { display: flex; gap: 10px; align-items: baseline; line-height: 1.45; color: var(--text-2); }
.insights li span { font-size: 11px; flex: none; color: var(--muted); }
.insights li.good span { color: var(--good); }
.insights li.bad span { color: var(--bad); }

/* lane matchups (inside strengths & weaknesses) */
.mu-note { margin-bottom: 14px; line-height: 1.5; }
.mu-sub { font-size: 13px; font-weight: 600; margin: 22px 0 8px; }
.mu-table th small { display: block; font-size: 10px; font-weight: 400; }
.mu-table th.sortable { cursor: pointer; user-select: none; }
.mu-table th.sortable:hover, .mu-table th.sorted { color: var(--text); }
.mu-table td.hl { background: rgba(255, 255, 255, 0.03); font-weight: 600; }
.mu-table tr.thin td { opacity: 0.6; }
.mu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 12px 32px; }
.mu-col h3 { font-size: 12px; font-weight: 500; color: var(--muted); margin: 0 0 6px; }
.mu-row { display: grid; grid-template-columns: 28px minmax(100px, 160px) 1fr 120px; align-items: center; gap: 10px; padding: 3px 0; }
.mu-row img { width: 28px; height: 28px; border-radius: 6px; background: var(--surface-2); }
.mu-name { font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mu-name small, .mu-val small, .mc-name small, .mc-val small, .mc-lead small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.mu-bar { position: relative; height: 12px; }
.mu-bar .axis { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--axis); }
.mu-bar .fill { position: absolute; top: 0; height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; }
.mu-bar .fill.neg { background: var(--bad); border-radius: 4px 0 0 4px; }
.mu-val { text-align: right; line-height: 1.2; font-variant-numeric: tabular-nums; }

/* your champions (dumbbell rows) */
.mc-legend { margin-bottom: 10px; }
.key-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--s1); display: inline-block; }
.key-tick { width: 2px; height: 12px; background: var(--text-2); display: inline-block; }
.mc-list { overflow-x: auto; }
.mc-row { display: grid; grid-template-columns: 32px minmax(110px, 170px) minmax(240px, 1fr) 110px 84px; align-items: center; gap: 12px; padding: 5px 8px; min-width: 620px; width: 100%; }
button.mc-row { background: transparent; border: 1px solid transparent; border-radius: 8px; color: inherit; font-weight: 400; text-align: left; cursor: pointer; }
button.mc-row:hover { background: var(--surface-2); filter: none; }
button.mc-row.selected { background: var(--surface-2); border-color: var(--s1); }
.mc-row.thin { opacity: 0.55; }
.mc-row img { width: 32px; height: 32px; border-radius: 6px; background: var(--surface-2); }
.mc-name { font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-plot { position: relative; height: 22px; display: block; }
.mc-grid i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--grid); }
.mc-link { position: absolute; top: 50%; height: 3px; margin-top: -1.5px; border-radius: 2px; opacity: 0.7; }
.mc-link.up { background: var(--good); }
.mc-link.down { background: var(--bad); }
.mc-typ { position: absolute; top: 3px; bottom: 3px; width: 2px; margin-left: -1px; background: var(--text-2); }
.mc-you { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--s1); box-shadow: 0 0 0 2px var(--surface); }
.mc-val, .mc-lead { text-align: right; line-height: 1.2; font-variant-numeric: tabular-nums; }
.mc-scale { padding: 0; }
.mc-scale .mc-plot { height: 16px; }
.mc-scale .mc-plot span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* cards & charts */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.grid-2 > .card { margin: 0; }
#content .card { margin-bottom: 16px; }
#content .grid-2 .card { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { font-size: 14px; font-weight: 600; margin: 0; color: var(--text); }
select.inline { padding: 2px 6px; font-weight: 600; }
.chart { position: relative; height: 260px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-2); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 16px; height: 2px; border-radius: 1px; }
.key.s1 { background: var(--s1); }
.key.s2 { background: var(--s2); }
.key.s3 { background: var(--s3); }
.key.band { height: 10px; background: rgba(25, 158, 112, 0.22); }
.key.faint { opacity: 0.45; height: 3px; }
.key.dash { background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 7px); }
.key.dash.s3 { background: repeating-linear-gradient(90deg, var(--s3) 0 4px, transparent 4px 7px); }

/* tables */
.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th {
  text-align: right; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap;
}
.tbl td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tbl th.l, .tbl td.l { text-align: left; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.games tbody tr.row { cursor: pointer; }
.games tbody tr.row:hover td { background: var(--hover); }
.games tbody tr.open td { background: var(--surface-2); }
.champ { display: flex; align-items: center; gap: 10px; }
.champ img { width: 32px; height: 32px; border-radius: 6px; background: var(--surface-2); }
.champ img.sm { width: 22px; height: 22px; border-radius: 4px; }
.champ .name { font-weight: 600; }
.champ .role { font-size: 12px; color: var(--muted); }
.res { display: inline-block; width: 22px; text-align: center; font-weight: 700; font-size: 12px; border-radius: 4px; padding: 2px 0; }
.res.w { color: var(--good); background: rgba(12, 163, 12, 0.12); }
.res.l { color: var(--bad); background: rgba(230, 103, 103, 0.12); }
.cs-cell .d { display: block; font-size: 11px; }
.pill { display: inline-block; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.pill.good { background: rgba(12, 163, 12, 0.14); color: var(--good); }
.pill.warn { background: rgba(250, 178, 25, 0.12); color: var(--warn); }
.pill.bad { background: rgba(230, 103, 103, 0.12); color: var(--bad); }
.detail td { padding: 16px; background: var(--surface-2); }
.detail .chart { height: 220px; }
.detail .meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; color: var(--text-2); font-size: 12px; }

@media (max-width: 640px) {
  .topbar, .wrap { padding-left: 16px; padding-right: 16px; }
  .p-sync { align-items: flex-start; width: 100%; }
  .kpi.hero .value { font-size: 32px; }
}

/* footer & legal page */
.site-footer {
  display: flex; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap;
  max-width: 1320px; margin: 24px auto 0; padding: 18px 24px 28px;
  border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; line-height: 1.5;
}
.site-footer span:first-child { max-width: 760px; }
.site-footer a, .legal a { color: var(--text-2); }
.site-footer a:hover, .legal a:hover { color: var(--text); }
.legal { max-width: 760px; line-height: 1.6; color: var(--text-2); }
.legal h1 { color: var(--text); font-size: 26px; margin: 8px 0 24px; }
.legal h2 { color: var(--text); font-size: 16px; margin: 28px 0 8px; }
.legal b { color: var(--text); font-weight: 600; }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 8px; }
.legal .notice { border-left: 3px solid var(--s1); padding: 8px 14px; background: var(--surface); border-radius: 0 8px 8px 0; }
@media (max-width: 640px) { .site-footer { padding-left: 16px; padding-right: 16px; } }
