/* NexusWeb — Onyx Stats. Palette + type follow the main Onyx site (css/variables.css). Light + dark. */
:root {
  --primary: #0b8ec9;
  --primary-hover: #097aa8;
  --primary-soft: #e8f6fc;
  --gold: #e0a93b;

  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-2: #fbfdfe;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 999px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --container: min(1060px, 100% - 2rem);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1016; --surface: #141c26; --surface-2: #19232f; --border: #273445; --border-strong: #35485c;
    --text: #e8eef5; --text-2: #a9b7c6; --text-3: #7d8da0;
    --primary-soft: #0e2f40; --shadow-sm: 0 2px 8px rgba(0,0,0,.3); --shadow-md: 0 10px 30px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #0b1016; --surface: #141c26; --surface-2: #19232f; --border: #273445; --border-strong: #35485c;
  --text: #e8eef5; --text-2: #a9b7c6; --text-3: #7d8da0;
  --primary-soft: #0e2f40; --shadow-sm: 0 2px 8px rgba(0,0,0,.3); --shadow-md: 0 10px 30px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }

/* header */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.top .wrap { width: var(--container); margin: 0 auto; display: flex; align-items: center; gap: 12px; height: 60px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -0.02em; font-size: 18px; }
.logo .mark { width: 26px; height: 26px; flex: 0 0 auto; }
.logo small { color: var(--text-3); font-weight: 600; font-size: 12px; letter-spacing: 0.02em; text-transform: uppercase; }
.spacer { flex: 1; }
.theme-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); width: 38px; height: 38px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 16px; display: grid; place-items: center; flex: 0 0 auto; }
.theme-btn:hover { border-color: var(--border-strong); color: var(--text); }

/* nav */
.nav { display: flex; gap: 2px; margin-left: 6px; }
.navlink { color: var(--text-2); font-weight: 600; font-size: 14px; padding: 8px 12px; border-radius: var(--radius-sm); white-space: nowrap; }
.navlink:hover { color: var(--text); background: var(--bg); }
.navlink.active { color: var(--primary); background: var(--primary-soft); }
.burger { display: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 38px; height: 38px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 17px; flex: 0 0 auto; }
@media (max-width: 760px) {
  .burger { display: block; }
  .nav { position: absolute; top: 60px; left: 0; right: 0; flex-direction: column; gap: 0; background: var(--surface);
    border-bottom: 1px solid var(--border); padding: 6px; margin: 0; display: none; box-shadow: var(--shadow-md); }
  .nav.open { display: flex; }
  .navlink { padding: 11px 12px; }
  .top .wrap { position: relative; }
}

.kdlink { font-variant-numeric: tabular-nums; }

main { width: var(--container); margin: 0 auto; padding: 28px 0 60px; }

.head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 18px; margin-bottom: 18px; }
.head h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; text-wrap: balance; }
.head p { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }
.asof { color: var(--text-3); font-size: 12.5px; }
.asof b { color: var(--text-2); font-weight: 600; }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.field { display: flex; align-items: center; gap: 0; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); overflow: hidden; }
.field label { padding: 0 10px; color: var(--text-3); font-size: 13px; font-weight: 600; border-right: 1px solid var(--border); align-self: stretch; display: flex; align-items: center; }
.field input { border: 0; background: transparent; color: var(--text); padding: 9px 11px; font: inherit; width: 120px; outline: none; }
.field input::placeholder { color: var(--text-3); }
.btn { border: 1px solid var(--primary); background: var(--primary); color: #fff; padding: 9px 16px;
  border-radius: var(--radius-sm); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn.ghost:hover { border-color: var(--border-strong); color: var(--text); }

/* table */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
thead th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 11.5px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-3); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th.num, td.num { text-align: right; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--primary-soft); }
.rank { color: var(--text-3); font-weight: 700; font-variant-numeric: tabular-nums; width: 1%; }
.rank.top { color: var(--gold); }
.tag { font-family: var(--mono); font-weight: 600; background: var(--primary-soft); color: var(--primary);
  padding: 2px 7px; border-radius: var(--radius-sm); font-size: 13px; }
