@font-face { font-family: "Cinzel"; src: url("fonts/Cinzel.ttf") format("truetype"); font-weight: 400 900; }
@font-face { font-family: "Cinzel Decorative"; src: url("fonts/CinzelDecorative-Bold.ttf") format("truetype"); font-weight: 700; }
@font-face { font-family: "EB Garamond"; src: url("fonts/EBGaramond.ttf") format("truetype"); font-weight: 400 800; }
@font-face { font-family: "EB Garamond"; src: url("fonts/EBGaramond-Italic.ttf") format("truetype"); font-style: italic; font-weight: 400 800; }

:root {
  --navy-bg: rgba(13, 23, 39, 0.94);
  --navy-card: rgba(20, 34, 56, 0.92);
  --navy-elev: rgba(28, 46, 74, 0.95);
  --gold: #d9b45b;
  --gold-bright: #f3d78a;
  --gold-dim: rgba(217, 180, 91, 0.36);
  --ivory: #f5eedc;
  --ivory-muted: #b6c4d6;
  --crimson: #b83342;
  --sea-deep: #2e4e72;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; width: 100%; overflow: hidden;
  background: var(--sea-deep) url("sea_bg.jpg") repeat;
  color: var(--ivory);
  font-family: "EB Garamond", Georgia, serif;
}

#map {
  position: fixed; inset: 0;
  background: var(--sea-deep) url("sea_bg.jpg") repeat;
}
#map-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 450;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(7, 14, 26, 0.42) 100%);
  box-shadow: inset 0 0 48px rgba(5, 10, 20, 0.55);
}
.leaflet-container {
  background: var(--sea-deep) url("sea_bg.jpg") repeat !important;
  font-family: "EB Garamond", Georgia, serif;
}
/* Pre-promote tile containers to GPU layers so the first CSS3 zoom never flashes */
.leaflet-tile-pane {
  transform: translate3d(0, 0, 0);
}
.leaflet-tile-container {
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.leaflet-tile {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Custom position & styling for Leaflet zoom controls (bottom-left) */
.leaflet-top.leaflet-left {
  top: auto !important;
  bottom: 26px !important;
  left: 16px !important;
}
.leaflet-control-zoom {
  margin: 0 !important;
  border: 1.5px solid var(--gold-dim) !important;
  border-radius: 8px !important;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(6, 12, 22, 0.55) !important;
}
.leaflet-control-zoom a {
  background: var(--navy-bg) !important;
  color: var(--gold-bright) !important;
  border-bottom-color: rgba(217, 180, 91, 0.22) !important;
  border-radius: 0 !important;
  font-family: "Cinzel", serif !important;
  width: 34px !important;
  height: 34px !important;
  line-height: 32px !important;
}
.leaflet-control-zoom a:hover {
  background: var(--navy-elev) !important;
  color: #ffffff !important;
}
.leaflet-control-attribution {
  font-size: 11.5px;
  background: rgba(11, 20, 34, 0.85) !important;
  color: var(--ivory-muted) !important;
  border-top: 1px solid rgba(217, 180, 91, 0.25);
  border-left: 1px solid rgba(217, 180, 91, 0.25);
  border-radius: 6px 0 0 0;
  padding: 2px 8px !important;
}
.leaflet-control-attribution a { color: var(--gold-bright) !important; }

/* ---------------- Left Floating Command Dock ---------------- */
#command-dock {
  position: fixed;
  top: 14px;
  left: 16px;
  width: 404px;
  max-width: calc(100vw - 32px);
  z-index: 1000;
  background: linear-gradient(165deg, rgba(16, 28, 48, 0.96), rgba(10, 19, 34, 0.95));
  border: 1.5px solid var(--gold-dim);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 12px 34px rgba(5, 10, 20, 0.65), inset 0 1px 0 rgba(255, 238, 190, 0.18);
  backdrop-filter: blur(8px);
}

#dock-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(217, 180, 91, 0.24);
}
#command-dock.collapsed #dock-top {
  padding-bottom: 0;
  border-bottom: none;
}
#command-dock.collapsed #dock-body {
  display: none;
}
#brand-header {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  min-width: 0;
  flex: 1 1 auto;
}
#dock-toggle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 0;
  border: 1px solid rgba(217, 180, 91, 0.34);
  background: rgba(10, 19, 34, 0.78);
  color: var(--ivory-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.16s ease;
}
#dock-toggle:hover {
  color: var(--gold-bright);
  border-color: var(--gold-bright);
  background: rgba(217, 180, 91, 0.2);
}
#dock-toggle .dock-chev {
  transition: transform 0.22s ease;
}
#command-dock.collapsed #dock-toggle .dock-chev {
  transform: rotate(180deg);
}
#brand-header .emblem {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 3px 8px rgba(4, 9, 18, 0.72));
  transition: transform 0.25s ease, filter 0.25s ease;
}
#brand-header:hover .emblem {
  transform: translateY(-1.5px) scale(1.06);
  filter: drop-shadow(0 4px 11px rgba(243, 215, 138, 0.38));
}
.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand-kicker {
  font-family: "Cinzel", serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--gold);
  line-height: 1.1;
  margin-bottom: 2px;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.08;
}
.brand-row .word-primary {
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 21px;
  letter-spacing: 0.09em;
  color: #fbf5e4;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
}
.brand-row .word-sep {
  font-size: 9px;
  color: #c84b58;
  text-shadow: 0 0 6px rgba(217, 180, 91, 0.45);
}
.brand-row .word-accent {
  font-family: "Cinzel Decorative", "Cinzel", serif;
  font-weight: 700;
  font-size: 21px;
  letter-spacing: 0.07em;
  background: linear-gradient(180deg, #fff3cc 0%, #e4be64 55%, #b88b32 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
}
.brand-text .subtitle {
  font-size: 12.8px;
  font-style: italic;
  color: var(--ivory-muted);
  margin-top: 2px;
}

/* Search Box */
#search-wrap {
  position: relative;
  margin-top: 10px;
  display: flex;
  align-items: center;
}
.search-ic {
  position: absolute;
  left: 11px;
  color: var(--gold);
  pointer-events: none;
}
#q {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 7px 34px 7px 34px;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid rgba(217, 180, 91, 0.38);
  background: rgba(8, 15, 27, 0.85);
  color: var(--ivory);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#q::placeholder { color: rgba(182, 196, 214, 0.62); }
