:root {
  --bg: #000;
  --panel: rgba(8, 12, 24, 0.92);
  --edge: #2a3350;
  --text: #dfe6f5;
  --muted: #8d97ad;
  --orange: #ff9c3a;
  --lilac: #c99cff;
  --blue: #8fb8ff;
  --canon: #4f8fe0;
  --books: #d9a441;
  --radius: 14px;
  font-family: "Roboto Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--bg); }
.leaflet-container { background: var(--bg); font: inherit; cursor: default; }
.leaflet-container.measuring, .leaflet-container.zoomboxing { cursor: crosshair; }
.zoom-box { position: absolute; z-index: 800; border: 2px dashed var(--orange); background: rgba(255,156,58,.10); pointer-events: none; box-sizing: border-box; }
.zoom-box span { position: absolute; right: 4px; bottom: 2px; font-size: 11px; color: var(--orange); text-shadow: 0 0 3px #000; white-space: nowrap; }
.leaflet-zoom-box { border: 2px dashed var(--orange); background: rgba(255,156,58,.10); }
.leaflet-container.hovering { cursor: pointer; }
.leaflet-control-attribution { background: rgba(0,0,0,.6) !important; color: var(--muted) !important; font-size: 11px; }
.leaflet-control-attribution a { color: var(--blue) !important; }
.leaflet-pane.leaflet-sky-pane { pointer-events: none; }
button, input { font: inherit; }
a { color: var(--blue); }

/* top bar ---------------------------------------------------------------- */
.topbar { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 1000; display: flex; gap: 10px; align-items: flex-start; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--edge); border-radius: 22px; padding: 6px 14px 6px 6px; }
.brand h1 { margin: 0; font-size: 15px; letter-spacing: .12em; text-transform: uppercase; color: var(--orange); font-weight: 600; white-space: nowrap; }
.pill { display: inline-block; width: 34px; height: 20px; border-radius: 10px; }
.pill-orange { background: var(--orange); }
.search { position: relative; flex: 0 1 340px; }
.search input { width: 100%; padding: 9px 14px; border-radius: 20px; border: 1px solid var(--edge); background: var(--panel); color: var(--text); outline: none; }
.search input:focus { border-color: var(--lilac); }
.search-results { position: absolute; top: 42px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; max-height: 60vh; overflow: auto; }
.search-results li { padding: 6px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.search-results li[aria-selected="true"], .search-results li:hover { background: #1b2340; }
.search-results .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.search-results small { color: var(--muted); margin-left: auto; white-space: nowrap; }
.era { margin-left: auto; display: flex; background: var(--panel); border: 1px solid var(--edge); border-radius: 20px; padding: 3px; }
.era button { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 16px; cursor: pointer; }
.era button small { opacity: .8; }
.era button[aria-pressed="true"] { background: var(--lilac); color: #140a24; font-weight: 600; }

/* toolbar ---------------------------------------------------------------- */
.toolbar { position: absolute; left: 10px; top: 62px; z-index: 1000; display: flex; flex-direction: column; gap: 6px; }
.toolbar button { text-align: left; min-width: 104px; padding: 7px 14px 7px 12px; border: 0; border-radius: 0 16px 16px 0; background: #2c3a63; color: #e8eeff; cursor: pointer; border-left: 6px solid var(--blue); text-transform: uppercase; font-size: 12px; letter-spacing: .1em; }
.toolbar button:nth-child(2) { border-left-color: var(--lilac); }
.toolbar button:nth-child(3) { border-left-color: var(--lilac); }
.toolbar button:nth-child(4) { border-left-color: var(--orange); }
.toolbar button:hover, .toolbar button:focus-visible { background: #3b4c80; outline: none; }
.toolbar button[aria-pressed="true"], .toolbar button[aria-expanded="true"] { background: var(--orange); color: #1c1006; }

/* panels ----------------------------------------------------------------- */
.panel { position: absolute; z-index: 1000; background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.panel h2 { margin: 2px 0 8px; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--lilac); font-weight: 600; }
.small-panel { left: 130px; top: 62px; width: 270px; max-height: calc(100vh - 90px); overflow: auto; }
.small-panel label { display: block; padding: 3px 0; cursor: pointer; }
.legend-powers, .legend-symbols { list-style: none; margin: 0 0 10px; padding: 0; }
.legend-powers li, .legend-symbols li { display: flex; align-items: center; gap: 8px; padding: 2px 0; font-size: 13px; }
.legend-powers img { width: 20px; height: 20px; object-fit: contain; }
.swatch { width: 20px; height: 14px; border-radius: 4px; flex: none; border: 1px solid rgba(255,255,255,.35); }
.close { position: absolute; top: 6px; right: 8px; background: transparent; border: 0; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; }
.close:hover { color: var(--text); }

.info { right: 10px; top: 62px; width: 360px; max-height: calc(100vh - 110px); overflow: auto; }
.info .head { display: flex; gap: 12px; align-items: center; margin-right: 24px; }
.info .head img { width: 46px; height: 46px; object-fit: contain; flex: none; }
.info .head .emblem-swatch { width: 46px; height: 46px; border-radius: 50%; flex: none; border: 2px solid rgba(255,255,255,.3); }
.info h3 { margin: 0; font-size: 21px; color: #fff; font-weight: 600; }
.info .sub { color: var(--orange); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.info p { line-height: 1.45; margin: 10px 0; }
.info dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 10px 0; font-size: 13px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; }
.info ul.facts { padding-left: 0; list-style: none; margin: 8px 0; }
.info ul.facts li { margin: 6px 0; line-height: 1.4; }
.info h4 { margin: 14px 0 4px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--lilac); font-weight: 600; }
.info .refs { font-size: 12.5px; color: #c3cbe0; line-height: 1.45; margin: 0; padding-left: 16px; }
.info .links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.info .links a, .info .links button { display: inline-block; padding: 6px 12px; border-radius: 14px; background: #24305a; color: #e8eeff; text-decoration: none; border: 0; cursor: pointer; font-size: 13px; }
.info .links a:hover, .info .links button:hover { background: #33437a; }
.info .note { font-size: 12px; color: var(--muted); }
.badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 1px 7px; border-radius: 8px; vertical-align: 1px; margin-right: 4px; }
.badge.canon { background: var(--canon); color: #fff; }
.badge.books { background: var(--books); color: #1d1404; }

.measure { left: 130px; top: 62px; width: 350px; max-height: calc(100vh - 100px); overflow: auto; }
.measure p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.measure .total { font-size: 22px; color: #fff; margin: 4px 0 2px; }
.measure .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.measure table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.measure td { padding: 2px 4px; border-bottom: 1px solid #1c2440; }
.measure td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.measure tr.hl td { color: #fff; background: rgba(255,156,58,.14); }
.measure tr.hl td:first-child::after { content: attr(data-tag); margin-left: 6px; font-size: 10px; color: var(--orange); text-transform: uppercase; letter-spacing: .08em; }
.nav-opts { border: 1px solid var(--edge); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; font-size: 13px; }
.nav-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.nav-label { color: var(--muted); width: 74px; flex: none; }
.nav-row select { flex: 1; min-width: 0; background: #111830; color: var(--text); border: 1px solid var(--edge); border-radius: 8px; padding: 4px 6px; }
.seg { display: inline-flex; border: 1px solid var(--edge); border-radius: 14px; padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 3px 12px; border-radius: 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--lilac); color: #140a24; font-weight: 600; }
.nav-check { display: block; margin: 4px 0; cursor: pointer; }
#nav-avoid-box summary { cursor: pointer; margin: 4px 0; color: var(--text); }
#nav-avoid-count { color: var(--orange); }
.nav-avoid { display: flex; flex-wrap: wrap; gap: 4px 6px; padding: 4px 0 2px; }
.nav-avoid label { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 4px; border-radius: 10px; background: #141c36; cursor: pointer; font-size: 12px; }
.nav-avoid .dot { width: 9px; height: 9px; border-radius: 50%; }
.nav-btns { display: flex; gap: 6px; margin-top: 8px; }
.nav-btns button { flex: 1; padding: 4px 0; border-radius: 12px; border: 0; background: #24305a; color: #e8eeff; cursor: pointer; font-size: 12.5px; }
.nav-btns button:hover { background: #33437a; }
.measure .legs { margin: 6px 0; padding-left: 16px; font-size: 12.5px; color: #c3cbe0; }
.measure .legs li { margin: 2px 0; }
.measure .crosses { font-size: 12.5px; margin: 6px 0; }
.measure .crosses .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.measure .warn { font-size: 12.5px; color: #ffcf9a; background: rgba(255,120,40,.12); border-radius: 8px; padding: 6px 8px; margin: 6px 0; }
.measure .eta { font-size: 13px; margin: 6px 0; color: #fff; }
.measure .note { font-size: 11.5px; color: var(--muted); margin-top: 8px; }

.readout { position: absolute; left: 10px; bottom: 10px; z-index: 900; background: rgba(0,0,0,.6); color: var(--muted); padding: 4px 10px; border-radius: 10px; font-size: 12px; font-variant-numeric: tabular-nums; pointer-events: none; }
.scale { position: absolute; right: 52px; bottom: 32px; z-index: 900; background: rgba(0,0,0,.7); color: #c9d3ea; padding: 4px 10px; border-radius: 10px; font-size: 12px; font-variant-numeric: tabular-nums; pointer-events: none; white-space: nowrap; }
.tip { position: absolute; z-index: 1100; pointer-events: none; background: rgba(10,14,28,.95); border: 1px solid var(--edge); padding: 4px 8px; border-radius: 8px; font-size: 13px; white-space: nowrap; }
.tip small { color: var(--muted); }
.tip .terr { display: flex; align-items: center; gap: 6px; line-height: 1.5; }
.tip .terr .swatch { width: 14px; height: 10px; border-radius: 3px; }
.loading { position: absolute; inset: 0; z-index: 2000; display: grid; place-items: center; background: var(--bg); color: var(--orange); letter-spacing: .2em; text-transform: uppercase; transition: opacity .4s; }
.loading.done { opacity: 0; pointer-events: none; }
.loading.busy { background: rgba(0,0,0,.55); transition: opacity .15s; font-size: 14px; }
.loading.busy::before { content: ""; position: absolute; width: 46px; height: 46px; margin-top: -70px; border-radius: 50%; border: 3px solid rgba(255,156,58,.25); border-top-color: var(--orange); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading.busy::before { animation: none; } }

.power-label { color: rgba(255,255,255,.55); font-size: 13px; letter-spacing: .3em; text-transform: uppercase; text-align: center; white-space: nowrap; pointer-events: none; text-shadow: 0 0 4px #000, 0 0 8px #000; font-weight: 600; }
.zone-label { color: rgba(255,255,255,.6); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; white-space: nowrap; pointer-events: none; text-shadow: 0 0 4px #000; }
.quad-label { color: rgba(201,156,255,.85); font-size: 18px; letter-spacing: .35em; text-transform: uppercase; white-space: nowrap; pointer-events: none; text-shadow: 0 0 8px #000; }
.feature-label { color: rgba(255,200,150,.85); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; pointer-events: none; text-shadow: 0 0 4px #000, 0 0 6px #000; }
.map-label { background: none; border: 0; }
.map-label span { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); display: block; }

dialog.credits { max-width: 720px; width: calc(100% - 30px); background: #0a0f1e; color: var(--text); border: 1px solid var(--edge); border-radius: var(--radius); padding: 18px 24px; line-height: 1.5; }
dialog.credits::backdrop { background: rgba(0,0,0,.6); }
dialog.credits h2 { color: var(--orange); letter-spacing: .12em; text-transform: uppercase; font-size: 16px; margin-top: 0; }
dialog.credits h3 { color: var(--lilac); font-size: 14px; letter-spacing: .1em; text-transform: uppercase; }
dialog.credits li { margin-bottom: 8px; }
dialog.credits .fine { font-size: 12px; color: var(--muted); }

@media (max-width: 760px) {
  .brand h1 { display: none; }
  .brand { padding: 6px; }
  .era button small { display: none; }
  .toolbar { top: auto; bottom: 34px; flex-direction: row; flex-wrap: wrap; right: 10px; }
  .toolbar button { min-width: 0; padding: 6px 10px; border-radius: 14px; border-left-width: 4px; }
  .small-panel { left: 10px; right: 10px; width: auto; top: 60px; }
  .info { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 55vh; border-radius: var(--radius) var(--radius) 0 0; }
  .measure { left: 10px; right: 10px; width: auto; top: 60px; bottom: auto; max-height: calc(100vh - 150px); }
  .readout { display: none; }
  .scale { right: 10px; bottom: auto; top: 56px; font-size: 11px; }
}
