:root { color-scheme: light; font-family: "Trebuchet MS", system-ui, sans-serif; color: #293e42; background: #eee8d8; }
* { box-sizing: border-box; }
body { margin: 0; }
main { width: min(100%, 44rem); margin: auto; background: #fffaed; min-height: 100svh; }
header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem clamp(1rem,5vw,2.5rem); }
header strong { font: bold clamp(1.2rem,4vw,1.65rem) Georgia, serif; }
button { font: inherit; cursor: pointer; color: inherit; }
#sound, #replay { border: 1px solid #c7c2ab; border-radius: 2rem; background: #fffdf6; padding: .6rem 1rem; min-height: 44px; }
button:focus-visible { outline: 4px solid #204e85; outline-offset: 3px; }
.scene { position: relative; isolation: isolate; overflow: hidden; height: clamp(145px,29svh,300px); background: #b9dcd9; }
.sun { position: absolute; top: 10%; right: 15%; width: 12%; aspect-ratio: 1; border-radius: 50%; background: #fae5a3; }
.cloud { position: absolute; width: 16%; height: 7%; border-radius: 90px; background: #eff3df; left: 11%; top: 22%; }
.valley { position: absolute; inset: 6% 0 0; background: url("./valley.png") repeat-x left bottom / auto 100%; }
.station { position: absolute; width: 32%; bottom: 9%; left: 108%; }
.rail { position: absolute; bottom: 9%; width: 100%; height: 12px; border-block: 3px solid #4a5147; background: repeating-linear-gradient(90deg,#ac997a 0 15px,#6b5743 15px 24px); }
.engine { position: absolute; bottom: calc(9% + 8px - min(3.88cqw,7.83cqh)); left: 49%; width: min(57%,115cqh); aspect-ratio: 720 / 420; transform: translateX(-50%); }
.scene { container-type: size; }
.train { display: block; width: 100%; }
.wheel { position: absolute; border-radius: 50%; background: conic-gradient(from 15deg,#ecce99 0 9deg,transparent 9deg 120deg,#ecce99 120deg 129deg,transparent 129deg 240deg,#ecce99 240deg 249deg,transparent 249deg); }
.front,.middle { width: 8%; aspect-ratio: 1; top: 69.3%; left: 63.9%; }
.middle { left: 40.3%; }
.rear { width: 9%; aspect-ratio: 1; top: 67.8%; left: 16.5%; }
.steam { position: absolute; top: 12%; left: 70%; width: 10%; aspect-ratio: 1; }
.steam i { position: absolute; inset: 0; border-radius: 45% 60% 40% 55%; background: #fffbee; opacity: 0; }
.arrived .engine { left: 37%; }
.arrived .station { left: 67%; }
.journey .engine { animation: depart 4.8s both; }
.journey .station { animation: arrive 4.8s ease-out both; }
.journey .valley { animation: scenery 4.8s ease-in-out both; }
.journey .rail { animation: sleepers 4.8s ease-in-out both; }
.journey .wheel { animation: turning 4.8s ease-in-out both; }
.journey .steam i { animation: puff 1.15s ease-out 3; }
.journey .steam i:nth-child(2) { animation-delay: .32s; }
.journey .steam i:nth-child(3) { animation-delay: .67s; }
@keyframes depart { 0% { left: 49%; } 32% { left: 54%; } 100% { left: 37%; } }
@keyframes arrive { 0%,28% { left: 108%; } 100% { left: 67%; } }
@keyframes scenery { to { background-position-x: -185px; } }
@keyframes sleepers { to { background-position-x: -528px; } }
@keyframes turning { to { transform: rotate(1080deg); } }
@keyframes puff { 0% { opacity: 0; transform: translate(-40%,-25%) scale(.27); } 17% { opacity: .9; } 100% { opacity: 0; transform: translate(-165%,-175%) scale(1.4); } }
#ride { min-height: 44px; padding: .6rem 1rem; border: 1px solid #637d73; border-radius: 2rem; background: transparent; margin: .2rem; }
#sound[aria-pressed="true"] { background: #d8ede3; border-color: #5c8070; }
.tile:active { outline: 3px solid #59786c; }
section { padding: clamp(1rem,3vh,2rem) .75rem 2rem; text-align: center; }
h1 { font: bold clamp(1.6rem,6vw,2.3rem)/1.15 Georgia,serif; margin: 0 0 1rem; }
#slots,#tiles { display: flex; gap: clamp(6px,2vw,13px); justify-content: center; }
.slot,.tile { width: clamp(49px,16vw,83px); height: clamp(58px,17vw,87px); display: grid; place-items: center; border-radius: 15px; font: bold clamp(2.1rem,9vw,3.7rem)/1 Georgia,serif; }
.slot { color: #7b796c; border: 2px dashed #b4ae98; background: #f7f1df; }
.tile,.placed { color: #243c40; border: 2px solid #0002; background: var(--color); box-shadow: 0 4px 0 #283e422b; }
.tile { touch-action: none; user-select: none; }
.picked { visibility: hidden; }
.dragging { position: relative; z-index: 2; pointer-events: none; }
#hint { margin: 1.2rem auto; font-size: 1rem; }
#replay { background: #2f655f; color: white; font-weight: bold; min-width: 9rem; }
.sr { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { .scene .journey, .scene.journey * { animation: none !important; } }
