:root {
  --map-ink: #22313d;
  --map-muted: #66717c;
  --map-primary: #315d74;
  --map-primary-dark: #163f57;
  --map-paper: #fffdf9;
  --map-sea: #dcebf0;
  --map-land: #d8d6cf;
  --map-context: #c7d9dd;
  --map-selected: #b48957;
  --map-correct: #397759;
  --map-wrong: #b9473a;
  --map-missed: #f4d993;
  --map-line: rgba(62, 74, 87, 0.16);
  --map-shadow: 0 16px 38px rgba(35, 49, 61, 0.11);
}

* { box-sizing: border-box; }

body.europe-page {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--map-ink);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 7% 0%, rgba(180, 137, 87, 0.14), transparent 26rem),
    radial-gradient(circle at 96% 4%, rgba(49, 93, 116, 0.13), transparent 28rem),
    linear-gradient(180deg, #f8f4ed 0%, #f4efe6 58%, #ebe2d4 100%);
}

button { font: inherit; }

.page-shell {
  width: min(1660px, calc(100% - 32px));
  margin: 16px auto 28px;
}

.page-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: clamp(12px, 1.7vw, 24px) 6px 18px;
}

.hero-labels {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pilot-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(49, 93, 116, 0.22);
  border-radius: 999px;
  color: var(--map-primary-dark);
  background: rgba(255, 253, 249, 0.76);
  font-size: 0.72rem;
  font-weight: 800;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--map-primary);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.095em;
  text-transform: uppercase;
}

.page-hero h1 {
  margin: 5px 0 3px;
  color: var(--map-ink);
  font: 700 clamp(2.35rem, 4vw, 4.25rem) / 0.98 "EB Garamond", Georgia, serif;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.page-hero .hero-copy > p:last-child {
  max-width: 62ch;
  margin: 0;
  color: var(--map-muted);
  font-size: clamp(0.98rem, 1.35vw, 1.16rem);
  line-height: 1.45;
}

.mode-switch {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(49, 93, 116, 0.18);
  border-radius: 14px;
  background: rgba(255, 253, 249, 0.9);
  box-shadow: 0 10px 24px rgba(48, 43, 34, 0.07);
}

.mode-button {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #4e606b;
  background: transparent;
  font-weight: 800;
  line-height: 1.15;
  text-align: left;
  cursor: pointer;
}

.mode-title { display: block; }

.mode-note {
  color: #7b898f;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.015em;
}

.mode-button-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.mode-badge {
  display: inline-flex;
  padding: 3px 6px;
  border: 1px solid rgba(49, 93, 116, 0.2);
  border-radius: 999px;
  color: var(--map-primary);
  background: rgba(49, 93, 116, 0.07);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.mode-button-warmup {
  color: #64757d;
  background: rgba(231, 236, 235, 0.5);
}

.mode-button-main {
  color: var(--map-primary-dark);
  background: rgba(49, 93, 116, 0.08);
}

.mode-button-warmup.is-active {
  border-color: rgba(79, 104, 113, 0.2);
  color: #405861;
  background: #e5ecec;
}

.mode-button-main.is-active {
  color: #fff;
  background: var(--map-primary-dark);
}

.mode-button-main.is-active .mode-badge {
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.activity-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.15fr) minmax(330px, 1fr);
  gap: 18px;
  align-items: start;
}

.map-card,
.task-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(62, 74, 87, 0.13);
  border-radius: 22px;
  background: rgba(255, 253, 249, 0.94);
  box-shadow: var(--map-shadow);
}

.map-toolbar {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 17px;
  border-bottom: 1px solid var(--map-line);
  color: #556671;
  font-size: 0.84rem;
  font-weight: 700;
}

.text-button {
  min-height: 36px;
  padding: 6px 8px;
  border: 0;
  color: var(--map-primary);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.map-stage {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 610px;
  aspect-ratio: 1.6 / 1;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 48% 45%, rgba(255, 255, 255, 0.28), transparent 56%),
    var(--map-sea);
  isolation: isolate;
}

.map-loading {
  color: #4d6672;
  font-weight: 750;
}

.map-stage svg {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 760px;
  touch-action: manipulation;
}

