:root {
  --navy: #102a43;
  --navy-2: #183b56;
  --blue: #176b87;
  --aqua: #1aa6a6;
  --mint: #e4f5f0;
  --cream: #f7f4ed;
  --paper: #fffdfa;
  --amber: #f4b942;
  --amber-dark: #b97700;
  --green: #16805d;
  --red: #c84a42;
  --ink: #172b3a;
  --muted: #657582;
  --line: #dce3e5;
  --shadow: 0 18px 50px rgba(19, 48, 65, .13);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 5%, rgba(26, 166, 166, .08), transparent 28rem),
    linear-gradient(180deg, #fbfaf6, #f2f5f3);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

button, a { font: inherit; }
button { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  transform: translateY(-150%);
  background: #fff;
  padding: .7rem 1rem;
  border-radius: 8px;
  color: var(--navy);
}
.skip-link:focus { transform: none; }

.site-header {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 68px);
  border-bottom: 1px solid rgba(16, 42, 67, .1);
  background: rgba(255, 253, 250, .88);
  backdrop-filter: blur(14px);
  position: relative;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--navy);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: var(--navy);
  color: #fff;
  border-radius: 12px 12px 12px 3px;
  font-size: 1.3rem;
  box-shadow: 0 8px 18px rgba(16, 42, 67, .2);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; letter-spacing: .02em; }
.brand small { color: var(--muted); font-size: .72rem; margin-top: 1px; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.icon-button, .reset-button, .secondary-button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.75);
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--navy);
  font-weight: 800;
}

.reset-button {
  padding: .58rem .85rem;
  border-radius: 9px;
  color: var(--muted);
  font-size: .8rem;
}

.icon-button:hover, .reset-button:hover, .secondary-button:hover { border-color: var(--aqua); color: var(--blue); }

main { width: min(1450px, calc(100% - 40px)); margin: 0 auto; }

.hero {
  min-height: calc(100vh - 82px);
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(420px, 1.1fr);
  align-items: center;
  gap: clamp(38px, 7vw, 110px);
  padding: 60px clamp(0px, 3vw, 42px) 80px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--blue);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.hero h1, .game-topbar h1, .results-card h1 {
  margin: 0;
  color: var(--navy);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  line-height: .98;
}

.hero h1 { font-size: clamp(3.2rem, 6vw, 6.5rem); letter-spacing: -.045em; }
.hero h1 em { color: var(--aqua); font-weight: 500; }

.hero-intro {
  max-width: 590px;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.2rem);
  line-height: 1.7;
  margin: 28px 0 30px;
}

.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin: 0 0 34px;
}

.feature-row > div { display: flex; align-items: center; gap: 9px; }
.feature-row > div > span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--mint);
  color: var(--green);
  font-weight: 900;
}
.feature-row p, .feature-row strong, .feature-row small { margin: 0; display: block; }
.feature-row strong { font-size: .8rem; color: var(--navy); }
.feature-row small { margin-top: 2px; font-size: .7rem; color: var(--muted); }

.primary-button {
  border: 0;
  min-height: 52px;
  padding: 0 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  border-radius: 11px;
  color: white;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  box-shadow: 0 12px 25px rgba(16, 42, 67, .22);
  cursor: pointer;
  font-weight: 800;
  transition: transform .18s ease, box-shadow .18s ease;
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 15px 30px rgba(16, 42, 67, .28); }
.primary-button:active { transform: translateY(0); }

.saved-note { margin: 13px 0 0; color: var(--green); font-size: .78rem; }

.hero-visual { position: relative; min-height: min(560px, 60vw); }
.preview-card {
  position: absolute;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.preview-back {
  inset: 8% 7% 10% 3%;
  background: var(--aqua);
  transform: rotate(-5deg);
  opacity: .22;
}
.preview-main { inset: 6% 0 8% 5%; background: white; transform: rotate(2deg); }
.preview-main img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-main::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(9, 28, 43, .48));
}
.preview-label { position: absolute; z-index: 2; left: 24px; bottom: 22px; color: white; }
.preview-label strong, .preview-label span { display: block; }
.preview-label strong { font-family: Georgia, serif; font-size: 1.45rem; }
.preview-label span { font-size: .75rem; margin-top: 3px; opacity: .8; }
.preview-target {
  position: absolute;
  z-index: 3;
  width: 32px;
  height: 32px;
  border: 3px solid white;
  border-radius: 50%;
  background: rgba(244, 185, 66, .85);
  box-shadow: 0 0 0 8px rgba(244, 185, 66, .22);
  animation: targetPulse 2s infinite;
}
.target-one { left: 45%; top: 29%; }
.target-two { right: 18%; bottom: 29%; animation-delay: .8s; }

