
:root {
  --bg: #ffffff;
  --ink: rgba(0,0,0,0.85);
  --muted: #a7a7a7;
  --muted-2: #d7d7d7;
  --boundary: #8a8a8a;
  --hover: #c8102e;
  --country-empty: #f2f2f2;
  --shadow: 0 18px 48px rgba(0,0,0,0.08);
  --border-soft: rgba(0,0,0,0.08);
  --ui-bg: rgba(255,255,255,0.96);
  --title-max: 34rem;
  --font: "Inter", "Helvetica Neue", Arial, sans-serif;
  --texture-cursive: "Pacifico", cursive;
  --texture-typewriter: "Special Elite", "Courier New", monospace;
  --texture-handwritten: "Caveat", cursive;
  --texture-bookish: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
}

body {
  min-height: 100dvh;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  background: var(--bg);
}

#mapShell {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--bg);
}

#loading {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(0,0,0,0.55);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  z-index: 30;
  pointer-events: none;
}

.title-block {
  position: absolute;
  z-index: 60;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  background: transparent;
}

.title-block h1 {
  margin: 0;
  font-weight: 500;
  line-height: 0.96;
  letter-spacing: -0.03em;
}

.title-block p {
  margin: 0.7rem 0 0;
  font-size: 1.2rem;
  line-height: 1.35;
  color: rgba(0,0,0,0.68);
  max-width: 28rem;
}

.desktop-only {
  left: 2.6rem;
  bottom: 2.6rem;
  max-width: var(--title-max);
}

.desktop-only h1 {
  font-size: clamp(2.05rem, 3.15vw, 4rem);
}

.mobile-only {
  display: none;
}

.info-btn {
  appearance: none;
  border: 1px solid rgba(0,0,0,0.14);
  background: var(--ui-bg);
  color: rgba(0,0,0,0.82);
  width: 2.05rem;
  height: 2.05rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.info-btn:hover,
.info-btn:focus-visible {
  border-color: rgba(0,0,0,0.28);
}

.country-base {
  fill: #ffffff;
  stroke: var(--boundary);
  stroke-width: 0.75px;
  vector-effect: non-scaling-stroke;
  transition: fill 150ms ease, stroke 150ms ease;
}

.country-base.no-data {
  fill: var(--country-empty);
}

.text-fill text {
  fill: var(--muted);
  user-select: none;
  pointer-events: none;
  transition: fill 120ms ease;
  dominant-baseline: hanging;
  text-rendering: geometricPrecision;
}

.text-fill text.font-cursive { font-family: var(--texture-cursive); }
.text-fill text.font-typewriter { font-family: var(--texture-typewriter); }
.text-fill text.font-handwritten { font-family: var(--texture-handwritten); }
.text-fill text.font-bookish { font-family: var(--texture-bookish); }

.country-group.hovered .text-fill text {
  fill: var(--hover);
}

.country-group.hovered .country-base {
  stroke: rgba(0,0,0,0.72);
}

.popup,
.modal {
  z-index: 90;
}

.popup {
  position: absolute;
  right: 1.15rem;
  top: 1.15rem;
  width: min(28rem, calc(100vw - 2.3rem));
  max-height: calc(100dvh - 2.3rem);
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-radius: 1rem;
}

.popup.hidden,
.modal.hidden,
.backdrop.hidden,
.orientation-guard.hidden {
  display: none;
}

.popup-close {
  position: absolute;
  top: 0.75rem;
  right: 0.8rem;
  width: 2rem;
  height: 2rem;
  border: 0;
  background: transparent;
  color: rgba(0,0,0,0.45);
  font-size: 1.7rem;
  cursor: pointer;
}

#popupContent,
.modal-card {
  padding: 1.25rem 1.35rem 1.25rem;
}

#popupContent {
  max-height: calc(100dvh - 2.3rem);
  overflow: auto;
  padding-right: 1.75rem;
}

#popupContent h2 {
  margin: 0 1.5rem 0.35rem 0;
  font-size: 1.55rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 500;
}

.popup-meta {
  font-size: 0.93rem;
  line-height: 1.5;
  color: rgba(0,0,0,0.72);
  margin-bottom: 1rem;
}

.popup-summary {
  font-size: 0.98rem;
  line-height: 1.58;
  margin: 0.95rem 0 0;
}

.popup-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 1rem 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(0,0,0,0.42);
}

.popup-section ul {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}

.popup-section li {
  margin: 0.25rem 0;
  line-height: 1.45;
}

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.001);
  z-index: 80;
}

.modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(255,255,255,0.42);
}

.modal-card {
  position: relative;
  width: min(36rem, calc(100vw - 2rem));
  max-height: min(42rem, calc(100dvh - 2rem));
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow);
  border-radius: 1rem;
}

.modal-card h2 {
  margin: 0 1.5rem 0.75rem 0;
  font-size: 1.45rem;
  font-weight: 500;
}

.modal-section + .modal-section {
  margin-top: 1.15rem;
}

.modal-section h3 {
  margin: 0 0 0.35rem;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(0,0,0,0.42);
}

.modal-section ul {
  margin: 0;
  padding-left: 1.05rem;
}

.modal-section li,
.modal-section p {
  line-height: 1.55;
}

.credits p {
  margin: 0.35rem 0;
}

.orientation-guard {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.96);
  z-index: 120;
}

.orientation-card {
  padding: 1.5rem 1.35rem;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 20rem;
}

.orientation-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
}

.orientation-card p {
  margin: 0;
  line-height: 1.45;
  color: rgba(0,0,0,0.7);
}

@media (max-width: 820px) {
  .desktop-only {
    display: none;
  }

  .mobile-only {
    position: absolute;
    display: flex;
    inset: 0 auto auto 0;
    width: 100%;
    justify-content: space-between;
    align-items: flex-start;
    padding: max(env(safe-area-inset-top), 0.6rem) 0.8rem 0.6rem;
    background: rgba(255,255,255,0.94);
    border-bottom: 1px solid rgba(0,0,0,0.07);
  }

  .mobile-only h1 {
    font-size: 1.2rem;
    letter-spacing: -0.02em;
  }

  .mobile-only p {
    margin-top: 0.22rem;
    font-size: 0.8rem;
    max-width: none;
  }

  #mapShell {
    top: 3.55rem;
    height: calc(100% - 3.55rem);
  }

  .popup {
    left: 0.75rem;
    right: 0.75rem;
    top: auto;
    bottom: 0.75rem;
    width: auto;
    max-height: min(58dvh, 28rem);
  }
}

@media (max-width: 820px) and (orientation: portrait) {
  .orientation-guard {
    display: grid;
  }
}

@media (min-width: 821px) {
  .orientation-guard {
    display: none !important;
  }
}
