:root {
  --ink: #10192e;
  --cream: #fff4ce;
  --paper: #fff9e8;
  --orange: #f25538;
  --gold: #f7bd35;
  --teal: #087f82;
  --green: #35a853;
  --shadow: rgba(20, 20, 20, .28);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: #16223a;
  color: var(--ink);
  font-family: Nunito, system-ui, sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.world-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  background:
    radial-gradient(circle at 50% 0%, rgba(255,244,206,.24), transparent 45%),
    #16223a;
}

.game-bar {
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 24px;
  background: rgba(255,249,232,.96);
  border-bottom: 3px solid var(--ink);
  box-shadow: 0 5px 0 rgba(16,25,46,.14);
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-family: "Archivo Black", sans-serif;
  letter-spacing: -.02em;
}
.cat-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--cream);
  background: var(--ink);
  border: 3px solid var(--gold);
  font: 700 12px/1 "JetBrains Mono", monospace;
}
.world-state {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font: 800 12px/1 "JetBrains Mono", monospace;
  text-transform: uppercase;
}
.world-state i, .chat-status i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(53,168,83,.14);
}
.bar-actions { display: flex; align-items: center; gap: 8px; }
.sound-toggle, .map-toggle {
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--gold);
  font: 900 11px/1 "JetBrains Mono", monospace;
  cursor: pointer;
}
.map-toggle { background: #fff; }

.viewport {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.stage {
  position: relative;
  width: min(100vw, calc((100dvh - 58px) * 1.5));
  max-height: calc(100dvh - 58px);
  aspect-ratio: 3 / 2;
  overflow: hidden;
  isolation: isolate;
  background: #f8e6b3;
  box-shadow: 0 0 60px rgba(0,0,0,.45);
  cursor: crosshair;
}
.stage:focus-visible { outline: 4px solid var(--gold); outline-offset: -4px; }
.room-plate { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; object-fit: fill; user-select: none; pointer-events: none; }
.actors, .foreground, .station-glows, .machine-effects, .speech-layer { position: absolute; inset: 0; pointer-events: none; }
.actors { z-index: 20; }
.machine-effects { z-index: 25; }
.foreground { z-index: 30; }
.station-glows { z-index: 4; }
.speech-layer { z-index: 900; }
.route-debug { position: absolute; inset: 0; z-index: 880; pointer-events: none; opacity: 0; transition: opacity .2s; }
.route-debug.visible { opacity: 1; }
.route-debug svg { width: 100%; height: 100%; overflow: visible; }
.route-floor { fill: rgba(77,141,240,.12); stroke: rgba(77,141,240,.75); stroke-width: 3; stroke-dasharray: 9 7; }
.route-edge { stroke: #f7bd35; stroke-width: 6; stroke-linecap: round; opacity: .9; }
.route-edge.elevator { stroke: #f25538; stroke-dasharray: 12 8; }
.route-node { fill: #fff9e8; stroke: #10192e; stroke-width: 3; }
.route-node.elevator { fill: #f25538; }

.station-glow {
  position: absolute;
  width: 8%;
  aspect-ratio: 2 / 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(247,189,53,.5), rgba(247,189,53,0) 68%);
  opacity: 0;
  transition: opacity .35s ease;
}
.station-glow.active { opacity: 1; animation: stationPulse 1.2s ease-in-out infinite alternate; }
@keyframes stationPulse { to { transform: scale(1.2); opacity: .62; } }

.machine-prop { overflow: visible; }
.machine-base,
.machine-live-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.machine-base { animation: machineStandbyBody 6.8s ease-in-out var(--motion-delay) infinite alternate; }
.machine-live-layer {
  opacity: 0;
  filter: brightness(1.45) saturate(1.16);
  transition: opacity .25s ease;
}
.machine-prop.attended .machine-screen-layer { opacity: .20; }
.machine-prop.attended .machine-controls-layer { opacity: .16; }
.machine-prop:not(.attended) .machine-screen-layer { opacity: .045; animation: machineStandby 5.6s steps(2,end) var(--motion-delay) infinite; }
.machine-prop:not(.attended) .machine-controls-layer { opacity: .035; animation: machineStandby 7.2s steps(2,end) var(--motion-delay) infinite reverse; }
.machine-prop.working .machine-screen-layer { opacity: .62; }
.machine-prop.working .machine-controls-layer { opacity: .32; }
.machine-prop-deploy.working .machine-live-layer { animation-duration: .72s; filter: brightness(1.55) saturate(1.25); }
@keyframes machineStandbyBody { to { filter: brightness(1.012) saturate(1.008); } }
@keyframes machineStandby { 50% { opacity: .085; filter: brightness(1.22) saturate(1.08); } }

/* Machine internals are true runtime pieces: screens, levers, buttons and beacons. */
.machine-display {
  position: absolute;
  overflow: hidden;
  border-radius: 5px;
  opacity: .16;
  transition: opacity .22s ease, filter .22s ease;
}
.machine-display::before {
  content: "";
  position: absolute;
  inset: 8% 7%;
  background: repeating-linear-gradient(0deg, transparent 0 12%, rgba(116,233,222,.24) 13% 15%);
  opacity: .45;
}
.display-scan { position: absolute; left: 0; right: 0; top: -12%; height: 7%; background: rgba(174,255,241,.22); transform: translateY(var(--scan-y, 0%)); transition: transform .12s steps(1,end); }
.display-cursor { position: absolute; left: 15%; bottom: 14%; width: 23%; height: 5%; border-radius: 3px; background: rgba(178,255,218,.45); opacity: .46; transition: opacity .1s ease, transform .1s ease; }
.display-signal { position: absolute; bottom: 12%; width: 6%; aspect-ratio: 1; border-radius: 50%; background: #6ee59a; box-shadow: 0 0 5px rgba(110,229,154,.72); }
.signal-a { right: 26%; } .signal-b { right: 16%; } .signal-c { right: 6%; }
.machine-prop.attended .machine-display { opacity: .34; }
.machine-prop.working .machine-display { opacity: .82; filter: brightness(1.2) saturate(1.25); }
.machine-prop.working[data-beat="1"] .display-cursor,
.machine-prop.working[data-beat="3"] .display-cursor,
.machine-prop.working[data-beat="5"] .display-cursor { opacity: .95; transform: scaleX(.58); }
.machine-prop.working[data-beat="2"] .signal-a,
.machine-prop.working[data-beat="3"] .signal-b,
.machine-prop.working[data-beat="4"] .signal-c { opacity: 1; filter: brightness(1.45); }
.machine-display-deploy .display-signal { right: 12%; }
.machine-display-deploy .signal-a { bottom: 68%; } .machine-display-deploy .signal-b { bottom: 43%; } .machine-display-deploy .signal-c { bottom: 18%; }
.machine-display-brain::before { background: radial-gradient(circle at 32% 35%, rgba(110,229,154,.5) 0 3%, transparent 4%), radial-gradient(circle at 65% 52%, rgba(247,189,53,.5) 0 3%, transparent 4%), radial-gradient(circle at 45% 72%, rgba(242,85,56,.5) 0 3%, transparent 4%); transition: filter .1s ease, transform .1s ease; }
.machine-display-projects .display-signal,
.machine-display-deploy .display-signal,
.machine-display-brain .display-signal { display: none; }
.machine-prop.working[data-beat="2"] .machine-display-brain::before,
.machine-prop.working[data-beat="4"] .machine-display-brain::before { filter: brightness(1.55); transform: scale(1.025); }

.machine-part { position: absolute; object-fit: fill; pointer-events: none; }
.machine-prop.working .machine-part { will-change: transform; }
.machine-part-lever { transform-origin: 50% 86%; transition: transform .12s cubic-bezier(.2,.8,.25,1), filter .12s ease; }
.machine-part-lever.is-active { transform: translateY(3%) rotate(-14deg); filter: brightness(1.04); }
.machine-part-lever.is-active.is-reverse { transform: translateY(4%) rotate(14deg); }
.machine-part-button { transform-origin: 50% 82%; transition: transform .09s cubic-bezier(.2,.8,.3,1), filter .09s ease; }
.machine-part-button.is-active { transform: translateY(18%) scaleY(.78); filter: brightness(1.08) saturate(1.06); }
.machine-part-beacon { transform-origin: 50% 100%; animation: beaconIdle 3.7s ease-in-out var(--part-delay) infinite alternate; }
.machine-prop.working .machine-part-beacon { animation: beaconWorking .52s steps(2,end) infinite; }
.machine-contact { position: absolute; width: 1px; height: 1px; translate: -50% -50%; opacity: 0; pointer-events: none; }
@keyframes beaconIdle { to { filter: brightness(1.17) drop-shadow(0 0 3px rgba(91,225,245,.34)); } }
@keyframes beaconWorking { 50% { filter: brightness(1.65) saturate(1.3) drop-shadow(0 0 5px rgba(255,137,82,.72)); } }

/* The window is now a parallax environment rather than baked scenery. */
.environment-window {
  overflow: hidden;
  clip-path: polygon(50% 0, 67% 3%, 82% 12%, 93% 27%, 100% 45%, 100% 84%, 96% 93%, 86% 98%, 70% 100%, 30% 100%, 14% 98%, 4% 93%, 0 84%, 0 45%, 7% 27%, 18% 12%, 33% 3%);
  box-shadow: inset 0 0 18px rgba(29,87,115,.2);
}
.environment-window::after { content: ""; position: absolute; inset: 0; z-index: 8; pointer-events: none; background: linear-gradient(118deg, rgba(255,255,255,.08), transparent 38% 72%, rgba(20,70,98,.08)); }
.environment-part { position: absolute; object-fit: fill; transform-origin: 50% 50%; pointer-events: none; }
.environment-part-city { animation: cityParallax 14s ease-in-out var(--motion-delay) infinite alternate; }
.environment-part-cloud-left { animation: cloudLeft 19s linear var(--motion-delay) infinite; }
.environment-part-cloud-right { animation: cloudRight 23s linear var(--motion-delay) infinite; }
.environment-part-cloud-small { animation: cloudSmall 17s linear var(--motion-delay) infinite; }
.environment-part-blimp { animation: blimpCruise 24s linear var(--motion-delay) infinite; }
@keyframes cityParallax { 0%,100% { transform: translateX(0); opacity: .94; } 50% { transform: translateX(-1.2%); opacity: 1; } }
@keyframes cloudLeft { 0% { transform: translate(-18%, 1%); opacity: 0; } 12% { opacity: .92; } 88% { opacity: .88; } 100% { transform: translate(34%, -2%); opacity: 0; } }
@keyframes cloudRight { 0% { transform: translate(22%, -1%); opacity: 0; } 14% { opacity: .9; } 86% { opacity: .86; } 100% { transform: translate(-31%, 2%); opacity: 0; } }
@keyframes cloudSmall { 0% { transform: translate(28%, 0); opacity: 0; } 16% { opacity: .82; } 84% { opacity: .78; } 100% { transform: translate(-44%, -2%); opacity: 0; } }
@keyframes blimpCruise { 0% { transform: translate(-72%, 5%) rotate(-1deg); opacity: 0; } 9% { opacity: 1; } 48% { transform: translate(-3%, -3%) rotate(.6deg); } 91% { opacity: 1; } 100% { transform: translate(78%, 2%) rotate(-.4deg); opacity: 0; } }

.actor.is-seated-work .actor-shadow { opacity: 0; }
.object-prop.off-camera * { animation-play-state: paused !important; }
.object-prop.off-camera, .object-prop.off-camera * { transition: none !important; }

.actor {
  position: absolute;
  width: 11.72%;
  translate: -50% -91.015625%;
  transform-origin: 50% 91.015625%;
  transform: scale(var(--actor-scale, 1));
  pointer-events: auto;
  cursor: pointer;
  padding: 0;
  border: 0;
  background: transparent;
  transition: filter .15s ease;
}
.scene-prop { position: absolute; pointer-events: none; user-select: none; }
.object-prop {
  --object-energy: 0;
  isolation: isolate;
  transform-origin: 50% 100%;
  transition: filter .35s ease;
}
.object-prop.object-nearby { filter: brightness(1.012) saturate(1.015); }
.object-prop.object-curious { filter: brightness(1.045) saturate(1.035); }
.object-prop.engaged { --object-energy: 1; }
.object-base { position: absolute; inset: 0; width: 100%; height: 100%; transform-origin: 50% 100%; }

/* Every separated painting layer owns a distinct, restrained motion contract. */
.motion-logo-breathe .object-base { animation: logoBreathe 7.8s ease-in-out var(--motion-delay) infinite alternate; }
@keyframes logoBreathe { to { filter: brightness(1.025) saturate(1.018); } }

.motion-paper-sway .object-base { transform-origin: 50% 4%; animation: paperSway 5.7s ease-in-out var(--motion-delay) infinite alternate; }
.motion-paper-sway.engaged .object-base { animation-duration: 2.8s; }
@keyframes paperSway { from { transform: rotate(-.22deg); } to { transform: rotate(.34deg); } }

.motion-fabric-sway .object-base { transform-origin: 51% 4%; animation: fabricSway 4.4s ease-in-out var(--motion-delay) infinite alternate; }
.motion-fabric-sway.engaged .object-base { animation-duration: 2.2s; }
@keyframes fabricSway { from { transform: rotate(-.3deg) skewX(-.18deg); } to { transform: rotate(.48deg) skewX(.22deg); } }

.motion-cushion-settle .object-base { animation: couchBreathe 6.2s ease-in-out var(--motion-delay) infinite; }
.motion-cushion-settle.engaged .object-base { animation: couchSettle 2.1s cubic-bezier(.3,.8,.3,1) infinite; }
@keyframes couchBreathe { 50% { transform: scaleY(.992) translateY(.25%); } }
@keyframes couchSettle { 0%,100% { transform: scaleY(1); } 35% { transform: scaleY(.955) translateY(2.6%); } 62% { transform: scaleY(1.012) translateY(-.5%); } }

.motion-catwalk-glow { overflow: hidden; }
.motion-catwalk-glow .object-base { animation: catwalkBreath 8s ease-in-out var(--motion-delay) infinite alternate; }
.motion-catwalk-glow .object-glint { position: absolute; inset: 0; background: linear-gradient(90deg, transparent 0 42%, rgba(255,224,144,.14) 49%, transparent 56%); transform: translateX(-70%); animation: catwalkSweep 11s ease-in-out var(--motion-delay) infinite; }
.motion-catwalk-glow.engaged .object-glint { animation-duration: 4.8s; }
@keyframes catwalkBreath { to { filter: brightness(1.035); } }
@keyframes catwalkSweep { 0%,58% { transform: translateX(-70%); opacity: 0; } 68% { opacity: 1; } 88%,100% { transform: translateX(70%); opacity: 0; } }

.motion-chair-nudge .object-base { animation: chairRest 7.2s ease-in-out var(--motion-delay) infinite alternate; }
.motion-chair-nudge.engaged .object-base { animation: chairNudge 2.8s cubic-bezier(.25,.8,.3,1) infinite; }
@keyframes chairRest { from { transform: rotate(-.16deg); } to { transform: rotate(.12deg); } }
@keyframes chairNudge { 0%,100% { transform: translateX(0) rotate(0); } 35% { transform: translateX(-1.4%) rotate(-.7deg); } 62% { transform: translateX(.7%) rotate(.35deg); } }

.motion-chair-swivel .object-base { animation: chairSwivelRest 8.5s ease-in-out var(--motion-delay) infinite alternate; }
.motion-chair-swivel.engaged .object-base { animation: chairSwivel 3.6s ease-in-out infinite; }
@keyframes chairSwivelRest { from { transform: rotate(-.2deg); } to { transform: rotate(.24deg); } }
@keyframes chairSwivel { 0%,100% { transform: translateX(0) rotate(-.5deg); } 45% { transform: translateX(1.2%) rotate(1.35deg); } 72% { transform: translateX(-.5%) rotate(-.8deg); } }

.motion-stool-bounce .object-base { animation: stoolIdle 5.8s ease-in-out var(--motion-delay) infinite; }
.motion-stool-bounce.engaged .object-base { animation: stoolEngaged 2.2s cubic-bezier(.35,.75,.35,1) infinite; }
@keyframes stoolIdle { 50% { transform: translateY(-.45%); } }
@keyframes stoolEngaged { 0%,100% { transform: translateY(0) scaleY(1); } 42% { transform: translateY(1.4%) scaleY(.975); } 68% { transform: translateY(-.8%) scaleY(1.01); } }

.motion-steam .object-base { animation: mugWarm 6s ease-in-out var(--motion-delay) infinite alternate; }
@keyframes mugWarm { to { filter: brightness(1.025); } }
.steam-wisp { position: absolute; z-index: 2; left: 51%; top: -5%; width: 9%; height: 34%; border-left: 2px solid rgba(255,249,232,.58); border-radius: 50%; opacity: .22; filter: blur(.5px); transform-origin: 50% 100%; animation: steamRise 3.4s ease-in-out infinite; }
.steam-wisp-1 { left: 59%; animation-delay: -1.15s; animation-duration: 3.8s; }
.steam-wisp-2 { left: 44%; animation-delay: -2.3s; animation-duration: 4.1s; }
.motion-steam.engaged .steam-wisp { opacity: .46; animation-duration: 2.45s; }
@keyframes steamRise { 0% { transform: translateY(38%) translateX(0) scale(.65); opacity: 0; } 24% { opacity: .34; } 64% { transform: translateY(-34%) translateX(45%) scale(1); } 100% { transform: translateY(-78%) translateX(-25%) scale(.72); opacity: 0; } }

.motion-bowl-shimmer { overflow: visible; }
.motion-bowl-shimmer .object-base { animation: bowlIdle 5s ease-in-out var(--motion-delay) infinite alternate; }
.motion-bowl-shimmer .object-glint { position: absolute; left: 29%; top: 28%; width: 47%; height: 27%; border-radius: 50%; background: radial-gradient(ellipse, rgba(255,244,185,.42), transparent 68%); opacity: .16; animation: bowlGlint 4.7s ease-in-out var(--motion-delay) infinite; }
.motion-bowl-shimmer.engaged .object-base { animation: bowlNibble 1.15s ease-in-out infinite; }
.motion-bowl-shimmer.engaged .object-glint { opacity: .52; animation-duration: 1.5s; }
@keyframes bowlIdle { to { filter: brightness(1.02); } }
@keyframes bowlGlint { 50% { transform: translateX(5%) scale(1.08); opacity: .38; } }
@keyframes bowlNibble { 50% { transform: translateY(.8%) scaleX(1.008); } }

.motion-fish-flop .object-base { transform-origin: 17% 65%; animation: fishBreathe 4.8s ease-in-out var(--motion-delay) infinite; }
.motion-fish-flop.engaged .object-base { animation: fishFlop 1.7s cubic-bezier(.35,.75,.35,1) infinite; }
@keyframes fishBreathe { 50% { transform: rotate(.55deg) translateY(-.4%); } }
@keyframes fishFlop { 0%,100% { transform: rotate(0) translateY(0); } 28% { transform: rotate(-4deg) translateY(-3%); } 52% { transform: rotate(3deg) translateY(-1%); } 72% { transform: rotate(-1.2deg); } }

.motion-paper-flutter .object-base { transform-origin: 50% 100%; animation: easelIdle 7s ease-in-out var(--motion-delay) infinite alternate; }
.motion-paper-flutter .object-glint { position: absolute; left: 18%; top: 7%; width: 65%; height: 62%; border-radius: 3px; box-shadow: inset -3px 0 7px rgba(255,255,255,.08); transform-origin: 50% 7%; animation: pageLift 5.3s ease-in-out var(--motion-delay) infinite; }
.motion-paper-flutter.engaged .object-base { animation-duration: 3.2s; }
.motion-paper-flutter.engaged .object-glint { animation-duration: 2.3s; }
@keyframes easelIdle { to { transform: rotate(.18deg); } }
@keyframes pageLift { 50% { transform: skewY(.25deg) scaleX(.992); box-shadow: inset -6px 0 10px rgba(255,255,255,.16); } }

.motion-plant-sway .object-base { transform-origin: 50% 94%; animation: plantSway 6.4s ease-in-out var(--motion-delay) infinite alternate; }
.motion-plant-sway.engaged .object-base { animation-duration: 3.1s; }
@keyframes plantSway { from { transform: rotate(-.28deg) skewX(-.18deg); } to { transform: rotate(.38deg) skewX(.22deg); } }

.motion-robot-bob .object-base { animation: robotBob 5.2s ease-in-out var(--motion-delay) infinite; }
.motion-robot-bob.engaged .object-base { animation-duration: 2.4s; }
@keyframes robotBob { 0%,100% { transform: translateY(0) rotate(0); } 48% { transform: translateY(-.65%) rotate(.22deg); } 58% { transform: translateY(-.55%) rotate(-.16deg); } }

.motion-shelf-hum .object-base { animation: shelfHum 7.3s ease-in-out var(--motion-delay) infinite alternate; }
.motion-shelf-hum.engaged .object-base { animation-duration: 3s; }
@keyframes shelfHum { to { filter: brightness(1.025) saturate(1.015); transform: translateY(-.18%); } }

.motion-research-pulse .object-base { animation: researchPulse 6.6s ease-in-out var(--motion-delay) infinite alternate; }
.motion-research-pulse.engaged .object-base { animation-duration: 2.7s; }
@keyframes researchPulse { to { filter: brightness(1.035) saturate(1.025); } }

.motion-bench-settle .object-base { animation: benchIdle 7.8s ease-in-out var(--motion-delay) infinite alternate; }
.motion-bench-settle.engaged .object-base { animation: benchSettle 2.5s cubic-bezier(.3,.8,.3,1) infinite; }
@keyframes benchIdle { to { filter: brightness(1.015); transform: scaleY(.997); } }
@keyframes benchSettle { 0%,100% { transform: scaleY(1); } 42% { transform: scaleY(.982) translateY(1.1%); } 70% { transform: scaleY(1.004) translateY(-.2%); } }

.motion-control-console .object-base { transform-origin: 50% 92%; animation: controlConsoleIdle 5.9s ease-in-out var(--motion-delay) infinite alternate; }
.motion-control-console.engaged .object-base { animation: controlConsoleWork 1.8s steps(3,end) infinite; }
@keyframes controlConsoleIdle { to { filter: brightness(1.025) saturate(1.02); } }
@keyframes controlConsoleWork { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.12) saturate(1.08); transform: translateY(-.25%); } }
.elevator-system {
  transform-origin: 50% 100%;
  transition: filter .25s ease;
  filter: drop-shadow(0 8px 7px rgba(11,24,34,.22));
  overflow: visible;
}
.elevator-shell { position: absolute; inset: 0; width: 100%; height: 100%; animation: elevatorStandby 5.5s ease-in-out var(--motion-delay) infinite alternate; }
@keyframes elevatorStandby { to { filter: brightness(1.035) saturate(1.025); } }
.elevator-passenger-window {
  position: absolute;
  z-index: 1;
  left: 15%;
  top: 25%;
  width: 70%;
  height: 55%;
  overflow: hidden;
  border-radius: 9px 9px 15px 15px;
  opacity: 0;
  transition: opacity .18s ease;
}
.elevator-system.occupied .elevator-passenger-window { opacity: 1; }
.elevator-passenger-sprite {
  position: absolute;
  left: 50%;
  bottom: -8%;
  width: 205%;
  aspect-ratio: 1;
  translate: -50% 0;
  background-repeat: no-repeat;
  filter: brightness(1.18) saturate(1.08) drop-shadow(0 0 4px rgba(255,238,174,.68));
}
.elevator-door {
  position: absolute;
  z-index: 2;
  top: 25.5%;
  bottom: 21.5%;
  width: 26.5%;
  border: 1px solid rgba(232,181,95,.72);
  background: linear-gradient(90deg, rgba(18,52,61,.38), rgba(83,128,128,.22));
  box-shadow: inset 0 0 0 1px rgba(9,24,34,.62);
  transition: transform .42s cubic-bezier(.65,0,.25,1), opacity .32s ease;
}
.door-left { left: 23.5%; border-radius: 10px 1px 1px 10px; transform-origin: right center; }
.door-right { right: 23.5%; border-radius: 1px 10px 10px 1px; transform-origin: left center; }
.elevator-system.doors-open .door-left { transform: translateX(-68%) scaleX(.28); opacity: .25; }
.elevator-system.doors-open .door-right { transform: translateX(68%) scaleX(.28); opacity: .25; }
.elevator-system.traveling {
  filter: drop-shadow(0 10px 9px rgba(11,24,34,.30)) brightness(1.04);
}
.actor.in-elevator {
  opacity: 1;
  pointer-events: none;
  filter: brightness(1.12) saturate(1.04) drop-shadow(0 0 4px rgba(255,238,174,.48));
}
.actor.in-elevator .actor-shadow { opacity: 0; }
.actor:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; border-radius: 40%; }
.actor-shadow {
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 91.015625%;
  width: 52%;
  height: 10%;
  translate: -50% -48%;
  transform: scale(var(--shadow-scale, 1));
  border-radius: 50%;
  background: rgba(26,27,25,var(--shadow-opacity, .24));
  filter: blur(1px);
}
.actor:hover:not(.in-elevator), .actor.nearby:not(.in-elevator) { filter: brightness(1.05); }
.actor-sprite {
  width: 100%;
  background-repeat: no-repeat;
  image-rendering: auto;
  transform-origin: 50% 100%;
  transform: translate(var(--sprite-sway, 0), calc(var(--sprite-bob, 0px) + var(--sprite-lift, 0%) + var(--operator-lift, 0%))) rotate(var(--sprite-tilt, 0deg)) scale(var(--sprite-flip, 1), var(--sprite-breathe, 1));
}
.actor.is-settling .actor-sprite { transition: transform .22s cubic-bezier(.22,.75,.24,1); }
.actor.is-seated-work .actor-sprite { transition: transform .13s cubic-bezier(.2,.75,.25,1); }
.actor.is-idle .actor-sprite,
.actor.is-typing .actor-sprite,
.actor.is-thinking .actor-sprite,
.actor.is-sleeping .actor-sprite,
.actor.is-happy .actor-sprite { animation: none; }
.actor.facing-left .actor-sprite { --sprite-flip: -1; }
.actor.selected::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3%;
  width: 58%;
  height: 12%;
  translate: -50% 50%;
  border: 3px solid var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--ink);
  animation: selectRing 1s ease-in-out infinite alternate;
}
@keyframes selectRing { to { transform: scale(1.12); opacity: .7; } }

.occluder { position: absolute; pointer-events: none; user-select: none; }
.cursor-spark {
  position: absolute;
  z-index: 950;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid var(--orange);
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(242,85,56,.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.stage.pointer-active .cursor-spark { opacity: 1; }

.speech {
  position: absolute;
  max-width: 230px;
  translate: -50% -100%;
  padding: 10px 13px;
  border: 3px solid var(--ink);
  border-radius: 15px 15px 15px 4px;
  background: var(--paper);
  box-shadow: 5px 6px 0 rgba(16,25,46,.19);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.25;
  animation: speechIn .22s cubic-bezier(.2,.9,.2,1.25) both;
}
.speech::after { content: ""; position: absolute; left: 22px; bottom: -11px; width: 15px; height: 15px; background: var(--paper); border-right: 3px solid var(--ink); border-bottom: 3px solid var(--ink); transform: rotate(45deg); }
.speech b { display: block; margin-bottom: 3px; color: var(--orange); font: 900 10px/1 "JetBrains Mono", monospace; letter-spacing: .07em; text-transform: uppercase; }
@keyframes speechIn { from { opacity: 0; transform: translateY(8px) scale(.85); } }

.mission-card {
  position: absolute;
  z-index: 800;
  left: 1.5%;
  bottom: 2%;
  display: grid;
  gap: 2px;
  width: min(290px, 27%);
  padding: 12px 14px;
  color: var(--cream);
  background: rgba(16,25,46,.91);
  border: 2px solid var(--cream);
  border-radius: 12px;
  box-shadow: 5px 6px 0 rgba(0,0,0,.2);
}
.mission-label { color: var(--gold); font: 800 9px/1 "JetBrains Mono", monospace; letter-spacing: .1em; }
.mission-card strong { font-size: clamp(12px, 1.15vw, 17px); }
.mission-card > span:last-child { opacity: .8; font-size: clamp(9px, .85vw, 12px); }
.hint {
  position: absolute;
  z-index: 810;
  right: 2%;
  top: 2%;
  bottom: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: rgba(255,249,232,.9);
  font-size: clamp(10px, .9vw, 13px);
  font-weight: 900;
  transition: opacity .25s;
}
.hint-mouse { color: var(--orange); font-size: 18px; animation: nudge 1s ease-in-out infinite alternate; }
@keyframes nudge { to { transform: translate(-4px,-4px); } }

.chat-dock {
  position: fixed;
  z-index: 2000;
  right: 22px;
  bottom: 22px;
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr) auto auto;
  width: min(390px, calc(100vw - 28px));
  height: min(510px, calc(100vh - 92px));
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 12px 14px 0 rgba(16,25,46,.32);
  animation: dockIn .28s cubic-bezier(.2,.9,.2,1.15) both;
}
.chat-dock[hidden] { display: none; }
@keyframes dockIn { from { opacity: 0; transform: translateY(22px) scale(.94); } }
.chat-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 14px 15px; color: var(--cream); background: var(--ink); }
.chat-head > div { display: grid; grid-template-columns: auto auto; align-items: center; gap: 3px 10px; }
.chat-kicker { grid-column: 1 / -1; color: var(--gold); font: 800 9px/1 "JetBrains Mono", monospace; letter-spacing: .12em; }
.chat-head strong { font-family: "Archivo Black", sans-serif; font-size: 19px; }
.chat-status { display: inline-flex; align-items: center; gap: 6px; font: 700 10px/1 "JetBrains Mono", monospace; opacity: .9; }
.chat-head button { border: 0; color: var(--cream); background: transparent; font-size: 28px; line-height: .8; cursor: pointer; }
.chat-log { display: flex; flex-direction: column; gap: 9px; overflow-y: auto; padding: 14px; background: linear-gradient(rgba(255,255,255,.72), rgba(255,244,206,.65)); }
.msg { max-width: 84%; padding: 9px 11px; border: 2px solid var(--ink); border-radius: 12px; font-size: 13px; font-weight: 700; line-height: 1.35; }
.msg.cat { align-self: flex-start; background: #fff; border-bottom-left-radius: 3px; }
.msg.user { align-self: flex-end; color: #fff; background: var(--teal); border-bottom-right-radius: 3px; }
.msg.system { align-self: center; padding: 5px 8px; border-width: 1px; border-style: dashed; background: var(--cream); font: 700 9px/1.2 "JetBrains Mono", monospace; text-transform: uppercase; opacity: .8; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 11px; border-top: 3px solid var(--ink); background: #fff; }
.chat-form input { min-width: 0; padding: 10px 11px; border: 2px solid var(--ink); border-radius: 8px; outline: none; }
.chat-form input:focus { box-shadow: 0 0 0 3px var(--gold); }
.chat-form button { padding: 0 14px; border: 2px solid var(--ink); border-radius: 8px; background: var(--orange); color: #fff; font: 900 11px/1 "JetBrains Mono", monospace; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); }
.chat-form button:active { translate: 2px 2px; box-shadow: 1px 1px 0 var(--ink); }
.chat-note { margin: 0; padding: 6px 10px 8px; text-align: center; color: rgba(16,25,46,.64); background: #fff; font: 700 8px/1 "JetBrains Mono", monospace; text-transform: uppercase; }
.mobile-camera { display: none; }

@media (max-width: 760px) {
  .world-shell { grid-template-rows: 56px minmax(0,1fr); }
  .game-bar { padding: 0 10px; gap: 8px; }
  .cat-mark { width: 44px; height: 44px; }
  .wordmark span:last-child { display: none; }
  .world-state { font-size: 9px; padding: 6px 8px; }
  .sound-toggle, .map-toggle { min-height: 44px; font-size: 9px; padding: 7px 8px; }
  .viewport { align-content: start; }
  .stage {
    width: calc((100dvh - 108px) * 1.5);
    min-width: 100vw;
    max-width: none;
    height: calc(100dvh - 108px);
    max-height: none;
  }
  .viewport { display: block; place-items: start; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; touch-action: pan-x; padding-bottom: 52px; box-sizing: border-box; }
  .mission-card { position: fixed; left: 50%; top: 64px; bottom: auto; translate: -50% 0; width: min(230px, 58vw); padding: 7px 9px; pointer-events: none; }
  .mission-card > span:last-child { display: none; }
  .hint { display: none; }
  .chat-dock { right: 7px; bottom: max(7px, env(safe-area-inset-bottom)); height: min(410px, 48dvh); }
  body:has(.chat-dock:not([hidden])) .mission-card { display: none; }
  .mobile-camera {
    position: fixed;
    z-index: 1300;
    right: 8px;
    bottom: max(4px, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 5px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: rgba(255,249,232,.92);
    box-shadow: 3px 4px 0 rgba(16,25,46,.2);
  }
  .mobile-camera [data-camera] { position: relative; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; margin: -3px; }
  .mobile-camera [data-camera]::after { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; translate: -50% -50%; border: 2px solid var(--ink); border-radius: 50%; background: #fff; }
  .mobile-camera [data-camera].active::after { background: var(--orange); }
  .camera-recenter { min-height: 44px; padding: 0 10px; border: 0; border-left: 1px solid rgba(16,25,46,.25); background: transparent; font: 900 9px/1 "JetBrains Mono", monospace; }
  .mobile-camera span { position: absolute; right: 0; bottom: calc(100% + 7px); white-space: nowrap; padding: 5px 7px; border-radius: 7px; color: var(--cream); background: rgba(16,25,46,.9); font: 800 8px/1 "JetBrains Mono", monospace; animation: swipeHintOut .4s ease 5s both; }
  @keyframes swipeHintOut { to { opacity: 0; visibility: hidden; } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