#q:focus {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px rgba(217, 180, 91, 0.22);
}
.search-kbd {
  position: absolute;
  right: 9px;
  font-family: monospace;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(217, 180, 91, 0.28);
  color: var(--ivory-muted);
  pointer-events: none;
}
#results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 5px 0;
  list-style: none;
  background: rgba(12, 22, 38, 0.98);
  border: 1.5px solid var(--gold);
  border-radius: 0;
  box-shadow: 0 14px 36px rgba(4, 8, 16, 0.78);
  display: none;
  max-height: 62vh;
  overflow: auto;
  z-index: 1100;
}
#results li {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(217, 180, 91, 0.1);
}
#results li:last-child { border-bottom: none; }
#results li .r-main {
  font-weight: 600;
  color: var(--ivory);
  font-size: 15.5px;
  line-height: 1.2;
}
#results li .r-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
#results li .r-type {
  font-family: "Cinzel", serif;
  font-size: 10.5px;
  color: var(--gold-bright);
  background: rgba(217, 180, 91, 0.12);
  border: 1px solid rgba(217, 180, 91, 0.3);
  border-radius: 0;
  padding: 1px 5px;
}
#results li.active, #results li:hover {
  background: rgba(217, 180, 91, 0.18);
}

/* Action Buttons Bar */
#nav-actions {
  display: flex;
  align-items: stretch;
  gap: 5px;
  margin-top: 9px;
  width: 100%;
}
#nav-actions button {
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: "Cinzel", serif;
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  padding: 6px 6px;
  border-radius: 0;
  border: 1px solid rgba(217, 180, 91, 0.32);
  background: rgba(22, 37, 62, 0.85);
  color: var(--ivory);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
}
#nav-actions button svg {
  flex-shrink: 0;
}
#nav-actions button:hover, #nav-actions button.active {
  background: rgba(217, 180, 91, 0.22);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