.map-legend {
  display: flex;
  min-height: 48px;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 9px 17px;
  border-top: 1px solid var(--map-line);
  color: #5b6971;
  font-size: 0.76rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-swatch {
  width: 24px;
  height: 16px;
  border: 2px solid #4d5b62;
  border-radius: 4px;
  background: var(--map-land);
}

.legend-swatch.context { border-color: #6f888e; background: var(--map-context); }
.legend-swatch.selected { border-width: 3px; border-color: #715632; background: var(--map-selected); }
.legend-swatch.correct { border-width: 3px; border-color: #1f553d; background: var(--map-correct); }
.legend-swatch.wrong {
  border-width: 3px;
  border-color: #7f2c27;
  background: repeating-linear-gradient(135deg, #b9473a 0 4px, #f2d3ce 4px 7px);
}
.legend-swatch.missed {
  border: 3px dashed #6e5526;
  background: var(--map-missed);
}

.task-card {
  position: sticky;
  top: 12px;
  min-height: 610px;
  padding: clamp(22px, 2.4vw, 34px);
}

.task-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--map-muted);
  font-size: 0.79rem;
  font-weight: 800;
}

.task-meta strong { color: var(--map-primary-dark); }
.panel-kicker { margin-top: clamp(28px, 4.2vh, 48px); }

.task-card h2 {
  margin: 7px 0 13px;
  color: var(--map-ink);
  font: 700 clamp(1.8rem, 2.4vw, 2.55rem) / 1.08 "EB Garamond", Georgia, serif;
  text-wrap: balance;
}

.task-help {
  margin: 0;
  color: #5c6a73;
  line-height: 1.55;
}

.answer-count {
  margin: 13px 0 0;
  color: #667680;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.task-card.is-warmup {
  background: rgba(255, 253, 249, 0.86);
  box-shadow: 0 12px 30px rgba(35, 49, 61, 0.08);
}

.task-card.is-warmup h2 {
  margin-top: 10px;
  font-size: clamp(2.55rem, 4vw, 4.25rem);
}

.selection-summary {
  margin-top: 20px;
  padding: 11px 13px;
  border: 1px solid rgba(49, 93, 116, 0.14);
  border-radius: 11px;
  color: #52636d;
  background: rgba(220, 235, 240, 0.42);
  font-size: 0.83rem;
  font-weight: 750;
}

.feedback {
  margin-top: 20px;
  padding: 15px 16px;
  border-left: 4px solid var(--map-correct);
  border-radius: 0 12px 12px 0;
  background: #e5f0e9;
  line-height: 1.5;
}

.feedback.is-wrong {
  border-color: var(--map-wrong);
  background: #f6e4e0;
}

.feedback strong { display: block; margin-bottom: 4px; }
.feedback p { margin: 0; }

.result { margin-top: 26px; }
.result-complete {
  margin: 0;
  color: #53646d;
  line-height: 1.5;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0 0;
}

.result-stats div {
  padding: 11px 10px;
  border: 1px solid rgba(49, 93, 116, 0.12);
  border-radius: 10px;
  background: rgba(220, 235, 240, 0.34);
}

.result-stats dt {
  color: #73818a;
  font-size: 0.67rem;
  font-weight: 850;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.result-stats dd {
  margin: 4px 0 0;
  color: var(--map-primary-dark);
  font-weight: 850;
}
.result-score {
  margin: 0;
  color: var(--map-primary-dark);
  font: 700 clamp(3.1rem, 5vw, 4.8rem) / 0.95 "EB Garamond", Georgia, serif;
}
.result h3 {
  margin: 9px 0 6px;
  font: 700 1.55rem / 1.15 "EB Garamond", Georgia, serif;
}
.result p:last-child { margin: 0; color: var(--map-muted); line-height: 1.5; }

.task-actions {
  display: flex;
  gap: 10px;
  margin-top: 25px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 11px;
  font-weight: 850;
  cursor: pointer;
}

.primary-button {
  order: 2;
  border: 1px solid var(--map-primary-dark);
  color: #fff;
  background: var(--map-primary-dark);
  box-shadow: 0 10px 22px rgba(22, 63, 87, 0.16);
}

.secondary-button {
  border: 1px solid rgba(49, 93, 116, 0.24);
  color: var(--map-primary-dark);
  background: #fffdf9;
}

button:disabled { opacity: 0.42; cursor: not-allowed; }
button:focus-visible {
  outline: 3px solid #d69b42;
  outline-offset: 3px;
}

.map-country:focus-visible,
.small-state-target:focus-visible {
  outline: none;
}

.map-country,
.map-country * {
  cursor: pointer;
  transition: fill 150ms ease;
}

.small-state-target {
  fill: transparent;
  stroke: transparent;
  pointer-events: all;
  cursor: pointer;
}

.map-country.is-context,
.map-country.is-context * {
  fill: var(--map-context) !important;
}

.map-country.is-selected,
.map-country.is-selected * {
  fill: var(--map-selected) !important;
}

.map-country.is-correct,
.map-country.is-correct * {
  fill: var(--map-correct) !important;
}

.map-country.is-wrong,
.map-country.is-wrong * {
  fill: var(--map-wrong) !important;
}

.map-country.is-missed,
.map-country.is-missed * {
  fill: var(--map-missed) !important;
}

@media (hover: hover) {
  .mode-button:not(.is-active):hover { background: rgba(49, 93, 116, 0.08); }
  .map-country:not(.is-selected):not(.is-correct):not(.is-wrong):not(.is-missed):hover,
  .map-country:not(.is-selected):not(.is-correct):not(.is-wrong):not(.is-missed):hover * {
    fill: #e3cda9 !important;
  }
  .primary-button:not(:disabled):hover,
  .secondary-button:not(:disabled):hover { transform: translateY(-1px); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.source-note {
  margin: 13px 5px 0;
  color: #68757d;
  font-size: 0.76rem;
}

@media (max-width: 1050px) {
  .page-shell { width: min(100% - 20px, 900px); margin-top: 10px; }
  .activity-layout { grid-template-columns: 1fr; }
  .task-card { position: static; order: -1; min-height: 0; }
  .panel-kicker { margin-top: 25px; }
  .map-stage { min-height: 0; aspect-ratio: 1.35 / 1; }
}

@media (max-width: 680px) {
  .page-shell { width: min(100% - 12px, 620px); margin-top: 6px; }
  .page-hero { display: grid; gap: 17px; padding-inline: 5px; }
  .hero-labels { align-items: flex-start; flex-direction: column; gap: 6px; }
  .page-hero h1 { font-size: clamp(2.45rem, 12vw, 3.5rem); }
  .mode-switch { width: 100%; }
  .mode-button { flex: 1; padding-inline: 8px; }
  .map-card, .task-card { border-radius: 17px; }
  .task-card { padding: 20px; }
  .task-card h2 { font-size: 1.9rem; }
  .map-toolbar { min-height: 48px; padding-inline: 12px; font-size: 0.75rem; }
  .map-stage { aspect-ratio: auto; height: min(112vw, 530px); }
  .map-legend { gap: 8px 12px; padding-inline: 12px; font-size: 0.7rem; }
  .task-actions { flex-wrap: wrap; }
  .task-actions button { flex: 1 1 42%; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
