:root {
  --ink: #efe4c6;
  --ink-dim: #b9ab88;
  --gold: #c9a45c;
  --gold-bright: #ecd08e;
  --panel: rgba(16, 25, 35, 0.98);
  --panel-2: rgba(28, 41, 56, 0.98);
  --line: rgba(201, 164, 92, 0.55);
  --serif: "Palatino Linotype", Palatino, "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --sans: -apple-system, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --topbar-h: 42px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d2a47; color: var(--ink); font-family: var(--sans); }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--gold-bright); }
:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }

#map { position: fixed; inset: 0; width: 100%; height: 100%; cursor: grab; display: block; touch-action: none; }
#map.dragging { cursor: grabbing; }

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 8px 24px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,235,190,.08);
  border-radius: 6px;
}

#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 10;
  display: flex; align-items: center; gap: 14px; padding: 0 12px;
  background: linear-gradient(180deg, #24364a, #131e2a);
  border-bottom: 1px solid rgba(201,164,92,.45);
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--serif); letter-spacing: .12em; font-size: 15px; }
.brand-emblem {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 40% 35%, #d23a3a, #8c1d2c 70%);
  color: #f8f0d8; font-size: 11px; font-weight: 700; border: 1px solid var(--gold);
}
.yields { display: flex; gap: 14px; font-size: 13px; color: var(--gold-bright); white-space: nowrap; }
.yields b { color: var(--ink); font-weight: 600; margin-left: 4px; }
.spacer { flex: 1; }
.search input {
  width: 180px; height: 28px; border-radius: 4px; padding: 0 10px;
  background: rgba(0,0,0,.35); border: 1px solid rgba(201,164,92,.4);
  color: var(--ink);
}
.btn {
  height: 28px; padding: 0 10px; border-radius: 4px; cursor: pointer;
  background: rgba(0,0,0,.3); border: 1px solid rgba(201,164,92,.45); color: var(--ink-dim);
}
.btn:hover { color: var(--gold-bright); border-color: var(--gold); }

#lens-dock {
  position: fixed; left: 12px; bottom: 42px; z-index: 8; padding: 6px;
}
.lens-quick { display: flex; flex-direction: column; gap: 4px; }
.lens-btn {
  display: flex; align-items: center; gap: 8px;
  min-width: 108px; height: 30px; padding: 0 10px; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: 4px;
  color: var(--ink-dim); text-align: left;
}
.lens-btn[aria-pressed="true"], .lens-btn:hover {
  background: rgba(201,164,92,.12); border-color: var(--line); color: var(--gold-bright);
}
.legend {
  position: fixed; left: 130px; bottom: 42px; z-index: 8;
  padding: 8px 10px; font-size: 11px; color: var(--ink-dim); min-width: 140px;
}
.legend h4 { margin: 0 0 6px; font-weight: 600; color: var(--gold); font-size: 11px; }
.legend .bar { height: 8px; border-radius: 2px; margin: 4px 0; border: 1px solid rgba(0,0,0,.4); }
.legend .ticks { display: flex; justify-content: space-between; }

#panel {
  position: fixed; top: 54px; right: 12px; width: 320px; max-height: calc(100% - 110px);
  z-index: 9; padding: 14px 16px 16px; overflow: auto;
}
#panel h2 { margin: 0 0 4px; font-family: var(--serif); font-size: 20px; color: var(--gold-bright); }
#panel .sub { color: var(--ink-dim); font-size: 12px; margin-bottom: 10px; }
#panel .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 13px; }
#panel .stats span { color: var(--ink-dim); }
#panel .tags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; font-size: 11px; color: var(--gold-bright); }
#panel .note { margin-top: 10px; font-size: 11px; color: var(--ink-dim); line-height: 1.45; }
#panel h3 { margin: 14px 0 6px; font-size: 12px; color: var(--gold); letter-spacing: .08em; }

.tooltip {
  position: fixed; z-index: 12; pointer-events: none;
  padding: 6px 8px; font-size: 12px; max-width: 240px;
  background: rgba(16,25,35,.94); border: 1px solid var(--line); border-radius: 4px;
}
.search-results {
  position: fixed; top: 44px; right: 86px; z-index: 13; width: 220px; max-height: 280px; overflow: auto;
  padding: 4px;
}
.search-results button {
  display: block; width: 100%; text-align: left; padding: 6px 8px; background: transparent;
  border: 0; cursor: pointer; color: var(--ink); border-radius: 3px;
}
.search-results button:hover { background: rgba(201,164,92,.15); }

.credits {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
  height: 28px; display: flex; align-items: center; gap: 6px; padding: 0 12px;
  font-size: 11px; color: var(--ink-dim);
  background: linear-gradient(180deg, transparent, rgba(8,14,22,.85));
}
.credits button {
  background: none; border: 0; color: var(--gold-bright); cursor: pointer; text-decoration: underline; padding: 0; font-size: 11px;
}

.modal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.45);
  display: grid; place-items: center;
}
.modal-card { width: min(640px, calc(100% - 32px)); max-height: 80vh; overflow: auto; padding: 22px 24px; position: relative; }
.modal-card h2 { font-family: var(--serif); color: var(--gold-bright); margin: 0 0 12px; }
.close {
  position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.3); border: 1px solid rgba(201,164,92,.45); cursor: pointer;
}
.src-body { font-size: 13px; line-height: 1.55; color: var(--ink); }
.src-body ul { padding-left: 1.2em; }
.src-body li { margin: 6px 0; }

#loading {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: #0d2a47; font-family: var(--serif); font-size: 22px; letter-spacing: .2em;
  color: var(--gold-bright);
}
