:root {
  color-scheme: dark;
  --sky-top: #ccd5ca;
  --sky-mid: #678176;
  --sky-bottom: #20312c;
  --panel: rgba(18, 28, 25, 0.88);
  --panel-strong: rgba(11, 18, 16, 0.94);
  --line: rgba(240, 238, 226, 0.12);
  --line-strong: rgba(212, 240, 166, 0.28);
  --text: #f4f1e6;
  --muted: #c2c9b8;
  --accent: #d4f0a6;
  --info: rgba(15, 31, 41, 0.94);
  --warning: rgba(73, 57, 16, 0.94);
  --error: rgba(76, 31, 24, 0.96);
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 16%, rgba(244, 239, 197, 0.24), transparent 24%),
    radial-gradient(circle at 84% 12%, rgba(156, 184, 143, 0.24), transparent 26%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 28%, var(--sky-bottom) 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.82), transparent 78%);
  pointer-events: none;
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(212, 240, 166, 0.1), transparent 24%),
    linear-gradient(180deg, rgba(11, 18, 16, 0.7), rgba(5, 8, 7, 0.72));
}

.stage.page-surface-mode {
  background:
    radial-gradient(circle at 50% 16%, rgba(243, 235, 190, 0.62), transparent 36%),
    linear-gradient(180deg, rgba(248, 246, 238, 0.98), rgba(232, 238, 245, 0.96));
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.viewer-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  width: min(248px, calc(100vw - 32px));
  pointer-events: none;
}

.overlay-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(31, 45, 40, 0.92), rgba(15, 23, 21, 0.9));
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
  pointer-events: auto;
}

.overlay-details-panel {
  min-width: 0;
  padding: 10px 12px;
}

.control-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

#terrainSelect {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(242, 239, 225, 0.08);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

#terrainSelect:focus-visible {
  outline: none;
  border-color: rgba(212, 240, 166, 0.58);
  background: rgba(212, 240, 166, 0.12);
}

#terrainSelect:disabled {
  opacity: 0.72;
  cursor: wait;
}

#terrainSelect option {
  color: #0f1715;
}

.map-details {
  display: grid;
  gap: 8px;
}

.map-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.map-title {
  margin: 0;
  font-size: 32px;
  line-height: 1;
  color: var(--text);
}

.map-description {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.page-context {
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.page-context-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-title {
  margin: 0;
  font-size: 23px;
  line-height: 1.08;
  color: var(--text);
}

.page-meta {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.inline-link {
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
}

.inline-link:hover,
.inline-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.details-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(242, 239, 225, 0.08);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

button:hover,
button:focus-visible {
  border-color: rgba(212, 240, 166, 0.58);
  background: rgba(212, 240, 166, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.status-line {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--info);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.status-line[data-tone="warning"] {
  background: var(--warning);
}

.status-line[data-tone="error"] {
  background: var(--error);
}

.details-panel {
  min-height: 0;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.details-panel summary {
  list-style: none;
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.details-panel summary::-webkit-details-marker {
  display: none;
}

.details-panel summary::after {
  content: "+";
  float: right;
  color: var(--muted);
}

.details-panel[open] summary::after {
  content: "-";
}

.layer-catalog {
  margin-top: 10px;
  max-height: min(30vh, 320px);
  overflow-y: auto;
  display: grid;
  gap: 12px;
  padding-right: 4px;
}

.layer-category {
  display: grid;
  gap: 8px;
}

.layer-category-title {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.layer-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.layer-item:last-child {
  border-bottom: none;
}

.layer-item input[type="checkbox"] {
  margin: 2px 0 0;
}

.layer-item-label {
  display: grid;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.layer-item-title {
  font-size: 14px;
  color: var(--text);
}

.layer-item-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.atlas-label-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.atlas-label-button {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 0;
  padding: 0 4px;
  background: transparent;
  color: #1b2e4c;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  line-height: 1.02;
  text-align: center;
  text-shadow:
    0 0 2px rgba(255, 255, 255, 0.95),
    0 0 6px rgba(255, 255, 255, 0.95),
    0 0 12px rgba(255, 255, 255, 0.9);
  pointer-events: auto;
  cursor: pointer;
}

.atlas-label-button.medium {
  font-size: 18px;
}

.atlas-label-button.large {
  font-size: 24px;
}

.atlas-label-button.xlarge {
  font-size: 30px;
}

.atlas-label-button.is-pgh {
  font-size: 16px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 720px) {
  .viewer-overlay {
    top: 12px;
    left: 12px;
    width: calc(100vw - 24px);
  }

  .overlay-details-panel {
    width: 100%;
    padding: 10px 12px;
  }

  .map-title {
    font-size: 26px;
  }

  button {
    padding: 8px 10px;
    font-size: 13px;
  }
}
