:root {
  color-scheme: light;
  --navy: #102f43;
  --ink: #173e4d;
  --teal: #087f82;
  --teal-dark: #07585f;
  --sky: #bfe7dc;
  --paper: #fff9e9;
  --coral: #ef6b4f;
  --gold: #f2bb3f;
  --west: #ef805f;
  --midwest: #e4af37;
  --south: #3ca68d;
  --northeast: #4b89b7;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 1100px; height: 100%; margin: 0; }
body {
  overflow: hidden;
  color: var(--ink);
  background: #0c4550 url("./art/quest-backdrop-01.webp") center / cover no-repeat;
  font-family: ui-rounded, "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
}
body::before { content: ""; position: fixed; inset: 0; background: rgba(9, 48, 58, .26); pointer-events: none; }
button { font: inherit; }

.quest {
  position: relative;
  display: grid;
  grid-template-columns: minmax(760px, 1fr) 268px;
  gap: 22px;
  width: min(1320px, calc(100vw - 64px));
  height: calc(100vh - 44px);
  margin: 22px auto;
}

.mission-panel, .sash {
  border: 1px solid rgba(255,255,255,.42);
  background: rgba(255, 249, 233, .95);
  box-shadow: 0 24px 70px rgba(7, 39, 48, .3);
  backdrop-filter: blur(10px);
}
.mission-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto 22px 54px;
  min-height: 0;
  overflow: hidden;
  padding: 22px 32px 22px;
  border-radius: 30px;
}
.mission-copy { max-width: 700px; padding-left: 8px; }
.kicker { margin: 0 0 5px; color: var(--teal); font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; color: var(--navy); font-size: clamp(29px, 3vw, 44px); line-height: 1.02; letter-spacing: -.045em; }
#missionPrompt { margin: 7px 0 0; color: #55727a; font-size: 16px; font-weight: 650; }

