:root {
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  color: #fff;
  background: #160f2f;
  font-synthesis: none;
  --berry: #f14f72;
  --gold: #ffcf5a;
  --violet: #35245f;
  --ink: #21153e;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; overflow: hidden; background: #160f2f; }
button { font: inherit; }

.book { min-height: 100dvh; display: grid; place-items: center; }

.stage {
  position: relative;
  width: min(100vw, 980px);
  height: 100dvh;
  max-height: 760px;
  overflow: hidden;
  isolation: isolate;
  background-position: center;
  background-size: cover;
  touch-action: manipulation;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: radial-gradient(circle at 50% 38%, #7655aa 0 14%, #2b2359 46%, #17102f 100%);
}

.scene-forest { background-image: url("assets/forest-cottage.png"); }
.scene-kitchen { background-image: url("assets/kitchen.png"); }
.scene-bedroom { background-image: url("assets/bedroom-bears.png"); background-position: 32% center; }
.scene-bedroom.scene-bears { background-position: right center; }

.shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(14, 9, 35, .32), transparent 34%, rgba(10, 6, 30, .35));
}

.topbar {
  position: absolute;
  z-index: 20;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.round-button {
  width: 48px;
  height: 48px;
  border: 2px solid rgba(255,255,255,.45);
  border-radius: 50%;
  background: rgba(28,18,59,.75);
  color: white;
  font-size: 1.35rem;
  box-shadow: 0 8px 22px rgba(0,0,0,.25);
  backdrop-filter: blur(8px);
}

.round-button:active, .primary-button:active, .next-button:active, .choice:active { transform: scale(.96); }

.progress { flex: 1; display: flex; justify-content: center; gap: 7px; }
.progress i { width: 11px; height: 11px; border-radius: 50%; background: rgba(255,255,255,.38); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.progress i.active { width: 28px; border-radius: 12px; background: var(--gold); }

.panel {
  position: absolute;
  left: 50%;
  top: 51%;
  width: min(88%, 560px);
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
}

.cover {
  padding: 30px 24px 26px;
  border: 2px solid rgba(255,255,255,.25);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(31,20,66,.91), rgba(75,43,105,.78));
  box-shadow: 0 24px 70px rgba(0,0,0,.42);
  backdrop-filter: blur(10px);
}

.eyebrow { margin: 0 0 10px; color: #f9d988; font-size: .86rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(2.4rem, 10vw, 5rem); line-height: .92; text-shadow: 0 4px 0 rgba(0,0,0,.18); }
h1 span { color: var(--gold); }
.cover-copy { margin: 20px auto 24px; max-width: 380px; font-size: clamp(1rem, 3vw, 1.25rem); line-height: 1.35; }

.primary-button, .next-button {
  min-height: 58px;
  border: 0;
  border-radius: 999px;
  padding: 0 26px;
  color: #271342;
  background: linear-gradient(180deg, #ffe178, #ffbd43);
  box-shadow: 0 8px 0 #c77928, 0 15px 30px rgba(0,0,0,.3);
  font-weight: 1000;
  font-size: 1.12rem;
  transition: transform .15s;
}

.story-card {
  position: absolute;
  z-index: 15;
  top: max(76px, calc(env(safe-area-inset-top) + 70px));
  left: 50%;
  width: min(88%, 650px);
  transform: translateX(-50%);
  padding: 13px 20px;
  border: 2px solid rgba(255,255,255,.34);
  border-radius: 20px;
  background: rgba(29,19,59,.82);
  box-shadow: 0 10px 35px rgba(0,0,0,.25);
  backdrop-filter: blur(10px);
  text-align: center;
}
.story-card p { margin: 0; font-size: clamp(1.05rem, 3.8vw, 1.45rem); line-height: 1.3; font-weight: 800; }

.hotspots { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.hotspot {
  position: absolute;
  display: grid;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: rgba(255,201,72,.32);
  box-shadow: 0 0 0 7px rgba(255,207,90,.18), 0 0 28px rgba(255,207,90,.7);
  color: white;
  cursor: pointer;
  pointer-events: auto;
  animation: breathe 1.4s ease-in-out infinite;
}
.hotspot::after { content: "●"; font-size: .75rem; color: #fff6b0; }
.hotspot.used { opacity: .25; animation: none; pointer-events: none; }

@keyframes breathe { 50% { transform: scale(1.12); box-shadow: 0 0 0 12px rgba(255,207,90,.08), 0 0 38px rgba(255,207,90,.85); } }

.masha {
  position: absolute;
  z-index: 7;
  left: 3%;
  bottom: -3%;
  height: min(67%, 560px);
  max-width: 45%;
  object-fit: contain;
  object-position: bottom;
  filter: drop-shadow(0 18px 18px rgba(0,0,0,.28));
  transform-origin: bottom center;
  animation: enterMasha .65s cubic-bezier(.2,.8,.2,1) both;
}
.masha.sleeping { left: 42%; bottom: 0; height: 43%; transform: rotate(10deg); }
.masha.celebrate { animation: bounce .7s ease-in-out infinite alternate; }
@keyframes enterMasha { from { transform: translateX(-30px); opacity: 0; } }
@keyframes bounce { to { transform: translateY(-16px) rotate(2deg); } }

.reaction {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: 49%;
  transform: translate(-50%, -50%);
  min-width: min(82%, 320px);
  padding: 20px;
  border-radius: 24px;
  background: #fff;
  color: var(--ink);
  text-align: center;
  font-size: clamp(1.35rem, 5vw, 2rem);
  font-weight: 1000;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  animation: pop .35s cubic-bezier(.2,.9,.25,1.3);
}
@keyframes pop { from { transform: translate(-50%,-50%) scale(.5); opacity: 0; } }

.choices {
  position: absolute;
  z-index: 25;
  left: 50%;
  bottom: max(92px, calc(env(safe-area-inset-bottom) + 82px));
  transform: translateX(-50%);
  width: min(92%, 620px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.choice {
  min-height: 64px;
  border: 2px solid rgba(255,255,255,.7);
  border-radius: 20px;
  padding: 10px;
  background: rgba(35,22,70,.88);
  color: white;
  font-size: clamp(.95rem, 3vw, 1.15rem);
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(0,0,0,.28);
  backdrop-filter: blur(8px);
}
.choice.good { background: #238768; }
.choice.wiggle { animation: wiggle .35s; }
@keyframes wiggle { 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }

.next-button {
  position: absolute;
  z-index: 26;
  right: 18px;
  bottom: max(20px, env(safe-area-inset-bottom));
}

.fireflies { position: absolute; inset: 0; pointer-events: none; }
.fireflies i { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #ffe76c; box-shadow: 0 0 14px #ffe76c; animation: float 4s ease-in-out infinite alternate; }
@keyframes float { to { transform: translate(16px,-25px); opacity: .25; } }

.confetti { position: absolute; z-index: 28; width: 10px; height: 18px; top: -20px; border-radius: 3px; animation: fall 2.6s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(760deg); } }

.hidden { display: none !important; }

@media (max-width: 620px) {
  .stage { width: 100vw; max-height: none; }
  .stage { background-position: 54% center; }
  .scene-kitchen { background-position: 50% center; }
  .scene-bedroom { background-position: 32% center; }
  .scene-bedroom.scene-bears { background-position: 100% center; }
  .masha { height: 56%; max-width: 52%; left: -3%; }
  .choices { grid-template-columns: 1fr; bottom: max(86px, calc(env(safe-area-inset-bottom) + 78px)); }
  .choice { min-height: 54px; }
  .cover { top: 54%; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .stage { max-width: none; max-height: none; }
  .cover { padding: 18px 22px; }
  h1 { font-size: clamp(2rem, 8vh, 3.5rem); }
  .cover-copy { margin: 10px auto 14px; }
  .story-card { top: 66px; }
  .masha { height: 72%; }
  .choices { grid-template-columns: repeat(3,1fr); bottom: 16px; width: min(72%, 650px); }
  .next-button { bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Illustrated cards and responsive story layout. */
html, body { overflow: auto; }
.stage { min-height: 660px; max-height: 900px; height: 100dvh; background-size: 100% auto; background-repeat: no-repeat; background-position: center 38%; background-color: #211b35; }
.stage::before { display: none; }
.shade { z-index: 0; background: linear-gradient(180deg, #19122cd9, transparent 32%, transparent 55%, #19122cf2 88%); }
.topbar { z-index: 20; }
.round-button { cursor: pointer; flex-shrink: 0; }
.mute-button { width: auto; padding: 0 16px; border-radius: 24px; font-size: .9rem; margin-left: auto; }
.progress { min-width: 0; }
.story-card { top: 78px; background: #211735ed; }
.story-card .chapter { color: #ffcf5a; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 8px; }
.masha { left: 18px; bottom: 285px; width: 100px; height: 120px; max-width: none; object-fit: cover; object-position: center 18%; border-radius: 50% 50% 42% 42%; border: 3px solid #ffcf5a; }
.masha.sleeping { left: 18px; bottom: 285px; height: 120px; transform: none; filter: brightness(.75); }
.scene-forest .masha { bottom: 60px; }
.choices { width: min(94%, 670px); grid-template-columns: repeat(3, minmax(0, 1fr)); bottom: 95px; gap: 12px; }
.choice { cursor: pointer; padding: 12px 8px; font-size: 1rem; min-width: 0; transition: background .2s, transform .2s; }
.picture-choice { color: #31203b; background: #fff2d6; border-color: #efd092; }
.object-picture { height: 128px; display: flex; align-items: end; justify-content: center; margin-bottom: 8px; }
.object-art { display: block; max-height: 128px; background-image: url('assets/objects.png'); background-repeat: no-repeat; }
.choice.good { color: #fff; background: #216d55; border-color: #8bf1b4; }
.choice:disabled:not(.good) { opacity: .58; }
button:focus-visible { outline: 4px solid #78dfff; outline-offset: 4px; }
.hotspot { font-size: .85rem; font-weight: bold; background: #39214ecc; }
.hotspot::after { display: none; }
.reaction { top: 41%; width: min(88%, 440px); min-width: 0; pointer-events: none; font-size: 1.3rem; }
.cover { top: auto; bottom: 35px; transform: translateX(-50%); padding: 24px; background: #241738ed; }
.cover h1 { font-size: clamp(2.5rem, 6vw, 4rem); }
.cover .cover-copy { margin: 16px auto 20px; }
.scene-bears .masha { bottom: 230px; }
.scene-bears:has(.celebrate) .masha { bottom: 95px; width: 145px; height: 175px; }
@media (max-width: 620px) {
  .stage { min-height: 640px; max-height: none; background-size: auto 52%; background-position: center 37%; }
  .stage.scene-forest { background-size: auto 78%; background-position: center top; }
  .stage.scene-bears { background-position: 90% 38%; }
  .story-card { width: 94%; padding: 12px; }
  .story-card p { font-size: 1.05rem; }
  .story-card .chapter { font-size: .78rem; }
  .topbar { gap: 8px; left: 10px; right: 10px; }
  .round-button { height: 44px; width: 44px; }
  .mute-button { width: auto; padding: 0 12px; font-size: .8rem; }
  .progress { gap: 4px; }
  .progress i { width: 7px; height: 7px; }
  .progress i.active { width: 17px; }
  .choices { gap: 7px; bottom: 100px; }
  .choice { padding: 10px 5px; font-size: .88rem; min-height: 65px; border-radius: 16px; }
  .object-picture { height: 92px; }
  .object-art { max-height: 92px; }
  .masha, .masha.sleeping { width: 72px; height: 88px; bottom: 280px; left: 10px; }
  .scene-bears .choices { grid-template-columns: 1fr; }
  .scene-bears .choice { min-height: 46px; }
  .scene-bears .masha { bottom: 275px; }
  .cover { top: auto; bottom: 28px; width: 92%; padding: 22px 16px; }
  .cover-copy { font-size: 1rem; }
  .primary-button { font-size: 1rem; padding: 0 20px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .stage { min-height: 360px; height: 100dvh; max-height: none; background-size: cover; background-position: center; }
  .topbar { right: auto; width: 42%; }
  .story-card { left: 12px; top: 70px; width: 41%; transform: none; }
  .story-card p { font-size: 1rem; }
  .choices { left: auto; right: 12px; width: 53%; transform: none; bottom: 95px; gap: 6px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .object-picture { height: 88px; }
  .object-art { max-height: 88px; }
  .choice { font-size: .88rem; min-height: 60px; }
  .masha, .masha.sleeping, .scene-bears .masha { left: 18px; bottom: 12px; width: 64px; height: 78px; }
  .reaction { left: 72%; top: 19%; width: 50%; padding: 12px; font-size: 1rem; }
  .cover { left: auto; right: 20px; bottom: 20px; top: auto; width: 52%; transform: none; padding: 16px; }
  .cover h1 { font-size: 2.6rem; }
  .cover-copy { margin: 10px auto !important; }
  .cover .eyebrow { font-size: .75rem; }
  .scene-bears .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .scene-bears:has(.celebrate) .masha { height: 125px; width: 100px; bottom: 12px; }
}

/* Interaction coordinates stay attached to the full illustration. */
.stage.playing { background-image: none; }
.scene-art { position: absolute; left: 0; top: 200px; width: 100%; aspect-ratio: 1672 / 941; background-size: 100% 100%; background-repeat: no-repeat; }
.scene-forest .scene-art { background-image: url('assets/forest-cottage.png'); }
.scene-kitchen .scene-art { background-image: url('assets/kitchen.png'); }
.scene-bedroom .scene-art { background-image: url('assets/bedroom-bears.png'); }
.hotspot { transform: translate(-50%, -50%); animation: none; }
.object-hotspot { position: absolute; transform: translate(-50%, -50%); min-width: 44px; min-height: 44px; pointer-events: auto; background: transparent; border: 2px solid #ffe28d80; border-radius: 45%; cursor: pointer; box-shadow: 0 0 12px #ffce5230; }
.object-hotspot:not(:disabled)::after {
  content: '';
  position: absolute;
  inset: 14%;
  border: 3px solid #fff3a8cc;
  border-radius: inherit;
  animation: objectHint 1.55s ease-out infinite;
  pointer-events: none;
}
@keyframes objectHint { 70%, 100% { inset: -12%; opacity: 0; } }
.object-hotspot:hover, .object-hotspot:focus-visible { background: #ffe28d25; border-color: #fff2b0; }
.object-hotspot.good { border: 4px solid #8bf1b4; background: #8bf1b425; box-shadow: 0 0 22px #8bf1b4; }
.object-hotspot.wrong { animation: objectWrong .4s; }
.object-hotspot:disabled:not(.good) { border-color: transparent; box-shadow: none; }
@keyframes objectWrong { 50% { background: #ee726a70; border-color: #ee726a; } }
.playing .masha, .playing .masha.sleeping, .playing.scene-bears .masha { bottom: 20px; left: 18px; width: 72px; height: 88px; }
.playing .reaction { top: auto; bottom: 110px; transform: translateX(-50%); font-size: 1.15rem; animation: none; }
.playing .choices { bottom: 110px; }
@media (max-width: 620px) {
  .scene-art { top: 215px; }
  .playing .reaction { bottom: 125px; }
  .playing .scene-art { box-shadow: 0 16px 50px #0005; }
  .playing.scene-bears .choices { bottom: 115px; }
  .playing.scene-bears .reaction { bottom: 280px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .scene-art { left: auto; right: 0; top: 0; width: 56%; height: auto; aspect-ratio: 1672 / 941; }
  .playing .reaction { bottom: 85px; left: 72%; }
  .playing .choices, .playing.scene-bears .choices { bottom: 95px; }
  .playing .masha, .playing .masha.sleeping, .playing.scene-bears .masha { bottom: 12px; height: 75px; width: 62px; }
}
.playing .masha { display: none; }
.actor { position: absolute; z-index: 5; width: 17%; height: 44%; left: 20%; top: 64%; transform: translate(-50%, -100%); background-repeat: no-repeat; pointer-events: none; transition: left .65s ease-in-out, top .65s ease-in-out; filter: drop-shadow(0 5px 3px #0004); }
.actor.pose-sitting, .actor.pose-eating { height: 34%; width: 18%; }
.actor.pose-sleeping { height: 20%; width: 26%; }
.actor.chair-wobble { animation: chairWobble .25s 3; }
@keyframes chairWobble { 50% { transform: translate(-50%, -95%) rotate(12deg); } }
.actor.pose-eating { animation: eatingNod .7s infinite; }
@keyframes eatingNod { 50% { transform: translate(-50%, -100%) rotate(-2deg); } }
.stage[data-kind="bowls"] .actor.pose-sitting, .stage[data-kind="bowls"] .actor.pose-eating { clip-path: inset(0 0 30% 0); }
@media (prefers-reduced-motion: reduce) { .actor { transition-duration: .01ms; } }
/* Give the illustration most of the screen in landscape. */
@media (orientation: landscape) and (max-height: 520px) {
  .scene-art { width: 72%; top: 50%; transform: translateY(-50%); }
  .topbar { width: 27%; gap: 4px; }
  .topbar .progress { display: none; }
  .round-button { width: 38px; height: 38px; }
  .mute-button { width: auto; padding: 0 9px; font-size: .7rem; }
  .story-card { width: 26%; padding: 10px; top: 65px; }
  .story-card p { font-size: .95rem; }
  .story-card .chapter { font-size: .72rem; }
  .playing .reaction { bottom: 10px; left: 60%; max-width: 48%; padding: 10px; }
  .playing .next-button { left: 14px; right: auto; min-height: 48px; padding: 0 16px; font-size: .95rem; }
  .playing.scene-bears .choices { left: 30%; right: 12px; width: 68%; bottom: 8px; }
  .playing.scene-bears .reaction { bottom: 90px; }
}
.actor { background-image: url('assets/masha-poses.png'); }
.pose-standing { background-size: 330% 186.607%; background-position: 17.162% 0%; }
.actor.pose-sitting { background-size: 317.468% 199.048%; background-position: 85.565% 6.41%; width: 15%; height: 42%; }
.actor.pose-eating { background-size: 302.169% 216.58%; background-position: 12.515% 100%; width: 15%; height: 42%; }
.actor.pose-sleeping { background-size: 197.48% 418%; background-position: 97.738% 85.954%; }
/* Scene reactions are acted and heard; the live status stays accessible. */
.reaction { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip-path: inset(50%) !important; white-space: nowrap !important; border: 0 !important; }
.doorway { display: none; position: absolute; left: 46.4%; top: 35.4%; width: 10.6%; height: 24%; background: #20120b; border-radius: 48% 48% 0 0; perspective: 500px; z-index: 2; }
.scene-forest .doorway { display: block; }
.door-panel { width: 100%; height: 100%; transform-origin: left center; transition: transform 1.3s ease-in-out; background: url('assets/forest-cottage.png') 51.9% 46.58% / 943.4% 416.67%; border-radius: inherit; }
.door-open .door-panel { transform: rotateY(-82deg); }
.actor.entering { transition: left .8s ease-in-out, top .8s ease-in-out, opacity .65s, scale .9s; scale: .72; }
.actor.inside { opacity: 0; scale: .3; }
.actor.too-hot { animation: startled .6s 2; }
@keyframes startled { 30% { transform: translate(-57%, -107%) rotate(-9deg); } 65% { transform: translate(-50%, -100%) rotate(4deg); } }
.stage[data-kind="chairs"][data-selected="1"] .actor.pose-sitting { clip-path: inset(0 0 30% 0); }
.actor.pose-surprised { background-image: url('assets/masha-surprised.png'); background-size: contain; background-position: center bottom; width: 21%; height: 49%; }
.scene-kitchen .scene-art.chair-broken { background-image: url('assets/kitchen-broken.png'); }
.actor.jumping-off { animation: jumpOff .8s ease-out both; }
@keyframes jumpOff { 0% { transform: translate(10%, -110%) rotate(-10deg); } 45% { transform: translate(-30%, -135%) rotate(-6deg); } 100% { transform: translate(-50%, -100%) rotate(0); } }
.stage[data-kind="bowls"] .actor.pose-surprised { clip-path: inset(0 0 30% 0); height: 42%; width: 18%; }
.actor.pose-sleeping { background-image: url('assets/masha-sleeping-back.png'); background-size: contain; background-position: center bottom; width: var(--sleep-width, 9%); height: var(--sleep-height, 18%); transform: translate(-50%, -100%) rotate(var(--sleep-angle, 0deg)); transform-origin: center 70%; }
.scene-bedroom:not(.scene-bears) .scene-art { background-image: url('assets/bedroom-empty.png'); }
.scene-forest .hotspot { background: transparent; border: 2px solid #ffde8970; box-shadow: 0 0 12px #ffde8940; border-radius: 48% 48% 0 0; min-width: 44px; min-height: 44px; }
.scene-forest .hotspot.used { opacity: 0; }
.door-hint { display: none; position: absolute; z-index: 9; top: 21%; left: 51%; transform: translateX(-50%); color: #fff9d3; background: #231830dd; border: 1px solid #ffd466; border-radius: 12px; padding: 8px 12px; font-size: clamp(.8rem, 2.1vw, 1.1rem); font-weight: bold; white-space: nowrap; pointer-events: none; }
.scene-forest .door-hint { display: block; }
.door-open .door-hint { display: none; }
.actor.pose-surprised { height: 44%; width: 22%; }
.stage[data-kind="bowls"] .actor.pose-surprised { height: 42%; width: 22%; }
.actor.too-cold { animation: shiver .12s 12; }
@keyframes shiver { 50% { transform: translate(-52%, -100%) rotate(-1deg); } }
.scene-finale .scene-art { background-image: url('assets/happy-repaired-chair.png'); }
.scene-finale .actor { display: none; }
.stage[data-scene="4"] .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Non-reading children choose gestures rather than written answers. */
.scene-forest .hotspot { border-radius: 50%; border: 3px solid #fff5b2; background: #ffd35a25; box-shadow: 0 0 0 6px #ffd35a30, 0 0 22px #ffcf5a; animation: doorPulse 1.5s ease-in-out infinite; }
@keyframes doorPulse { 50% { transform: translate(-50%, -50%) scale(1.1); } }
.scene-forest .hotspot.used { animation: none; opacity: 0; }
.stage[data-scene="4"] .actor { display: none; }
.stage[data-scene="4"] .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.gesture-choice { padding: 8px; min-height: 0; background: #fbe6d1; border-color: #ffcf5a; overflow: hidden; }
.gesture-art { display: block; width: 100%; height: 170px; background-image: url('assets/masha-gestures.png'); background-repeat: no-repeat; background-size: 300% 100%; }
.gesture-0 { background-position: 0% center; }
.gesture-1 { background-position: 50% center; }
.gesture-2 { background-position: 100% center; }
.gesture-choice.good { background: #c9f4db; border-color: #67dca1; box-shadow: 0 0 22px #67dca180; }
@media (max-width: 620px) {
  .stage[data-scene="4"] .choices { bottom: 105px; gap: 8px; }
  .gesture-art { height: 145px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .stage[data-scene="4"] .choices { left: auto; right: 12px; bottom: 10px; width: 68%; gap: 12px; }
  .gesture-art { height: 125px; }
}

/* Movable pieces use exact crops from the illustration. */
#props { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.prop { position: absolute; padding: 0; border: 0; background: transparent; pointer-events: auto; cursor: pointer; perspective: 500px; }
.prop::after { content: ''; position: absolute; inset: 0; border: 1px solid #ffe8a65c; border-radius: 8px; pointer-events: none; }
.prop-surface { display: block; width: 100%; height: 100%; background-repeat: no-repeat; transition: transform .8s ease, filter .7s; }
.prop-door { background: #24160c; border-radius: 40% 0 0 0; }
.prop-door .prop-surface { transform-origin: right center; border-radius: inherit; }
.prop-door.activated .prop-surface { transform: rotateY(72deg); }
.prop-drawer { background: #271b12; }
.prop-drawer.activated .prop-surface { transform: translateY(35%) scale(1.07); box-shadow: 0 5px 4px #0008; }
.prop-curtain .prop-surface { transform-origin: left top; }
.prop-curtain.activated .prop-surface { transform: scaleX(2.2); }
.prop-lamp.activated .prop-surface { filter: brightness(.35) saturate(.3); }
.prop-fire { border-radius: 40%; overflow: hidden; }
.prop-fire.activated .prop-surface { animation: fireDance .7s infinite alternate; }
@keyframes fireDance { to { filter: brightness(1.55) saturate(1.4); transform: scale(1.035); } }
.actor.pose-sleeping.sleep-crosswise { background-image: url('assets/masha-poses.png'); background-size: 197.48% 418%; background-position: 97.738% 85.954%; width: 27%; height: 20%; transform: translate(-50%, -100%); }
.gesture-art { position: relative; height: auto; aspect-ratio: 890 / 724; background: none; overflow: hidden; }
.gesture-art img { position: absolute; top: 0; height: 100%; width: 244.045%; max-width: none; }
.gesture-0 img { left: 13.48%; clip-path: inset(0 70.074% 0 0); }
.gesture-1 img { left: -73.034%; clip-path: inset(0 29.098% 0 29.926%); }
.gesture-2 img { left: -158.54%; clip-path: inset(0 0 0 70.902%); }
.scene-finale .scene-art { background-image: url('assets/happy-tea.png'); }
.scene-bears .scene-art.bears-unknown { background-image: url('assets/bears-unknown.png'); }
.scene-bears .scene-art.bears-not-me { background-image: url('assets/bears-not-me.png'); }
.reaction-slide { animation: slideReply .6s ease-out; }
@keyframes slideReply { from { opacity: .15; translate: 18px 0; } to { opacity: 1; translate: 0 0; } }
html, body { overflow-x: hidden; }
.scene-reveal .scene-art { animation: sceneReveal .58s ease-out both; }
.tap-pop {
  position: absolute;
  z-index: 120;
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-size: clamp(1.8rem, 5vw, 3.5rem);
  filter: drop-shadow(0 4px 6px #0007);
  animation: tapPop .8s ease-out forwards;
}
@keyframes sceneReveal { from { opacity: .28; filter: brightness(.65) blur(2px); } to { opacity: 1; filter: none; } }
@keyframes tapPop { 0% { opacity: 0; scale: .35; } 38% { opacity: 1; scale: 1.15; } 100% { opacity: 0; translate: 0 -52px; scale: .82; } }
@media (orientation: landscape) and (max-height: 520px) {
  html, body { overflow: hidden; }
  .stage { height: calc(100dvh - 1px); }
}

/* Phone landscape is a clean, full-screen play surface. The story is heard. */
@media (orientation: landscape) and (max-height: 520px) {
  html, body, .book {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: #160f2f;
  }
  .stage {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    max-width: none;
    max-height: none;
  }
  .stage.playing .story-card { display: none !important; }
  .stage.playing .scene-art {
    left: 50%;
    right: auto;
    top: 50%;
    width: max(100vw, calc(100dvh * 1.7779));
    height: max(100dvh, calc(100vw / 1.7779));
    min-width: 0;
    aspect-ratio: 1672 / 941;
    transform: translate(-50%, -50%);
    box-shadow: none;
  }
  .stage.playing .topbar {
    top: max(8px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    width: auto;
    gap: 8px;
    pointer-events: none;
  }
  .stage.playing .topbar button { pointer-events: auto; }
  .stage.playing .topbar .progress {
    display: flex;
    opacity: .82;
  }
  .stage.playing .round-button {
    width: 44px;
    height: 44px;
    border-width: 1px;
    background: rgba(24, 15, 49, .62);
    box-shadow: 0 5px 16px rgba(0, 0, 0, .28);
  }
  .stage.playing .mute-button { display: none; }
  .stage.playing.scene-bears .choices,
  .stage.playing[data-scene="4"] .choices {
    left: 50%;
    right: auto;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: min(72vw, 680px);
    transform: translateX(-50%);
    gap: 10px;
  }
  .stage.playing .next-button {
    left: auto;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    min-height: 48px;
    padding: 0 20px;
    font-size: 1rem;
  }
}
