:root {
  --bg: #14171b;
  --panel: #1b2026;
  --panel-2: #22282f;
  --line: #2c333c;
  --text: #d7dde3;
  --text-dim: #8b949e;
  --accent: #e0b64f;
  --sea: #a3cbd3;
  --radius: 10px;
  --panel-w: 292px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#map {
  position: fixed;
  inset: 0;
  background: var(--sea);
  outline: none;
}

/* ---------- password gate ---------- */

#gate {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

#gate[hidden] { display: none; }

#gate-form {
  width: min(320px, calc(100vw - 48px));
  padding: 26px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  text-align: center;
}

#gate-form h2 {
  font-size: 17px;
  font-weight: 650;
}

.gate-sub {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 13px;
}

#gate-input {
  width: 100%;
  margin-top: 16px;
  padding: 9px 12px;
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  text-align: center;
}

#gate-input:focus { border-color: var(--accent); }

#gate-err {
  margin-top: 10px;
  color: #e05c5c;
  font-size: 13px;
}

#gate-form button {
  width: 100%;
  margin-top: 14px;
  padding: 9px 12px;
  font: inherit;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 7px;
  cursor: pointer;
}

#gate-form button:hover { filter: brightness(1.08); }

/* ---------- side panel ---------- */

#panel {
  position: fixed;
  top: 12px;
  left: 12px;
  bottom: 12px;
  width: var(--panel-w);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  z-index: 1000;
  overflow: hidden;
  transition: transform .25s ease, opacity .25s ease;
}

.panel-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.panel-head h1 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .01em;
}

/* Scene dropdown styled as the heading itself. */
#scene-select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  padding: 0 20px 0 0;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238b949e' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
  background-size: 11px;
}

#scene-select:hover { color: var(--accent); }

#scene-select:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

#scene-select option {
  background: var(--panel);
  color: var(--text);
  font-weight: 400;
}

.panel-head .sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-dim);
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.searchbox { padding: 10px 12px 4px; }

#search {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
#search:focus { outline: none; border-color: #4a5563; }
#search::placeholder { color: var(--text-dim); }

.group { padding: 8px 12px 2px; }

.group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0 6px;
}

.group-head .count {
  color: var(--text-dim);
  font-size: 11.5px;
  flex: 1;
}

.label.heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-dim);
}

.mini {
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.mini:hover { color: var(--text); background: var(--panel-2); }

/* checkbox rows */

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.check input { display: none; }
.check .box {
  width: 14px;
  height: 14px;
  flex: none;
  border: 1.5px solid #4a5563;
  border-radius: 4px;
  position: relative;
  transition: background .12s, border-color .12s;
}
.check input:checked + .box {
  background: var(--accent);
  border-color: var(--accent);
}
.check input:checked + .box::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: .5px;
  width: 4px;
  height: 8px;
  border: solid #1b2026;
  border-width: 0 2px 2px 0;
  transform: rotate(43deg);
}
.check.master .label { font-weight: 650; font-size: 13.5px; }

.items { list-style: none; }

.items li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px 3px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.items li:hover { background: var(--panel-2); }
.items li .dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,.25);
}
.items li .ico {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 6px;
  background: var(--panel-2);
  object-fit: contain;
}
.items li .nm {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.items li .n { color: var(--text-dim); font-size: 11.5px; }
.items li.off { opacity: .42; }
.items li.off .dot { box-shadow: none; }
.items li.off .ico { box-shadow: none !important; }
.items li .only {
  visibility: hidden;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 10.5px;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 4px;
}
.items li:hover .only { visibility: visible; }
.items li .only:hover { color: var(--accent); }
.items li.hidden-by-search { display: none; }

.opts { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; }
.opt { padding: 4px 2px; font-size: 13px; }

.note {
  padding: 8px 2px 10px;
  font-size: 11.5px;
  color: var(--text-dim);
  opacity: .8;
}

.panel-foot {
  border-top: 1px solid var(--line);
  padding: 8px 16px;
  font-size: 11.5px;
  color: var(--text-dim);
}

/* ---------- floating bits ---------- */

#panel-toggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1001;
  width: 40px;
  height: 40px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}

#coords {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 1000;
  padding: 5px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11.5px;
  color: var(--text-dim);
  pointer-events: none;
  white-space: nowrap;
}
#coords b { color: var(--text); font-weight: 600; }