/* Media / Category Highlight Filter Pills */
#media-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(217, 180, 91, 0.18);
}
.mf-pill {
  font-family: "Cinzel", serif;
  font-size: 9.8px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 7px;
  border-radius: 0;
  border: 1px solid rgba(217, 180, 91, 0.28);
  background: rgba(12, 22, 38, 0.72);
  color: var(--ivory-muted);
  cursor: pointer;
  transition: all 0.16s ease;
}
.mf-pill:hover {
  border-color: var(--gold);
  color: var(--ivory);
  background: rgba(217, 180, 91, 0.14);
}
.mf-pill.active {
  background: linear-gradient(90deg, rgba(226, 182, 78, 0.34), rgba(168, 122, 34, 0.30));
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  box-shadow: 0 0 8px rgba(217, 180, 91, 0.25);
}

/* Continent Gazetteer Drawer */
#gazetteer {
  display: none;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(217, 180, 91, 0.25);
  max-height: 54vh;
  overflow-y: auto;
}
#gazetteer.open { display: block; }
.gaz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: "Cinzel", serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
#gaz-close {
  border: none;
  background: none;
  color: var(--ivory-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
#gaz-close:hover { color: var(--gold-bright); }
#gaz-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gaz-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 0;
  background: rgba(12, 22, 38, 0.65);
  border: 1px solid rgba(217, 180, 91, 0.16);
  cursor: pointer;
  transition: all 0.15s ease;
}
.gaz-item:hover {
  background: rgba(217, 180, 91, 0.18);
  border-color: var(--gold);
}
.gaz-name {
  font-family: "Cinzel", serif;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ivory);
  display: flex;
  align-items: center;
  gap: 7px;
}
.gaz-dot {
  width: 9px;
  height: 9px;
  border-radius: 0;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.45);
}
.gaz-cnt {
  font-size: 12.5px;
  color: var(--ivory-muted);
  font-style: italic;
  white-space: nowrap;
}

/* ---------------- Hover Tooltip ---------------- */
#hover-tip {
  position: fixed;
  z-index: 950;
  pointer-events: none;
  display: none;
  background: rgba(12, 22, 38, 0.96);
  border: 1.5px solid var(--gold);
  border-radius: 8px;
  padding: 7px 12px;
  box-shadow: 0 8px 22px rgba(4, 8, 16, 0.65);
  max-width: 320px;
  transform: translate(15px, -20px);
}
#hover-tip .ht-name {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--gold-bright);
  line-height: 1.2;
}
#hover-tip .ht-sub {
  font-style: italic;
  font-size: 13px;
  color: var(--ivory-muted);
  line-height: 1.2;
  margin-top: 2px;
}
#hover-tip .ht-reg {
  font-size: 12px;
  color: var(--ivory);
  margin-top: 4px;
  border-top: 1px solid rgba(217, 180, 91, 0.25);
  padding-top: 3px;
}

/* ---------------- Right Territory Chronicle Drawer ---------------- */
#panel {
  position: fixed;
  top: 14px;
  right: 16px;
  width: 410px;
  max-height: calc(100% - 92px);
  overflow-y: auto;
  z-index: 1000;
  background: linear-gradient(170deg, rgba(16, 28, 48, 0.97), rgba(10, 18, 32, 0.96));
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  padding: 16px 20px 18px;
  box-shadow: 0 14px 40px rgba(4, 8, 16, 0.72), inset 0 1px 0 rgba(255, 238, 190, 0.2);
  backdrop-filter: blur(10px);
  display: none;
  transition: max-height 0.24s ease, padding 0.2s ease;
}
#panel.open { display: block; }

#panel-grip {
  display: none;
  width: 100%;
  padding: 2px 0 6px;
  cursor: pointer;
  justify-content: center;
  align-items: center;
}
#panel-grip span {
  display: block;
  width: 38px;
  height: 4px;
  border-radius: 0;
  background: rgba(217, 180, 91, 0.48);
  transition: background 0.15s;
}
#panel-grip:hover span { background: var(--gold-bright); }

#panel-controls {
  position: absolute;
  top: 10px;
  right: 11px;
  display: flex;
  align-items: center;
  gap: 5px;
  z-index: 5;
}
#panel-toggle, #close {
  width: 28px;
  height: 28px;
  border-radius: 0;
  border: 1px solid rgba(217, 180, 91, 0.34);
  background: rgba(10, 19, 34, 0.78);
  color: var(--ivory-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: all 0.16s ease;
}
#close {
  font-size: 21px;
  padding-bottom: 2px;
}
#panel-toggle:hover, #close:hover {
  color: var(--gold-bright);
  border-color: var(--gold-bright);
  background: rgba(217, 180, 91, 0.2);
}
#panel-toggle .chev-ic {
  transition: transform 0.22s ease;
}
#panel.collapsed #panel-toggle .chev-ic {
  transform: rotate(180deg);
}

