:root {
  color-scheme: dark;
  --background: #111b18;
  --ivory: #fff6e4;
  --muted: #c4cec5;
  --gold: #ffd38b;
  --line: #c6d5c02e;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --serif: Georgia, 'Times New Roman', serif;
  font-family: var(--sans);
  color: var(--ivory);
  background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(ellipse at top, #1c2b22, transparent 75%); }
button, summary, input { font: inherit; }
button, summary { cursor: pointer; }
[hidden] { display: none !important; }
button:focus-visible, summary:focus-visible, input:focus-visible, canvas:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.experience { width: min(100%, 1480px); margin: 0 auto; padding: 0 clamp(12px, 3vw, 44px); }
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 18px; min-height: 76px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; flex: none; color: var(--gold); }
.brand-name { display: block; font: 600 1.25rem/1.08 var(--serif); letter-spacing: .16em; text-transform: uppercase; }
.brand-caption { display: block; margin-top: 4px; color: var(--muted); font-size: .72rem; }
.sound-controls { display: flex; align-items: center; position: relative; z-index: 5; }
.sound-button, .sound-settings summary, .icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  color: var(--ivory);
  background: #17241fe8;
}
.sound-button { gap: 7px; border-radius: 12px 0 0 12px; padding: 0 13px; font-size: .8rem; }
.sound-button svg, .sound-settings svg, .icon-button svg { width: 20px; height: 20px; }
.sound-settings summary { list-style: none; border-left: none; border-radius: 0 12px 12px 0; }
.sound-settings summary::-webkit-details-marker { display: none; }
.sound-button:hover, .sound-settings summary:hover, .icon-button:hover { background: #2a3e32; }
.sound-settings[open] summary { color: var(--gold); }
.sound-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 156px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #17241f;
  box-shadow: 0 10px 20px #060b0880;
}
.sound-panel label { display: flex; gap: 8px; align-items: center; min-height: 44px; font-size: .88rem; cursor: pointer; }
.sound-panel input { accent-color: #dca85a; width: 16px; height: 16px; margin: 0; }
.sound-button[aria-pressed='true'] .sound-mute, .sound-button[aria-pressed='false'] .sound-waves { display: none; }

.stage {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 440px;
  max-height: calc(100svh - 140px);
  overflow: hidden;
  border: 1px solid #bac7ad40;
  border-radius: 20px;
  background: #283f3b;
  box-shadow: 0 18px 54px #0006;
}
.cover, #river, .intro, .overlay, .search, .story-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.cover { background: #394e43 url('assets/nile/cover.webp') 45% 56% / cover no-repeat; }
.stage[data-view='intro'] .cover {
  background-image: var(--story-image, url('assets/nile/egypt.webp')), url('assets/nile/miriam.webp');
}
.stage[data-view='search'] .cover { background-image: url('assets/nile/river-background.webp'), url('assets/nile/cover.webp'); }
.stage:is([data-view='rescue'], [data-view='quiz'], [data-view='finish']) .cover {
  background-image: var(--story-image, url('assets/nile/rescue.webp')), url('assets/nile/rescue.webp');
  background-position: 42% 50%;
}
#river { display: block; z-index: 0; touch-action: none; }
.intro, .overlay, .hud, .search, .story-overlay { z-index: 1; }
#river:focus-visible { outline-offset: -4px; }
.intro {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  padding: clamp(22px, 5vw, 72px);
  background: linear-gradient(270deg, #101913ef, #10191394 29%, transparent 59%), linear-gradient(0deg, #111c17c9, transparent 60%);
}
.intro-copy { width: min(42%, 30rem); }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  color: var(--gold);
  font: 680 .72rem/1.4 var(--sans);
  letter-spacing: .18em;
  text-transform: uppercase;
}
.eyebrow span { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 1px solid #ffd38b70; border-radius: 50%; letter-spacing: .05em; }
h1, h2 { font-family: var(--serif); font-weight: 500; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(3rem, 7.4vw, 7rem); line-height: .95; letter-spacing: -.06em; }
h1 em { display: block; color: var(--gold); font-weight: 400; }
h2 { font-size: clamp(2rem, 3.8vw, 3.5rem); line-height: 1.05; letter-spacing: -.045em; }
h2[tabindex='-1']:focus { outline: none; }
.intro-copy > p:not(.eyebrow), .scene-panel > p:not(.eyebrow) { color: #eee9db; line-height: 1.55; }
.intro-copy > .story-copy { margin: 20px 0 25px; }
.primary-button, .secondary-button, .paddle-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 52px;
  border: 1px solid #ffdea6;
  border-radius: 10px;
  background: #f1bd71;
  color: #241a10;
  padding: 10px 17px;
  font-size: 1.08rem;
  font-weight: 730;
  box-shadow: 0 4px 14px #12100948;
  transition: background-color .15s ease, transform .15s ease;
}
.primary-button svg { width: 20px; height: 20px; }
.primary-button:hover { background: #ffda9d; transform: translateY(-1px); }
.primary-button:active { transform: translateY(1px); }
.secondary-button {
  border-color: #eedab164;
  background: #1d2d25;
  color: var(--ivory);
}
.secondary-button:hover { background: #33483b; }

.search { background: linear-gradient(0deg, #0a1713c9, transparent 60%); }
.search-panel {
  position: absolute;
  inset: auto auto 20px 20px;
  width: min(52%, 490px);
  padding: clamp(16px, 2vw, 25px);
  border: 1px solid #eedab164;
  border-radius: 14px;
  background: #13221bee;
  box-shadow: 0 10px 35px #08120d85;
}
.search-panel .eyebrow { margin-bottom: 8px; }
.search-panel h2 { font-size: clamp(1.75rem, 3.2vw, 3rem); }
.search-panel .story-copy { margin: 9px 0 13px; }
.hotspot {
  position: absolute;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  transform: translate(-50%, -50%);
  padding: 6px 13px 6px 6px;
  border: 1px solid #ffdd9e;
  border-radius: 999px;
  background: #16251eef;
  box-shadow: 0 0 0 4px #ffe0a431, 0 6px 17px #06130f9c;
  color: var(--ivory);
  font-size: 1.05rem;
  font-weight: 700;
}
.hotspot span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #f1bd71; color: #241a10; }
.hotspot:hover { background: #354939; }
.hotspot[data-seen] { border-color: #cbd5bf; box-shadow: 0 5px 12px #06130f80; }
.hotspot-bank { left: 26%; top: 45%; }
.hotspot-water { left: 59%; top: 63%; }
.hotspot-reeds { left: 77%; top: 43%; }
.basket-cue {
  position: absolute;
  width: clamp(80px, 12vw, 148px);
  left: 76%;
  top: 56%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 8px #13160eaa);
  animation: basket-bob 2.8s ease-in-out infinite alternate;
}
@keyframes basket-bob {
  from { transform: translate(-50%, -51%) rotate(-3deg); }
  to { transform: translate(-50%, -44%) rotate(2deg); }
}
.notice { color: var(--gold); font-size: 1rem; }

.hud { position: absolute; inset: 16px 16px auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; pointer-events: none; }
.hud-right { display: flex; align-items: center; gap: 8px; }
.progress-group, .finds, .icon-button { background: #13221bec; border: 1px solid #ebdfbc55; border-radius: 10px; }
.progress-group { width: min(36%, 220px); padding: 9px 12px 10px; font-size: .73rem; }
.progress { overflow: hidden; height: 4px; margin-top: 6px; border-radius: 8px; background: #fff6e43d; }
.progress span { display: block; width: 100%; height: 100%; background: #ffce7d; transform: scaleX(0); transform-origin: left; }
.finds { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 11px; font-size: .82rem; font-variant-numeric: tabular-nums; }
.finds svg { width: 17px; height: 17px; color: var(--gold); }
.stage[data-river-phase='rapids'] .progress-group { border-color: #ffdc9b80; }
#guard-hud { position: relative; }
.score-gain { position: absolute; top: calc(100% + 8px); right: 5px; color: var(--gold); font-size: 1.2rem; font-weight: 750; opacity: 0; text-shadow: 0 2px 4px #111b18; }
.icon-button { pointer-events: auto; }
.river-hint {
  position: absolute;
  z-index: 2;
  inset: auto auto 14px 14px;
  max-width: min(65%, 480px);
  margin: 0;
  padding: 9px 13px;
  border: 1px solid #ebdfbc70;
  border-radius: 10px;
  background: #13221bf5;
  color: var(--ivory);
  font-size: clamp(1rem, 1.7vw, 1.15rem);
  line-height: 1.35;
  pointer-events: none;
}
.paddle-button {
  position: absolute;
  z-index: 2;
  inset: auto 14px 14px auto;
  background: #f1bd71;
  color: #241a10;
  touch-action: manipulation;
}
.paddle-button:hover { background: #ffda9d; }

.overlay {
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: auto;
  background: #101d16ba;
}
.story-overlay {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: clamp(18px, 4vw, 60px);
  overflow: auto;
  background: linear-gradient(270deg, #101913ee, #10191355 48%, transparent 74%);
}
.scene-panel {
  width: min(100%, 640px);
  margin: auto;
  padding: clamp(20px, 4vw, 40px);
  background: #14241ded;
  border: 1px solid #eedab164;
  border-radius: 16px;
  box-shadow: 0 18px 45px #08120db5;
}
.rescue-panel { width: min(49%, 510px); margin: 0; }
.story-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.compact-panel { max-width: 420px; }
.scene-panel > p:not(.eyebrow) { margin: 13px 0 18px; }
.story-copy, .intro-copy > .story-copy { color: var(--ivory); font-size: clamp(1.25rem, 2vw, 1.45rem); line-height: 1.48; }
.intro-copy > .story-copy { max-width: 32ch; }
.answers { display: grid; gap: 8px; margin-top: 18px; }
.answer {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 51px;
  padding: 6px 12px;
  border: 1px solid #e7e4cf3d;
  border-radius: 9px;
  color: var(--ivory);
  background: #23372c;
  text-align: left;
  font-size: 1.12rem;
}
.answer .answer-key { flex: none; display: grid; place-items: center; width: 29px; height: 29px; border-radius: 5px; background: #101c17; color: var(--gold); font-size: .95rem; }
.answer:hover { background: #344c3d; border-color: #ebd6af86; }
.answer[data-tried] { border-color: #d4ad7a90; }
.answer[data-correct] { border-color: #b7e3ac; background: #354e3c; }
.answer:disabled { cursor: default; }
.scene-panel .quiz-feedback { margin: 11px 0 12px; min-height: 1.5em; color: var(--gold); font-size: 1.13rem; line-height: 1.42; }
.scene-panel .finish-finds { color: var(--gold); font-size: .9rem; font-weight: 650; }

.controls { display: flex; justify-content: space-between; align-items: center; gap: 8px 20px; padding: 13px 2px 16px; }
.control-item { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8rem; }
.control-item svg { flex: none; width: 18px; height: 18px; color: #f2c982; }
.control-item strong { color: var(--ivory); margin-right: 4px; font-weight: 670; }
kbd { display: inline-grid; place-items: center; min-width: 18px; height: 20px; margin-left: 3px; border: 1px solid var(--line); border-radius: 4px; padding: 0 2px; color: var(--ivory); font: .7rem var(--sans); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.no-script { position: absolute; bottom: 0; left: 18px; padding: 10px; background: var(--background); }

@media (max-width: 720px) {
  .masthead { min-height: 62px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand { gap: 9px; }
  .brand-name { font-size: 1.1rem; }
  .stage { min-height: 355px; border-radius: 14px; }
  .intro { padding: 22px; }
  .intro-copy { width: min(58%, 24rem); }
  .intro-copy h1 { font-size: clamp(2.35rem, 6.3vw, 3.5rem); }
  .rescue-panel { width: min(58%, 480px); }
}

@media (max-width: 560px) and (orientation: portrait) {
  .stage { aspect-ratio: 4 / 5; min-height: 410px; }
  .cover { background-position: 32% 50%; }
  .intro { justify-content: flex-start; background: linear-gradient(0deg, #101913fa 0%, #101913ba 42%, transparent 77%); }
  .intro-copy { width: 100%; }
  .intro-copy > .story-copy, .story-copy { font-size: 1.125rem; }
  .intro-copy h1 { font-size: clamp(2.7rem, 12vw, 4rem); }
  h1 em { display: inline; }
  .intro-copy > p:not(.eyebrow) { margin: 12px 0 17px; }
  .controls { flex-wrap: wrap; }
  .hud { inset: 10px 10px auto; }
  .progress-group { width: 43%; }
  .find-label { display: none; }
  .guard-label { font-size: .72rem; }
  .search-panel { width: auto; inset: auto 10px 10px; padding: 13px; }
  .hotspot-bank { left: 19%; top: 30%; }
  .hotspot-water { left: 49%; top: 46%; }
  .hotspot-reeds { left: 79%; top: 29%; }
  .basket-cue { left: 66%; top: 37%; }
  .story-overlay { align-items: flex-end; padding: 10px; }
  .rescue-panel { width: 100%; }
  .river-hint { inset: auto auto 9px 9px; max-width: calc(100% - 113px); }
  .paddle-button { inset: auto 9px 9px auto; padding: 8px 11px; }
}

@media (max-height: 490px) and (orientation: landscape) {
  .masthead { min-height: 54px; }
  .stage { min-height: 280px; max-height: none; height: calc(100svh - 95px); }
  .intro { padding: 16px 28px; }
  .intro-copy > p:not(.eyebrow) { margin: 10px 0 14px; }
  .intro-copy h1 { font-size: clamp(2.5rem, 7vw, 3.8rem); }
  h1 em { display: inline; }
  .overlay { padding: 12px; }
  .scene-panel { padding: 17px; }
  .eyebrow { margin-bottom: 8px; }
  .eyebrow span { width: 25px; height: 25px; }
  .answers { margin-top: 10px; gap: 5px; }
  .answer { min-height: 44px; }
  .controls { padding: 8px 1px; }
  .search-panel { inset: auto auto 12px 12px; padding: 12px; }
  .search-panel .story-copy { margin: 6px 0 8px; }
  .hotspot-bank { left: 20%; top: 30%; }
  .hotspot-water { left: 62%; top: 55%; }
  .hotspot-reeds { left: 81%; top: 42%; }
}

@media (prefers-reduced-motion: reduce) {
  .primary-button { transition: none; }
  .basket-cue { animation: none; }
}
