*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}html,body{touch-action:none;overscroll-behavior:none;margin:0;width:100%;height:100%;overflow:hidden;background:#b4d6d8;color:#244640;font:15px system-ui,sans-serif}button{-webkit-tap-highlight-color:transparent;font:inherit;cursor:pointer;border:0;color:inherit}*:focus,*:focus-visible{outline:none}#world{position:fixed;inset:0;width:100%;height:100%;touch-action:none}#topline{position:fixed;top:max(20px,env(safe-area-inset-top));right:max(24px,env(safe-area-inset-right));font-size:32px;font-weight:900;font-variant-numeric:tabular-nums;color:white;text-shadow:0 2px 3px #36534560;pointer-events:none}#labels{position:fixed;inset:0;pointer-events:none}.label{position:absolute;transform:translate(-50%,-50%);white-space:nowrap}.station-label,#tip,#traffic{display:none!important}dialog{position:fixed;inset:0;margin:auto;border:0;padding:8px;background:transparent;overflow:visible}dialog::backdrop{background:#20483e18}#next{display:grid;place-items:center;min-width:150px;height:64px;padding:0 32px;border-radius:32px;background:#fffdf0;font-size:26px;font-weight:850;box-shadow:0 4px 12px #25403730}#next.retry{width:80px;min-width:80px;height:80px;padding:0;border-radius:50%;font-size:54px;font-weight:500;line-height:1}#loading{position:fixed;inset:0;background:#b4d6d8;display:grid;place-items:center;z-index:20}#loading[hidden],[hidden]{display:none!important}

#next.retry svg{width:40px;height:40px;fill:none;stroke:currentColor;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round}

#topline{display:flex;align-items:center;gap:18px;font-size:28px;pointer-events:auto}#menuButton{width:44px;height:44px;padding:7px;background:transparent;color:white}#menuButton svg{fill:none;stroke:currentColor;stroke-width:2.7;stroke-linecap:round;width:100%;height:100%}#menu{width:min(320px,calc(100vw - 40px));padding:30px 24px 24px;border-radius:22px;background:#fffdf0;color:#244640;box-shadow:0 12px 50px #25403740}#menu::backdrop{background:#24464050}#menu h2{margin:0 0 24px;font-size:28px}#menu>button:not(#menuClose){display:block;width:100%;padding:16px;margin-top:12px;border-radius:12px;background:#dfe8c9;font-weight:750;font-size:18px;text-align:left}#menuClose{position:absolute;right:14px;top:10px;background:transparent;font-size:30px;width:40px;height:40px}.freight-warning{width:46px;height:42px;display:grid;place-items:center;background:#fffdf0;color:#344c40;border-radius:14px;box-shadow:0 3px 8px #24464040;}.freight-warning:after{content:"";position:absolute;bottom:-8px;border-top:10px solid #fffdf0;border-left:8px solid transparent;border-right:8px solid transparent}.freight-warning svg{width:29px;height:29px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

.freight-warning{width:52px;height:52px;border-radius:50%;box-shadow:0 2px 6px #24464030}.freight-warning .arrival-ring{position:absolute;width:48px;height:48px;inset:2px;transform:rotate(-90deg);stroke-width:2.5}.arrival-track{stroke:#dce3d3}.arrival-progress{stroke:#b78036;stroke-dasharray:1;stroke-linecap:round}

#celebration{position:fixed;inset:0;width:100vw;height:100vh;pointer-events:none;z-index:-1}#result #next{position:relative;z-index:1}body.victory #result::backdrop{background:#eff5e938}body.victory #topline,body.victory #levelCounter{opacity:.35}@media(prefers-reduced-motion:reduce){#celebration{display:none}}


#levelCounter{position:fixed;top:max(20px,env(safe-area-inset-top));left:50%;transform:translateX(-50%);height:44px;display:flex;align-items:center;color:white;font-size:24px;font-weight:900;text-shadow:0 2px 3px #36534560;pointer-events:none;white-space:nowrap}#restartConfirm{width:min(340px,calc(100vw - 40px));padding:28px 24px;border-radius:22px;background:#fffdf0;color:#244640;box-shadow:0 12px 50px #25403740}#restartConfirm::backdrop{background:#24464050}#restartConfirm h2{margin:0 0 12px;font-size:26px}#restartConfirm p{margin:0 0 24px;line-height:1.5}.confirm-actions{display:flex;gap:12px}.confirm-actions button{flex:1;padding:14px 8px;border-radius:12px;font-weight:750;background:#dfe8c9}#restartCancel{background:#eeeade}@media(max-width:480px){#levelCounter{font-size:20px}#topline{gap:8px;right:max(12px,env(safe-area-inset-right));font-size:24px}}

#landscapeFade{position:fixed;inset:-3px;width:calc(100% + 6px);height:calc(100% + 6px);filter:blur(2.5px);pointer-events:none}body.victory #world{opacity:.62}

.loading-train{width:min(320px,80vw);height:auto;overflow:hidden}
.loader-arrive,.loader-push,.loader-leave{animation-duration:3.2s;animation-iteration-count:infinite;animation-timing-function:linear}
.loader-arrive{animation-name:loader-arrive}.loader-push{animation-name:loader-push}.loader-leave{animation-name:loader-leave}
/* No holds between arrival, coupling and departure. The shared push ends at
   the departing wagon's speed; identical remaining wagons preserve the loop. */
@keyframes loader-arrive{0%{transform:translateX(-84px);opacity:0;animation-timing-function:cubic-bezier(.3,.3,.7,1)}28%{transform:translateX(0);opacity:1;animation-timing-function:cubic-bezier(.32,0,.68,.58)}64%,100%{transform:translateX(64px);opacity:1}}
@keyframes loader-push{0%,28%{transform:translateX(0);opacity:1;animation-timing-function:cubic-bezier(.32,0,.68,.58)}64%,100%{transform:translateX(64px);opacity:1}}
@keyframes loader-leave{0%,28%{transform:translateX(0);opacity:1;animation-timing-function:cubic-bezier(.32,0,.68,.58)}64%{transform:translateX(64px);opacity:1;animation-timing-function:linear}100%{transform:translateX(148px);opacity:0}}
@media(prefers-reduced-motion:reduce){.loader-arrive,.loader-push,.loader-leave{animation-duration:9.6s}}

/* Passenger target met, including the final trips before Next appears. */
body::after{content:"";position:fixed;inset:0;pointer-events:none;z-index:2;opacity:0;box-shadow:inset 0 0 clamp(48px,9vw,100px) #5de7b3;transition:opacity .45s ease}
body.target-reached::after{animation:target-glow 2.8s ease-in-out infinite}
@keyframes target-glow{0%,100%{opacity:.3}50%{opacity:.75}}
@media(prefers-reduced-motion:reduce){body.target-reached::after{animation:none;opacity:.5}}
