
:root {
  --bg-deep: #3b0f13;
  --bg-mid: #60191d;
  --bg-accent: #7f2222;
  --paper: #f1d778;
  --paper-dim: #ceb968;
  --line: #2f2414;
  --green-deep: #42553d;
  --green-soft: #73856a;
  --neutral-land: #7d6a58;
  --strict-5: #8d1f28;
  --strict-4: #c64a33;
  --balanced-3: #d7a93d;
  --lenient-2: #84a56b;
  --lenient-1: #45684a;
  --selection: #ffd98a;
  --shadow: rgba(0,0,0,0.28);
  --overlay: rgba(22, 7, 8, 0.7);
  --font-display: "Russo One", Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  --font-body: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(246,181,49,0.08) 0 6%, transparent 6% 100%),
    linear-gradient(160deg, #320b0f 0%, #5e171c 48%, #7a2120 100%);
  color: var(--paper);
  font-family: var(--font-body);
}

body {
  overflow: hidden;
}

#app {
  position: relative;
  min-height: 100vh;
  padding: 18px;
  background:
    linear-gradient(24deg, rgba(241,215,120,0.12) 0 10%, transparent 10% 100%),
    linear-gradient(206deg, rgba(241,215,120,0.08) 0 12%, transparent 12% 100%);
}

.poster-ornament {
  position: absolute;
  top: 0;
  width: 20vw;
  height: 42vh;
  pointer-events: none;
  opacity: 0.65;
  filter: drop-shadow(0 0 14px rgba(0,0,0,0.22));
}

.ornament-left {
  left: 0;
  background:
    linear-gradient(155deg, transparent 0 22%, rgba(241,215,120,0.75) 22% 28%, transparent 28% 100%),
    linear-gradient(155deg, transparent 0 30%, rgba(241,215,120,0.38) 30% 36%, transparent 36% 100%),
    linear-gradient(155deg, transparent 0 38%, rgba(241,215,120,0.20) 38% 44%, transparent 44% 100%);
}

.ornament-right {
  right: 0;
  background:
    linear-gradient(25deg, transparent 0 20%, rgba(66,85,61,0.72) 20% 26%, transparent 26% 100%),
    linear-gradient(25deg, transparent 0 28%, rgba(66,85,61,0.40) 28% 34%, transparent 34% 100%),
    linear-gradient(25deg, transparent 0 36%, rgba(66,85,61,0.20) 36% 42%, transparent 42% 100%);
}

.title-banner {
  position: absolute;
  top: 18px;
  left: 24px;
  z-index: 20;
  max-width: min(720px, calc(100vw - 120px));
  padding: 16px 20px 12px 20px;
  background:
    linear-gradient(125deg, rgba(39,12,15,0.84) 0 74%, rgba(241,215,120,0.16) 74% 100%);
  clip-path: polygon(0 0, 94% 0, 100% 36%, 100% 100%, 0 100%, 0 0);
  border: 2px solid rgba(241,215,120,0.35);
  box-shadow: 0 18px 42px var(--shadow);
}

.banner-kicker {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-dim);
  margin-bottom: 8px;
}

.title-banner h1 {
  margin: 0;
  font-family: var(--font-display);
  text-transform: uppercase;
  line-height: 0.96;
  font-size: clamp(1.9rem, 5vw, 4.5rem);
  letter-spacing: 0.04em;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.25);
}

.banner-subtitle {
  margin: 10px 0 0;
  max-width: 60ch;
  font-size: clamp(0.84rem, 1.2vw, 1rem);
  color: #f7e6aa;
}

.utility-strip {
  position: absolute;
  top: 20px;
  right: 22px;
  z-index: 21;
  display: flex;
  gap: 10px;
}

.utility-button,
.popup-close {
  appearance: none;
  border: 2px solid rgba(241,215,120,0.4);
  background: rgba(34, 10, 12, 0.86);
  color: var(--paper);
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0,0,0,0.22);
  transition: transform 0.15s ease, background 0.15s ease;
  clip-path: polygon(0 0, 100% 0, 100% 84%, 92% 100%, 0 100%);
}

.utility-button:hover,
.popup-close:hover {
  transform: translateY(-1px);
  background: rgba(64, 18, 22, 0.94);
}

.map-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  height: calc(100vh - 36px);
  border: 2px solid rgba(241,215,120,0.15);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.14), 0 30px 60px rgba(0,0,0,0.28);
  background:
    radial-gradient(circle at 18% 26%, rgba(241,215,120,0.08), transparent 26%),
    radial-gradient(circle at 84% 74%, rgba(66,85,61,0.16), transparent 24%),
    linear-gradient(180deg, rgba(15,4,6,0.16), rgba(15,4,6,0.32));
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.loading-panel {
  position: absolute;
  inset: auto auto 24px 24px;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(26, 8, 10, 0.84);
  border: 2px solid rgba(241,215,120,0.35);
  max-width: min(420px, calc(100% - 48px));
  box-shadow: 0 14px 30px rgba(0,0,0,0.28);
}

