:root {
  color-scheme: light;
  --page: #f1ede4;
  --surface-1: #fcfcfb;
  --surface-2: #f5f3ee;
  --rule: #e2ddd2;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77756f;
  --forever: #2a78d6;
  --classic: #eb6834;
  --kept: #a3a29b;
  --gold: #9a7a2e;
  --grid: #e7e4dc;
  --q0: #9d9d9d; --q1: #8a8a85; --q2: #1eaa00; --q3: #0070dd; --q4: #a335ee; --q5: #ff8000;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #121211;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --rule: #33322f;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #9a998f;
    --forever: #3987e5;
    --classic: #d95926;
    --kept: #6c6b65;
    --gold: #d1b26a;
    --grid: #2b2a28;
    --q0: #9d9d9d; --q1: #d7d6d0; --q2: #3ccf1e; --q3: #3d97ff; --q4: #c07cff; --q5: #ff9a33;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #121211;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --rule: #33322f;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #9a998f;
  --forever: #3987e5;
  --classic: #d95926;
  --kept: #6c6b65;
  --gold: #d1b26a;
  --grid: #2b2a28;
  --q0: #9d9d9d; --q1: #d7d6d0; --q2: #3ccf1e; --q3: #3d97ff; --q4: #c07cff; --q5: #ff9a33;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.55 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--forever); }
code { font-size: 0.85em; color: var(--text-muted); }
h1, h2, h3 { font-family: Cinzel, Georgia, serif; letter-spacing: 0.02em; line-height: 1.2; }
h2 { font-size: 1.35rem; margin: 0 0 0.25rem; }
h3 { font-size: 1.02rem; margin: 0 0 0.4rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

/* Masthead */
.masthead { background: var(--surface-1); border-bottom: 1px solid var(--rule); }
.masthead-inner {
  max-width: 1240px; margin: 0 auto; padding: 18px 16px 8px;
  display: flex; gap: 16px; justify-content: space-between; align-items: flex-end; flex-wrap: wrap;
}
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem; color: var(--gold); margin: 0; font-weight: 600; }
h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 2px 0 4px; }
.lede { color: var(--text-secondary); margin: 0; max-width: 62ch; }
.legend-key { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 0.88rem; color: var(--text-secondary); }
.legend-key span { display: inline-flex; gap: 6px; align-items: center; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw-forever { background: var(--forever); }
.sw-classic { background: var(--classic); }
.sw-kept { background: var(--kept); }
.tabs {
  max-width: 1240px; margin: 0 auto; padding: 0 16px; display: flex; gap: 2px; overflow-x: auto;
  scrollbar-width: none;
}
.tabs button {
  appearance: none; border: 0; background: none; color: var(--text-secondary); font: inherit; font-weight: 500;
  padding: 10px 12px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--gold); }
.tabs button:hover { color: var(--text-primary); }
button.ghost, .chip {
  appearance: none; font: inherit; font-size: 0.85rem; cursor: pointer;
  border: 1px solid var(--rule); background: var(--surface-1); color: var(--text-secondary);
  border-radius: 999px; padding: 4px 11px;
}
.chip[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }

main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 40px; }
.tab-panel { display: grid; gap: 18px; }
.tab-panel[hidden] { display: none; }
.section-head { display: grid; gap: 4px; margin-top: 8px; }
.section-head p { color: var(--text-secondary); max-width: 80ch; margin: 0; }

.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card { background: var(--surface-1); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card > p.note { font-size: 0.85rem; color: var(--text-muted); margin: 8px 0 0; }
.card .sub { color: var(--text-secondary); font-size: 0.9rem; margin: -2px 0 10px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface-1); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; }
.tile .num { font-family: Cinzel, Georgia, serif; font-size: 2rem; font-weight: 700; line-height: 1.1; }
.tile .lbl { color: var(--text-secondary); font-size: 0.88rem; }
.tile .ctx { color: var(--text-muted); font-size: 0.78rem; margin-top: 4px; }

.callout { border-left: 3px solid var(--gold); background: var(--surface-2); padding: 12px 14px; border-radius: 6px; color: var(--text-secondary); font-size: 0.92rem; }
.callout strong { color: var(--text-primary); }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.controls input[type="search"], .controls select {
  font: inherit; font-size: 0.9rem; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--rule);
  background: var(--surface-1); color: var(--text-primary); min-width: 0;
}
.controls input[type="search"] { flex: 1 1 220px; }