.panel-header {
  cursor: pointer;
  padding-right: 66px;
  user-select: none;
}
#panel.collapsed {
  overflow: hidden;
  padding-top: 11px;
  padding-bottom: 11px;
}
#panel.collapsed .panel-body {
  display: none;
}
#panel.collapsed .chr-kicker {
  display: none;
}
#panel.collapsed h2 {
  font-size: 18px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#panel.collapsed .badge-row {
  margin-bottom: 0;
}
#panel .collapsed-only {
  display: none;
}
#panel.collapsed .collapsed-only {
  display: inline-block;
}

.chr-kicker {
  font-family: "Cinzel", serif;
  font-size: 10.5px;
  letter-spacing: 0.09em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 3px;
}
#panel h2 {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 22px;
  margin: 0 0 4px 0;
  color: var(--gold-bright);
  line-height: 1.18;
}
#panel .alt {
  font-style: italic;
  color: var(--ivory-muted);
  font-size: 14.5px;
  margin-bottom: 8px;
}
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
#panel .type-badge {
  display: inline-block;
  font-family: "Cinzel", serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 2px 9px;
  border: 1px solid rgba(217, 180, 91, 0.48);
  border-radius: 0;
  background: rgba(217, 180, 91, 0.14);
  color: var(--gold-bright);
}
#panel .regions-trail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  font-size: 13.5px;
  color: var(--ivory-muted);
  background: rgba(8, 15, 27, 0.65);
  border: 1px solid rgba(217, 180, 91, 0.22);
  border-radius: 0;
  padding: 6px 10px;
  margin: 6px 0 11px;
}
.regions-trail .reg-chip {
  color: var(--ivory);
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s;
}
.regions-trail .reg-chip:hover {
  color: var(--gold-bright);
  text-decoration: underline;
}
.regions-trail .sep {
  color: var(--gold);
  font-size: 12px;
}

#panel .hero-img {
  width: 100%;
  max-height: 230px;
  object-fit: cover;
  border: 1px solid rgba(217, 180, 91, 0.45);
  border-radius: 0;
  margin: 4px 0 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

/* English Wikipedia Telemetry Card */
.lang-card {
  background: linear-gradient(180deg, rgba(24, 40, 66, 0.9), rgba(14, 25, 44, 0.92));
  border: 1px solid rgba(217, 180, 91, 0.38);
  border-radius: 0;
  padding: 11px 13px;
  margin: 8px 0 12px;
  box-shadow: inset 0 1px 0 rgba(255, 244, 210, 0.12);
}
.lc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(217, 180, 91, 0.22);
  padding-bottom: 5px;
}
.lc-lang {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 12.5px;
  color: var(--ivory);
  letter-spacing: 0.05em;
}
.lc-rank {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 11.5px;
  color: #101b2d;
  background: linear-gradient(90deg, #e0bc62, #f5dca0);
  border-radius: 0;
  padding: 1px 8px;
}
.lc-metric { margin: 7px 0; }
.lc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 14px;
  line-height: 1.25;
  margin-bottom: 4px;
}
.lc-label {
  color: var(--ivory-muted);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lc-val {
  font-weight: 700;
  color: var(--ivory);
  font-size: 14.5px;
}
.lc-val small {
  font-weight: 600;
  color: var(--gold-bright);
  font-size: 12px;
  margin-left: 3px;
}
.q-icon {
  height: 20px;
  width: auto;
  object-fit: contain;
  vertical-align: middle;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}
.pbar {
  position: relative;
  height: 9px;
  width: 100%;
  background: rgba(6, 12, 22, 0.65);
  border: 1px solid rgba(217, 180, 91, 0.35);
  border-radius: 0;
  overflow: hidden;
}
.pbar-fill {
  height: 100%;
  border-radius: 0;
  transition: width 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.lc-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px dashed rgba(217, 180, 91, 0.28);
  font-size: 13px;
}
.lc-links a {
  color: var(--gold-bright);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 0;
  background: rgba(217, 180, 91, 0.1);
  border: 1px solid rgba(217, 180, 91, 0.25);
  transition: all 0.15s;
}
.lc-links a:hover {
  background: rgba(217, 180, 91, 0.24);
  border-color: var(--gold-bright);
}

#panel p.abstract {
  font-size: 16px;
  line-height: 1.42;
  color: var(--ivory);
  margin: 8px 0 12px;
}
#panel h3 {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--gold-bright);
  letter-spacing: 0.06em;
  margin: 14px 0 6px;
  border-bottom: 1px solid rgba(217, 180, 91, 0.28);
  padding-bottom: 3px;
}
#panel ul.related {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#panel ul.related li {
  padding: 5px 8px;
  border-radius: 0;
  background: rgba(8, 15, 27, 0.55);
  border: 1px solid rgba(217, 180, 91, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.15s;
}
#panel ul.related li:hover {
  background: rgba(217, 180, 91, 0.18);
  border-color: var(--gold);
}
.rel-name {
  font-weight: 600;
  color: var(--ivory);
  font-size: 14.5px;
}
.rel-cs {
  font-size: 12px;
  color: var(--ivory-muted);
  font-style: italic;
  white-space: nowrap;
}