.loading-panel.hidden { display: none; }

.loading-mark {
  width: 18px;
  height: 18px;
  background: var(--paper);
  clip-path: polygon(50% 0, 61% 36%, 100% 36%, 69% 57%, 81% 100%, 50% 74%, 19% 100%, 31% 57%, 0 36%, 39% 36%);
  animation: pulse 1.4s linear infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.8; }
  50% { transform: scale(1.15) rotate(10deg); opacity: 1; }
}

.legend-panel,
.popup-panel {
  position: absolute;
  z-index: 19;
  background: rgba(28, 9, 11, 0.9);
  border: 2px solid rgba(241,215,120,0.34);
  box-shadow: 0 18px 36px rgba(0,0,0,0.28);
  color: #f5e5a5;
}

.legend-panel {
  right: 22px;
  bottom: 22px;
  width: min(340px, calc(100vw - 44px));
  padding: 14px;
}

.legend-panel.minimized .legend-items,
.legend-panel.minimized .legend-note {
  display: none;
}

.legend-title,
.popup-country {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.legend-items {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.legend-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 0.92rem;
}

.swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(241,215,120,0.55);
}

.legend-note {
  margin-top: 10px;
  font-size: 0.78rem;
  color: #d7c798;
}

.popup-panel {
  top: 116px;
  right: 22px;
  width: min(430px, calc(100vw - 44px));
  min-height: 150px;
  padding: 18px 18px 16px;
}

.popup-panel.hidden { display: none; }

.popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
}

.popup-country {
  font-size: 1.55rem;
  max-width: calc(100% - 54px);
  margin-bottom: 8px;
}

.popup-category {
  color: var(--paper-dim);
  margin-bottom: 10px;
  font-weight: 700;
}

.popup-description {
  line-height: 1.5;
  font-size: 0.96rem;
  color: #f9edc5;
}

.popup-quote {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(241,215,120,0.22);
  font-size: 0.8rem;
  color: #d7c798;
  font-style: italic;
}

.bottom-attribution {
  position: absolute;
  left: 22px;
  bottom: 14px;
  z-index: 18;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: rgba(241,215,120,0.86);
  max-width: min(700px, calc(100vw - 420px));
  pointer-events: none;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 2, 3, 0.72);
}

.modal-dialog {
  position: relative;
  margin: min(7vh, 56px) auto;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  padding: 24px 24px 18px;
  background: #2b0f12;
  border: 2px solid rgba(241,215,120,0.4);
  color: #f5e5a5;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

.modal-dialog h2,
.modal-dialog h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-dialog a { color: #ffd98a; }
.modal-dialog code { color: #ffd98a; }

.country {
  cursor: pointer;
  transition: filter 0.16s ease, stroke-width 0.16s ease, fill 0.16s ease;
}

.country:hover {
  filter: brightness(1.06);
}

.country.selected {
  stroke: var(--selection);
  stroke-width: 1.75px;
  filter: brightness(1.16);
}

.sphere {
  fill: rgba(28, 12, 15, 0.28);
}

.graticule {
  fill: none;
  stroke: rgba(241,215,120,0.08);
  stroke-width: 0.55px;
  stroke-dasharray: 2 5;
}

.country-boundary {
  fill: none;
  stroke: rgba(27, 16, 7, 0.55);
  stroke-width: 0.55px;
  pointer-events: none;
}

@media (max-width: 900px) {
  body { overflow: auto; }
  #app { min-height: 100vh; padding: 10px; }
  .title-banner {
    left: 10px;
    top: 10px;
    right: 10px;
    max-width: none;
    padding-right: 52px;
  }
  .utility-strip {
    top: auto;
    right: 10px;
    bottom: 10px;
    z-index: 30;
    flex-direction: column;
  }
  .map-shell {
    height: calc(100vh - 20px);
  }
  .popup-panel {
    top: auto;
    right: 10px;
    left: 10px;
    bottom: 88px;
    width: auto;
  }
  .legend-panel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
  }
  .bottom-attribution {
    left: 10px;
    right: 96px;
    max-width: none;
    bottom: 54px;
  }
}

@media (max-width: 620px) {
  .banner-subtitle { display: none; }
  .popup-country { font-size: 1.22rem; }
  .utility-button { font-size: 0.72rem; }
}
