:root {
  --sea: #142033;
  --sea-2: #0e1726;
  --ink: #f3ead2;
  --ink-2: #b9ae92;
  --gold: #d8b25e;
  --gold-2: #8a6d2e;
  --panel: rgba(17, 26, 42, 0.94);
  --line: rgba(216, 178, 94, 0.45);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 40%, #1d2c45 0%, var(--sea) 55%, var(--sea-2) 100%);
  color: var(--ink);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; cursor: pointer; }

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px;
  background: linear-gradient(#1a263b, #111a2a);
  border-bottom: 2px solid var(--gold-2);
  box-shadow: 0 2px 0 rgba(216, 178, 94, .25), 0 6px 18px rgba(0, 0, 0, .4);
  z-index: 3;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.crest { font-size: 30px; color: var(--gold); text-shadow: 0 0 10px rgba(216, 178, 94, .5); line-height: 1; }
h1 { margin: 0; font-size: 20px; letter-spacing: .12em; }
.sub { margin: 2px 0 0; font-size: 12px; color: var(--ink-2); letter-spacing: .06em; }
.by { margin: 1px 0 0; font-size: 11px; letter-spacing: .04em; }
.by a { color: var(--gold); opacity: .8; text-decoration: none; }
.by a:hover { opacity: 1; text-decoration: underline; }

.lenses { display: flex; gap: 6px; }
.lenses button {
  padding: 6px 14px; border-radius: 3px;
  background: #1f2c44; border: 1px solid var(--gold-2);
  font-size: 14px; letter-spacing: .08em;
}
.lenses button[aria-selected="true"] {
  background: linear-gradient(#e2c174, #b08a3c); color: #1b1407; border-color: var(--gold);
  font-weight: 700;
}
.lenses button:focus-visible, .zoom button:focus-visible, .close:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#stage { position: relative; flex: 1; min-height: 0; }
#map { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#map.dragging { cursor: grabbing; }

.hex { stroke: rgba(10, 16, 28, .35); stroke-width: .6; transition: opacity .15s; }
.hex.dim { opacity: .38; }
.icon { pointer-events: none; }
.border { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; opacity: .75; pointer-events: none; }
.border.outer { stroke: var(--gold); stroke-width: 3; opacity: .9; }
.sel-border { fill: none; stroke: #fff6d8; stroke-width: 3.4; stroke-linecap: round; pointer-events: none; filter: drop-shadow(0 0 4px rgba(255, 230, 160, .9)); }
.river { fill: none; stroke: #5fa3e6; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: .9; pointer-events: none; }
.river-label { fill: #a9d0f5; font-size: 11px; letter-spacing: .3em; pointer-events: none; paint-order: stroke; stroke: rgba(10, 20, 35, .7); stroke-width: 3px; }

.plate { cursor: pointer; }
.plate rect.bg { fill: #1b2740; stroke: var(--gold); stroke-width: 1.2; }
.plate .pop-bg { fill: var(--gold); }
.plate text { font-size: 12px; fill: var(--ink); dominant-baseline: central; }
.plate .pop { fill: #1b1407; font-weight: 700; font-size: 11px; }
.plate.on rect.bg { fill: #3a2c10; stroke: #fff2c8; }
.citydot { fill: #fff2c8; stroke: #1b1407; stroke-width: 1.2; pointer-events: none; }

.wonder { cursor: pointer; }
.wonder path { fill: #f4cf6b; stroke: #3b2a07; stroke-width: 1; }
.wonder text { font-size: 10px; fill: #ffe6a3; paint-order: stroke; stroke: rgba(14, 20, 32, .85); stroke-width: 3px; pointer-events: none; }

.zoom { position: absolute; right: 14px; bottom: 30px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.zoom button { width: 36px; height: 36px; border-radius: 50%; background: var(--panel); border: 1px solid var(--gold-2); font-size: 18px; }

.legend {
  position: absolute; left: 14px; bottom: 30px; z-index: 2;
  background: var(--panel); border: 1px solid var(--gold-2); border-radius: 4px;
  padding: 10px 12px; font-size: 12px; min-width: 150px;
}
.legend h3 { margin: 0 0 6px; font-size: 13px; color: var(--gold); letter-spacing: .1em; }
.legend .row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.legend .sw { width: 14px; height: 14px; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); flex: none; }
.legend .ramp { height: 10px; border-radius: 2px; margin: 6px 0 2px; }
.legend .ends { display: flex; justify-content: space-between; color: var(--ink-2); }
.legend .n { margin-left: auto; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.tip {
  position: absolute; z-index: 4; pointer-events: none;
  background: var(--panel); border: 1px solid var(--gold); border-radius: 3px;
  padding: 6px 9px; font-size: 12px; line-height: 1.5; max-width: 220px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
}
.tip b { color: var(--gold); }

.src { position: absolute; left: 14px; bottom: 6px; margin: 0; font-size: 11px; color: var(--ink-2); z-index: 2; }

.panel {
  position: fixed; right: 16px; top: 76px; bottom: 16px; width: 330px; z-index: 5;
  background: var(--panel); border: 2px solid var(--gold-2); border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(216, 178, 94, .3) inset, 0 10px 30px rgba(0, 0, 0, .6);
  overflow-y: auto; padding: 0 0 14px;
}
.panel .close { position: absolute; right: 8px; top: 8px; background: none; border: 0; font-size: 16px; color: var(--ink-2); width: 32px; height: 32px; }
.ph { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); background: linear-gradient(rgba(216, 178, 94, .16), transparent); }
.ph .zone { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 2px; color: #10151f; font-weight: 700; letter-spacing: .1em; }
.ph h2 { margin: 8px 0 4px; font-size: 30px; letter-spacing: .2em; }
.ph .bigpop { display: flex; align-items: baseline; gap: 6px; }
.ph .bigpop b { font-size: 34px; color: var(--gold); font-variant-numeric: tabular-nums; }
.ph .bigpop span { color: var(--ink-2); font-size: 13px; }
.sec { padding: 12px 18px 0; }
.sec h4 { margin: 0 0 8px; font-size: 13px; color: var(--gold); letter-spacing: .15em; font-weight: 600; }
.stat { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; border-bottom: 1px dashed rgba(216, 178, 94, .18); font-size: 14px; }
.stat .v { font-variant-numeric: tabular-nums; }
.stat .rk { color: var(--ink-2); font-size: 12px; margin-left: 6px; }
.stack { display: flex; height: 14px; gap: 2px; border-radius: 3px; overflow: hidden; margin: 4px 0 8px; }
.stack i { display: block; height: 100%; }
.stack-l { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; font-size: 12px; }
.stack-l span { display: flex; align-items: center; gap: 6px; }
.stack-l .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.stack-l em { margin-left: auto; font-style: normal; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.wl { list-style: none; margin: 0; padding: 0; }
.wl li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed rgba(216, 178, 94, .18); }
.wl .st { color: #f4cf6b; font-size: 18px; line-height: 1.1; }
.wl b { display: block; font-size: 15px; }
.wl small { color: var(--ink-2); font-size: 12px; }
.note { padding: 10px 18px 0; font-size: 11px; color: var(--ink-2); line-height: 1.6; }

@media (max-width: 720px) {
  .bar { padding: 8px 16px; }
  h1 { font-size: 17px; }
  .lenses { width: 100%; }
  .lenses button { flex: 1; padding: 6px 4px; font-size: 13px; }
  .panel { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 56%; border-radius: 12px 12px 0 0; border-width: 2px 0 0; background: #111a2a; }
  .legend { bottom: 26px; left: 10px; padding: 8px 10px; min-width: 0; font-size: 11px; }
  .src { left: 10px; right: 10px; font-size: 10px; }
  .zoom { right: 10px; top: 10px; bottom: auto; }
}
