:root {
  --bg:#0b0d18; --card:#161a2e; --card-hover:#1b2038; --border:#262c4a;
  --ink:#eef0ff; --muted:#8d94bf; --muted-dim:#666d94;
  --accent:#7b8cff; --accent2:#ff8a5c; --gold:#ffb23e;
  --good:#3ddc97; --bad:#ff6b6b;
  --radius:14px;
  /* dataviz roles — validated against this dark surface, see scripts/validate_palette.js */
  --viz-cat-1:#3987e5; --viz-cat-2:#d95926; --viz-cat-3:#199e70;
  --viz-cat-4:#c98500; --viz-cat-5:#d55181;
  --viz-seq:#3987e5; --viz-div-pos:#3987e5; --viz-div-neg:#e66767; --viz-div-mid:#383835;
  --viz-grid:#2c2c2a;
}
* { box-sizing:border-box; }
body {
  margin:0; font-family:-apple-system,system-ui,Segoe UI,Roboto,sans-serif;
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(123,140,255,.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(255,138,92,.10), transparent 55%),
    var(--bg);
  color:var(--ink); min-height:100vh;
}
header {
  padding:14px 28px; display:flex; align-items:center; gap:18px; flex-wrap:wrap;
  border-bottom:1px solid var(--border);
  background:rgba(11,13,24,.75); backdrop-filter:blur(10px);
  position:sticky; top:0; z-index:10;
}
.brand { display:flex; align-items:center; gap:10px; text-decoration:none; }
.logo { width:28px; height:28px; border-radius:8px; display:block; }
.brand span {
  font-size:16px; font-weight:800; letter-spacing:.2px;
  background:linear-gradient(90deg, var(--ink), var(--muted));
  -webkit-background-clip:text; background-clip:text; color:transparent;
}
nav.pages { display:flex; gap:4px; }
nav.pages a {
  color:var(--muted); text-decoration:none; font-size:13.5px; font-weight:600;
  padding:7px 12px; border-radius:8px; transition:background .12s ease, color .12s ease;
}
nav.pages a:hover { background:var(--card-hover); color:var(--ink); }
nav.pages a.active { background:var(--card-hover); color:var(--ink); box-shadow:inset 0 0 0 1px var(--border); }
#whoBox { margin-left:auto; display:flex; align-items:center; gap:10px; }
#whoBox img.avatar { width:32px; height:32px; border-radius:9px; background:#0d1022; object-fit:cover; }
#whoBox .who-text { display:flex; flex-direction:column; line-height:1.25; }
#whoBox .who-name { font-size:13px; font-weight:700; }
#whoBox .who-sub { font-size:11.5px; color:var(--muted); }
#logout { padding:8px 14px; font-size:13px; }

/* Manual "refresh now" button — lives in #whoBox next to the avatar.
   Full accent color + label when it's actually clickable, so it reads as
   a real call-to-action rather than a stray icon; recedes to a muted pill
   (matching the Log out button) while loading/cooling down, so its own
   color communicates whether it's usable right now. */
.btn-refresh {
  flex:0 0 auto; display:flex; align-items:center; gap:7px;
  padding:9px 15px 9px 13px; font-size:13px; white-space:nowrap;
  animation: refresh-pulse 2.4s ease-in-out infinite;
}
.btn-refresh .refresh-icon { display:inline-flex; font-size:15px; line-height:1; }
.btn-refresh.spinning .refresh-icon { animation:spin .8s linear infinite; }
.btn-refresh:disabled,
.btn-refresh.waiting {
  background:#1d2340; color:var(--muted); box-shadow:none; opacity:1;
  cursor:default; transform:none; animation:none;
}
.btn-refresh:disabled:hover { transform:none; box-shadow:none; }
@keyframes spin { to { transform:rotate(360deg); } }
@keyframes refresh-pulse {
  0%, 100% { box-shadow:0 4px 14px rgba(123,140,255,.28); }
  50% { box-shadow:0 4px 20px rgba(123,140,255,.55); }
}
@media (max-width:600px) {
  .btn-refresh .refresh-label { display:none; }
  .btn-refresh { padding:9px; border-radius:50%; }
}