.gname { color: var(--text); max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.cups { font-weight: 700; }
.cups .u { color: var(--text-3); font-weight: 600; font-size: 12px; margin-left: 3px; }
.lang { font-size: 11.5px; color: var(--text-2); border: 1px solid var(--border); border-radius: var(--radius-full); padding: 1px 8px; }
.kd a { font-variant-numeric: tabular-nums; }

.foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; }
.foot .count { color: var(--text-3); font-size: 13px; }
.msg { padding: 40px 16px; text-align: center; color: var(--text-3); }
.msg.err { color: #c0392b; }
.pageinfo { color: var(--text-3); font-size: 13px; }
.site-foot { width: var(--container); margin: 24px auto 0; color: var(--text-3); font-size: 12px; text-align: center; }

@media (max-width: 560px) {
  .head h1 { font-size: 22px; }
  .gname { max-width: 150px; }
  .field input { width: 92px; }
}

/* ---- shared components (overview, kingdom, player, leaderboard) ---- */
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (max-width: 720px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }

.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.tile .label { color: var(--text-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.tile .value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel > h2 { margin: 0; padding: 14px 16px; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; }
.panel > h2 a { margin-left: auto; font-size: 12.5px; font-weight: 600; }
.panel .body { padding: 6px 0; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; }
.row:hover { background: var(--primary-soft); }
.row .r { color: var(--text-3); font-weight: 700; width: 30px; font-variant-numeric: tabular-nums; }
.row .r.top { color: var(--gold); }
.row .main { flex: 1; min-width: 0; }
.row .main .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .main .meta { color: var(--text-3); font-size: 12px; }
.row .val { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.version-badge { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: var(--radius-full);
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }
.dot.down { background: #ef4444; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text-2); font: inherit; font-weight: 600; padding: 8px 15px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--primary); color: #fff; }

.hero { background: linear-gradient(135deg, var(--primary) 0%, #0a6fa0 100%); color: #fff; border-radius: var(--radius-lg);
  padding: 26px 24px; box-shadow: var(--shadow-md); margin-bottom: 18px; }
.hero h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: -0.02em; }
.hero p { margin: 0; opacity: 0.9; font-size: 15px; }
.hero .badges { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.hero .badge { background: rgba(255,255,255,0.16); border-radius: var(--radius-full); padding: 5px 12px; font-size: 13px; font-weight: 600; }

.mig-dir { font-weight: 700; }
.mig-dir .arw { color: var(--text-3); margin: 0 4px; }
.up { color: #16a34a; } .down2 { color: #dc2626; }

/* small utilities (used instead of inline styles so the strict CSP holds) */
.mb-18 { margin-bottom: 18px; }
.pad14 { padding: 14px; }
.ml8 { margin-left: 8px; }
.mr6 { margin-right: 6px; }
.wfull { width: 100%; }
.field-grow { flex: 1; max-width: 360px; }
.h1-sm { font-size: 20px; }
.note { color: var(--text-3); font-size: 12.5px; }

/* ===== Live Wonders ===== */
.livepill { font: 600 12.5px/1 var(--font); padding: 7px 12px; border-radius: var(--radius-full); border: 1px solid var(--border); color: var(--text-2); background: var(--surface); white-space: nowrap; }
.livepill.on { color: #0a7d3b; border-color: #9fe0bb; background: #e9f9f0; }
.livepill.off { color: var(--text-3); }
:root[data-theme="dark"] .livepill.on, :root:not([data-theme="light"]) .livepill.on { color: #46d98a; border-color: #1c4733; background: #0f2a1d; }
.wcard { display: flex; flex-direction: column; gap: 6px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); text-decoration: none; color: var(--text); transition: border-color .12s, transform .12s; }
.wcard:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.wcard.islive { border-color: #e4572e; box-shadow: 0 0 0 1px rgba(228,87,46,.25), var(--shadow-sm); }
.wcard-top { display: flex; align-items: center; gap: 8px; }
.kbadge { font: 700 12px/1 var(--mono); color: var(--primary); background: var(--primary-soft); padding: 4px 8px; border-radius: var(--radius-sm); }
.wstate { font: 600 11.5px/1 var(--font); color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin-left: auto; }
.wcard.islive .wstate { color: #e4572e; }
.wtimer { font: 700 26px/1 var(--mono); color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.wtimer.live { color: #e4572e; }
.wtimer.due { color: var(--gold); }
.wover { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; min-height: 20px; }
.wover .gkd { font: 600 11px/1 var(--mono); color: var(--text-3); }
.muted { color: var(--text-3); }

/* ===== Interactive map ===== */
.wsmall { width: 92px; }
.mapwrap { position: relative; padding: 0; overflow: hidden; }
.mapcanvas { display: block; width: 100%; height: min(72vh, 760px); touch-action: none; cursor: grab; background: #1d2a1e; border-radius: var(--radius); }
.mapcanvas.grabbing { cursor: grabbing; }
.mapover { position: absolute; top: 12px; left: 12px; background: rgba(12,18,12,.82); color: #eaf1e8; border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius-sm); padding: 10px 12px; max-width: 220px; backdrop-filter: blur(3px); }
.mapover .mo-t { font-size: 12px; color: #c7d4c3; display: flex; align-items: center; gap: 6px; }
.mapover .mo-n { font: 700 15px/1.2 var(--font); margin: 3px 0; }
.mapover .mo-w { font-size: 12.5px; color: #c7d4c3; } .mapover .mo-w b { color: #f2c661; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.maplegend { position: absolute; right: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; background: rgba(12,18,12,.82); border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius-sm); padding: 8px 11px; max-width: 220px; }
.maplegend .lgi { display: flex; align-items: center; gap: 6px; font: 600 11.5px/1 var(--font); color: #dbe6d7; }
.maplegend .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.sw.t0 { background: #8aa0b4; } .sw.t1 { background: #63b0dc; } .sw.t2 { background: #2e8fce; }
.sw.t3 { background: #0b6fb0; } .sw.t4 { background: #e0a93b; } .sw.t5 { background: #e4572e; }
@media (max-width: 560px) { .maplegend { max-width: 150px; } .mapover { max-width: 160px; } }

/* map coordinate readout */
.coord { font-family: var(--mono); font-weight: 600; color: var(--primary); white-space: nowrap; }
