/* Layout: header con pestañas, mapa a la izquierda y panel de zona a la derecha (apilado en móvil), luego ranking, tabla y notas. */
:root {
  --bg: #0e1417;
  --surface: #151d22;
  --surface-2: #1c262c;
  --line: #2a3840;
  --fg: #e4ebe8;
  --muted: #8fa0a7;
  --accent: #7ad3c6;
  --accent-ink: #0e1417;
  --g: #4cc775;
  --b: #6a9bf5;
  --a: #e3ab45;
  --m: #b896f2;
  --elite: #e9c46a;
  --shadow: 0 10px 30px rgb(0 0 0 / .35);
  --f-display: "Marcellus", "Palatino Linotype", Georgia, serif;
  --f-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --f-data: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #edf1f2; --surface: #ffffff; --surface-2: #f4f7f8; --line: #d3dcdf; --fg: #13212a; --muted: #56676e;
    --accent: #13806f; --accent-ink: #ffffff; --g: #1f9548; --b: #2f68d6; --a: #b97a0d; --m: #7b52c9; --elite: #9a6d07;
    --shadow: 0 10px 30px rgb(20 40 50 / .12); color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #edf1f2; --surface: #ffffff; --surface-2: #f4f7f8; --line: #d3dcdf; --fg: #13212a; --muted: #56676e;
  --accent: #13806f; --accent-ink: #ffffff; --g: #1f9548; --b: #2f68d6; --a: #b97a0d; --m: #7b52c9; --elite: #9a6d07;
  --shadow: 0 10px 30px rgb(20 40 50 / .12); color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.wrap { max-width: 1320px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3 { font-family: var(--f-display); font-weight: 400; text-wrap: balance; margin: 0; letter-spacing: .01em; }
a { color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.top-in { display: flex; gap: 16px 32px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; padding-block: 18px 0; }
.brand { min-width: 0; padding-bottom: 14px; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.3rem); line-height: 1.05; }
.lede { margin: 6px 0 0; color: var(--muted); max-width: 62ch; font-size: .97rem; }
.tabs { display: flex; gap: 4px; }
.tabs button { font: 600 .95rem var(--f-body); color: var(--muted); background: none; border: 0; padding: 10px 16px 12px; border-bottom: 3px solid transparent; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--fg); }

/* Stone selector */
.controls { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding-block: 18px 14px; }
.ctl-label { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { font: 600 .9rem var(--f-body); color: var(--muted); background: none; border: 0; border-radius: 999px; padding: 6px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.seg button .dot { width: 10px; height: 10px; border-radius: 3px; transform: rotate(45deg); background: var(--c); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }
.ctl-hint { color: var(--muted); font-size: .9rem; }

/* Stage */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.map-col { min-width: 0; }
.map-wrap { position: relative; width: 100%; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); user-select: none; }
.map-wrap img { display: block; width: 100%; height: auto; max-width: 100%; filter: saturate(.75) brightness(.92); }
.map-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.zone { cursor: pointer; transition: opacity .15s ease, stroke-width .15s ease; stroke-linejoin: round; }
.zone.dim { opacity: .45; }
.zone.on { stroke-width: 3.2; }
.landmark { fill: none; stroke: #ffffff; stroke-opacity: .55; stroke-width: 1.6; stroke-dasharray: 5 5; pointer-events: none; }
.chip-bg { fill: #0d1317; fill-opacity: .88; }
.chip-num { font: 700 15px var(--f-body); fill: #ffffff; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.chip-val { font: 500 12px var(--f-data); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.chip { pointer-events: none; }
.map-note { color: var(--muted); font-size: .85rem; margin: 8px 2px 0; }

/* Panel */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); position: sticky; top: calc(env(safe-area-inset-top, 0px) + 96px); max-height: calc(100vh - 120px); display: flex; flex-direction: column; min-width: 0; }
.panel-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.panel-head .kicker { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.panel-head h3 { font-size: 1.35rem; margin-top: 4px; }
.panel-head .meta { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.tot { background: var(--surface-2); border-radius: 8px; padding: 6px 8px; border-top: 3px solid var(--c); }
.tot .v { font: 500 1.05rem var(--f-data); color: var(--fg); font-variant-numeric: tabular-nums; }
.tot .l { font-size: .72rem; color: var(--muted); }
.tot.sel { box-shadow: inset 0 0 0 1px var(--c); }
.mob-list { list-style: none; margin: 0; padding: 6px 8px 10px; overflow-y: auto; }
.mob { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 8px; }
.mob + .mob { border-top: 1px solid var(--line); }
.mob .ic { width: 40px; height: 40px; border-radius: 8px; background: var(--surface-2); overflow: hidden; display: grid; place-items: center; font: 700 .8rem var(--f-body); color: var(--muted); border: 1px solid var(--line); }
.mob .ic img { width: 100%; height: 100%; object-fit: cover; }
.mob.elite .ic { border-color: var(--elite); }
.mob .nm { font-weight: 600; font-size: .93rem; line-height: 1.25; }
.mob .sub { font-size: .78rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--elite); border: 1px solid currentColor; border-radius: 999px; padding: 0 6px; }
.rates { display: grid; grid-template-columns: repeat(2, auto); gap: 0 10px; text-align: right; font: 500 .8rem var(--f-data); font-variant-numeric: tabular-nums; color: var(--muted); }
.rates .main { grid-column: 1 / -1; font-size: 1rem; color: var(--c); }
.panel-empty { padding: 20px 16px; color: var(--muted); }
.panel-empty h3 { color: var(--fg); font-size: 1.2rem; margin-bottom: 6px; }

/* Ranking */
.ranking-sec, .table-sec, .notes { margin-top: 44px; }
h2 { font-size: 1.45rem; }
.sec-sub { color: var(--muted); margin: 4px 0 14px; font-size: .92rem; }
.ranking { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 6px 18px; }
.rk { display: grid; grid-template-columns: 30px minmax(0, 1fr) 110px; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; background: none; color: inherit; font: inherit; text-align: left; width: 100%; }
.rk:hover, .rk.on { background: var(--surface); border-color: var(--line); }
.rk .n { font: 700 .85rem var(--f-body); color: var(--muted); text-align: center; }
.rk .z { font-weight: 600; font-size: .95rem; line-height: 1.2; min-width: 0; }
.rk .z small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.rk .bar { position: relative; height: 22px; display: flex; align-items: center; justify-content: flex-end; }
.rk .bar i { position: absolute; left: 0; top: 6px; height: 10px; border-radius: 4px; background: var(--c); opacity: .85; }
.rk .bar span { position: relative; font: 500 .85rem var(--f-data); color: var(--fg); background: var(--bg); padding-left: 4px; }

/* Table */
.table-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[type="search"], .filters select { font: inherit; font-size: .92rem; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
.filters input[type="search"] { width: 220px; max-width: 100%; }
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: .92rem; color: var(--muted); }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); max-height: 640px; overflow-y: auto; }
table.mobs { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 760px; }
.mobs th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 9px 10px; cursor: pointer; white-space: nowrap; border-bottom: 1px solid var(--line); }
.mobs th[aria-sort] { color: var(--fg); }
.mobs th[aria-sort="descending"]::after { content: " ↓"; }
.mobs th[aria-sort="ascending"]::after { content: " ↑"; }
.mobs td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.mobs .num { text-align: right; font-family: var(--f-data); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mobs td.nmc { display: flex; gap: 10px; align-items: center; min-width: 220px; }
.mobs td.nmc .ic { width: 30px; height: 30px; flex: none; border-radius: 6px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font: 700 .7rem var(--f-body); color: var(--muted); }
.mobs td.nmc .ic img { width: 100%; height: 100%; object-fit: cover; }
.mobs tr.elite td.nmc .ic { border-color: var(--elite); }
.mobs td.zc { color: var(--muted); }
.st-g { color: var(--g) !important; } .st-b { color: var(--b) !important; } .st-a { color: var(--a) !important; } .st-m { color: var(--m) !important; }
.mobs td.dash { color: var(--muted) !important; opacity: .5; }

/* Notes */
.notes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; padding-bottom: 56px; border-top: 1px solid var(--line); padding-top: 28px; }
.notes h2 { font-size: 1.15rem; margin-bottom: 8px; }
.notes ul { margin: 0; padding-left: 18px; color: var(--fg); font-size: .93rem; display: grid; gap: 6px; }
.notes .fine { color: var(--muted); font-size: .82rem; margin-top: 14px; }

@media (max-width: 980px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .panel { position: static; max-height: none; }
  .notes { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .top { position: static; }
  .totals { grid-template-columns: repeat(2, 1fr); }
  .chip-val { display: none; }
}
@media (prefers-reduced-motion: reduce) { .zone { transition: none; } }
