:root {
  color-scheme: dark;
  --panel: #202c28;
  --panel-raised: #2b3931;
  --edge: #45534a;
  --text: #f4f1e7;
  --quiet: #b7c4b9;
  --accent: #eed292;
  --header: 62px;
  --panel-width: clamp(308px, 25vw, 354px);
  --map-inset: 14px;
  --control-height: 42px;
  --edge-tab-width: 38px;
  --panel-motion: 260ms cubic-bezier(.22,.61,.36,1);
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: #15201c; overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.map-header {
  position: relative;
  z-index: 600;
  height: var(--header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: linear-gradient(110deg, #2c3328, #1c2923 46%, #18231e);
  border-bottom: 1px solid #706142;
  box-shadow: inset 0 1px #ffffff14, 0 3px 12px #09150e5c;
}
.map-brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; white-space: nowrap; font-weight: 700; }
.map-brand small { display: block; margin-top: 2px; color: var(--quiet); font-size: 11px; font-weight: 500; }
.atlas-embedded .map-brand small { display: none; }
.compass {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #a28b59;
  border-radius: 50%;
  color: var(--accent);
  background: radial-gradient(circle, #56523a, #2c3329 73%);
  box-shadow: inset 0 0 0 3px #242c25, 0 2px 5px #0b130e7a;
  font-size: 22px;
}
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions button, #map-spawn, .detail-action {
  min-height: var(--control-height);
  padding: 6px 12px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  color: var(--text);
  background: linear-gradient(180deg, #334136, #29372e);
  box-shadow: inset 0 1px #ffffff10, 0 2px 4px #0b160e38;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.header-actions button:hover, #map-spawn:hover, .detail-action:hover { border-color: #88744d; background: #3c4938; }
#show-panel { display: inline-flex; align-items: center; gap: 8px; }
#show-panel[aria-expanded="true"] { border-color: #877149; color: var(--accent); background: linear-gradient(180deg, #4d4933, #393d2d); }
.panel-glyph { position: relative; width: 16px; height: 13px; border: 1px solid currentColor; border-radius: 3px; }
.panel-glyph::before { content: ""; position: absolute; inset: 0 auto 0 4px; border-left: 1px solid currentColor; }
.atlas-layout {
  position: relative;
  display: grid;
  grid-template-columns: 0px minmax(0, 1fr);
  height: calc(100vh - var(--header));
  height: calc(100dvh - var(--header));
  transition: grid-template-columns var(--panel-motion);
  overflow: hidden;
}
.atlas-pinned .atlas-layout { grid-template-columns: var(--panel-width) minmax(0, 1fr); }
#map-panel {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--panel-width);
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-100%);
  transition: transform var(--panel-motion), opacity 190ms ease, visibility 0s linear 260ms;
  min-width: 0;
  min-height: 0;
  z-index: 550;
  border-right: 1px solid #505744;
  background:
    radial-gradient(ellipse at 4% 0, #ccac631b, transparent 325px),
    linear-gradient(156deg, #29332a 0%, #222e27 33%, #1b2923 100%);
  box-shadow: 8px 0 23px #0b1a105e, inset -1px 0 #d2bd7920;
}
.atlas-pinned #map-panel, .atlas-preview #map-panel {
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
  transform: translateX(0);
  transition-delay: 0s;
}
.atlas-preview #map-panel {
  transform: translateX(var(--edge-tab-width));
  border-radius: 0 11px 11px 0;
}
#peek-panel {
  position: absolute;
  z-index: 560;
  top: 14px;
  left: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  width: var(--edge-tab-width);
  min-height: 123px;
  padding: 10px 6px;
  writing-mode: vertical-rl;
  border: 1px solid #877149;
  border-left: 0;
  border-radius: 0 10px 10px 0;
  background: linear-gradient(90deg, #252c23, #3d402c);
  box-shadow: 3px 3px 9px #12201670;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
#peek-panel:hover, .atlas-preview #peek-panel { background: linear-gradient(90deg, #393a2a, #514733); }
.atlas-pinned #peek-panel { display: none; }
.edge-chevron { width: 7px; height: 7px; border-top: 1px solid; border-right: 1px solid; transform: rotate(45deg); }
.panel-scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #607260 #222f27;
  scrollbar-width: thin;
  padding: 21px 16px 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.panel-head h1 { margin: 0; letter-spacing: -.034em; font-size: 25px; line-height: 1.18; }
#close-panel, .detail-close {
  display: grid;
  place-items: center;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: #233028;
  color: var(--quiet);
  font-size: 21px;
  line-height: 1;
}
#close-panel { width: 35px; height: 35px; flex: 0 0 35px; }
#close-panel:hover, .detail-close:hover { color: var(--text); border-color: #8c7752; }
#search-form label { display: block; font-size: 12px; color: var(--quiet); margin: 0 0 6px; }
.search-field {
  display: flex;
  overflow: hidden;
  border: 1px solid #58664f;
  border-radius: 10px;
  background: #19271f;
  box-shadow: inset 0 2px 4px #0d160e7a, 0 2px 4px #0b130d30;
}
.search-field:focus-within { border-color: var(--accent); }
.search-field input { width: 100%; min-width: 0; height: 44px; padding: 0 12px; outline: none; border: 0; background: transparent; font-size: 14px; }
.search-field input::placeholder { color: var(--quiet); }
.search-field button {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  background: linear-gradient(180deg, #514933, #3b3b2a);
  border: 0;
  border-left: 1px solid #786746;
  color: var(--accent);
}
.search-field button:hover { background: #5f5337; }
.search-glyph { position: relative; width: 12px; height: 12px; margin: -3px 3px 0 0; border: 2px solid currentColor; border-radius: 50%; }
.search-glyph::after { content: ""; position: absolute; width: 6px; height: 2px; top: 7px; left: 7px; background: currentColor; transform: rotate(45deg); transform-origin: left center; }
.map-layer-panel {
  margin-top: 12px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: linear-gradient(150deg, #303f34, #243229);
}
.map-layer-panel summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 43px;
  padding: 8px 13px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 650;
  list-style: none;
  cursor: pointer;
}
.map-layer-panel summary::-webkit-details-marker { display: none; }
.map-layer-panel summary:hover { background: #39483b; }
.map-layer-panel summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.5px solid var(--accent);
  border-bottom: 1.5px solid var(--accent);
  transform: rotate(45deg);
  transition: transform 160ms ease;
}
.map-layer-panel[open] summary::after { transform: rotate(225deg); }
.layer-glyph {
  width: 13px;
  height: 13px;
  margin: 0 3px 0 1px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: #4a4934;
  box-shadow: 2px 2px #303f34, 3px 3px #ab9868;
}
#map-layer-controls .leaflet-control-layers {
  float: none;
  z-index: auto;
  margin: 0;
  padding: 0 7px 7px;
  border: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
}
#map-layer-controls .leaflet-control-layers-list { height: auto !important; overflow: visible; }
#map-layer-controls .leaflet-control-layers-overlays {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}
#map-layer-controls label {
  display: flex;
  align-items: center;
  min-height: 41px;
  margin: 0;
  padding: 5px 7px;
  border: 1px solid #455548;
  border-radius: 7px;
  background: #243229;
  color: var(--quiet);
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}
#map-layer-controls label > span { display: flex; align-items: center; gap: 6px; }
#map-layer-controls .leaflet-control-layers-selector {
  position: static;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
#map-layer-controls label:has(input:checked) { border-color: #72674a; background: #373e2f; color: var(--text); }
#map-layer-controls label:hover { border-color: #a38e5e; }
.atlas-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  margin: 13px 0 10px;
  padding: 4px;
  border: 1px solid #455347;
  border-radius: 10px;
  background: #19281f;
  box-shadow: inset 0 2px 5px #101b1370;
}
.atlas-tab { min-height: 35px; padding: 4px 3px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--quiet); font-size: 12px; }
.atlas-tab[aria-pressed="true"] {
  color: #241f15;
  border-color: #f3dba5;
  background: linear-gradient(180deg, #f0d497, #c7a76a);
  box-shadow: inset 0 1px #fff3cd8f, 0 2px 5px #0c160e80;
  font-weight: 700;
}
.atlas-tab:hover:not([aria-pressed="true"]) { color: var(--text); background: #2b3b2e; }
.atlas-list { display: grid; gap: 6px; }
.atlas-result {
  width: 100%;
  min-height: 50px;
  display: grid;
  grid-template-columns: 21px minmax(0, 1fr) auto;
  align-items: center;
  text-align: left;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid #415145;
  border-radius: 9px;
  background: linear-gradient(155deg, #304034, #26362b);
  box-shadow: inset 0 1px #ffffff08, 0 2px 4px #07130d28;
}
.atlas-result:hover, .atlas-result[aria-current="true"] { border-color: var(--entry-color, var(--accent)); background: #39483a; }
.atlas-result strong, .atlas-result small { display: block; overflow-wrap: anywhere; }
.atlas-result strong { font-size: 13px; line-height: 1.25; }
.atlas-result small { font-size: 11px; color: var(--quiet); margin-top: 2px; }
.atlas-result .go { color: var(--accent); font-size: 17px; }
.atlas-dot {
  justify-self: center;
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border-radius: 50%;
  border: 1px solid #ffffffe0;
  background: var(--entry-color, var(--accent));
  box-shadow: 0 0 0 3px #ffffff14;
}
.list-note { font-size: 13px; color: var(--quiet); margin: 12px 0; }
#map-details {
  position: relative;
  padding: 14px;
  margin-bottom: 10px;
  background:
    radial-gradient(ellipse at 0 0, color-mix(in srgb, var(--entry-color) 14%, transparent), transparent 68%),
    linear-gradient(148deg, #303f34, #243229);
  border: 1px solid var(--edge);
  border-top: 2px solid var(--entry-color, var(--accent));
  border-radius: 11px;
  box-shadow: inset 0 1px #ffffff12, 0 5px 13px #0d1a1061;
}
.detail-kind { margin: 0 27px 8px 0; color: var(--accent); font-size: 11px; font-weight: 650; }
.detail-title { display: flex; align-items: center; gap: 9px; }
.detail-title h2 { min-width: 0; margin: 0; font-size: 19px; line-height: 1.2; overflow-wrap: anywhere; }
.detail-title .atlas-dot { flex-shrink: 0; }
.detail-icon { width: 35px; height: 35px; object-fit: contain; flex-shrink: 0; }
.detail-close { position: absolute; top: 7px; right: 7px; width: 28px; height: 28px; }
.detail-context, .detail-coordinates { margin: 6px 0 0; color: var(--quiet); font-size: 12px; overflow-wrap: anywhere; }
.detail-coordinates { padding-top: 8px; border-top: 1px solid var(--edge); font-variant-numeric: tabular-nums; }
.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 12px 0 9px;
}
.detail-facts div { padding: 7px 8px; border: 1px solid #405045; border-radius: 7px; background: #1e2b23; overflow-wrap: anywhere; }
.detail-facts dt { font-size: 11px; color: var(--quiet); }
.detail-facts dd { margin: 2px 0 0; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.detail-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.detail-link:hover { color: #fff0c1; }
.detail-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.detail-action { flex: 1 1 auto; padding: 6px 9px; min-height: 36px; font-size: 12px; }
.detail-focus {
  background: linear-gradient(180deg, #eacb8b, #cca966);
  color: #272014;
  border-color: #ebcc8d;
}
.detail-focus:hover { background: #f0d496; color: #272014; border-color: #f0d496; }
#mobile-map-card { display: none; }
.map-canvas { position: relative; grid-column: 2; isolation: isolate; min-width: 0; min-height: 0; background: #24382c; }
#map .leaflet-top.leaflet-left { transition: margin-left var(--panel-motion); }
body:not(.atlas-pinned) #map .leaflet-top.leaflet-left { margin-left: var(--edge-tab-width); }
#map { position: absolute; inset: 0; width: 100%; height: 100%; isolation: isolate; background-color: #263a2e; }
.atlas-terrain-tile { overflow: hidden; }
.atlas-terrain-tile img { position: absolute; inset: 0 auto auto 0; width: 512px; height: 512px; max-width: none; }
#terrain-status {
  position: absolute;
  z-index: 500;
  left: 50%;
  top: 50%;
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: calc(100% - 25px);
  padding: 11px 14px;
  transform: translate(-50%, -50%);
  border: 1px solid #68735e;
  border-radius: 9px;
  background: #202d24;
  color: var(--text);
  box-shadow: 0 2px 9px #0007;
  font-size: 13px;
  text-align: center;
}
#retry-terrain {
  border: 1px solid #a28856;
  border-radius: 6px;
  padding: 4px 10px;
  background: #4b4430;
  color: var(--accent);
}
#sidebar, #map .leaflet-control.sidebar, #map .leaflet-control-layers {
  display: none !important;
}
.map-canvas .leaflet-bar { border: 1px solid #53614e; border-radius: 10px; overflow: hidden; box-shadow: 0 3px 9px #0008; }
.map-canvas .leaflet-bar a, .map-canvas .leaflet-bar a:hover { color: var(--text); background: #29382e; border-color: var(--edge); }
.map-tools {
  position: absolute;
  top: var(--map-inset);
  right: var(--map-inset);
  z-index: 501;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  max-width: calc(100% - 66px);
  pointer-events: none;
}
.map-tool-row { display: flex; align-items: center; gap: 8px; }
#map-spawn { pointer-events: auto; box-shadow: 0 3px 10px #0007; }
#map-position {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--control-height);
  padding: 4px 11px;
  color: var(--text);
  border: 1px solid #a38b58;
  border-radius: 10px;
  background: linear-gradient(160deg, #2c382b, #18261f);
  box-shadow: inset 0 1px #f6dea052, 0 4px 13px #0009;
  white-space: nowrap;
}
.position-caption { font-size: 11px; color: var(--quiet); }
.position-axis { display: inline-flex; gap: 6px; align-items: baseline; }
.position-axis + .position-axis { padding-left: 11px; border-left: 1px solid #68705a; }
.position-axis b { color: var(--accent); font-size: 12px; font-weight: 700; }
.position-axis strong { font: 700 15px/1.2 "Cascadia Mono", "Consolas", monospace; font-variant-numeric: tabular-nums; }
#atlas-status {
  padding: 7px 10px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip, .leaflet-tooltip { background: var(--panel); color: var(--text); }
.leaflet-popup-content { max-width: min(250px, 66vw); font: 13px/1.45 "Segoe UI", system-ui, sans-serif; }
.leaflet-popup-content .ccsm-card__eyebrow, .leaflet-popup-content .ccsm-card__buttons { display: none; }
.leaflet-popup-content h3 { margin: 3px 0; color: var(--accent); }
.leaflet-popup-content p { margin: 2px 0 8px; }
.ccsm-card__stat, .ccsm-culture-card__line { display: flex; gap: 10px; justify-content: space-between; margin: 3px 0; }
.ccsm-card__stat span, .ccsm-culture-card__line span, .ccsm-card__footer { color: var(--quiet); }
.ccsm-culture-card__title em { margin-left: 6px; color: var(--quiet); }
.ccsm-hover { display: flex; gap: 6px; align-items: center; }
.ccsm-hover span { color: var(--quiet); }
.leaflet-marker-icon[src*="/atlas-v1/icons/"] { filter: drop-shadow(0 2px 2px #000b); }
@media (max-width: 760px) {
  :root { --header: 52px; --map-inset: 9px; --control-height: 37px; }
  .map-header { padding: 0 9px; gap: 5px; }
  .map-brand { gap: 7px; font-size: 13px; }
  .map-brand small { font-size: 10px; }
  .compass { width: 28px; height: 28px; font-size: 17px; }
  .header-actions { gap: 5px; }
  .header-actions button, #map-spawn { padding: 4px 8px; font-size: 11px; }
  #show-panel { gap: 5px; }
  .panel-glyph { width: 14px; height: 12px; }
  .atlas-layout { display: block; position: relative; }
  .map-canvas { height: 100%; }
  #peek-panel { display: none; }
  body:not(.atlas-pinned) #map .leaflet-top.leaflet-left { margin-left: 0; }
  #map-panel {
    display: flex;
    flex-direction: column;
    inset: auto 7px max(7px, env(safe-area-inset-bottom)) 7px;
    width: auto;
    max-height: min(68%, 550px);
    border: 1px solid #6d7256;
    border-radius: 15px;
    box-shadow: 0 -6px 25px #0008, inset 0 1px #ecd49633;
    transform: translateY(calc(100% + 28px));
  }
  .atlas-pinned #map-panel { transform: translateY(0); }
  .panel-scroll { flex: 1 1 auto; min-height: 0; padding: 12px 11px 11px; }
  .panel-head { margin-bottom: 8px; }
  .panel-head h1 { font-size: 20px; }
  .map-tools { gap: 5px; }
  .map-tool-row { gap: 5px; }
  #mobile-map-card {
    display: block;
    position: absolute;
    z-index: 540;
    inset: auto 8px max(8px, env(safe-area-inset-bottom)) 8px;
    pointer-events: none;
  }
  .atlas-pinned #mobile-map-card { display: none; }
  #mobile-map-card #map-details {
    display: flex;
    flex-direction: column;
    margin: 0;
    max-height: min(50vh, 410px);
    pointer-events: auto;
  }
  .detail-body {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #72674a #1e2b23;
  }
  #mobile-map-card #map-details:not([hidden]) { animation: reveal-map-card 220ms ease-out; }
  #map-position { gap: 8px; padding: 4px 8px; }
  .position-caption { display: none; }
  .position-axis { gap: 4px; }
  .position-axis + .position-axis { padding-left: 7px; }
  .position-axis strong { font-size: 13px; }
}
@keyframes reveal-map-card {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .atlas-layout, #map-panel, #map .leaflet-top.leaflet-left { transition: none; }
  .map-layer-panel summary::after { transition: none; }
  #mobile-map-card #map-details:not([hidden]) { animation: none; }
}