/* ---------- leaflet re-skin ---------- */

.leaflet-container {
  background: var(--sea);
  font: inherit;
}

.leaflet-control-zoom {
  border: 1px solid var(--line) !important;
  border-radius: 8px !important;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,.35) !important;
}
.leaflet-control-zoom a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--line) !important;
  width: 34px !important;
  height: 34px !important;
  line-height: 33px !important;
  font-size: 17px !important;
}
.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover { background: var(--panel-2) !important; }
.leaflet-control-zoom a.leaflet-disabled { color: var(--text-dim) !important; opacity: .5; }

.leaflet-control-attribution {
  background: rgba(27, 32, 38, .8) !important;
  color: var(--text-dim) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
}
.leaflet-popup-tip {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: none;
}
.leaflet-popup-content { margin: 12px 14px; line-height: 1.4; }
.leaflet-popup-close-button { color: var(--text-dim) !important; }

.leaflet-tooltip {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,.35);
}
.leaflet-tooltip-top::before { border-top-color: var(--line); }

/* popup content */

.pop { min-width: 210px; }
.pop .pop-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pop .pop-head + .pop-head { margin-top: 10px; }
.pop .pop-ico {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  object-fit: contain;
}
.pop .pop-title {
  font-weight: 650;
  font-size: 14px;
}
.pop .pop-desc {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
}
.pop .pop-src {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--accent);
  opacity: .9;
}
.pop .imp { font-style: normal; color: var(--accent); font-weight: 600; }
.pop .pop-lore { margin-top: 6px; }
.pop .pop-lore summary {
  cursor: pointer;
  font-size: 11.5px;
  color: var(--text-dim);
  user-select: none;
  -webkit-user-select: none;
}
.pop .pop-lore summary:hover { color: var(--text); }
.pop .pop-lore p {
  margin-top: 5px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-dim);
  max-height: 180px;
  overflow-y: auto;
}
.pop .pop-meta {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-dim);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.pop .pop-kind { font-size: 11.5px; color: var(--text-dim); margin-top: 1px; }

/* ---------- point markers (icon badges) ---------- */

/* Size comes from --mk set on #map by app.js (rescales with zoom). */
.pt-wrap { background: none; border: none; }
.pt-mk {
  width: var(--mk, 20px);
  height: var(--mk, 20px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(22, 27, 33, .88);
  box-shadow: 0 0 0 2px var(--ring, #fff), 0 1px 5px rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pt-mk img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  pointer-events: none;
}
.pt-mk.pt-dot {
  width: calc(var(--mk, 20px) * .55);
  height: calc(var(--mk, 20px) * .55);
  background: var(--ring, #fff);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .85), 0 1px 4px rgba(0, 0, 0, .45);
}
.leaflet-marker-icon.pt-wrap:hover { z-index: 10000 !important; }

/* tooltip icon */
.tt-ico {
  width: 18px;
  height: 18px;
  vertical-align: -4px;
  margin-right: 5px;
  border-radius: 5px;
  background: var(--panel-2);
  object-fit: contain;
}

/* tile grid labels */
.tile-grid-pane { pointer-events: none; }

/* district area labels */
.leaflet-tooltip.area-label {
  background: none;
  border: none;
  box-shadow: none;
  pointer-events: none;
  font: 700 12px/1.2 system-ui, -apple-system, sans-serif;
  letter-spacing: .04em;
  color: #29404d;
  text-shadow:
    0 1px 3px rgba(255,255,255,.95), 0 -1px 3px rgba(255,255,255,.95),
    1px 0 3px rgba(255,255,255,.95), -1px 0 3px rgba(255,255,255,.95);
}
.leaflet-tooltip.area-label::before { display: none; }

/* ---------- mobile ---------- */

@media (max-width: 860px) {
  #panel-toggle { display: flex; }

  #panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 62vh;
    border-radius: 14px 14px 0 0;
    border-bottom: none;
    transform: translateY(calc(100% + 20px));
    opacity: .98;
  }
  #panel.open { transform: translateY(0); }

  #coords {
    right: auto;
    left: 60px;
    top: 12px;
    bottom: auto;
    line-height: 28px;
  }

  .leaflet-control-zoom { display: none; }
}
