.immersive {
  --scene-x: 0px;
  --scene-y: 0px;
  --cream: #fffaf0;
  --ink-forest: #192d28;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  background: #122821;
}
.full-world {
  position: fixed;
  z-index: -2;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: #132c23;
}
.world-image, .scene-shade, .sunbeams, .rolling-mist, .world-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.world-image { width: 100%; height: 100%; object-fit: cover; object-position: var(--view, 55%) center; }
[data-scene="trail"] { --view: 51%; }
[data-scene="river"] { --view: 59%; }
[data-scene="crossing"] { --view: 57%; }
[data-scene="cave"] { --view: 62%; }
.scene-shade {
  background: linear-gradient(180deg,#0b221bc7 0%,#152b214f 22%,transparent 42%,#10241b21 65%,#081711a4 100%);
}
.sunbeams {
  inset: -22% -15% 24% 12%;
  width: 112%;
  height: 90%;
  background:
    conic-gradient(from 144deg at 66% 6%, transparent 0deg, #ffeb9a25 8deg, transparent 14deg, #c7fee628 20deg, transparent 29deg, #fef5aa56 36deg, transparent 48deg);
  filter: blur(13px);
  mix-blend-mode: screen;
  opacity: .68;
  transform-origin: 66% 6%;
  animation: sun-sweep 11s ease-in-out infinite alternate;
}
.rolling-mist {
  inset: 39% -20% -10%;
  width: 140%;
  height: 72%;
  background:
    radial-gradient(ellipse at 15% 60%,#d1ffe128,transparent 36%),
    radial-gradient(ellipse at 51% 70%,#b0f2e43c,transparent 42%),
    radial-gradient(ellipse at 88% 44%,#9fffe127,transparent 39%);
  pointer-events: none;
  filter: blur(24px);
  mix-blend-mode: screen;
  animation: mist-travel 12s ease-in-out infinite alternate;
}
.world-particles { pointer-events: none; }
.world-light {
  inset: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 65% 53%, #ffe9a784, #f2bd633a 24%, transparent 62%);
}
.full-world.step-light .world-light { animation: amber-step .58s ease-out; }

.stage-bar {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  align-items: center;
  padding: max(10px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 4px max(12px,env(safe-area-inset-left));
  gap: 7px 16px;
  position: relative;
  z-index: 2;
}
.stage-brand, .stage-bar .tools, .stage-progress, .stage-menu .topbar .tools {
  border: 1px solid #c7f2dc46;
  border-radius: 16px;
  background: #102820e6;
  box-shadow: 0 8px 26px #061b112e;
}
.stage-brand { min-height: 42px; padding: 7px 11px; }
.stage-brand i { flex: none; }
.stage-bar .tools, .stage-menu .topbar .tools { padding: 3px; gap: 4px; }
.stage-bar .quiet, .stage-menu .topbar .quiet {
  border-color: transparent;
  background: transparent;
  min-height: 35px;
  padding-inline: 9px;
  font-size: 12px;
}
.stage-bar .quiet:hover, .stage-menu .topbar .quiet:hover { background: #d3f5db26; }
.stage-progress { display: grid; grid-template-columns:max-content minmax(0,1fr); gap:9px; align-items:center; justify-self:center; width:min(100%, 540px); padding:5px 8px; }
.stage-progress .counter { padding: 2px 6px; border: 0; border-radius: 6px; background: #273e31; font-size: 12px; white-space: nowrap; }
.stage-progress .tracks { display:grid;grid-template-columns:repeat(20,minmax(0,1fr));gap:3px;align-items:center;margin:0; }
.stage-progress .tracks li {
  display:grid;place-items:center;
  width:100%;height:auto;aspect-ratio:1;max-width:21px;
  border:1px solid #bad5c29e;border-radius:50%;
  transform:none;
  font-size:clamp(8px, .74vw, 11px);
  line-height:1;font-weight:800;
  background:#173d34;color:#dff3e8;
}
.stage-progress .tracks .current { color:#192c24;background:#e4fff4;border-color:#ffffff;box-shadow:0 0 8px #c1ffdfa8; }
.stage-progress .tracks .is-lit { color:#2a2214;background:#ffd47d;border-color:#ffeabb;box-shadow:none; }

.stage-main { display:flex; flex-direction:column; flex:1; gap:14px; min-height:0; padding:4px 14px max(13px,env(safe-area-inset-bottom)); }
.stage-heading { width:min(100%, 1250px); margin:9px auto 0; text-shadow:0 2px 18px #102019; pointer-events:none; position:relative; z-index:1; }
.stage-heading h1 { font:700 clamp(29px,4.65vw,77px)/1.02 Georgia,serif;letter-spacing:-.035em;margin:5px 0 7px;max-width:1100px; }
.stage-heading .eyebrow { color:#ffdc8e; }
.stage-location { display:inline-grid;gap:2px;padding:6px 11px;max-width:min(94vw,520px);background:#163129db;border:1px solid #a9d3ba60;border-radius:9px;font-size:clamp(12px,1.1vw,15px); }
.stage-location span { color:#def0e3; }

.actor-stage { flex: 1 0 clamp(155px, 31vh, 360px); display:grid; align-items:center; justify-items:end; padding-right:clamp(25px,8vw,140px); }
.actor-motion { position:relative; width:clamp(155px, 29vw, 380px); align-self:center; transform-origin:55% 91%; animation: companion-idle 3.65s ease-in-out infinite; }
.actor-motion::before {
  content:"";position:absolute;inset:auto 8% 17% 13%;height:10%;z-index:-1;border-radius:50%;background:#0a2219b8;filter:blur(13px);
}
.actor {
  display:block;width:100%;padding:0;border:0;background:transparent;position:relative;color:#e5fff0;
}
.actor img { display:block;width:100%;height:auto;max-height:36vh;object-fit:contain;filter:drop-shadow(0 9px 12px #10291dab); }
.actor span {
  position:absolute;right:10%;bottom:5%;font-size:12px;font-weight:800;
  background:#102d22e6;border:1px solid #b4f9ce94;padding:3px 8px;border-radius:20px;
}
.actor:hover span,.actor:focus-visible span { background:#25543e; }
.actor-note { position:absolute; left:50%; bottom:88%; translate:-50% 0; padding:4px 10px; font-size:12px; font-weight:700; white-space:nowrap;
  background:#ffebbd; color:#352918; border-radius:10px; box-shadow:0 8px 22px #0b20176b; }
.actor-note:empty { visibility:hidden; }
.actor-motion.reaction { animation: companion-hop .68s ease-out both; }
.actor-motion.wrong-answer { animation: companion-look .40s ease-out both; }

.stage-task {
  position:relative; z-index:1; width:min(100%, 820px); margin:0 auto; min-height:0;
  padding:clamp(12px,2.3vw,23px) clamp(14px,3vw,34px);
  background:#fffaf2fa; color:var(--ink-forest);
  border:1px solid #d8f0d6; border-radius:20px;
  box-shadow:0 16px 44px #061c16a1;
}
.task-head { display:flex;align-items:center;justify-content:space-between;gap:10px; }
.stage-task .eyebrow { color:#305c48; }
.stage-task h2 { font-size:clamp(19px,2.3vw,31px);margin:6px 0 5px; }
.stage-task p:not(.eyebrow) { color:#425c50; }
.stage-task .notice:not(:empty) { color:#82501d!important; }
.stage-task .bracelet { margin:0;border:0;padding:0;font-size:12px;font-weight:700;white-space:nowrap;color:#466150; }
.stage-task .bracelet ol { gap:2px; }
.stage-task .gem { width:17px;height:17px;border-color:#9ca3af;background:#d1d5db;box-shadow:none; }
.stage-task .gem.is-lit { background:#22c55e;border-color:#15803d;box-shadow:0 0 8px #22c55e70; }
.stage-task .gem.is-current { background:#facc15;border-color:#a16207;box-shadow:0 0 7px #facc1566; }
.stage-menu .route-list li:nth-child(2) .gem.is-lit {
  border-color:#607c9f; background:conic-gradient(#d9cbfb,#d6fff4,#8dd7f0,#d9cbfb); box-shadow:0 0 9px #85caff;
}
.stage-menu .route-list li:nth-child(3) .gem.is-lit {
  border-color:#6863a1; background:conic-gradient(#edf9ff,#dbbbff,#a5ebf8,#edf9ff); box-shadow:0 0 9px #baa4fe;
}
.stage-task .forms,.stage-task .choices { margin-top:7px; gap:7px; }
.stage-task .forms div,.stage-task .choice { background:#fffdf7;border-color:#9dc9b3;color:#233e31;border-radius:10px; }
.stage-task .forms div { padding:4px 3px; }
.stage-task .forms span,.stage-task .choice kbd { color:#4d6858; }
.stage-task .forms b { font-size:clamp(15px,2vw,21px); }
.stage-task .forms .gap { color:#764817;background:#fff1d2;border-color:#c78f3d; }
.stage-task .forms .resolved { color:#1b5b3b;background:#d9f3de;border-color:#54976e; }
.stage-task .choice { min-height:46px;padding:5px 4px;box-shadow:0 3px 0 #b3d8c5; }
.stage-task .choice:hover:not(:disabled) { background:#e9f9ee;border-color:#42836a;transform:translateY(-1px); }
.stage-task .choice.correct { color:#1f5336;background:#d9f3de;border-color:#4e9670;box-shadow:0 3px 0 #91cba6; }
.stage-task .choice.wrong { color:#883832;background:#ffebe4;border-color:#ad726a;box-shadow:0 3px 0 #e7b9ac; }
.stage-task .button { background:#f4bb63;color:#2d2317;min-height:40px; }
.stage-task .button:hover { background:#ffda92; }
.stage-task .button:disabled { background:#e3d9c8;color:#73654f; }
.stage-task .quiet { background:#e7efe7;color:#254c37;border-color:#a6bdac; }
.stage-task .quiet:hover { background:#d5eadb; }
.stage-task :focus-visible { outline-color:#26644b; }
.answer-status { display:flex;gap:8px;align-items:center;justify-content:space-between;margin-top:8px;min-height:40px; }
.answer-status .feedback { margin:0;min-height:0;font-size:14px; }
.stage-task .feedback.correct { color:#286542; }
.stage-task .feedback.wrong { color:#a33d36; }
.answer-status .button,.stage-task .task-actions .button,.stage-task #practice-link { margin:0;min-height:40px; }
.task-actions { display:flex;flex-wrap:wrap;align-items:center;gap:7px;margin-top:10px; }
.scene-preview img { max-height:calc(100svh - 174px);object-fit:contain; }

.stage-menu .menu-main { flex:1;display:flex;flex-direction:column; }
.stage-menu .cover { flex:1;min-height:min(56vh,510px);border:0;background:none;align-items:center;overflow:visible; }
.stage-menu .cover::after { display:none; }
.stage-menu .cover-copy { padding:clamp(15px,4vw,55px) 0; text-shadow:0 4px 23px #112019; }
.stage-menu .cover-actions { text-shadow:none; }
.stage-menu .route { margin:9px 0 12px; }
.stage-menu .route-list li { background:#14271fdc; }
.stage-menu .route-title { text-shadow:0 2px 12px #112818; }
.stage-menu .scene-shade { background:linear-gradient(90deg,#13261fe8,#13261f70 49%,transparent 81%),linear-gradient(0deg,#081a13aa,transparent 42%); }

@keyframes sun-sweep { from{transform:rotate(-3deg) translateX(-2%);opacity:.45}to{transform:rotate(5deg) translateX(2%);opacity:.84} }
@keyframes mist-travel { from{transform:translateX(-8%) translateY(2%)}to{transform:translateX(9%) translateY(-5%)} }
@keyframes companion-idle { 0%,100%{transform:translateY(0) rotate(-1.4deg)}50%{transform:translateY(-10px) rotate(1.3deg)} }
@keyframes companion-hop { 0%,100%{transform:translateY(0) rotate(0)}44%{transform:translateY(-28px) rotate(6deg)}68%{transform:translateY(-8px) rotate(-2deg)} }
@keyframes companion-look { 0%,100%{transform:none}38%{transform:rotate(-5deg) translateX(-6px)}70%{transform:rotate(3deg)} }

/* V11: hide mission overlay titles on all mission start screens */
.immersive[data-page="mission"] .stage-heading { display:none !important; }

@media (prefers-reduced-motion: no-preference) {
  .world-image {
    transform:translate(var(--scene-x),var(--scene-y)) scale(1.045);
    animation: world-breathe 16s ease-in-out infinite alternate;
  }
  .full-world.scene-enter .world-image { animation: scene-arrival .78s ease-out both, world-breathe 16s .78s ease-in-out infinite alternate; }
}
@keyframes world-breathe {
  from { transform:translate(var(--scene-x),var(--scene-y)) scale(1.045); }
  to { transform:translate(var(--scene-x),var(--scene-y)) scale(1.102); }
}
@keyframes scene-arrival {
  from { opacity:.55;filter:brightness(.88) saturate(1.3); }
  to { opacity:1;filter:none; }
}
.scene-echo {
  position:absolute; inset:0; width:100%;height:100%;object-fit:cover;object-position:var(--view,55%) center;
  animation: scene-echo .72s ease-out forwards;
}
@keyframes scene-echo { from{opacity:1;transform:scale(1.055)}to{opacity:0;transform:scale(1.09)} }

@media (max-width:1170px) {
  .stage-bar { grid-template-columns:1fr max-content; }
  .stage-progress { grid-column:1 / -1; grid-row:2; justify-self:start; }
  .stage-brand { justify-self:start; }
}
@media (max-width:640px) {
  .stage-bar { grid-template-columns:1fr;gap:5px;padding-inline:9px; }
  .stage-bar .tools { justify-self:start;max-width:100%;flex-wrap:nowrap; }
  .stage-bar .quiet[data-compact] { font-size:0;padding-inline:6px;min-height:33px;gap:0; }
  .stage-bar .quiet[data-compact]::after { content:attr(data-compact);font-size:11px;white-space:nowrap; }
  .stage-progress { grid-row:auto; width:100%; }
  .stage-progress .tracks { gap:2px; }
  .stage-progress .tracks li { font-size:8px; }
  .stage-main { padding-inline:8px;gap:8px; }
  .stage-heading { margin-top:4px; }
  .stage-heading h1 { font-size:clamp(25px,5.9vw,40px);margin-block:3px; }
  .stage-heading .eyebrow { font-size:10px; }
  .stage-location { padding:4px 7px; line-height:1.35; }
  .stage-location strong { font-size:12px; }
  .actor-stage { flex-basis:clamp(100px,20vh,225px);padding-right:16px; }
  .actor-motion { width:clamp(126px,46vw,235px); }
  .actor img { max-height:25vh; }
  .stage-task { border-radius:14px; padding:10px 11px; }
  .stage-task .eyebrow { font-size:10px; }
  .stage-task .bracelet { gap:3px;font-size:10px; }
  .stage-task .gem { width:13px;height:13px; }
  .stage-task .choice { font-size:clamp(12px,3.5vw,18px); }
  .stage-menu .cover h1 { font-size:clamp(44px,13vw,72px); }
  .stage-menu .cover { min-height:47vh; }
}
@media (max-width:365px) {
  .stage-progress { grid-template-columns:1fr;gap:3px; }
  .stage-progress .counter { justify-self:start; }
}
@media (max-height:540px) and (orientation:landscape) {
  .actor-stage { flex-basis:46px; justify-items:end; padding:0; }
  .actor-motion { position:absolute; right:3.5vw; top:24vh; width:min(23vw,180px); z-index:1; }
  .stage-task { width:min(83%,680px); align-self:flex-start; margin-inline:0 auto; }
  .stage-heading h1 { font-size:clamp(22px,4vw,39px); }
  .stage-location { padding:3px 6px;line-height:1.2; }
}
@media (prefers-reduced-motion:reduce) {
  .sunbeams,.rolling-mist,.actor-motion,.actor-motion.reaction,.actor-motion.wrong-answer,.full-world.step-light .world-light,.scene-echo {
    animation:none;
  }
}
.stage-menu .route-list li:nth-child(4) .gem.is-lit {background:#63dd97;border-color:#d5ffe2;box-shadow:0 0 10px #47d98b;}