.game-view { padding: 34px 0 70px; }
.game-topbar { display: flex; justify-content: space-between; align-items: end; margin-bottom: 22px; }
.game-topbar h1 { font-size: clamp(2rem, 3.5vw, 3.3rem); }
.score-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 135px;
  padding: 10px 16px;
  border: 1px solid #e7d9b6;
  border-radius: 14px;
  background: #fffbef;
  color: var(--amber-dark);
}
.score-card > span { font-size: 1.3rem; }
.score-card small, .score-card strong { display: block; }
.score-card small { color: var(--muted); font-size: .65rem; text-transform: uppercase; letter-spacing: .1em; }
.score-card strong { color: var(--navy); font-size: 1.25rem; font-variant-numeric: tabular-nums; }

.progress-wrap { margin-bottom: 22px; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: .72rem; color: var(--muted); }
.progress-copy strong { color: var(--navy); }
.progress-track { height: 7px; overflow: hidden; background: #dfe7e5; border-radius: 999px; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--aqua), #60c6ae); border-radius: inherit; transition: width .5s ease; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 22px; align-items: start; }
.picture-panel, .mission-card, .found-card {
  background: var(--paper);
  border: 1px solid rgba(16, 42, 67, .1);
  border-radius: var(--radius);
  box-shadow: 0 12px 35px rgba(25, 56, 70, .08);
}
.picture-panel { overflow: hidden; }
.picture-header { height: 48px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; font-size: .76rem; color: var(--muted); }
.picture-header p { margin: 0; }
.picture-header strong { color: var(--green); }
.pulse-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; background: var(--aqua); border-radius: 50%; box-shadow: 0 0 0 5px rgba(26, 166, 166, .13); }

