/* Short, replayable cutout animations. The first response reads inside one second. */
.station-stage {
  --st-paint:#8bc6b4;
  position:relative;
  isolation:isolate;
  width:100%;
  height:clamp(94px,14vh,134px);
  margin:5px 0 10px;
  overflow:hidden;
  border:2px solid #344e5a;
  border-radius:5px;
  box-shadow:0 2px 0 #70867e;
  background:
    linear-gradient(90deg,transparent 0 3%,#77918b26 3% 3.3%,transparent 3.3% 96.7%,#77918b26 96.7% 97%,transparent 97%),
    repeating-linear-gradient(120deg,#1f3b4b 0 9px,#233f4e 9px 16px);
  pointer-events:none;
}
.station-stage svg {display:block;width:100%;height:100%}
.station-stage:before,.station-stage:after {
  content:"";
  position:absolute;z-index:1;top:5px;bottom:5px;width:5px;
  background:radial-gradient(circle at 50% 3px,#d2ba8b 0 1px,#49636b 1.3px 2px,transparent 2.3px),
             radial-gradient(circle at 50% calc(100% - 3px),#d2ba8b 0 1px,#49636b 1.3px 2px,transparent 2.3px);
}
.station-stage:before{left:4px}.station-stage:after{right:4px}
.st-state-check,.st-state-cross,.st-route-number,.st-plume,.st-connect-flare,.st-vent,.st-reveal-sign,.st-current,.st-diverted-drops{opacity:0}
.st-number-mask,.st-state-wait{opacity:1}
.station-stage[data-state="pre"] .st-signal-green,.station-stage[data-state="wrong"] .st-signal-green,.station-stage[data-state="recover"] .st-signal-green{fill:#52736c}
.station-stage[data-state="pre"] .st-signal-red{fill:#dca461}
.station-stage[data-state="ready"] .st-signal-green,.station-stage[data-state="hint"] .st-signal-green{fill:#a5c197}
.station-stage:is([data-state="correct"],[data-state="board"]) .st-state-check{opacity:1}
.station-stage:is([data-state="correct"],[data-state="board"]) .st-state-wait,.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-state-wait{opacity:0}
.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-state-cross{opacity:1}
.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-signal-red{fill:#fc8a70}
.station-stage:is([data-state="correct"],[data-state="board"]) .st-signal-green{fill:#adf0b9}
.station-stage[data-state="hint"] .st-state-wait{stroke:#ffdc90;stroke-width:3.5}
.station-stage[data-state="pre"] .st-cloud{animation:st-cloud-arrive 2s ease-out both}
@keyframes st-cloud-arrive{from{transform:translateX(-5px)}to{transform:translateX(0)}}
.station-stage[data-state="hint"] .st-shape-sign{stroke:#fff2b5;opacity:1}
.station-stage[data-state="recover"] .st-shape-sign{opacity:1}

/* Tunnel shutter rises before the head car reaches the portal. */
.st-shutter {transform:translateY(0)}
.station-stage[data-state="pre"] .st-tunnel-train {animation:st-park .58s ease-out both}
.station-stage[data-state="correct"] .st-shutter {animation:st-open-shutter .44s cubic-bezier(.18,.8,.28,1) both}
.station-stage[data-state="correct"] .st-tunnel-train {animation:st-dive 1.04s cubic-bezier(.44,.02,.7,.95) both}
.station-stage[data-state="correct"] .st-reveal-sign{opacity:1}
.station-stage[data-state="wrong"] .st-tunnel-train,
.station-stage[data-state="recover"] .st-tunnel-train {animation:st-buffer-stop .62s ease-out both}
.station-stage[data-state="wrong"] .st-shutter {animation:st-shutter-lock .45s ease both}
@keyframes st-park{from{transform:translateX(-23px)}to{transform:translateX(0)}}
@keyframes st-open-shutter{0%{transform:translateY(0);opacity:1}85%{transform:translateY(-42px);opacity:.7}100%{transform:translateY(-46px);opacity:0}}
@keyframes st-dive{0%,12%{transform:translateX(0);opacity:1}66%{opacity:1}100%{transform:translateX(333px) scale(.78,.86);opacity:0}}
@keyframes st-buffer-stop{0%{transform:translateX(0)}26%{transform:translateX(11px)}60%{transform:translateX(-5px)}100%{transform:translateX(-3px)}}
@keyframes st-shutter-lock{0%{transform:translateY(-4px)}55%{transform:translateY(2px)}100%{transform:translateY(0)}}

/* Loading sequence: lift, traverse on overhead rail, lower into wagon. */
.station-stage[data-state="pre"] .st-lift {animation:st-hook-descend .57s ease-out both}
.station-stage:is([data-state="correct"],[data-state="board"]) .st-crane-route{animation:st-gantry-run .94s cubic-bezier(.25,.05,.4,1) both}
.station-stage:is([data-state="correct"],[data-state="board"]) .st-lift{animation:st-hoist-deliver .94s ease-in-out both}
.station-stage:is([data-state="correct"],[data-state="board"]) .st-load{animation:st-load-settle .94s ease-out both;transform-origin:0 30px}
.station-stage[data-state="correct"] .st-wagon{animation:st-wagon-release 1.09s ease-in both}
.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-crane-route{animation:st-gantry-return .68s ease-out both}
.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-load{animation:st-crate-swing .68s ease-out both;transform-origin:0 30px}
@keyframes st-hook-descend{from{transform:translateY(-10px)}to{transform:translateY(0)}}
@keyframes st-gantry-run{0%,18%{transform:translateX(0)}78%,100%{transform:translateX(143px)}}
@keyframes st-hoist-deliver{0%{transform:translateY(0)}22%,72%{transform:translateY(-12px)}100%{transform:translateY(-6px)}}
@keyframes st-load-settle{0%,73%{transform:rotate(0)}84%{transform:rotate(5deg)}100%{transform:rotate(0)}}
@keyframes st-wagon-release{0%,84%{transform:translateX(0)}100%{transform:translateX(8px)}}
@keyframes st-gantry-return{0%{transform:translateX(0)}42%{transform:translateX(32px)}100%{transform:translateX(0)}}
@keyframes st-crate-swing{0%{transform:rotate(0)}35%{transform:rotate(9deg)}71%{transform:rotate(-6deg)}100%{transform:rotate(0)}}

/* Bascule repair swings on a fixed pin. The train only moves after rails join. */
.st-drawbridge{transform-origin:270px 100px;transform:rotate(-31deg)}
.station-stage[data-state="pre"] .st-drawbridge{animation:st-bridge-break .65s ease-out both}
.station-stage[data-state="correct"] .st-drawbridge{animation:st-bridge-close .54s cubic-bezier(.3,.04,.6,1) both}
.station-stage[data-state="correct"] .st-connect-flare{animation:st-spark .92s ease both}
.station-stage[data-state="correct"] .st-bridge-train{animation:st-bridge-go 1.06s ease-in-out both}
.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-drawbridge{animation:st-bridge-check .61s ease both}
.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-bridge-train{animation:st-buffer-stop .61s ease both}
@keyframes st-bridge-break{from{transform:rotate(-17deg)}to{transform:rotate(-31deg)}}
@keyframes st-bridge-close{0%{transform:rotate(-31deg)}78%{transform:rotate(1.2deg)}100%{transform:rotate(0)}}
@keyframes st-bridge-check{0%{transform:rotate(-31deg)}42%{transform:rotate(-15deg)}100%{transform:rotate(-31deg)}}
@keyframes st-bridge-go{0%,45%{transform:translateX(0)}100%{transform:translateX(236px)}}
@keyframes st-spark{0%,40%{opacity:0}52%,64%{opacity:1}100%{opacity:0}}

/* Nozzle tests a stroke over the carriage; rejected paint runs into the catch pan. */
.st-spray-arm{transform-origin:0 0}
.station-stage[data-mode="colorPick"][data-state="pre"] .st-spray-arm{animation:st-arm-inspect .65s ease-out both}
.station-stage[data-mode="colorPick"][data-state="correct"] .st-spray-arm{animation:st-arm-sweep .78s ease-in-out both}
.station-stage[data-mode="colorPick"][data-state="correct"] .st-plume{animation:st-mist .82s ease both}
.station-stage[data-mode="colorPick"][data-state="correct"] .st-shell{animation:st-paint-dry .65s ease both}
.station-stage[data-mode="colorPick"][data-state="correct"] .st-painted-train{animation:st-booth-exit 1.08s ease-in both}
.station-stage[data-mode="colorPick"]:is([data-state="wrong"],[data-state="recover"]) .st-spray-arm{animation:st-arm-divert .65s ease both}
.station-stage[data-mode="colorPick"]:is([data-state="wrong"],[data-state="recover"]) .st-painted-train{animation:st-buffer-stop .65s ease-out both}
.station-stage[data-mode="colorPick"]:is([data-state="wrong"],[data-state="recover"]) .st-diverted-drops{animation:st-waste-catch .65s ease-in both}
@keyframes st-waste-catch{0%,30%{opacity:0;transform:translate(-4px,-7px)}48%{opacity:1}90%{opacity:.8}100%{opacity:0;transform:translate(2px,12px)}}
@keyframes st-arm-inspect{from{transform:rotate(-18deg)}to{transform:rotate(0)}}
@keyframes st-arm-sweep{0%{transform:translateX(0) rotate(0)}26%{transform:translateX(-21px) rotate(12deg)}62%{transform:translateX(16px) rotate(-13deg)}100%{transform:translateX(0) rotate(0)}}
@keyframes st-mist{0%,12%{opacity:0}28%{opacity:.95}69%{opacity:.85}89%,100%{opacity:0}}
@keyframes st-paint-dry{0%,30%{fill:#f2ead3}100%{fill:var(--st-paint)}}
@keyframes st-booth-exit{0%,57%{transform:translateX(0)}100%{transform:translateX(95px)}}
@keyframes st-arm-divert{0%{transform:translateX(0) rotate(0)}50%,73%{transform:translateX(52px) rotate(-48deg)}100%{transform:translateX(16px) rotate(-16deg)}}

/* Platform doors, boarding passengers and the turnstile share one handoff timing. */
.st-passenger-coat{fill:var(--st-paint)}
.station-stage:is([data-mode="colorSort"],[data-mode="numCount"]):is([data-state="correct"],[data-state="board"]) .st-door-left{animation:st-door-left .32s ease-out both}
.station-stage:is([data-mode="colorSort"],[data-mode="numCount"]):is([data-state="correct"],[data-state="board"]) .st-door-right{animation:st-door-right .32s ease-out both}
.station-stage:is([data-mode="colorSort"],[data-mode="numCount"]):is([data-state="wrong"],[data-state="recover"]) .st-door-left{animation:st-lock-left .52s ease both}
.station-stage:is([data-mode="colorSort"],[data-mode="numCount"]):is([data-state="wrong"],[data-state="recover"]) .st-door-right{animation:st-lock-right .52s ease both}
.station-stage[data-state="pre"] .st-rider-move{animation:st-queue .47s ease-out both}
.station-stage:is([data-state="correct"],[data-state="board"]) .st-rider-move{animation:st-rider-in .92s ease-in-out both}
.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-rider-move{animation:st-please-wait .61s ease both}
.station-stage:is([data-state="correct"],[data-state="board"]) .st-rice-boarder{animation:st-onigiri-in .84s ease-in-out both}
.station-stage[data-state="board"][data-board-direction="out"] .st-rice-boarder{animation:st-onigiri-out .72s ease-in-out both}
.station-stage[data-state="correct"] .st-rice-follow{animation:st-onigiri-follow 1.04s ease-in both}
.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-rice-boarder{animation:st-please-wait .58s ease both}
.st-ticket-flap{transform-origin:2px -21px}
.station-stage[data-mode="numCount"][data-state="pre"] .st-ticket-flap{animation:st-flap-open .72s ease both}
.station-stage[data-mode="numCount"][data-state="pre"] .st-rice-boarder{animation:st-queue .52s ease-out both}
.station-stage:is([data-state="correct"],[data-state="board"]) .st-ticket-flap{animation:st-flap-open .77s ease both}
.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-ticket-flap{animation:st-flap-lock .53s ease both}
@keyframes st-door-left{from{transform:translateX(0)}to{transform:translateX(-11px)}}
@keyframes st-door-right{from{transform:translateX(0)}to{transform:translateX(11px)}}
@keyframes st-lock-left{0%{transform:translateX(-8px)}47%,100%{transform:translateX(0)}}
@keyframes st-lock-right{0%{transform:translateX(8px)}47%,100%{transform:translateX(0)}}
@keyframes st-queue{from{transform:translate(-8px,-1px)}to{transform:translate(0)}}
@keyframes st-rider-in{0%,10%{transform:translate(0);opacity:1}36%{transform:translate(52px,-3px)}59%{transform:translate(107px,0)}80%{transform:translate(144px,-3px);opacity:1}100%{transform:translate(165px,-2px) scale(.84);opacity:0}}
@keyframes st-please-wait{0%{transform:translate(0)}33%{transform:translate(18px,-2px)}100%{transform:translate(-8px,0)}}
@keyframes st-onigiri-in{0%{transform:translate(0);opacity:1}32%{transform:translate(46px,-6px)}48%{transform:translate(75px,-2px)}77%{transform:translate(132px,-8px);opacity:1}100%{transform:translate(178px,-14px) scale(.82);opacity:0}}
@keyframes st-onigiri-follow{0%,18%{transform:translate(0);opacity:1}49%{transform:translate(63px,-5px)}83%{transform:translate(160px,-6px);opacity:1}100%{transform:translate(201px,-14px) scale(.82);opacity:0}}
@keyframes st-onigiri-out{0%{transform:translate(178px,-14px) scale(.82);opacity:0}18%{opacity:1}63%{transform:translate(73px,-4px)}100%{transform:translate(0);opacity:1}}
@keyframes st-flap-open{0%{transform:rotate(0)}35%,75%{transform:rotate(-59deg)}100%{transform:rotate(0)}}
@keyframes st-flap-lock{0%{transform:rotate(-23deg)}40%,100%{transform:rotate(0)}}

/* Electrical filling is directional; a rejected can sends the pulse backwards. */
.st-turbine{transform-origin:166px 76px}
.st-charge{fill:#405c63}
.st-cell-low{fill:#719b8a}
.station-stage[data-state="pre"] .st-turbine{animation:st-turbine-wake .72s ease-out both}
.station-stage[data-state="correct"] .st-current{animation:st-current-on .82s linear both}
.station-stage[data-state="correct"] .st-turbine{animation:st-turbine-boost .90s ease-in-out both}
.station-stage[data-state="correct"] .st-charge{animation:st-cell-on .23s ease both}
.station-stage[data-state="correct"] .st-cell-low{animation-delay:.16s}
.station-stage[data-state="correct"] .st-cell-mid{animation-delay:.31s}
.station-stage[data-state="correct"] .st-cell-top{animation-delay:.46s}
.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-current{animation:st-current-return .64s linear both}
.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-vent{animation:st-valve-open .64s ease both}
.station-stage:is([data-state="wrong"],[data-state="recover"]) .st-cell-low{fill:#996b5c}
@keyframes st-current-on{0%{stroke-dashoffset:50;opacity:0}15%{opacity:1}82%{opacity:1}100%{stroke-dashoffset:-61;opacity:.55}}
@keyframes st-current-return{0%{stroke-dashoffset:-45;opacity:0;stroke:#ffa47f}22%{opacity:.88}100%{stroke-dashoffset:52;opacity:0;stroke:#ffa47f}}
@keyframes st-turbine-wake{from{transform:rotate(-23deg)}to{transform:rotate(0)}}
@keyframes st-turbine-boost{from{transform:rotate(0)}to{transform:rotate(310deg)}}
@keyframes st-cell-on{from{fill:#405c63}to{fill:#a5dbae}}
@keyframes st-valve-open{0%,16%{opacity:0}45%,68%{opacity:.9}100%{opacity:0}}

/* Switch blades move first. The train follows a different visible platform track. */
.st-points{transform-origin:0 0;transform:rotate(-4deg)}
.station-stage[data-mode="numPick"][data-state="pre"] .st-switch-train{animation:st-park .56s ease-out both}
.station-stage[data-mode="numPick"][data-state="correct"] .st-points{animation:st-set-upper .32s ease both}
.station-stage[data-mode="numPick"][data-state="correct"][data-branch="lower"] .st-points{animation:st-set-lower .32s ease both}
.station-stage[data-mode="numPick"][data-state="correct"] .st-switch-train{animation:st-route-upper 1.0s ease-in-out both;transform-origin:50px 24px}
.station-stage[data-mode="numPick"][data-state="correct"][data-branch="lower"] .st-switch-train{animation:st-route-lower 1.0s ease-in-out both}
.station-stage[data-mode="numPick"]:is([data-state="wrong"],[data-state="recover"]) .st-switch-train{animation:st-buffer-stop .58s ease both}
.station-stage[data-mode="numPick"]:is([data-state="wrong"],[data-state="recover"]) .st-points{animation:st-switch-block .58s ease both}
.station-stage[data-mode="numPick"][data-state="correct"] .st-route-number{opacity:1}
.station-stage[data-mode="numPick"][data-state="correct"] .st-number-mask{opacity:0}
@keyframes st-set-upper{from{transform:rotate(-4deg)}to{transform:rotate(-16deg)}}
@keyframes st-set-lower{from{transform:rotate(-4deg)}to{transform:rotate(4deg)}}
@keyframes st-switch-block{0%{transform:rotate(-4deg)}50%{transform:rotate(-10deg)}100%{transform:rotate(-4deg)}}
@keyframes st-route-upper{0%,12%{transform:translate(0)}50%{transform:translate(147px,0)}78%{transform:translate(235px,-26px) rotate(-11deg)}100%{transform:translate(332px,-39px)}}
@keyframes st-route-lower{0%,12%{transform:translate(0)}50%{transform:translate(147px,0)}82%{transform:translate(253px,7px) rotate(3deg)}100%{transform:translate(333px,11px)}}

@media(max-width:560px){.station-stage{height:clamp(72px,11vh,100px);margin:3px 0 6px}}
@media(max-height:560px) and (orientation:landscape){.station-stage{height:clamp(54px,12vh,68px);margin:2px 0 4px;border-width:1px}}
.calm .station-stage *{animation-duration:.001ms!important;animation-delay:0s!important;animation-iteration-count:1!important;transition:none!important}
@media(prefers-reduced-motion:reduce){.station-stage *{animation-duration:.001ms!important;animation-delay:0s!important;animation-iteration-count:1!important;transition:none!important}}