/* ---------------- Bottom-Left World Locator Minimap ---------------- */
#minimap-wrap {
  position: fixed;
  left: 60px;
  bottom: 26px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}
#minimap-box {
  position: relative;
  width: 148px;
  height: 148px;
  border: 1.5px solid var(--gold);
  border-radius: 9px;
  overflow: hidden;
  background: #1b314d;
  box-shadow: 0 10px 28px rgba(4, 9, 18, 0.72);
  cursor: crosshair;
}
#minimap-box.collapsed {
  display: none;
}
#minimap-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
}
#minimap-rect {
  position: absolute;
  border: 1.8px solid var(--gold-bright);
  background: rgba(243, 215, 138, 0.18);
  box-shadow: 0 0 0 1px rgba(10, 18, 32, 0.85), 0 0 8px rgba(243, 215, 138, 0.65);
  pointer-events: none;
  border-radius: 0;
}
#minimap-toggle {
  font-family: "Cinzel", serif;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--gold-bright);
  background: var(--navy-bg);
  border: 1.2px solid var(--gold-dim);
  border-radius: 0;
  padding: 3px 9px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(5, 10, 20, 0.55);
}
#minimap-toggle:hover {
  background: var(--navy-elev);
  border-color: var(--gold-bright);
}

/* ---------------- Bottom-Right Atlas HUD & Key ---------------- */
#atlas-hud {
  position: fixed;
  right: 16px;
  bottom: 26px;
  z-index: 900;
  width: 318px;
  background: linear-gradient(165deg, rgba(16, 28, 48, 0.94), rgba(10, 19, 34, 0.94));
  border: 1.5px solid var(--gold-dim);
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 8px 26px rgba(5, 10, 20, 0.6);
  backdrop-filter: blur(6px);
}
#hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.hud-btns {
  display: flex;
  align-items: center;
  gap: 5px;
}
#hud-coords {
  font-family: "Cinzel", serif;
  font-size: 10.8px;
  color: var(--ivory-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#legend-toggle, #arcs-toggle {
  font-family: "Cinzel", serif;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--gold-bright);
  background: rgba(217, 180, 91, 0.14);
  border: 1px solid rgba(217, 180, 91, 0.35);
  border-radius: 0;
  padding: 2px 7px;
  cursor: pointer;
  white-space: nowrap;
}
#arcs-toggle.active {
  background: rgba(217, 180, 91, 0.30);
  border-color: var(--gold-bright);
}
#legend-toggle:hover, #arcs-toggle:hover { background: rgba(217, 180, 91, 0.25); }
#legend {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(217, 180, 91, 0.22);
  font-size: 12.8px;
  line-height: 1.45;
}
#legend.collapsed { display: none; }
#legend .lg-title {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 12px;
  color: var(--gold-bright);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
}
#legend .lg-note {
  font-style: italic;
  font-size: 11.8px;
  color: var(--ivory-muted);
  margin-top: 6px;
  line-height: 1.28;
}
.ic {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 7px;
  vertical-align: -2px;
  border: 1.5px solid #2a1c16;
  background: #f8eed4;
}
.ic.tier3 {
  border-radius: 2px;
  background: linear-gradient(180deg, #942430 0%, #f8eed4 50%, #dab25c 100%);
  box-shadow: 0 0 0 1px #dab25c;
}
.ic.castle { border-radius: 3px 3px 1px 1px; box-shadow: inset 0 4px 0 #38608e; }
.ic.house { border-radius: 2px; background: linear-gradient(90deg, #f8eed4 45%, #942430 50%, #f8eed4 55%); }
.ic.shield { clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%); background: #dab25c; border: none; }
.ic.diamond { border-radius: 50% 50% 2px 2px; box-shadow: inset 0 -4px 0 #942430; }
.ic.star { clip-path: polygon(20% 0%, 80% 0%, 65% 65%, 85% 100%, 15% 100%, 35% 65%); background: #dab25c; border: none; }
.ic.dot { border-radius: 50%; border: 2.5px solid #16243a; background: #dab25c; }

/* ---------------- Crisp Symmetrical SVG Map Markers (Target, Arcs & Media Highlights) ---------------- */
.agy-marker {
  background: none !important;
  border: none !important;
}

.target-pin-wrap {
  position: relative;
  width: 36px;
  height: 46px;
  pointer-events: none;
}
.target-pin-svg {
  display: block;
  width: 36px;
  height: 46px;
  filter: drop-shadow(0 1px 2px rgba(255, 252, 230, 0.92)) drop-shadow(0 4px 8px rgba(255, 252, 230, 0.70));
}
.target-pulse {
  position: absolute;
  left: 18px;
  top: 42px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.2px solid #8c5d08;
  background: rgba(158, 108, 13, 0.34);
  box-shadow: 0 0 8px rgba(255, 252, 230, 0.70);
  transform: translate(-50%, -50%) scale(0.75);
  animation: targetPulse 2.1s ease-out infinite;
}
@keyframes targetPulse {
  0%   { transform: translate(-50%, -50%) scale(0.55); opacity: 0.95; }
  100% { transform: translate(-50%, -50%) scale(1.85); opacity: 0; }
}

.arc-pin-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  cursor: pointer;
}
.arc-pin-svg {
  display: block;
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 1px 2px rgba(255, 252, 230, 0.92)) drop-shadow(0 3px 6px rgba(255, 252, 230, 0.70));
  transition: transform 0.16s ease;
}
.arc-pin-wrap:hover .arc-pin-svg {
  transform: scale(1.16);
}

.hl-pin-wrap {
  position: relative;
  width: 32px;
  height: 40px;
  cursor: pointer;
}
.hl-pin-svg {
  display: block;
  width: 32px;
  height: 40px;
  filter: drop-shadow(0 1px 2px rgba(255, 252, 230, 0.92)) drop-shadow(0 4px 8px rgba(255, 252, 230, 0.70));
  transition: transform 0.16s ease;
}
.hl-pin-wrap:hover .hl-pin-svg {
  transform: translateY(-2px) scale(1.10);
}

.marker-label {
  position: absolute;
  left: 50%;
  top: calc(100% + 2px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(11, 20, 35, 0.94);
  border: 1px solid var(--gold);
  border-radius: 0;
  padding: 2px 7px;
  color: var(--ivory);
  font-family: "Cinzel", serif;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.25;
  text-align: center;
  box-shadow: 0 3px 10px rgba(255, 252, 230, 0.7);
  pointer-events: auto;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.arc-pin-wrap:hover .marker-label,
.hl-pin-wrap:hover .marker-label {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  background: rgba(20, 36, 60, 0.98);
}
.leaflet-marker-icon:hover {
  z-index: 9999 !important;
}

/* ---------------- About / Guide Modal ---------------- */
#about-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(6, 12, 22, 0.72);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
#about-backdrop.open { display: flex; }
#about-modal {
  position: relative;
  max-width: 700px;
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  background: linear-gradient(165deg, #13223a, #0c1729);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 24px 28px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 240, 200, 0.22);
  color: var(--ivory);
  font-size: 16px;
  line-height: 1.48;
}
#about-close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: none;
  background: none;
  font-size: 28px;
  color: var(--ivory-muted);
  cursor: pointer;
  line-height: 1;
}
#about-close:hover { color: var(--gold-bright); }
.modal-kicker {
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: 2px;
}
#about-modal h2 {
  font-family: "Cinzel Decorative", "Cinzel", serif;
  font-weight: 700;
  font-size: 25px;
  color: var(--gold-bright);
  margin: 0 28px 10px 0;
  border-bottom: 1px solid rgba(217, 180, 91, 0.35);
  padding-bottom: 8px;
}
#about-modal .about-lead {
  font-size: 17px;
  margin: 6px 0 14px;
  color: var(--ivory);
}
#about-modal h3 {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 15.5px;
  color: var(--gold-bright);
  margin: 16px 0 6px;
  letter-spacing: 0.05em;
}
#about-modal ul { margin: 4px 0 10px; padding-left: 20px; }
#about-modal li { margin-bottom: 8px; }
#about-modal code {
  font-family: monospace;
  font-size: 13.5px;
  background: rgba(217, 180, 91, 0.14);
  color: var(--gold-bright);
  padding: 1px 5px;
  border-radius: 0;
}

@media (max-width: 860px) {
  /* Compact & collapsible mobile top block (#command-dock) */
  #command-dock {
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    top: 8px;
    padding: 6px 9px;
    border-radius: 10px;
  }
  #dock-top {
    padding-bottom: 5px;
    gap: 6px;
  }
  #brand-header {
    gap: 7px;
  }
  #brand-header .emblem svg {
    width: 26px;
    height: 26px;
  }
  .brand-kicker,
  .brand-text .subtitle {
    display: none;
  }
  .brand-row {
    gap: 5px;
  }
  .brand-row .word-primary,
  .brand-row .word-accent {
    font-size: 15.5px;
    letter-spacing: 0.06em;
  }
  .brand-row .word-sep {
    font-size: 7.5px;
  }
  #dock-toggle {
    width: 25px;
    height: 25px;
  }
  #search-wrap {
    margin-top: 5px;
  }
  .search-ic {
    left: 9px;
    width: 14px;
    height: 14px;
  }
  #q {
    font-size: 16px;
    padding: 4px 10px 4px 28px;
    border-radius: 0;
    height: 31px;
  }
  .search-kbd {
    display: none;
  }
  #nav-actions {
    margin-top: 5px;
    gap: 4px;
    flex-wrap: nowrap;
  }
  #nav-actions button {
    padding: 4px 4px;
    font-size: 9.2px;
    gap: 3px;
    border-radius: 0;
  }
  #nav-actions button svg {
    width: 11px;
    height: 11px;
  }
  #media-filters {
    margin-top: 5px;
    padding-top: 5px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
  }
  #media-filters::-webkit-scrollbar {
    display: none;
  }
  .mf-pill {
    flex: 0 0 auto;
    padding: 2px 7px;
    font-size: 9px;
  }
  #gazetteer {
    margin-top: 6px;
    padding-top: 6px;
    max-height: 40vh;
  }

  #atlas-hud, #minimap-wrap { display: none; }
  /* Mobile article panel reduced by 40% (from 56% down to 33.5vh) + collapsible */
  #panel {
    left: 10px;
    right: 10px;
    width: auto;
    top: auto;
    bottom: 10px;
    max-height: 33.5vh;
    padding: 7px 13px 11px;
    border-radius: 11px;
  }
  #panel-grip { display: flex; }
  #panel-controls { top: 8px; right: 9px; gap: 4px; }
  #panel-toggle, #close { width: 26px; height: 26px; }
  /* On mobile bottom drawer: expanded chevron points down (collapse), collapsed points up (expand) */
  #panel-toggle .chev-ic { transform: rotate(180deg); }
  #panel.collapsed #panel-toggle .chev-ic { transform: rotate(0deg); }
  #panel.collapsed {
    padding-top: 6px;
    padding-bottom: 8px;
  }
  .chr-kicker { font-size: 9.5px; margin-bottom: 1px; }
  #panel h2 { font-size: 17.5px; margin-bottom: 3px; }
  #panel.collapsed h2 { font-size: 15.5px; }
  .badge-row { gap: 4px; margin-bottom: 6px; }
  #panel .type-badge { font-size: 10px; padding: 1px 7px; }
  #panel .regions-trail { font-size: 12px; padding: 4px 8px; margin: 4px 0 8px; }
  #panel .hero-img { max-height: 110px; margin: 3px 0 7px; }
  .lang-card { padding: 8px 10px; margin: 6px 0 9px; }
  #panel p.abstract { font-size: 14.5px; line-height: 1.35; margin: 6px 0 9px; }
}

@media (max-width: 360px) {
  #nav-actions button svg { display: none; }
}