.image-stage {
  position: relative;
  overflow: hidden;
  background: #d8dfdf;
  cursor: crosshair;
  user-select: none;
  touch-action: manipulation;
  aspect-ratio: 16 / 9;
}
.image-stage > img { display: block; width: 100%; height: 100%; object-fit: contain; }
.image-stage.is-complete { cursor: default; }
.image-stage.is-waiting { cursor: wait; }
.wait-progress {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: 16px;
  width: min(360px, calc(100% - 32px));
  transform: translateX(-50%);
  padding: 9px 12px 11px;
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 11px;
  color: white;
  background: rgba(16,42,67,.92);
  box-shadow: 0 8px 24px rgba(0,0,0,.24);
  pointer-events: none;
}
.wait-progress > span { display: block; margin-bottom: 6px; font-size: .68rem; font-weight: 800; text-align: center; }
.wait-progress > div { height: 6px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.22); }
.wait-progress i { display: block; width: 100%; height: 100%; transform-origin: left; border-radius: inherit; background: linear-gradient(90deg, var(--amber), #ffe19a); }
.wait-progress i.running { animation: waitCountdown var(--countdown-duration, 1s) linear forwards; }
.marker-layer { position: absolute; inset: 0; pointer-events: none; }
.marker {
  position: absolute;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%) scale(0);
  border-radius: 50%;
  color: white;
  background: var(--green);
  border: 3px solid white;
  box-shadow: 0 0 0 5px rgba(22, 128, 93, .28), 0 4px 12px rgba(0, 0, 0, .2);
  font-size: .85rem;
  font-weight: 900;
  animation: markerIn .35s cubic-bezier(.2, .9, .3, 1.35) forwards;
}
.miss-marker {
  position: absolute;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(200, 74, 66, .88);
  border-radius: 50%;
  animation: missOut .8s ease forwards;
}
.hint-ring {
  position: absolute;
  display: none;
  width: 100px;
  height: 100px;
  transform: translate(-50%, -50%);
  border: 4px dashed white;
  border-radius: 50%;
  background: rgba(244, 185, 66, .22);
  box-shadow: 0 0 0 10px rgba(244, 185, 66, .16);
  pointer-events: none;
  animation: hintPulse 1.1s ease-in-out infinite;
}
.hint-ring.show { display: block; }

.feedback {
  min-height: 68px;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #fbfcfa;
  transition: background .2s;
}
.feedback-icon { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; margin: 0; border-radius: 50%; background: #e6efee; color: var(--blue); font-size: 1rem; font-weight: 900; line-height: 1; text-align: center; }
.feedback p, .feedback p strong, .feedback p span { margin: 0; display: block; }
.feedback p strong { font-size: .82rem; color: var(--navy); }
.feedback p span { margin-top: 2px; font-size: .72rem; color: var(--muted); line-height: 1.35; }
.feedback.correct { background: #edf8f3; }
.feedback.correct .feedback-icon { background: var(--green); color: white; }
.feedback.wrong { background: #fff5f1; }
.feedback.wrong .feedback-icon { background: var(--red); color: white; }

.side-panel { display: grid; gap: 14px; }
.mission-card { padding: 21px; position: relative; overflow: hidden; }
.mission-number { position: absolute; right: 14px; top: 8px; font-family: Georgia, serif; font-size: 3.6rem; color: rgba(26, 166, 166, .1); }
.mission-card h2 { margin: 0 0 10px; color: var(--navy); font-family: Georgia, serif; font-size: 1.4rem; font-weight: 500; }
.mission-card > p:last-child { margin: 0; color: var(--muted); font-size: .76rem; line-height: 1.55; }
.found-card {
  padding: 23px;
  min-height: 280px;
  border: 2px solid rgba(26, 166, 166, .28);
  background: linear-gradient(145deg, #fffdfa, #f2faf7);
  box-shadow: 0 16px 38px rgba(22, 128, 93, .12);
}
.found-card > .eyebrow { margin-bottom: 7px; }
.card-heading { display: flex; align-items: center; justify-content: space-between; }
.card-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 1.45rem; font-weight: 500; color: var(--navy); }
.card-heading span { padding: 5px 10px; background: var(--green); color: white; border-radius: 999px; font-size: .75rem; font-weight: 850; }
.found-list { margin: 17px 0 0; padding: 0; list-style: none; display: grid; gap: 9px; counter-reset: found; }
.found-list li { counter-increment: found; display: flex; gap: 10px; align-items: center; padding: 11px 12px; border: 1px solid rgba(22, 128, 93, .12); border-radius: 11px; background: #e8f7f1; color: #185b45; font-size: .78rem; font-weight: 700; line-height: 1.35; animation: listIn .3s ease both; }
.found-list li::before { content: "✓"; display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 24px; border-radius: 50%; background: var(--green); color: white; font-size: .72rem; font-weight: 900; box-shadow: 0 3px 8px rgba(22, 128, 93, .25); }
.empty-found { color: var(--muted); font-size: .78rem; font-weight: 500; line-height: 1.55; padding: 18px 4px; background: transparent !important; border: 0 !important; }
.empty-found::before { display: none !important; }

.hint-button {
  width: 100%;
  display: flex;
  gap: 11px;
  align-items: center;
  border: 1px solid #e5d6aa;
  background: #fffaf0;
  border-radius: 13px;
  padding: 12px 15px;
  color: var(--amber-dark);
  text-align: left;
  cursor: pointer;
}
.hint-button > span:first-child { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #f8e9ba; font-weight: 900; }
.hint-button strong, .hint-button small { display: block; }
.hint-button strong { font-size: .76rem; }
.hint-button small { margin-top: 2px; color: var(--muted); font-size: .65rem; }
.hint-button:disabled { opacity: .48; cursor: not-allowed; filter: grayscale(.4); }

.results-view { min-height: calc(100vh - 82px); display: grid; place-items: center; padding: 50px 0; }
.results-card { width: min(680px, 100%); padding: clamp(28px, 5vw, 55px); text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); }
.trophy { margin: 0 auto 18px; width: 70px; height: 70px; display: grid; place-items: center; border-radius: 50%; background: #fff2c9; color: var(--amber-dark); font-size: 2rem; box-shadow: 0 0 0 10px #fffaeb; }
.results-card h1 { font-size: clamp(2.8rem, 6vw, 4.8rem); }
.results-card > p:not(.eyebrow):not(.mastery-note) { color: var(--muted); }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 30px 0 20px; }
.result-stats div { padding: 17px 8px; border: 1px solid var(--line); border-radius: 13px; background: #fafbf8; }
.result-stats small, .result-stats strong { display: block; }
.result-stats small { color: var(--muted); font-size: .68rem; }
.result-stats strong { margin-top: 4px; color: var(--navy); font-size: 1.5rem; }
.mastery-note { padding: 12px 16px; border-radius: 10px; background: var(--mint); color: var(--green); font-size: .78rem; line-height: 1.45; }
.result-actions { margin-top: 24px; display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.secondary-button { min-height: 52px; border-radius: 11px; padding: 0 20px; font-weight: 750; }

dialog { width: min(520px, calc(100% - 32px)); border: 0; padding: 0; border-radius: 22px; color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(12, 31, 44, .65); backdrop-filter: blur(4px); }
dialog form { padding: 30px; position: relative; }
dialog h2 { margin: 0 0 22px; color: var(--navy); font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.dialog-close { position: absolute; right: 18px; top: 14px; border: 0; background: none; color: var(--muted); font-size: 1.7rem; cursor: pointer; }
dialog ol { padding: 0; margin: 0 0 24px; list-style: none; display: grid; gap: 15px; }
dialog li { display: flex; gap: 12px; }
dialog li > span { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--mint); color: var(--green); font-size: .72rem; font-weight: 900; }
dialog li p, dialog li strong { display: block; margin: 0; }
dialog li p { color: var(--muted); font-size: .78rem; line-height: 1.45; }
dialog li strong { color: var(--navy); font-size: .85rem; }
.dialog-action { width: 100%; }

.toast { position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translate(-50%, 120px); padding: 11px 18px; border-radius: 10px; color: white; background: var(--navy); box-shadow: var(--shadow); font-size: .78rem; opacity: 0; transition: .3s ease; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.discovery-popover {
  position: fixed;
  z-index: 85;
  left: 0;
  top: 0;
  width: min(440px, calc(100vw - 32px));
  padding: 22px 26px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 2px solid rgba(255, 255, 255, .7);
  border-radius: 18px;
  color: white;
  background: linear-gradient(135deg, #123a4c, #176b67);
  box-shadow: 0 22px 60px rgba(8, 34, 45, .38);
  pointer-events: none;
  will-change: left, top, transform, opacity;
  overflow: hidden;
}
.discovery-popover > .discovery-check {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--navy);
  background: var(--amber);
  box-shadow: 0 0 0 7px rgba(244, 185, 66, .16);
  font-size: 1.35rem;
  font-weight: 950;
}
.discovery-popover p, .discovery-popover strong, .discovery-popover small { display: block; margin: 0; }
.discovery-popover small { margin-bottom: 4px; color: #bfece3; font-size: .67rem; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.discovery-popover strong { font-family: Georgia, serif; font-size: clamp(1.15rem, 2vw, 1.55rem); font-weight: 500; line-height: 1.15; }
.discovery-countdown { position: absolute; inset: auto 0 0; height: 7px; background: rgba(255,255,255,.18); }
.discovery-countdown i { display: block; width: 100%; height: 100%; transform-origin: left; background: linear-gradient(90deg, var(--amber), #ffe19a); }
.discovery-countdown i.running { animation: waitCountdown var(--countdown-duration, 1s) linear forwards; }

.found-card.receive-discovery {
  animation: receiveDiscovery .45s ease;
}

[hidden] { display: none !important; }

@keyframes targetPulse { 50% { box-shadow: 0 0 0 14px rgba(244, 185, 66, .08); } }
@keyframes markerIn { to { transform: translate(-50%, -50%) scale(1); } }
@keyframes missOut { 0% { opacity: 1; scale: .5; } 60% { opacity: 1; scale: 1.4; } 100% { opacity: 0; scale: 1.7; } }
@keyframes hintPulse { 50% { scale: 1.12; background: rgba(244, 185, 66, .35); } }
@keyframes listIn { from { opacity: 0; transform: translateY(5px); } }
@keyframes receiveDiscovery {
  50% { border-color: var(--green); box-shadow: 0 0 0 8px rgba(22, 128, 93, .12), 0 16px 38px rgba(22, 128, 93, .18); transform: scale(1.015); }
}
@keyframes waitCountdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; padding-top: 55px; }
  .hero-copy { text-align: center; }
  .hero-intro { margin-left: auto; margin-right: auto; }
  .feature-row { justify-content: center; }
  .hero-visual { min-height: 480px; width: min(720px, 100%); margin: 0 auto; }
  .game-layout { grid-template-columns: 1fr; }
  .side-panel { grid-template-columns: 1fr 1fr; }
  .hint-button { grid-column: 1 / -1; }
}

@media (max-width: 650px) {
  .site-header { height: 70px; padding: 0 16px; }
  .reset-button { display: none; }
  main { width: min(100% - 20px, 1450px); }
  .hero { min-height: calc(100vh - 70px); padding: 42px 0; }
  .hero h1 { font-size: clamp(2.85rem, 15vw, 4.4rem); }
  .hero-visual { min-height: 330px; }
  .preview-label { left: 15px; bottom: 13px; }
  .feature-row { gap: 12px; }
  .feature-row > div { width: calc(50% - 8px); text-align: left; }
  .game-view { padding-top: 22px; }
  .game-topbar { align-items: center; }
  .game-topbar h1 { font-size: 1.75rem; }
  .score-card { min-width: 105px; padding: 8px 10px; }
  .picture-header { padding: 0 10px; font-size: .68rem; }
  .feedback { min-height: 74px; padding: 10px 12px; }
  .side-panel { grid-template-columns: 1fr; }
  .hint-button { grid-column: auto; }
  .result-stats { grid-template-columns: 1fr; }
  .result-stats div { padding: 11px; }
  .result-stats small, .result-stats strong { display: inline; }
  .result-stats strong { margin-left: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
  .wait-progress i.running, .discovery-countdown i.running { animation-duration: var(--countdown-duration, 1s) !important; }
}