/* Tables */
.table-wrap { overflow: auto; max-height: 460px; border: 1px solid var(--rule); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--text-secondary); z-index: 1; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.gem { display: inline-block; width: 8px; height: 8px; border-radius: 2px; transform: rotate(45deg); margin-right: 7px; vertical-align: 1px; }
.tag { display: inline-block; font-size: 0.72rem; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--rule); color: var(--text-secondary); white-space: nowrap; }
.tag.new { border-color: var(--forever); color: var(--text-primary); }
.tag.new::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--forever); margin-right: 5px; vertical-align: 1px; }
.tag.gone::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--classic); margin-right: 5px; vertical-align: 1px; }

/* Charts */
.chart { width: 100%; overflow-x: auto; }
.chart svg { max-width: 100%; height: auto; }
figure { margin: 0; }
[aria-label="tip"] { font-size: 12px; }

/* Map compare */
.map-compare { position: relative; width: 100%; aspect-ratio: 1002 / 668; border-radius: 8px; overflow: hidden; background: #000; user-select: none; }
.map-compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.map-compare .top { clip-path: inset(0 0 0 var(--split, 50%)); }
.map-compare .divider { position: absolute; top: 0; bottom: 0; left: var(--split, 50%); width: 2px; background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.6); pointer-events: none; }
.map-compare .lab { position: absolute; top: 10px; font-size: 0.75rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; }
.map-compare .lab.l { left: 10px; } .map-compare .lab.r { right: 10px; }
.zone-box { position: absolute; border: 2px solid var(--forever); background: color-mix(in srgb, var(--forever) 18%, transparent); border-radius: 4px; cursor: help; }
.zone-box span { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 3px); white-space: nowrap; font-size: 11px; font-weight: 600; color: #fff; background: rgba(0,0,0,.7); padding: 1px 6px; border-radius: 4px; }
.zone-box.old { border: 1px dashed rgba(255,255,255,.35); background: transparent; }
.zone-box.old span { display: none; }
.zone-box.old:hover { border-color: #fff; }
.zone-box.old:hover span { display: block; }
input[type="range"] { width: 100%; accent-color: var(--gold); }
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.gallery figure { background: var(--surface-1); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.gallery img { width: 100%; display: block; aspect-ratio: 1002 / 668; object-fit: cover; }
.gallery figcaption { padding: 10px 12px; font-size: 0.85rem; color: var(--text-secondary); }
.gallery figcaption strong { color: var(--text-primary); font-family: Cinzel, Georgia, serif; font-size: 0.98rem; display: block; }

/* Talent trees */
.class-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.tree-wrap { overflow-x: auto; }
.tree-svg text { font-size: 11px; fill: var(--text-secondary); }
.tree-svg .sec-title { font-family: Cinzel, Georgia, serif; font-size: 13px; fill: var(--text-primary); font-weight: 700; }
.tree-svg .node { cursor: help; }
.tree-svg .node:hover rect.ring { stroke-width: 3.5; }
.tree-svg .rank { font-size: 10px; fill: #fff; font-weight: 600; paint-order: stroke; stroke: #000; stroke-width: 2.5px; }
.tree-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; color: var(--text-secondary); margin: 6px 0 10px; }
.tree-legend span { display: inline-flex; gap: 6px; align-items: center; }

.chiplist { display: flex; flex-wrap: wrap; gap: 6px; }
.chiplist .tag { font-size: 0.8rem; }
.boss-list { margin: 6px 0 0; padding-left: 18px; color: var(--text-secondary); font-size: 0.9rem; columns: 2; column-gap: 18px; }
.quote { font-family: Georgia, serif; font-style: italic; color: var(--text-secondary); border-left: 3px solid var(--gold); padding: 4px 0 4px 14px; }

.tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 320px;
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--rule);
  border-radius: 8px; padding: 9px 11px; font-size: 0.82rem; box-shadow: 0 6px 22px rgba(0,0,0,.18);
}
.tip strong { display: block; margin-bottom: 2px; }
.tip .tip-desc { color: var(--text-secondary); margin-top: 4px; }

.foot { max-width: 1240px; margin: 0 auto; padding: 0 16px 30px; color: var(--text-muted); font-size: 0.8rem; }

@media (max-width: 640px) {
  .boss-list { columns: 1; }
  .tile .num { font-size: 1.6rem; }
}
