.stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; container-type: inline-size;
}
.viewer .stage {
  aspect-ratio: auto; height: auto; flex: 1 1 auto; min-height: 34vh; max-height: min(62dvh, 118vw); --actor-scale: 1.3;
  background: #CDE9FA;
}
.stage .cam { position: absolute; inset: 0; transform-origin: var(--cx, 50%) var(--cy, 60%); }
.stage .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.stage .tint { position: absolute; inset: 0; mix-blend-mode: multiply; pointer-events: none; }
.stage .tint.sunset { background: rgba(255, 140, 90, .22); }
.stage .tint.night { background: rgba(30, 40, 110, .38); }
.stage .layer { position: absolute; inset: 0; }
.stage .fx { pointer-events: none; overflow: hidden; }

/* position via the `translate` property so `scale`/`transform` stay free for animation */
.actor { position: absolute; aspect-ratio: 1 / 1; translate: -50% -100%; transform-origin: 50% 100%; }
.actor-move, .actor-flip, .actor-anim { width: 100%; height: 100%; position: relative; }
.actor-flip { transform-origin: 50% 100%; }
.actor-flip.left { transform: scaleX(-1); }
.actor-anim, .actor-move { transform-origin: 50% 100%; }
.actor-anim svg { height: 100%; width: auto; display: block; overflow: visible; margin: 0 auto; }
.actor-anim.raster .char-talk { width: 100%; height: 100%; transform-origin: 50% 100%; }
.actor-anim .char-img { display: block; height: 100%; width: auto; margin: 0 auto; transform-origin: 50% 100%; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.emote { position: absolute; left: 56%; top: -2%; width: 24%; aspect-ratio: 1; pointer-events: none; transform-origin: 50% 100%; }
.emote img { display: block; width: 100%; height: 100%; }
.actor-fallback { width: 70%; height: 70%; margin: 30% auto 0; border-radius: 50%; background: var(--c1, #F59AC0); border: 6px solid #4A3B35; }

/* one face visible at a time */
.actor-anim .face { display: none; }
.actor-anim[data-emotion="happy"] .face-happy,
.actor-anim[data-emotion="sad"] .face-sad,
.actor-anim[data-emotion="surprised"] .face-surprised,
.actor-anim[data-emotion="sleepy"] .face-sleepy,
.actor-anim[data-emotion="scared"] .face-scared,
.actor-anim[data-emotion="grumpy"] .face-grumpy { display: inline; }

/* rig: every part pivots around --ox/--oy in viewBox units */
.actor-anim .part, .actor-anim .eyes, .actor-anim .mouth {
  transform-box: view-box;
  transform-origin: var(--ox, 120px) var(--oy, 200px);
}
.actor-anim .part { will-change: transform; }
.actor-anim .rig { transform-box: view-box; transform-origin: 120px 240px; will-change: transform; }

.prop { position: absolute; translate: -50% -100%; transform-origin: 50% 100%; display: block; pointer-events: none; }
.prop.alive-spin, .prop.alive-twinkle { transform-origin: 50% 50%; }
.zzz {
  position: absolute; right: -4%; top: 6%; font-size: 5cqw; font-weight: 800; color: #6B7BD6; opacity: 0;
  animation: zzz 3s ease-out infinite; pointer-events: none;
}
.zzz:nth-of-type(2) { animation-delay: 1s; }
.zzz:nth-of-type(3) { animation-delay: 2s; }

.fx-p { position: absolute; left: var(--x, 50%); top: var(--y, 0); width: var(--size, 3%); }
.fx-p img { display: block; width: 100%; height: auto; }
