/* ==========================================================================
   Visual polish layer (loaded last). Only looks: no layout logic lives here.
   Gradients come from the hidden .svg-defs block in index.html.
   Scene art lives in assets/scene/*.svg and is placed with pseudo-elements,
   so index.html and js/*.js do not change when a scene gets richer.
   ========================================================================== */

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }

/* ---------- Zakzak: soft 3D shading, arms, shoes, gloss ---------- */
.zakzak .zk-fill { fill: url(#zk-grad); }
.zakzak .zk-leg { fill: url(#zk-limb-grad); }
.zakzak .zk-horn { fill: url(#zk-horn-grad); }
.zakzak .zk-cheek { fill: url(#zk-cheek-grad); opacity: .85; }
.zk-foot { fill: #8f7be6; stroke: var(--zk-line); stroke-width: 4; stroke-linejoin: round; }
.zk-horn-hi { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; opacity: .75; }
.zk-gloss { fill: none; stroke: #fff; stroke-width: 7; stroke-linecap: round; opacity: .4; }
.zk-gloss-dot { fill: #fff; opacity: .5; }
.zk-arm-line { fill: none; stroke: var(--zk-line); stroke-width: 26; stroke-linecap: round; }
.zk-arm-fill { fill: none; stroke: #ab97fa; stroke-width: 18; stroke-linecap: round; }

/* Arms swing gently with the breathing; shoulders are the pivot */
.zk-arm { transform-box: fill-box; animation: zk-arm-idle 3s ease-in-out infinite; }
.zk-arm--l { transform-origin: 100% 0; --sw: 7deg;  --up: 100deg;  --tx: -6px; --shrug: 55deg; }
.zk-arm--r { transform-origin: 0 0;    --sw: -7deg; --up: -100deg; --tx: 6px;  --shrug: -55deg; }
@keyframes zk-arm-idle { 50% { transform: rotate(var(--sw)); } }

/* The horn wobbles now and then (both parts share one pivot) */
.zakzak .zk-horn, .zk-horn-hi {
  transform-box: view-box;
  transform-origin: 100px 52px;
  animation: zk-horn 6s ease-in-out infinite;
}
@keyframes zk-horn {
  0%, 82%, 100% { transform: rotate(0); }
  86% { transform: rotate(-9deg); }
  91% { transform: rotate(7deg); }
  96% { transform: rotate(-3deg); }
}

/* Eyes look around a little while idle (translate composes with the "wrong" look-up) */
.zakzak .zk-pupil, .zakzak .zk-shine { animation: zk-look 9s ease-in-out infinite; }
@keyframes zk-look {
  0%, 28%, 100% { translate: 0 0; }
  33%, 48% { translate: -5px -2px; }
  54%, 70% { translate: 5px -3px; }
  76% { translate: 0 0; }
}
.zakzak.is-wrong .zk-pupil, .zakzak.is-wrong .zk-shine { animation: none; }

/* right: both arms up (cheer); wrong: a small shrug */
.zakzak.is-right .zk-arm { animation: zk-arm-up .9s ease-out; }
@keyframes zk-arm-up {   /* the shoulder slides up the body so the raised hand clears the head */
  0%, 100% { transform: translate(0, 0) rotate(0); }
  25%, 45% { transform: translate(var(--tx), -16px) rotate(var(--up)); }
  55% { transform: translate(var(--tx), -16px) rotate(calc(var(--up) * .75)); }
  70% { transform: translate(var(--tx), -16px) rotate(var(--up)); }
}
.zakzak.is-wrong .zk-arm { animation: zk-arm-shrug 1.2s ease-in-out; }
@keyframes zk-arm-shrug {
  0%, 100% { transform: rotate(0); }
  25%, 70% { transform: rotate(var(--shrug)); }
}

/* A burst of light behind Zakzak on every happy jump */
.zakzak::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 48%;
  width: 150%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 236, 140, .75) 0 10deg, transparent 10deg 30deg);
  -webkit-mask: radial-gradient(closest-side, #000 25%, transparent 75%);
  mask: radial-gradient(closest-side, #000 25%, transparent 75%);
  opacity: 0;
  z-index: -1;
  pointer-events: none;
}
.zakzak.is-right::after { animation: zk-burst .9s ease-out; }
@keyframes zk-burst {
  0%   { opacity: 0; scale: .3; rotate: 0deg; }
  25%  { opacity: 1; }
  100% { opacity: 0; scale: 1.05; rotate: 45deg; }
}
.zakzak::before { background: radial-gradient(closest-side, rgba(40, 34, 70, .22), rgba(40, 34, 70, 0)); }

/* ---------- Owl: shading, feathers, a doubtful raised brow ---------- */
.friend .fr-fill, .friend .fr-wing { fill: url(#fr-grad); }
.friend .fr-belly { fill: url(#fr-belly-grad); }
.fr-feather { fill: none; stroke: #6b4428; stroke-width: 2.2; stroke-linecap: round; opacity: .45; }
.fr-brow { fill: none; stroke: #4a2f1b; stroke-width: 4.5; stroke-linecap: round; }
.friend.is-in .fr-brow--up { animation: fr-brow 1.6s ease-in-out .5s infinite; }
@keyframes fr-brow { 50% { transform: translateY(-2px); } }
.friend svg { filter: drop-shadow(0 4px 0 rgba(74, 63, 122, .15)); }

/* ---------- Speech bubbles with tails ---------- */
.bubble { border: 3px solid #e4ddff; box-shadow: 0 4px 0 rgba(74, 63, 122, .12); }
.bubble::after {   /* tail down toward Zakzak */
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 16px;
  height: 16px;
  translate: -50% -9px;
  rotate: 45deg;
  background: inherit;
  border: inherit;
  border-top: 0;
  border-left: 0;
  border-radius: 0 0 4px 0;
}
.bubble--friend::after {   /* tail left toward the owl */
  left: 0;
  top: 22px;
  translate: -9px 0;
  rotate: 135deg;
}

/* ---------- Doors: planks, lit window, step, soft shadow ---------- */
.door-shadow { fill: rgba(40, 34, 70, .18); }
.door-frame-hi { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; opacity: .35; }
.door-plank { fill: none; stroke: rgba(50, 25, 5, .16); stroke-width: 1.4; }
.door-inner { fill: none; stroke: rgba(40, 20, 5, .2); stroke-width: 3; }
.door-window { fill: #fff3bf; stroke: rgba(50, 25, 5, .35); stroke-width: 2; }
.door-window-bar { fill: none; stroke: rgba(50, 25, 5, .35); stroke-width: 1.6; }
.door-step { fill: #f1e7d6; stroke: rgba(60, 40, 20, .22); stroke-width: 1.5; }
.door-knob { stroke: #c79a12; stroke-width: 1.2; }
.door.is-locked svg { opacity: 1; filter: saturate(.7) brightness(.93); }
.door.is-locked .door-window { fill: #8d7d70; }
.door.is-current .door-window { fill: #fff8d8; }
.door-star { filter: drop-shadow(0 2px 0 rgba(120, 90, 0, .35)); }
.door.is-done .door-star { animation: door-star 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes door-star { 50% { transform: scale(1.12) rotate(8deg); } }

/* The door to play next: a bouncing pointer above it */
.door.is-current:not(.door--travel)::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  width: 26px;
  height: 22px;
  translate: -50% -100%;
  background: url("../assets/scene/pointer.svg") center / contain no-repeat;
  animation: door-pointer 1s ease-in-out infinite;
  pointer-events: none;
}
.door { position: relative; }
@keyframes door-pointer { 50% { transform: translateY(-7px); } }

/* Doors and options pop in one after another (first render only, class changes do not replay it) */
.doors .door, .stage > .option {
  transition: transform .08s, opacity .35s ease-out, scale .45s cubic-bezier(.3, 1.5, .5, 1);
}
@starting-style {
  .doors .door, .stage > .option { opacity: 0; scale: .5; }
}
.doors .door:nth-child(2), .stage > .option:nth-child(2) { transition-delay: 0s, .07s, .07s; }
.doors .door:nth-child(3), .stage > .option:nth-child(3) { transition-delay: 0s, .14s, .14s; }
.doors .door:nth-child(4) { transition-delay: 0s, .21s, .21s; }
.doors .door:nth-child(5) { transition-delay: 0s, .28s, .28s; }
.doors .door:nth-child(6) { transition-delay: 0s, .35s, .35s; }
.doors .door:nth-child(n+7) { transition-delay: 0s, .42s, .42s; }

/* ---------- Buttons: soft 3D, pressed state ---------- */
.option {
  background: linear-gradient(#fff 55%, #f2eeff);
  border: 3px solid #fff;
  box-shadow: 0 6px 0 #d8d0f7, 0 10px 18px rgba(74, 63, 122, .16);
}
.option:active { transform: translateY(4px) scale(.95); }
.option.is-right { box-shadow: 0 0 0 6px var(--grass), 0 6px 0 #d8d0f7, 0 10px 18px rgba(74, 63, 122, .16); }
.option.is-guess { box-shadow: 0 0 0 6px var(--zk), 0 6px 0 #d8d0f7, 0 10px 18px rgba(74, 63, 122, .16); }
.stage > .option.is-right { position: relative; }
.stage > .option.is-right::after {   /* a green tick */
  content: "";
  position: absolute;
  top: -14px;
  right: -14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #4cbf5a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 70% no-repeat;
  box-shadow: 0 3px 0 rgba(30, 90, 40, .35);
  animation: opt-pop .4s ease-out;
}
/* A wrong pick, in every game: a red cross, the opposite of the tick (shown ~0.7s by the JS) */
.option.is-wrong { position: relative; }
.option.is-wrong::after, .drag-ghost.is-wrong::after {
  content: "";
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 3;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #ef5b6b url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 7l10 10M17 7L7 17' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round'/%3E%3C/svg%3E") center / 64% no-repeat;
  box-shadow: 0 3px 0 rgba(130, 30, 45, .35);
  animation: opt-pop .3s ease-out;
}

.home-btn svg {
  background: radial-gradient(circle at 35% 30%, #fff, #f1edff 70%);
  border: 3px solid #fff;
  box-shadow: 0 5px 0 #d2c8f5, 0 8px 14px rgba(74, 63, 122, .18);
}
.home-btn:active svg { transform: translateY(3px); box-shadow: 0 2px 0 #d2c8f5; }

.books-btn {
  background: radial-gradient(circle at 35% 30%, #fff6cf, #ffd66b 75%);
  box-shadow: 0 6px 0 #e1b33f, 0 10px 16px rgba(74, 63, 122, .2);
}
.books-btn:active { translate: 0 3px; box-shadow: 0 3px 0 #e1b33f; }

.kid-btn { box-shadow: 0 5px 0 rgba(74, 63, 122, .18); }
.parents-btn { background: radial-gradient(circle at 35% 30%, #fff, #eeeaf9); }

.travel-sign {
  background: radial-gradient(circle at 35% 30%, #fff8dc, #ffe08a 75%);
  box-shadow: 0 6px 0 #e0b84a, 0 10px 16px rgba(74, 63, 122, .18);
}
.door--map .travel-sign { background: radial-gradient(circle at 35% 30%, #fffdf2, #ffeeb8 75%); }

.modal-box { box-shadow: 0 8px 0 rgba(40, 34, 70, .18); }
.modal-btn { box-shadow: 0 4px 0 #9d8be8; transition: transform .08s; }
.modal-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #9d8be8; }
.modal-btn--danger { box-shadow: 0 4px 0 #f0a8a8; }
.modal-btn--quiet { box-shadow: 0 4px 0 #d9d3f2; }
.modal { animation: modal-in .2s ease-out; }
.modal > * { animation: modal-pop .3s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes modal-in { from { opacity: 0; } }
@keyframes modal-pop { from { scale: .85; opacity: 0; } }

/* ---------- Room change: an iris opens on the new place around Zakzak ---------- */
@property --iris { syntax: "<length>"; inherits: false; initial-value: 0px; }
.scene { animation: none; }
.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 62%, transparent var(--iris), #fff var(--iris), #fff calc(var(--iris) + 1.5vmin), #b9a7ff calc(var(--iris) + 1.5vmin));
  animation: iris .7s cubic-bezier(.5, 0, .3, 1) forwards;
}
@keyframes iris {
  from { --iris: 0px; }
  to   { --iris: 130vmax; visibility: hidden; }
}

/* ---------- Celebration: shaped confetti that flutters, plus a ring of light ---------- */
.confetti i {
  animation-name: confetti-fall, confetti-sway;
  animation-timing-function: linear, ease-in-out;
  animation-fill-mode: forwards;
}
.confetti i:nth-child(3n)   { width: 12px; height: 12px; border-radius: 50%; }
.confetti i:nth-child(4n)   { width: 22px; height: 22px; border-radius: 0; background: #ffd84d !important;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.confetti i:nth-child(5n+1) { width: 7px; height: 26px; border-radius: 4px; }
@keyframes confetti-sway {
  0%, 100% { translate: 0 0; }
  25% { translate: 5vw 0; }
  75% { translate: -5vw 0; }
}
.confetti::before {   /* ring of light from Zakzak */
  content: "";
  position: absolute;
  left: 50%;
  bottom: 30%;
  width: 40vmin;
  aspect-ratio: 1;
  translate: -50% 50%;
  border-radius: 50%;
  border: 3vmin solid rgba(255, 236, 140, .8);
  animation: ring 1.1s ease-out forwards;
}
.confetti::after {    /* sparkles that pop around the screen */
  content: "";
  position: absolute;
  inset: 0;
  background:
    url("../assets/scene/sparkle.svg") 12% 22% / 9vmin no-repeat,
    url("../assets/scene/sparkle.svg") 84% 16% / 7vmin no-repeat,
    url("../assets/scene/sparkle.svg") 76% 58% / 10vmin no-repeat,
    url("../assets/scene/sparkle.svg") 20% 64% / 6vmin no-repeat,
    url("../assets/scene/sparkle.svg") 50% 8% / 8vmin no-repeat;
  animation: sparkle 1.6s ease-in-out forwards;
}
@keyframes ring {
  from { scale: .2; opacity: 1; }
  to   { scale: 3.2; opacity: 0; }
}
@keyframes sparkle {
  0%   { opacity: 0; scale: .6; }
  25%  { opacity: 1; scale: 1.05; }
  50%  { opacity: .4; scale: .95; }
  75%  { opacity: 1; scale: 1; }
  100% { opacity: 0; scale: 1.1; }
}

@media (prefers-reduced-motion: reduce) {
  .zk-arm, .zakzak .zk-horn, .zk-horn-hi, .zakzak .zk-pupil, .zakzak .zk-shine,
  .zakzak::after, .door.is-current::after, .door.is-done .door-star, .friend .fr-brow { animation: none !important; }
  .scene::after { display: none; }
  .doors .door, .stage > .option { transition: transform .08s; }
}

/* ==========================================================================
   Scenes: extra depth layers. .room--X::before is the far layer (behind the
   whole scene); .scene[data-room]::before is free per scene; ground blocks
   carry foreground props in their own pseudo-elements. .scene::after is the iris.
   ========================================================================== */
.room--garden::before, .room--beach::before, .room--farm::before, .room--forest::before,
.room--sea::before, .room--snow::before, .room--desert::before, .room--city::before, .room--space::before {
  content: "";
  position: absolute;
  pointer-events: none;
}
.scene::before { content: none; position: absolute; pointer-events: none; }

/* Sun goes top-right: the books button lives top-left and used to hide it */
.sun { left: auto; right: 7vmin; }
.sun.sun--low { right: 14vmin; }
.sun { background: radial-gradient(circle at 40% 38%, #fff3a8, var(--sun) 60%); }

/* ---- Garden: far hills, birds, a sandy path, mown stripes ---- */
.room--garden::before {
  left: 0; right: 0; bottom: 30%; height: 20%;
  background: url("../assets/scene/far-hills.svg") left bottom / auto 100% repeat-x;
}
.scene[data-room="garden"]::before {
  content: "";
  top: 17%; right: -18vmin; width: 13vmin; height: 6vmin;
  background: url("../assets/scene/birds.svg") center / contain no-repeat;
  animation: glide 26s linear infinite -6s;
}
.grass { background: repeating-linear-gradient(100deg, rgba(255, 255, 255, .09) 0 7vmin, transparent 7vmin 14vmin), var(--grass); }
.grass::before {
  content: "";
  position: absolute;
  left: 50%; top: 0; bottom: 0; width: 74vmin;
  translate: -50% 0;
  background: linear-gradient(#ecdcaa, #e3c98e);
  clip-path: polygon(46% 0, 54% 0, 100% 100%, 0 100%);
}
.tree-top { background: radial-gradient(circle at 35% 30%, #7fd06a, #5fb84d 55%, #4ea43e); }

/* ---- Beach: island on the horizon, glitter on the sea, umbrella ---- */
.room--beach::before {
  left: 3%; bottom: calc(46% - 1.6vmin); width: 34vmin; height: 15vmin;
  background: url("../assets/scene/island.svg") center bottom / contain no-repeat;
}
.sea::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1.4vmin .45vmin, #fff 55%, transparent 70%) 0 0 / 13vmin 7vmin,
    radial-gradient(1vmin .35vmin, #fff 55%, transparent 70%) 6vmin 3.5vmin / 11vmin 9vmin;
  opacity: .85;
  animation: twinkle 2.6s ease-in-out infinite;
}
.sand::before {   /* wet sand at the water line */
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0; height: 4vmin;
  border-radius: inherit;
  background: linear-gradient(rgba(170, 120, 50, .2), transparent);
}
.sand::after {
  content: "";
  position: absolute;
  right: 3%; top: -13vmin; width: 22vmin; height: 25vmin;
  background: url("../assets/scene/umbrella.svg") center bottom / contain no-repeat;
}

/* ---- Home: dotted wallpaper, clock, toys ---- */
.room--home {
  background:
    radial-gradient(circle, rgba(255, 255, 255, .45) 0 .7vmin, transparent .8vmin) 0 0 / 8vmin 8vmin,
    linear-gradient(#ffe9d2, #ffd9b8 62%);
}
.scene[data-room="home"]::before {
  content: "";
  left: 50%; top: 5vmin; width: 15vmin; height: 15vmin;
  translate: -50% 0;
  background: url("../assets/scene/clock.svg") center / contain no-repeat;
}
.floor::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(80, 40, 10, .14), transparent 45%);
}
.floor::after {
  content: "";
  position: absolute;
  right: 4%; top: 14%; width: 26vmin; height: 13vmin;
  background: url("../assets/scene/toys.svg") center / contain no-repeat;
}

/* ---- Farm: far hills, windmill with turning sails ---- */
.room--farm::before {
  left: 0; right: 0; bottom: 31%; height: 18%;
  background: url("../assets/scene/far-hills.svg") left bottom / auto 100% repeat-x;
}
.field::before {   /* tower */
  content: "";
  position: absolute;
  left: 6vmin; bottom: calc(100% - 2vmin); width: 13vmin; height: 24vmin;
  background: url("../assets/scene/windmill.svg") center bottom / contain no-repeat;
}
.field::after {    /* sails, centred on the tower top */
  content: "";
  position: absolute;
  left: 1.5vmin; bottom: calc(100% + 6vmin); width: 22vmin; height: 22vmin;
  background: url("../assets/scene/blades.svg") center / contain no-repeat;
  animation: spin 10s linear infinite;
}

/* ---- Forest: misty far trees, a mossy log, floating pollen ---- */
.room--forest::before {
  left: 0; right: 0; bottom: 28%; height: 26%;
  background: url("../assets/scene/forest-far.svg") left bottom / auto 100% repeat-x;
}
.scene[data-room="forest"]::before {
  content: "";
  inset: 12% 0 30% 0;
  background:
    radial-gradient(circle, rgba(255, 250, 190, .95) 0 .5vmin, transparent .9vmin) 0 0 / 17vmin 13vmin,
    radial-gradient(circle, rgba(255, 250, 190, .7) 0 .4vmin, transparent .8vmin) 8vmin 6vmin / 13vmin 17vmin;
  animation: twinkle 3s ease-in-out infinite, drift 12s ease-in-out infinite alternate;
}
.forest-floor::before {
  content: "";
  position: absolute;
  left: 4%; top: 26%; width: 28vmin; height: 12vmin;
  background: url("../assets/scene/log.svg") center / contain no-repeat;
}

/* ---- Under the sea: far rocks, swaying kelp, a treasure chest ---- */
.room--sea::before {
  left: 0; right: 0; bottom: 19%; height: 14vmin;
  background: url("../assets/scene/rocks-far.svg") left bottom / auto 100% repeat-x;
  opacity: .9;
}
.seabed::before {
  content: "";
  position: absolute;
  left: 1vmin; bottom: 55%; width: 18vmin; height: 30vmin;
  background: url("../assets/scene/seaweed.svg") center bottom / contain no-repeat;
  transform-origin: 50% 100%;
  animation: kelp 4s ease-in-out infinite;
}
@keyframes kelp { 50% { transform: skewX(7deg); } }
.seabed::after {
  content: "";
  position: absolute;
  right: 4%; top: 6%; width: 19vmin; height: 15vmin;
  background: url("../assets/scene/chest.svg") center / contain no-repeat;
}

/* ---- Snow: mountains, igloo, gentle snowfall ---- */
.room--snow::before {
  left: 0; right: 0; bottom: 34%; height: 26%;
  background: url("../assets/scene/mountains.svg") left bottom / auto 100% repeat-x;
}
.scene[data-room="snow"]::before {
  content: "";
  left: 0; right: 0; top: -88vmin; height: calc(100% + 88vmin);
  background:
    radial-gradient(circle, #fff 0 .55vmin, transparent .65vmin) 0 0 / 9vmin 11vmin,
    radial-gradient(circle, rgba(255, 255, 255, .85) 0 .35vmin, transparent .45vmin) 4vmin 5vmin / 7vmin 8vmin;
  animation: snowfall 16s linear infinite;
}
@keyframes snowfall { to { transform: translateY(88vmin); } }   /* 88 = 8 x 11 = 11 x 8: seamless */
.snow-ground::before {
  content: "";
  position: absolute;
  right: 3%; top: -8vmin; width: 26vmin; height: 18vmin;
  background: url("../assets/scene/igloo.svg") center bottom / contain no-repeat;
}

/* ---- Desert: the pyramids, a rolling tumbleweed ---- */
.room--desert::before {
  left: 36%; bottom: 36%; width: 52vmin; height: 24vmin;
  background: url("../assets/scene/pyramids.svg") center bottom / contain no-repeat;
}
.sand-floor::after {
  content: "";
  position: absolute;
  left: -10vmin; top: 18%; width: 8vmin; height: 8vmin;
  background: url("../assets/scene/tumbleweed.svg") center / contain no-repeat;
  animation: tumble 12s linear infinite, tumble-hop .7s ease-in-out infinite alternate;
}
@keyframes tumble { to { transform: translateX(calc(100vw + 20vmin)) rotate(3turn); } }
@keyframes tumble-hop { to { translate: 0 -2vmin; } }

/* ---- City: far skyline with domes, minarets and the Cairo Tower; colourful
        buildings with windows; a zebra crossing; a traffic light ---- */
.room--city::before {
  left: 0; right: 0; bottom: 38%; height: 26%;
  background: url("../assets/scene/city-far.svg") left bottom / auto 100% repeat-x;
}
.skyline { background: url("../assets/scene/buildings.svg") left bottom / auto 100% repeat-x; opacity: 1; }
.road::before {
  content: "";
  position: absolute;
  left: 50%; top: 14%; width: 40vmin; height: 70%;
  translate: -50% 0;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .85) 0 3vmin, transparent 3vmin 6vmin);
  clip-path: polygon(14% 0, 86% 0, 100% 100%, 0 100%);
}
.road::after {
  content: "";
  position: absolute;
  right: 22vmin; bottom: calc(100% + 1vmin); width: 7vmin; height: 24vmin;
  background: url("../assets/scene/traffic-light.svg") center bottom / contain no-repeat;
}

/* ---- Space: nebula, Earth seen from the Moon, a shooting star ---- */
.room--space::before {
  inset: 0;
  background:
    radial-gradient(ellipse 45% 30% at 20% 30%, rgba(255, 122, 200, .22), transparent 70%),
    radial-gradient(ellipse 40% 28% at 80% 58%, rgba(110, 198, 255, .2), transparent 70%);
}
.moon-ground::after {
  content: "";
  position: absolute;
  left: 5%; bottom: calc(100% + 17vh); width: 17vmin; height: 17vmin;
  background: url("../assets/scene/earth.svg") center / contain no-repeat;
  animation: float 6s ease-in-out infinite;
}
.stars::after {
  content: "";
  position: absolute;
  top: 12%; right: -24vmin; width: 22vmin; height: .6vmin;
  border-radius: 1vmin;
  background: linear-gradient(90deg, #fff, rgba(255, 255, 255, 0));
  rotate: -18deg;
  opacity: 0;
  animation: shoot 8s ease-in infinite 2s;
}
@keyframes shoot {
  0%, 80% { translate: 0 0; opacity: 0; }
  82% { opacity: 1; }
  94%, 100% { translate: -70vw 24vh; opacity: 0; }
}

@media (orientation: landscape) {
  .sun { right: auto; left: 20vw; }
  .sun.sun--low { right: auto; left: 22vw; }
  .room--beach::before { left: 6%; }
  .room--desert::before { left: 8%; }
  .moon-ground::after { left: 24%; bottom: calc(100% + 30vh); }
}

@media (prefers-reduced-motion: reduce) {
  .scene::before, .sea::before, .field::after, .seabed::before, .sand-floor::after,
  .moon-ground::after, .stars::after { animation: none !important; }
}

/* Owl: a bit bigger so its face reads on phones; its bubble keeps the golden border */
.friend { width: clamp(84px, 20vmin, 130px); }
.bubble--friend {
  left: calc(3vw + clamp(84px, 20vmin, 130px) + 12px + env(safe-area-inset-left, 0px));
  border: 3px solid #f6c35b;
}

/* ---------- Talking (js/talk.js sets .is-talking, and --open 0..1 from the mp3's loudness) ---------- */
.zk-talk { display: none; transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(calc(.14 + var(--open, 0) * .86)); }
.zk-talk-in { fill: var(--zk-line); }
.zk-tongue { fill: #ff8fb6; }
.zakzak.is-talking .zk-mouth--idle { display: none; }
.zakzak.is-talking .zk-talk { display: inline; }
.zakzak.is-talking.is-right .zk-talk, .zakzak.is-talking.is-wrong .zk-talk { display: none; }
/* talking while happy or puzzled: that mouth opens and closes instead */
.zk-mouth--right { transform-box: fill-box; transform-origin: 50% 0; }
.zk-mouth--wrong { transform-box: fill-box; transform-origin: 50% 50%; }
.zakzak.is-talking .zk-mouth--right { transform: scaleY(calc(.55 + var(--open, 0) * .45)); }
.zakzak.is-talking .zk-mouth--wrong { transform: scale(calc(.85 + var(--open, 0) * .2), calc(.6 + var(--open, 0) * .55)); }
/* device voice (no loudness to follow): a steady chatter */
.zakzak.is-talking.is-yap .zk-talk { animation: zk-yap .26s ease-in-out infinite alternate; }
.zakzak.is-talking.is-yap .zk-mouth--right { animation: zk-yap-big .26s ease-in-out infinite alternate; }
@keyframes zk-yap { from { transform: scaleY(.18); } to { transform: scaleY(.9); } }
@keyframes zk-yap-big { from { transform: scaleY(.6); } to { transform: scaleY(1); } }

/* the owl: the lower beak drops and shows a dark mouth */
.fr-mouth, .fr-beak-lo { display: none; }
.fr-mouth { fill: #5a2a12; transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(calc(.2 + var(--open, 0) * .9)); }
.fr-beak-lo { fill: #e0862a; stroke: #a95c14; stroke-width: 2; stroke-linejoin: round; transform: translateY(calc(var(--open, 0) * 6px)); }
.friend.is-talking .fr-mouth, .friend.is-talking .fr-beak-lo { display: inline; }
.friend.is-talking.is-yap .fr-beak-lo { animation: fr-yap .28s ease-in-out infinite alternate; }
.friend.is-talking.is-yap .fr-mouth { animation: fr-yap-mouth .28s ease-in-out infinite alternate; }
@keyframes fr-yap { from { transform: translateY(.5px); } to { transform: translateY(5.5px); } }
@keyframes fr-yap-mouth { from { transform: scaleY(.25); } to { transform: scaleY(1); } }

@media (prefers-reduced-motion: reduce) {
  /* the mouth still follows the voice (it is the speech itself), only the free chatter slows */
  .zakzak.is-talking.is-yap .zk-talk, .zakzak.is-talking.is-yap .zk-mouth--right,
  .friend.is-talking.is-yap .fr-beak-lo, .friend.is-talking.is-yap .fr-mouth { animation-duration: .5s; }
}

/* ---------- Map: every room shows its number, so the order is clear ---------- */
.room-map { counter-reset: map-room; }
.map-room { counter-increment: map-room; }
.map-room::before {
  content: counter(map-room, arabic-indic);
  position: absolute;
  top: -7px;
  right: -7px;   /* top right, where an Arabic reader starts; the lock/star badge sits bottom right */
  z-index: 1;
  box-sizing: border-box;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border: 3px solid var(--tier, #ffd84d);
  border-radius: 16px;
  background: #fff;
  color: var(--zk-line);
  font: 800 18px/26px system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 2px 0 rgba(74, 63, 122, .25);
}
