/* Letters use DejaVu Sans Bold: it has the two-story a, like the Verdana on the printed pages. */
@font-face { font-family: "Letters"; src: url("fonts/DejaVuSans-Bold.ttf"); font-weight: bold; }
* { box-sizing: border-box; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #10182c; touch-action: none; overscroll-behavior: none; }
:root { --navy: #22304a; --red: #e8504f; --blue: #2467c8; --car: #e2dcff; --long: #ffe9a8; }

/* The stage is always 1280 by 800 units, and the script scales it to the screen. */
#stage { position: absolute; left: 0; top: 0; width: 1280px; height: 800px; overflow: hidden; transform-origin: 0 0; font-family: "Letters", Verdana, sans-serif; color: var(--navy); }
#stage > div, #stage > button { position: absolute; }
#sky { inset: 0; background: linear-gradient(#8fd3ff, #dff3ff 62%); }
#orb { position: absolute; right: 90px; top: 40px; width: 110px; height: 110px; border-radius: 50%; background: #ffd43b; box-shadow: 0 0 0 14px #ffd43b44; }
.cloud { position: absolute; width: 170px; height: 54px; border-radius: 30px; background: #fff; opacity: .9; animation: drift 60s linear infinite alternate; }
.cloud::before { content: ""; position: absolute; left: 30px; top: -28px; width: 70px; height: 62px; border-radius: 50%; background: #fff; }
.cloud::after { content: ""; position: absolute; left: 82px; top: -16px; width: 56px; height: 48px; border-radius: 50%; background: #fff; }
@keyframes drift { to { margin-left: 120px; } }
#hills { left: 0; right: 0; top: 380px; height: 240px; background: radial-gradient(ellipse 420px 190px at 240px 240px, #9bd88f 99%, transparent 100%), radial-gradient(ellipse 520px 150px at 820px 240px, #86cd84 99%, transparent 100%), radial-gradient(ellipse 300px 120px at 1240px 240px, #9bd88f 99%, transparent 100%); }
#ground { left: 0; right: 0; top: 590px; bottom: 0; background: linear-gradient(#7cc576, #5aa862); }
#track { left: 0; right: 0; top: 579px; height: 30px; background: linear-gradient(#5b6474 0 9px, transparent 9px), repeating-linear-gradient(90deg, #8a6a4a 0 16px, transparent 16px 46px); background-size: auto, auto 21px; background-position: 0 0, 0 9px; background-repeat: no-repeat, repeat-x; }
#stage.sunset #sky { background: linear-gradient(#ff9e7a, #ffd9a8 62%); }
#stage.sunset #orb { background: #ff6b4a; box-shadow: 0 0 0 14px #ff6b4a44; top: 250px; }
#stage.night #sky { background: linear-gradient(#18244a, #3b4f8a 70%); }
#stage.night #orb { background: #fff6cf; box-shadow: 0 0 0 14px #fff6cf33; }
#stage.night .cloud { opacity: .25; }
#stage.night #hills { filter: brightness(.55); }
#stage.night #ground { filter: brightness(.65); }

/* Letter cars */
#world { inset: 0; }
#world > div { position: absolute; left: 0; top: 0; }
.car { height: 150px; transition: width .28s; touch-action: none; }
.car .body { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--car); border: 6px solid var(--navy); border-radius: 22px; font-size: 112px; line-height: 1; padding-bottom: 8px; transition: background .3s, border-radius .28s; }
.car::before, .car::after { content: ""; position: absolute; bottom: -26px; width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(#d7dee8 0 7px, var(--navy) 8px); z-index: 1; }
.car::before { left: 16px; }
.car::after { right: 16px; }
.car .hook { position: absolute; right: -24px; top: 96px; width: 24px; height: 12px; background: var(--navy); border-radius: 0 6px 6px 0; }
.car.last .hook, .car.jr .hook { display: none; }
.car.jl .body { border-left-width: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.car.jr .body { border-right-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.car.jl::before, .car.jr::after { display: none; }
.car.jl .body, .car.jr .body { background: var(--long); }
.car.empty .body { background: #f4f6fa; border-style: dashed; color: #22304a26; }
.car.lit .body { background: #fff; box-shadow: 0 0 0 8px #ffd43b, 0 0 40px 12px #ffd43baa; }
.car.lit { z-index: 3; }
.car.held .body { transform: scale(1.06) rotate(-2deg); }

/* Letter crates that hang from the beam */
#beam { width: 880px; height: 20px; border-radius: 10px; background: #6b7a93; border: 4px solid var(--navy); }
.crate { width: 132px; height: 132px; touch-action: none; z-index: 4; }
.crate .body { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border: 6px solid var(--navy); border-radius: 18px; font-size: 96px; line-height: 1; padding-bottom: 8px; background: #ffd9c7; animation: sway 2.4s ease-in-out infinite alternate; transform-origin: 50% -40px; }
.crate::before { content: ""; position: absolute; left: 63px; top: -46px; width: 6px; height: 48px; background: var(--navy); }
.crate.held::before { display: none; }
.crate.held .body { animation: none; transform: scale(1.1) rotate(4deg); box-shadow: 0 14px 0 #22304a22; }
@keyframes sway { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }

/* Left to right. The crate whose turn it is glows and sways, the others hang still. The cars that take the next step pulse green. */
.crate.wait .body { animation: none; opacity: .6; }
.crate.due:not(.held) .body { animation: sway .9s ease-in-out infinite alternate; box-shadow: 0 0 0 8px #51cf66, 0 0 40px 12px #51cf66aa; }
.car.target .body { animation: beckon .7s ease-in-out infinite alternate; }
@keyframes beckon { from { box-shadow: inset 0 0 0 100px #51cf6600; } to { box-shadow: inset 0 0 0 100px #51cf6688; } }
/* Where a word starts and which way it goes: a green dot under the first letter, and an arrow to the right. */
#order { height: 0; pointer-events: none; opacity: 0; }
#order u { position: absolute; left: 0; right: 28px; top: -8px; height: 16px; background: #fff; border: 4px solid var(--navy); border-radius: 8px; }
#order i { position: absolute; left: -24px; top: -24px; width: 48px; height: 48px; border-radius: 50%; background: #51cf66; border: 6px solid var(--navy); }
#order svg { position: absolute; right: -6px; top: -24px; width: 40px; height: 48px; fill: #fff; stroke: var(--navy); stroke-width: 5; stroke-linejoin: round; }

/* Who gets the mail */
#receiver { width: 240px; height: 240px; display: flex; align-items: flex-end; justify-content: center; }
#receiver svg { width: 220px; height: 220px; }
#receiver .emoji { font-size: 170px; line-height: 1.15; font-family: "Noto Color Emoji", "Samsung Color Emoji", sans-serif; }
#bubble { height: 130px; padding: 0 0 8px; display: flex; align-items: center; justify-content: center; background: #fff; border: 6px solid var(--navy); border-radius: 40px; font-size: 84px; opacity: 0; }
#bubble::after { content: ""; position: absolute; left: 50%; bottom: -26px; margin-left: -16px; border: 16px solid transparent; border-top: 22px solid var(--navy); border-bottom: 0; }
.runner { width: 70px; height: 77px; }
.runner svg { width: 70px; height: 77px; transform: rotate(90deg); }
.star { width: 40px; height: 40px; pointer-events: none; z-index: 6; }
.star svg { width: 100%; height: 100%; }
.puff { width: 34px; height: 34px; border-radius: 50%; background: #fff; pointer-events: none; }
#megasaur { width: 210px; height: 192px; }
#megasaur svg { width: 100%; height: 100%; }

/* Buttons */
.round { border: 6px solid var(--navy); border-radius: 50%; font-family: inherit; color: var(--navy); padding: 0; touch-action: none; }
#home { left: 18px; top: 18px; width: 84px; height: 84px; background: #fff; font-size: 40px; z-index: 8; }
#go { right: 60px; top: 628px; width: 140px; height: 140px; background: #51cf66; font-size: 70px; padding-left: 10px; color: #fff; text-shadow: 0 0 0 var(--navy); z-index: 8; display: none; animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); } }
#way { left: 0; top: 232px; width: 120px; height: 110px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 5; }
#way svg { width: 100%; height: 100%; }
#hint { left: 0; top: 0; width: 76px; height: 76px; margin: -38px 0 0 -38px; border-radius: 50%; background: #ffffffcc; border: 6px solid var(--navy); opacity: 0; pointer-events: none; z-index: 9; }

/* Screens that cover the round */
.screen { inset: 0; display: none; z-index: 20; }
.screen.on { display: block; }
#map { background: linear-gradient(#8fd3ff, #e9f7ff 55%, #9bd88f 55%, #7cc576); }
#banner { position: absolute; left: 0; right: 0; top: 14px; height: 120px; display: flex; align-items: center; justify-content: center; gap: 18px; }
#banner svg { height: 104px; width: auto; aspect-ratio: auto; }
#banner svg:first-child { width: 226px; }
#banner svg:nth-of-type(2) { width: 84px; }
#banner svg:nth-of-type(3) { width: 98px; }
#banner h1 { margin: 0 14px; font-size: 68px; color: var(--red); -webkit-text-stroke: 2px var(--navy); }
#rows { position: absolute; left: 30px; right: 30px; top: 150px; }
.row { display: flex; align-items: center; gap: 14px; height: 200px; margin-bottom: 12px; padding: 0 18px; background: #ffffff8c; border-radius: 34px; }
.row .len { display: flex; gap: 3px; width: 128px; flex: none; }
.row .len i { flex: 1; height: 34px; background: var(--car); border: 4px solid var(--navy); border-radius: 8px; }
.stop { width: 112px; height: 112px; flex: none; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 58px; font-family: "Noto Color Emoji", "Samsung Color Emoji", sans-serif; }
.stop svg { width: 78px; height: 78px; pointer-events: none; }
.stop.been { background: var(--long); }
#gear { position: absolute; right: 16px; top: 16px; width: 62px; height: 62px; background: #ffffffaa; font-size: 30px; border-width: 4px; opacity: .6; }
#gear.holding { background: conic-gradient(#51cf66 var(--p, 0%), #fff 0); opacity: 1; }

#finale { background: linear-gradient(#0b1230, #27336b 75%, #3d4a86); overflow: hidden; }
#finale > * { position: absolute; }
#stars { inset: 0; }
#parcels { left: 0; top: 0; }
#stars i { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #fff; }
#pad { left: 0; right: 0; bottom: 0; height: 90px; background: #5b6474; border-top: 8px solid var(--navy); }
#ship { left: 530px; top: 440px; width: 220px; height: 242px; }
#ship svg { width: 100%; height: 100%; }
#planet { left: 500px; top: -300px; width: 280px; height: 280px; }
#planet svg { width: 100%; height: 100%; }
.parcel { padding: 4px 22px 12px; background: var(--long); border: 6px solid var(--navy); border-radius: 20px; font-size: 64px; touch-action: none; }
#count { left: 0; right: 0; top: 130px; text-align: center; font-size: 240px; color: #fff; -webkit-text-stroke: 6px var(--navy); pointer-events: none; }
#launch { right: 70px; bottom: 120px; width: 170px; height: 170px; background: var(--red); box-shadow: inset 0 -14px 0 #0003; display: none; animation: pulse 1s ease-in-out infinite alternate; }
#crew { left: 700px; bottom: 150px; display: none; }
#crew svg { width: 150px; height: 180px; }

#grownup { background: #10182ccc; }
#panel { position: absolute; left: 140px; right: 140px; top: 50px; bottom: 50px; padding: 26px 36px; background: #fff; border-radius: 28px; overflow: auto; font: 24px/1.4 Helvetica, Arial, sans-serif; touch-action: pan-y; }
#panel h2 { margin: 0 0 8px; font-size: 34px; }
#log { columns: 6; font-size: 19px; line-height: 1.3; min-height: 60px; }
.opt { font: inherit; margin: 4px 8px 4px 0; padding: 10px 20px; border: 3px solid var(--navy); border-radius: 14px; background: #fff; color: var(--navy); }
.opt.on { background: var(--long); }

#start { background: linear-gradient(#8fd3ff, #e9f7ff); display: flex; align-items: center; justify-content: center; text-align: center; z-index: 30; }
#start.off { display: none; }
#start svg { width: 520px; height: 240px; animation: pulse 1s ease-in-out infinite alternate; }
#start p { margin: 10px 0 0; font-size: 90px; color: #51cf66; -webkit-text-stroke: 4px var(--navy); }
