@font-face {
  font-family: "Fredoka";
  src: url(fredoka.woff2) format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --ocean-1: #23394a;
  --ocean-2: #16242f;
  --ink: #2a2118;
  --parchment: #f4e9d3;
  --parchment-edge: #d9c79c;
  --gold: #dba43a;
  --text-muted: #6b5f4c;
  --river: #6ba0ac;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ocean-2);
  font-family: -apple-system, "SF Pro Rounded", "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

.map-stage {
  position: relative;
  width: 100%;
  height: 100vh;
  background: radial-gradient(ellipse at 50% 42%, var(--ocean-1) 0%, var(--ocean-2) 78%);
}

#map-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#map-svg:active {
  cursor: grabbing;
}

.wave {
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 1.4;
  fill: none;
}

.land {
  stroke: var(--ink);
  transition: fill-opacity 0.2s;
}

.top-cell {
  stroke: var(--river);
  stroke-width: 3.4;
  stroke-opacity: 0.85;
}

.sub-cell {
  stroke-width: 0.9;
  stroke-opacity: 0.35;
  pointer-events: none;
}

.dot {
  fill: rgba(90, 26, 42, 0.55);
  cursor: pointer;
  transition: r 0.15s, fill 0.15s;
}

.dot:hover {
  fill: var(--gold);
  r: 3.2;
}

.label {
  font-family: "Fredoka", ui-rounded, sans-serif;
  text-anchor: middle;
  dominant-baseline: middle;
  fill: #fff8ea;
  paint-order: stroke;
  stroke: rgba(30, 24, 16, 0.55);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
  letter-spacing: 0.04em;
  text-wrap: nowrap;
}

.top-label {
  font-size: 15px;
  font-weight: 700;
  transition: opacity 0.35s;
}

#map-svg.zoomed-in .top-label {
  opacity: 0;
}

.sub-label {
  font-size: 7.5px;
  font-weight: 600;
  fill: #fffaf0;
  opacity: 0;
  transition: opacity 0.35s;
  stroke-width: 2px;
}

#map-svg.zoomed-in .sub-label {
  opacity: 0.95;
}

.chrome-plate {
  position: absolute;
  background: var(--parchment);
  border: 1px solid var(--parchment-edge);
  border-radius: 3px 10px 4px 9px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  padding: 14px 18px;
  pointer-events: none;
}

/* Full-width horizontal header instead of a boxed "bubble" plate: title,
   subtitle, and the back link sit in one row and fade over the map on a
   soft gradient scrim rather than a parchment card, so it reads as a
   natural page header instead of a floating widget. */
.title-plate {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 16px;
  row-gap: 4px;
  /* Extra right padding clears the .reset-btn pinned to the same corner. */
  padding: 20px 140px 44px 26px;
  background: linear-gradient(to bottom, rgba(12, 17, 23, 0.62) 0%, rgba(12, 17, 23, 0.22) 60%, transparent 100%);
  background-color: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  pointer-events: none;
}

.title-plate h1,
.title-plate p,
.title-plate a {
  pointer-events: auto;
}

.title-plate h1 {
  font-family: "Fredoka", ui-rounded, sans-serif;
  font-size: calc(23px * var(--headline-scale, 1));
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--parchment);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

.title-plate p {
  margin: 0;
  font-size: calc(12.5px * var(--headline-scale, 1));
  line-height: 1.5;
  color: rgba(244, 233, 211, 0.78);
  flex: 1 1 280px;
  min-width: 160px;
}

.title-plate p:last-child {
  flex: 0 0 auto;
  margin-left: auto;
}

.title-plate a {
  color: rgba(244, 233, 211, 0.9);
  font-weight: 600;
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
}

.title-plate a:hover {
  text-decoration: underline;
}

.legend-plate {
  bottom: 20px;
  right: 20px;
  text-align: right;
  pointer-events: auto;
}

.legend-plate .stats {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 4px;
  font-variant-numeric: tabular-nums;
}

.legend-plate .hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
}

.reset-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--parchment);
  border: 1px solid var(--parchment-edge);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  padding: 8px 14px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
}

.reset-btn:hover {
  background: #fff6e2;
}

.reset-btn:focus-visible,
.popup-close:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

#popup {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 24px);
  width: min(420px, calc(100% - 40px));
  background: var(--parchment);
  border: 1px solid var(--parchment-edge);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  padding: 16px 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

#popup.open {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

#popup-text {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  text-wrap: balance;
}

#popup-meta {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 16px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.popup-close:hover {
  color: var(--ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
