:root {
  --ink: #f4eee3;
  --muted: #b8ad9a;
  --panel: rgba(17, 20, 26, 0.82);
  --panel-strong: rgba(9, 11, 16, 0.92);
  --line: rgba(226, 187, 105, 0.24);
  --gold: #d6ad5b;
  --gold-strong: #efc86d;
  --red: #d52b1e;
  --steel: #bfc4cb;
  --blue: #5f93c7;
  --blue-deep: #426f9f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius-lg: 22px;
  --radius-md: 14px;
  --font-display: "Optima", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(214, 173, 91, 0.16), transparent 27rem),
    radial-gradient(circle at 82% 16%, rgba(213, 43, 30, 0.12), transparent 22rem),
    linear-gradient(135deg, #07090e 0%, #111722 54%, #08090c 100%);
  color: var(--ink);
  font-family: var(--font-ui);
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: var(--gold-strong);
}

.app-shell {
  width: 100%;
  height: 100%;
  position: relative;
}

.masthead {
  position: absolute;
  z-index: 1200;
  top: 18px;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}


.masthead.is-receded {
  opacity: 0;
  transform: translateY(-22px);
  pointer-events: none;
}

.title-block {
  width: min(520px, calc(100vw - 40px));
  padding: 18px 20px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(30, 34, 44, 0.92), rgba(10, 12, 18, 0.78)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.03) 0 1px, transparent 1px 7px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold-strong);
  font-size: 0.72rem;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.35rem, 5vw, 4.7rem);
  line-height: 0.92;
  letter-spacing: -0.045em;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.55);
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(0.92rem, 1.6vw, 1.04rem);
  line-height: 1.45;
}

.utility-nav {
  pointer-events: auto;
}

.ghost-button {
  border: 1px solid rgba(214, 173, 91, 0.4);
  border-radius: 999px;
  background: rgba(7, 9, 14, 0.74);
  color: var(--ink);
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 14px 45px rgba(0,0,0,.26);
  backdrop-filter: blur(10px);
}

.ghost-button:hover,
.ghost-button:focus-visible {
  border-color: rgba(239, 200, 109, 0.9);
  outline: none;
}

.map-stage,
#map {
  position: absolute;
  inset: 0;
}

#map {
  z-index: auto;
  background: #0c1018;
}

#map::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 410;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 52%, transparent 0 42%, rgba(0, 0, 0, .24) 72%, rgba(0, 0, 0, .48) 100%),
    linear-gradient(180deg, rgba(6, 8, 12, .36), transparent 23%, transparent 72%, rgba(6, 8, 12, .45));
  mix-blend-mode: multiply;
}

.leaflet-pane,
.leaflet-control {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 420;
}

.leaflet-marker-pane {
  z-index: 650;
}

.leaflet-tooltip-pane {
  z-index: 690;
}

.leaflet-popup-pane {
  z-index: 1800;
}

.leaflet-control-attribution {
  background: rgba(8, 11, 16, 0.78) !important;
  color: rgba(244, 238, 227, 0.68) !important;
  border-radius: 10px 0 0 0;
  font-size: 10px;
}

.leaflet-control-attribution a {
  color: rgba(239, 200, 109, 0.92) !important;
}

#map .leaflet-tile {
  filter: saturate(0.8) contrast(1.04) brightness(0.72);
}