.map-stage {
  position: relative;
  min-height: 0;
  margin: 8px 0 0;
  overflow: hidden;
  border: 2px solid rgba(15, 72, 77, .16);
  border-radius: 26px;
  background: rgba(205, 235, 224, .78);
  box-shadow: inset 0 0 60px rgba(20, 111, 105, .08);
}
.map-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 50% 40%, transparent 45%, rgba(16,47,67,.08)); }
.map-glow { position: absolute; inset: 0; opacity: .22; background-image: linear-gradient(rgba(255,255,255,.25) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.25) 1px, transparent 1px); background-size: 44px 44px; }
.state-map { position: absolute; inset: 1% 2% 2%; width: 96%; height: 96%; overflow: visible; filter: drop-shadow(0 8px 0 rgba(16,47,67,.1)); }
.state {
  stroke: #fff8e9;
  stroke-width: 2.2;
  stroke-linejoin: round;
  cursor: crosshair;
  transition: filter 140ms ease-out, opacity 140ms ease-out, transform 140ms ease-out, fill 140ms ease-out;
  transform-box: fill-box;
  transform-origin: center;
}
.state[data-region="West"] { fill: var(--west); }
.state[data-region="Midwest"] { fill: var(--midwest); }
.state[data-region="South"] { fill: var(--south); }
.state[data-region="Northeast"] { fill: var(--northeast); }
.state:hover, .state.is-hovered { filter: brightness(1.14) drop-shadow(0 4px 3px rgba(16,47,67,.28)); transform: translateY(-3px) scale(1.018); }
.state.is-dim { opacity: .3; }
.state.is-target-region { filter: saturate(1.22) brightness(1.06); }
.state.is-correct { fill: #fff0a1; filter: drop-shadow(0 0 12px var(--gold)); animation: state-pop 480ms cubic-bezier(.2,.9,.25,1); }
.state.is-wrong { animation: state-shake 260ms ease-out; }
.state:focus-visible { outline: none; filter: drop-shadow(0 0 7px #102f43); }
.state-label { fill: rgba(16,47,67,.8); font-size: 10px; font-weight: 950; text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: rgba(255,249,233,.72); stroke-width: 2px; }
.label-layer.is-hidden { display: none; }
.flight-path { fill: none; stroke: var(--gold); stroke-width: 8; stroke-linecap: round; stroke-dasharray: 16 20; opacity: 0; }
.map-stage.is-celebrating .flight-path { opacity: 1; animation: route-draw 900ms ease-out both; }

.map-pin {
  position: absolute;
  z-index: 5;
  left: 18px;
  bottom: 16px;
  width: 82px;
  height: 82px;
  object-fit: contain;
  cursor: grab;
  filter: drop-shadow(0 9px 7px rgba(16,47,67,.3));
  transition: transform 140ms ease-out, left 260ms cubic-bezier(.2,.9,.25,1), top 260ms cubic-bezier(.2,.9,.25,1);
}
.map-pin:hover { transform: translateY(-5px) rotate(-4deg); }
.map-pin:active, .map-pin.is-dragging { cursor: grabbing; transform: scale(.94) rotate(5deg); }
.map-pin.is-snapped { animation: pin-snap 470ms cubic-bezier(.2,.9,.25,1); }
.map-pin.is-rebounding { animation: pin-rebound 330ms ease-out; }
.region-flag { position: absolute; z-index: 3; top: 14px; right: 14px; padding: 7px 12px; border-radius: 999px; color: white; background: rgba(16,47,67,.82); font-size: 12px; font-weight: 900; opacity: 0; transform: translateY(-5px); transition: 140ms ease-out; }
.region-flag.is-visible { opacity: 1; transform: none; }
.timer { position: absolute; z-index: 4; left: 50%; bottom: 14px; width: 170px; height: 8px; overflow: hidden; border-radius: 8px; background: rgba(16,47,67,.18); transform: translateX(-50%); }
.timer i { display: block; width: 100%; height: 100%; border-radius: inherit; background: var(--gold); transform-origin: left; }

.answer-tray { display: flex; justify-content: center; gap: 12px; min-height: 58px; padding-top: 8px; }
.answer-choice {
  min-width: 150px;
  min-height: 50px;
  padding: 10px 18px;
  border: 2px solid #c8d9d2;
  border-radius: 16px;
  color: var(--navy);
  background: white;
  box-shadow: 0 5px 0 #c8d9d2;
  font-weight: 900;
  cursor: pointer;
  transition: transform 130ms ease-out, box-shadow 130ms ease-out, border-color 130ms ease-out;
}
.answer-choice:hover { border-color: var(--teal); transform: translateY(-3px); box-shadow: 0 8px 0 #9bbeb4; }
.answer-choice:active { transform: translateY(3px); box-shadow: 0 2px 0 #9bbeb4; }
.answer-choice:focus-visible, .continue:focus-visible, .state:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
.feedback { min-height: 22px; margin: 3px 0 0; color: #b34635; text-align: center; font-size: 14px; font-weight: 850; }
.continue { align-self: end; justify-self: center; min-width: 230px; min-height: 50px; border: 0; border-radius: 16px; color: white; background: var(--teal); box-shadow: 0 6px 0 var(--teal-dark); font-size: 16px; font-weight: 950; cursor: pointer; }
.continue:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--teal-dark); }

.passport-card {
  position: absolute;
  z-index: 9;
  right: 44px;
  bottom: 88px;
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 16px;
  width: 410px;
  padding: 18px;
  border: 3px solid var(--gold);
  border-radius: 22px 22px 7px 22px;
  background: #fff7d6;
  box-shadow: 0 20px 48px rgba(38, 57, 53, .28);
  transform: rotate(1deg);
  animation: card-open 430ms cubic-bezier(.2,.9,.25,1);
}
.state-shape { width: 112px; height: 112px; overflow: visible; }
.state-shape path { fill: var(--coral); stroke: var(--navy); stroke-width: 1.8; vector-effect: non-scaling-stroke; }
.passport-card span { color: var(--teal-dark); font-size: 11px; font-weight: 950; letter-spacing: .1em; text-transform: uppercase; }
.passport-card h2 { margin: 3px 0 6px; color: var(--navy); font-size: 28px; letter-spacing: -.03em; }
.capital-line { margin: 0 0 7px; color: #5c664f; font-size: 13px; }
.capital-line strong { color: var(--navy); font-size: 18px; }
.fact { margin: 0; color: #5c664f; font-size: 13px; line-height: 1.35; }

.sash { display: flex; flex-direction: column; min-height: 0; padding: 16px 20px 22px; overflow: hidden; border-radius: 30px; }
.mascot-wrap { position: relative; height: 190px; margin: -6px -8px 8px; }
.mascot { position: absolute; left: 50%; bottom: 0; width: 190px; height: 190px; object-fit: contain; transform: translateX(-50%); transform-origin: bottom center; transition: 180ms ease-out; filter: drop-shadow(0 10px 8px rgba(16,47,67,.18)); }
.mascot.is-happy { animation: eagle-hop 540ms cubic-bezier(.2,.9,.25,1); }
.mascot.is-miss { animation: eagle-tilt 360ms ease-out; }
.mascot.is-level-up { animation: eagle-fly 900ms cubic-bezier(.2,.8,.2,1); }
.mascot-bubble { position: absolute; z-index: 3; right: -2px; top: 6px; max-width: 128px; padding: 8px 10px; border: 2px solid #d9c67b; border-radius: 14px 14px 3px 14px; color: var(--navy); background: #fff7d6; font-size: 11px; font-weight: 900; line-height: 1.25; transform: rotate(2deg); }
.mode-block { padding: 13px 4px 17px; border-top: 1px solid #d9e1d8; border-bottom: 1px solid #d9e1d8; }
.mode-block span, .stats span, .difficulty-block span, .badge-title span { display: block; color: #70817f; font-size: 10px; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
.mode-block strong { display: block; margin-top: 4px; color: var(--navy); font-size: 21px; line-height: 1.08; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 14px 0; }
.stats div { padding: 11px 13px; border-radius: 14px; background: #e7f1e9; }
.stats strong { display: block; color: var(--navy); font-size: 25px; }
.difficulty-block { padding: 2px 2px 12px; }
.difficulty-block > div:first-child, .badge-title { display: flex; align-items: end; justify-content: space-between; }
.difficulty-block b { color: var(--navy); font-size: 18px; }
.difficulty-track { height: 8px; margin: 7px 0 5px; overflow: hidden; border-radius: 8px; background: #dce7df; }
.difficulty-track i { display: block; width: 20%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--coral)); transition: width 280ms ease-out; }
.difficulty-block p, .scout-tip { margin: 0; color: #70817f; font-size: 11px; line-height: 1.35; }
.badge-title { margin-top: 3px; }
.badge-title b { color: var(--navy); font-size: 12px; }
.badge-rail { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; min-height: 88px; margin-top: 8px; align-content: start; }
.badge { width: 40px; height: 40px; object-fit: contain; filter: drop-shadow(0 3px 2px rgba(16,47,67,.22)); animation: badge-stamp 380ms cubic-bezier(.2,.9,.25,1); }
.badge.is-ghost { opacity: .14; filter: grayscale(1); }
.scout-tip { margin-top: auto; padding: 11px 12px; border-radius: 14px; background: #edf3e9; }
.toast { position: fixed; left: 50%; bottom: 20px; z-index: 20; padding: 11px 18px; border-radius: 999px; color: white; background: var(--navy); font-weight: 850; opacity: 0; transform: translate(-50%, 15px); transition: 170ms ease-out; pointer-events: none; }
.toast.is-showing { opacity: 1; transform: translate(-50%, 0); }

@keyframes state-pop { 50% { transform: translateY(-5px) scale(1.05); } }
@keyframes state-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes pin-snap { 0% { transform: scale(.75) rotate(-12deg); } 55% { transform: scale(1.18) rotate(4deg); } 100% { transform: none; } }
@keyframes pin-rebound { 35% { transform: translateY(-16px) rotate(-8deg); } 70% { transform: translateY(5px) rotate(5deg); } }
@keyframes card-open { from { opacity: 0; transform: translateY(30px) scale(.76) rotate(-4deg); } to { opacity: 1; transform: rotate(1deg); } }
@keyframes eagle-hop { 45% { transform: translateX(-50%) translateY(-16px) rotate(-4deg) scale(1.04); } }
@keyframes eagle-tilt { 40% { transform: translateX(-50%) rotate(-8deg) scale(.96); } }
@keyframes eagle-fly { 40% { transform: translateX(80px) translateY(-40px) rotate(9deg) scale(.9); } 75% { transform: translateX(-100px) translateY(-28px) rotate(-9deg) scale(.94); } }
@keyframes badge-stamp { from { opacity: 0; transform: scale(2.2) rotate(-25deg); } to { opacity: 1; transform: none; } }
@keyframes route-draw { from { stroke-dashoffset: 400; } to { stroke-dashoffset: 0; } }

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