/* First-time welcome modal, shown once right after linking a tag */
.modal-backdrop {
  position:fixed; inset:0; background:rgba(5,6,12,.72); z-index:100;
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.modal-backdrop.hidden { display:none; }
.modal-card { max-width:460px; width:100%; margin:0; }
.modal-list { margin:0 0 18px; padding-left:20px; color:var(--ink); font-size:13.5px; line-height:1.65; }
.modal-list li:not(:last-child) { margin-bottom:10px; }

/* Feedback popover — deliberately plain (no icon, no color) so it reads as
   a low-key utility link, not another call-to-action competing with Refresh. */
.feedback-wrap { position:relative; flex:0 0 auto; }
.feedback-link {
  background:none; border:none; box-shadow:none; padding:8px 4px;
  color:var(--muted); font-weight:600; font-size:13px; letter-spacing:0;
}
.feedback-link:hover { color:var(--ink); transform:none; box-shadow:none; }
.feedback-panel {
  position:absolute; top:calc(100% + 10px); right:0; z-index:40; width:260px;
  background:#11152a; border:1px solid var(--border); border-radius:11px;
  padding:14px; box-shadow:0 10px 28px rgba(0,0,0,.4);
}
.feedback-panel textarea { margin:0 0 8px; font-size:13px; }
.feedback-panel .row button { flex:1; padding:9px; font-size:13px; }

main { max-width:1000px; margin:0 auto; padding:28px 20px 60px; }

.card {
  background:linear-gradient(180deg, var(--card-hover), var(--card));
  border:1px solid var(--border); border-radius:var(--radius);
  padding:22px; margin-bottom:16px;
  box-shadow:0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.18);
}
.card h2 { margin:0 0 6px; font-size:15px; font-weight:700; letter-spacing:.2px; }
.card > p.muted:first-of-type { margin-top:0; }

/* Info icon + hover tooltip — replaces long explanatory captions under card
   titles so the page reads clean but the "why" is still one hover away. */