.control-panel {
  position: absolute;
  z-index: 1100;
  left: 20px;
  bottom: 26px;
  width: min(390px, calc(100vw - 40px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel-kicker {
  color: var(--gold-strong);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-bottom: 10px;
}

.metric-toggle {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 0;
  margin: 0;
  border: 0;
}

.metric-toggle label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255,255,255,.035);
  cursor: pointer;
}

.metric-toggle label:hover {
  border-color: rgba(214, 173, 91, .36);
}

.metric-toggle input {
  accent-color: var(--gold);
}

.metric-narrative {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.4;
}

.legend-panel {
  position: absolute;
  z-index: 1100;
  right: 20px;
  bottom: 26px;
  width: min(310px, calc(100vw - 40px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  transition: max-height .22s ease, transform .22s ease;
}

.legend-toggle {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid rgba(214, 173, 91, .18);
  background: rgba(8, 10, 14, .56);
  padding: 13px 15px;
  cursor: pointer;
  color: var(--ink);
  letter-spacing: .04em;
}

.toggle-word {
  color: var(--gold-strong);
  font-size: .88rem;
}

.legend-content {
  padding: 14px 15px 16px;
}

.legend-panel.collapsed .legend-content {
  display: none;
}

.legend-panel.collapsed .legend-toggle {
  border-bottom: 0;
}

.legend-section + .legend-section {
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.legend-section h2 {
  margin: 0 0 10px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--gold-strong);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.size-legend {
  display: grid;
  gap: 8px;
}

.size-item {
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: .82rem;
}

.legend-dial {
  display: inline-grid;
  place-items: center;
}

.hand-legend {
  display: grid;
  gap: 8px;
}

.hand-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: .84rem;
}

.hand-item strong {
  display: block;
  color: rgba(244, 238, 227, .88);
  font-weight: 700;
}

.hand-item small {
  display: block;
  margin-top: 2px;
  color: rgba(244, 238, 227, .58);
  font-size: .72rem;
}

.hand-dial {
  width: 34px;
  height: 34px;
}

.trend-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 7px 0;
  color: var(--muted);
  font-size: .84rem;
}

.trend-chip {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-block;
  border: 2px solid currentColor;
  background: rgba(10, 12, 17, .7);
  box-shadow: 0 0 14px currentColor;
}

.strong-growth { color: #efc86d; }
.modest-growth { color: #cda15a; }
.stable { color: #bfc4cb; }
.modest-decline { color: #78a2cc; }
.strong-decline { color: #426f9f; }

.fine-print p {
  margin: 0;
  color: rgba(244, 238, 227, .72);
  font-size: .78rem;
  line-height: 1.42;
}

.loading-card {
  position: absolute;
  z-index: 1300;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 17px;
  border: 1px solid rgba(214, 173, 91, .28);
  border-radius: 999px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.loading-card.is-hidden {
  display: none;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(214, 173, 91, .28);
  border-top-color: var(--gold-strong);
  border-radius: 999px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.watch-marker {
  position: relative;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 12px 22px rgba(0,0,0,.50));
  transition: transform .18s ease, filter .18s ease;
}

.watch-marker:hover {
  transform: translateY(-2px) scale(1.06);
  filter: drop-shadow(0 20px 30px rgba(0,0,0,.62));
}

.watch-marker svg {
  overflow: visible;
}

.origin-marker {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(213, 43, 30, .92);
  border: 2px solid rgba(255,255,255,.86);
  color: white;
  font-weight: 800;
  font-size: 12px;
  box-shadow: 0 0 0 5px rgba(213,43,30,.12), 0 15px 30px rgba(0,0,0,.46);
}

.origin-marker::before,
.origin-marker::after {
  content: "";
  position: absolute;
  background: white;
  border-radius: 2px;
}

.origin-marker::before {
  width: 16px;
  height: 5px;
}

.origin-marker::after {
  width: 5px;
  height: 16px;
}

.dial-tooltip {
  border: 1px solid rgba(214, 173, 91, .32) !important;
  border-radius: 12px !important;
  background: rgba(9, 11, 16, .92) !important;
  color: var(--ink) !important;
  box-shadow: 0 18px 50px rgba(0,0,0,.38) !important;
  padding: 8px 10px !important;
  font-size: 13.2px;
}

.dial-tooltip::before {
  border-top-color: rgba(9, 11, 16, .92) !important;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: rgba(9, 12, 18, .96) !important;
  color: var(--ink) !important;
  border: 1px solid rgba(214, 173, 91, .28);
  box-shadow: 0 24px 70px rgba(0,0,0,.56);
}

.leaflet-popup-content-wrapper {
  border-radius: 18px !important;
  backdrop-filter: blur(12px);
}

.leaflet-popup-content {
  width: 282px !important;
  margin: 16px !important;
}

.popup-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 500;
  letter-spacing: -.02em;
}

.rank-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid rgba(239, 200, 109, .55);
  border-radius: 999px;
  color: var(--gold-strong);
  font-family: var(--font-ui);
  font-size: .72rem;
  font-weight: 800;
}

.popup-sub {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: .91rem;
}

.popup-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.popup-metric {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 9px;
  background: rgba(255,255,255,.035);
}

.popup-metric span {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.popup-metric strong {
  display: block;
  margin-top: 3px;
  font-size: 1.05rem;
}

.sparkline-wrap {
  margin: 12px 0 10px;
  padding: 9px;
  border-radius: 14px;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.08);
}

.sparkline-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: .79rem;
}

.sparkline svg {
  width: 100%;
  height: auto;
  display: block;
}

.popup-note {
  margin: 10px 0 0;
  color: rgba(244, 238, 227, .66);
  font-size: .79rem;
  line-height: 1.4;
}

.leaflet-container a.leaflet-popup-close-button {
  color: var(--gold-strong) !important;
  top: 8px !important;
  right: 8px !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .56);
  backdrop-filter: blur(8px);
}

.modal.is-open {
  display: grid;
}

.modal-card {
  position: relative;
  width: min(680px, 100%);
  max-height: min(78vh, 720px);
  overflow: auto;
  padding: 28px;
  border: 1px solid rgba(214, 173, 91, .32);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(28, 33, 44, .98), rgba(9, 11, 17, .98));
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
}

.modal-card p,
.modal-card li {
  color: rgba(244, 238, 227, .78);
  line-height: 1.55;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  background: rgba(255,255,255,.04);
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.modal-made {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.noscript {
  position: fixed;
  z-index: 3000;
  inset: auto 20px 20px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #260b0b;
  color: white;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  clip: rect(0,0,0,0);
  overflow: hidden;
  border: 0;
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .masthead {
    top: 10px;
    left: 10px;
    right: 10px;
    flex-direction: column;
    gap: 10px;
  }

  .title-block {
    padding: 14px;
  }

  .utility-nav {
    align-self: flex-end;
  }

  .control-panel {
    left: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    padding: 12px;
  }

  .metric-toggle {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }

  .metric-toggle label {
    justify-content: center;
    padding: 8px 6px;
    font-size: .78rem;
  }

  .metric-toggle input {
    display: none;
  }

  .metric-toggle label:has(input:checked) {
    border-color: rgba(239, 200, 109, .78);
    background: rgba(214, 173, 91, .13);
  }

  .metric-narrative {
    display: none;
  }

  .legend-panel {
    right: 10px;
    top: 154px;
    bottom: auto;
    width: min(260px, calc(100vw - 20px));
  }

  .legend-content {
    max-height: 42vh;
    overflow: auto;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: 2.35rem;
  }

  .subtitle {
    font-size: .86rem;
  }

  .legend-panel {
    top: 146px;
  }
}