.info-icon {
  position:relative; display:inline-flex; align-items:center; justify-content:center;
  width:17px; height:17px; border-radius:50%; margin-left:3px;
  background:rgba(123,140,255,0.2); border:1px solid rgba(123,140,255,0.55);
  color:var(--accent); font-size:11px; font-weight:800; font-style:normal;
  letter-spacing:0; text-transform:none; cursor:help; flex:0 0 auto;
  vertical-align:middle; transition:background .12s ease, color .12s ease, border-color .12s ease;
}
.info-icon:hover, .info-icon:focus { background:var(--accent); color:#fff; border-color:var(--accent); outline:none; }
.info-icon .tooltip {
  visibility:hidden; opacity:0; pointer-events:none;
  position:absolute; top:22px; left:0; z-index:30;
  width:max-content; max-width:min(78vw, 300px);
  background:#11152a; color:var(--ink); border:1px solid var(--border);
  border-radius:9px; padding:10px 12px; font-size:12.5px; font-weight:400;
  line-height:1.5; letter-spacing:normal; text-transform:none; white-space:normal;
  box-shadow:0 10px 28px rgba(0,0,0,.4);
  transition:opacity .12s ease;
}
.info-icon:hover .tooltip, .info-icon:focus .tooltip { visibility:visible; opacity:1; }

input,button,select,textarea { font-size:14px; padding:11px 14px; border-radius:10px; border:1px solid var(--border); }
select { background:#0d1022; color:var(--ink); }
input,textarea { background:#0d1022; color:var(--ink); width:100%; margin:6px 0; transition:border-color .15s ease; font-family:inherit; }
input:focus,textarea:focus { outline:none; border-color:var(--accent); }
textarea { resize:vertical; }
button {
  background:linear-gradient(135deg, var(--accent), #5c6fe0); color:#fff; border:none;
  cursor:pointer; font-weight:700; letter-spacing:.2px;
  transition:transform .12s ease, box-shadow .12s ease, opacity .12s ease;
  box-shadow:0 4px 14px rgba(123,140,255,.28);
}
button:hover { transform:translateY(-1px); box-shadow:0 6px 18px rgba(123,140,255,.4); }
button:active { transform:translateY(0); }
button.secondary { background:#1d2340; color:var(--ink); box-shadow:none; border:1px solid var(--border); }
button.secondary:hover { background:#242a4c; box-shadow:none; }

.row { display:flex; gap:20px; flex-wrap:wrap; }
.stat { flex:1; min-width:150px; }
.stat .n { font-size:30px; font-weight:800; letter-spacing:-.5px; }
.stat .l { color:var(--muted); font-size:11.5px; text-transform:uppercase; letter-spacing:.6px; margin-top:2px; }

table { width:100%; border-collapse:collapse; font-size:13.5px; }
th,td { text-align:left; padding:10px 8px; vertical-align:middle; }
th {
  color:var(--muted-dim); font-weight:700; font-size:11px; text-transform:uppercase;
  letter-spacing:.5px; border-bottom:1px solid var(--border); padding-bottom:10px;
}
th.sortable { cursor:pointer; user-select:none; transition:color .12s ease; }
th.sortable:hover { color:var(--ink); }
tbody tr { border-bottom:1px solid rgba(255,255,255,.04); transition:background .12s ease; }
tbody tr:last-child { border-bottom:none; }
tbody tr:hover { background:rgba(123,140,255,.06); }

.hidden { display:none; }
.muted { color:var(--muted); font-size:13px; line-height:1.5; }
.err { color:var(--bad); font-size:13px; min-height:16px; margin-top:4px; }
.insight { display:flex; gap:10px; padding:10px 0; align-items:flex-start; }
.insight:not(:last-child) { border-bottom:1px solid rgba(255,255,255,.06); }
.insight .dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-top:6px; flex:0 0 auto; }
.insight .dot.good { background:var(--good); }
.insight .dot.bad { background:var(--bad); }
.insight .dot.neutral { background:var(--muted-dim); }
.insight .txt { font-size:14px; line-height:1.5; }
.insight .txt b { font-weight:700; }
.pill-row { display:flex; gap:8px; flex-wrap:wrap; }
.pill {
  padding:7px 14px; border-radius:999px; border:1px solid var(--border);
  background:#0d1022; color:var(--muted); font-size:13px; font-weight:600;
  cursor:pointer; transition:background .12s ease, color .12s ease, border-color .12s ease;
}
.pill:hover { background:var(--card-hover); color:var(--ink); }
.pill.active { background:var(--accent); color:#fff; border-color:var(--accent); }
.icon-col { width:38px; }
.chart-wrap { position:relative; width:100%; height:280px; }
.chart-wrap.tall { height:320px; }
img.thumb { width:28px; height:28px; object-fit:contain; border-radius:7px; background:#0d1022; display:block; }
img.thumb.map-thumb { width:42px; height:28px; border-radius:5px; object-fit:cover; }

#auth, #linkCard { max-width:420px; margin:60px auto 0; text-align:left; }
#auth h2, #linkCard h2 { font-size:19px; }
#auth label, #linkCard label {
  display:block; color:var(--muted); font-size:12px; font-weight:700;
  margin:10px 0 0;
}

/* Big nav cards on the hub page */
.nav-cards { display:grid; grid-template-columns:repeat(3,1fr); gap:16px; }
.nav-card {
  display:block; text-decoration:none; color:var(--ink);
  background:linear-gradient(180deg, var(--card-hover), var(--card));
  border:1px solid var(--border); border-radius:var(--radius); padding:24px;
  transition:transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.nav-card:hover { transform:translateY(-3px); border-color:var(--accent); box-shadow:0 10px 30px rgba(123,140,255,.18); }
.nav-card .nc-icon { width:22px; height:22px; margin-bottom:10px; display:block; }
.nav-card h3 { margin:0 0 6px; font-size:17px; }
.nav-card p { margin:0; color:var(--muted); font-size:13px; line-height:1.5; }

/* Pick cards (best-brawler-per-map) */
.pick-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(150px,1fr)); gap:12px; }
.pick-card {
  background:#11152a; border:1px solid var(--border); border-radius:11px; padding:12px;
  text-align:center;
}
.pick-card img.thumb { width:44px; height:44px; margin:0 auto 8px; }
.pick-card .pc-map { font-size:12px; color:var(--muted); margin-bottom:2px; }
.pick-card .pc-brawler { font-weight:700; font-size:13.5px; }
.pick-card .pc-wr { font-size:12px; color:var(--good); margin-top:4px; font-weight:700; }

/* Heatmap grid */
.heatmap { display:flex; flex-direction:column; gap:2px; overflow-x:auto; }
.heatmap-row { display:flex; gap:2px; align-items:center; }
.heatmap-row .hm-label { width:130px; flex:0 0 130px; font-size:12.5px; color:var(--muted); text-align:right; padding-right:10px; }
.hm-cell {
  flex:1; min-width:64px; height:38px; border-radius:6px; display:flex; align-items:center;
  justify-content:center; font-size:12px; font-weight:700; color:#0b0d18;
}
.hm-cell.empty { background:rgba(255,255,255,.03); color:var(--muted-dim); font-weight:500; }
/* Series count inline on the cell, not just in the hover title — a 0%/100%
   cell from 1 series should never look as confident as one from 10. */
.hm-n { font-size:8.5px; font-weight:600; opacity:.72; margin-left:3px; }
.heatmap-cols { display:flex; gap:2px; padding-left:140px; }
.heatmap-cols span { flex:1; min-width:64px; font-size:11px; color:var(--muted); text-align:center; }
.heatmap-cols .hm-total-label { color:var(--ink); font-weight:700; }
/* Row/column totals — same color-by-win-rate language as regular cells, plus
   a ring so they read as summaries, not just another data point. */
.hm-cell.hm-total { box-shadow:inset 0 0 0 1.5px rgba(255,255,255,.4); font-weight:800; }
.hm-total-row { border-top:1px solid var(--border); margin-top:4px; padding-top:4px; }
.hm-total-row .hm-label { color:var(--ink); font-weight:700; }

@media (max-width:600px) {
  main { padding:20px 14px 50px; }
  .card { padding:16px; }
  .stat .n { font-size:24px; }
  .nav-cards { grid-template-columns:1fr; }
  #whoBox .who-sub { display:none; }
}
@media (min-width:601px) and (max-width:850px) {
  .nav-cards { grid-template-columns:1fr 1fr; }
}
