.numbered-cover { position: relative; container-type: inline-size; line-height: 0; }
.numbered-cover img { display: block; width: 100%; height: auto; }
.numbered-cover .cover-plate { position: absolute; top: 58.4%; transform: translate(-50%, -50%); color: #343741; font: 800 5cqw/1 Library, 'Trebuchet MS', sans-serif; }
.numbered-cover .plate-one { left: 55.5%; }
.numbered-cover .plate-two { left: 73%; }
.numbered-cover .plate-three { left: 90%; }
.catalog-view .card-art.train-art { height: 235px; display: grid; align-items: center; background: #e4f5ef; }
.catalog-view .card-meta { flex-wrap: wrap; row-gap: 4px; }
.catalog-view .game-card { display: flex; flex-direction: column; }
.catalog-view .card-content { display: flex; flex-direction: column; flex: 1; }
.catalog-view .card-content .button { margin-top: auto; }
.catalog-view .card-art { flex-shrink: 0; }
body.thomas-game { background: #eaf6f4; }
body.thomas-game > .site-header, body.thomas-game > footer { display: none; }
body.thomas-game #app { width: calc(100% - 32px); max-width: 1100px; margin-inline: auto; padding-bottom: 16px; min-height: 100dvh; }
.thomas-game { --rail-blue: #226a9a; --rail-red: #bb473e; --rail-ink: #354950; }
.rail-toolbar { display: grid; grid-template-columns: 145px minmax(0, 1fr) auto 48px; align-items: center; gap: 12px; padding: 10px 0; }
.rail-toolbar h1 { font: 800 20px/1.25 Library, 'Trebuchet MS', sans-serif; margin: 0 0 4px; color: var(--rail-blue); }
.rail-toolbar span { font-size: 14px; color: #50666b; }
.rail-toolbar a { color: #305f74; font-size: 15px; }
.rail-toolbar .secondary { font-size: 15px; padding: 8px 12px; }
.rail-toolbar .rail-sound { font-size: 22px; padding: 0; }
.thomas-game button:focus-visible, .thomas-game a:focus-visible { outline: 3px solid #1876b0; outline-offset: 4px; }
.thomas-game .rail-primary { background: #c74d40; color: white; border: 2px solid #ae4036; box-shadow: 0 3px 0 #963d35; min-height: 48px; padding: 10px 20px; }
.thomas-game .rail-primary:hover { background: #ac3f35; }
.rail-cover { text-align: center; }
.rail-kicker { display: block; font-size: 13px; font-weight: 700; color: #317b7a; margin: 14px 0; }
.rail-cover h1, .rail-finish h1 { font: 800 38px/1.2 Library, 'Trebuchet MS', sans-serif; color: #246b96; max-width: none; margin: 12px 0 16px; }
.rail-cover > p, .rail-finish > p { max-width: 760px; margin: 0 auto 20px; color: #425e67; }
.rail-cover > .numbered-cover { max-width: 850px; margin: 24px auto 0; border-radius: 8px; }
.rail-cover .rail-cover-meta { font-size: 14px; margin: 14px auto; }
.thomas-engine { width: 180px; height: auto; display: block; }
.rail-intro { background: #fffefa; border: 1px solid #ceded9; border-radius: 8px; padding: 28px; text-align: center; }
.rail-intro > .thomas-engine { width: 200px; margin: 0 auto 16px; }
.rail-intro > p { max-width: 710px; margin: 16px auto; }
.rail-intro h2 { color: #286786; font-size: 27px; }
.rail-route { display: flex; align-items: center; justify-content: space-between; gap: 12px; list-style: none; padding: 0; margin: 0 0 12px; }
.rail-route li { flex: 1; display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 3px solid #c3d6ce; font-size: 15px; color: #5c7277; }
.rail-route li > span { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #d7e7e1; font-weight: 800; }
.rail-route li small { margin-left: auto; }
.rail-route li.current { color: #205f84; border-color: #51a6cb; }
.rail-route li.visited { color: #337956; border-color: #68b487; }
.rail-route li.visited > span { background: #c3e6ce; }
.rail-board { background: #fffefa; border: 1px solid #cbded9; border-radius: 8px; display: grid; grid-template-rows: auto minmax(270px, 1fr) 104px minmax(72px, auto); min-height: min(calc(100dvh - 150px), 590px); }
.rail-task-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 24px 8px; }
.rail-task-heading h2 { margin: 0; font-size: 25px; line-height: 1.25; color: #2c657c; }
.rail-task-heading > span { font-size: 14px; white-space: nowrap; color: #6b755b; }
.rail-learning { padding: 10px 24px 18px; align-content: center; min-width: 0; }
.rail-direction { text-align: center; font-size: 15px; color: #697770; min-height: 24px; margin-bottom: 14px; }
.rail-track { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; align-items: center; max-width: 780px; margin: 0 auto; padding-bottom: 14px; border-bottom: 5px solid #8f9a8b; }
.rail-track.neighbor-track { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 490px; }
.rail-car { --car: #de8076; --car-border: #af5955; position: relative; min-width: 48px; width: 100%; min-height: 82px; padding: 9px 12px 14px; border: 3px solid var(--car-border); border-bottom-width: 9px; border-radius: 8px; background: var(--car); box-shadow: inset 0 4px #ffffff60; font-size: 32px; color: #354750; touch-action: none; }
.rail-car:after { content: ''; position: absolute; width: 17px; height: 6px; right: -19px; top: 58%; background: #87959a; }
.rail-car:last-child:after { display: none; }
.rail-car .car-number { display: grid; place-items: center; background: #fffdf3; border: 1px solid #fff9e1; min-height: 44px; min-width: 0; width: 100%; border-radius: 4px; line-height: 1.1; font-weight: 800; }
.rail-car .car-wheels { position: absolute; bottom: -17px; left: 12%; width: 19px; height: 19px; border: 5px solid #3c535c; background: #d2e0df; border-radius: 50%; box-shadow: none; }
.rail-car .car-wheels:after { content: ''; position: absolute; width: 19px; height: 19px; border: 5px solid #3c535c; background: #d2e0df; border-radius: 50%; left: 47px; top: -5px; }
.car-1 { --car: #f4cf6b; --car-border: #cfab44; }
.car-2 { --car: #75c7c3; --car-border: #459c9a; }
.car-3 { --car: #a7c97d; --car-border: #7b9d59; }
.car-4 { --car: #d4aedf; --car-border: #a37eaf; }
.car-5 { --car: #f3ad74; --car-border: #ce8c58; }
.rail-car[aria-pressed='true'] { outline: 4px solid #23678f; outline-offset: 4px; transform: translateY(-3px); }
.rail-car:disabled { opacity: 1; cursor: default; }
.rail-pool .rail-car:disabled { opacity: .35; }
.empty-car { border: 3px dashed #91aaa9; background: #edf4f1; color: #64817f; box-shadow: none; }
.empty-car .car-number { background: #f9fcf8; }
.rail-pool { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; max-width: 780px; margin: 26px auto 12px; }
.rail-pool:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 650px; }
.rail-pool:has(> :nth-child(5):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.rail-pool:has(> :only-child) { grid-template-columns: 100px; justify-content: center; }
.rail-pool .rail-car:after { display: none; }
.rail-feedback { display: flex; align-items: center; gap: 20px; padding: 10px 24px; border-block: 1px solid #d6e5dd; background: #f0f6ed; }
.rail-feedback > .thomas-engine { width: 110px; flex-shrink: 0; }
.rail-feedback p { margin: 0; font-size: 17px; line-height: 1.45; }
.rail-feedback.success { color: #2e704c; }
.rail-feedback.error { color: #9a493a; }
.rail-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 10px 24px; }
.rail-actions .rail-primary { margin-left: auto; }
.rail-steps h3 { margin-bottom: 10px; color: #40778b; }
.rail-steps ol { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; padding-left: 24px; margin: 8px 0 18px; font-size: 16px; }
.rail-dialog { width: min(650px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; border: 1px solid #b6cdc6; border-radius: 8px; background: #fffefa; padding: 24px; color: #38525b; }
.rail-dialog::backdrop { background: #213f4c66; }
.rail-dialog h2 { font-size: 25px; }
.rail-dialog .rail-route { flex-direction: column; align-items: stretch; }
.rail-finish { text-align: center; }
.rail-cover-scene { position: relative; max-width: 900px; margin: 24px auto 0; }
.rail-landscape { width: 100%; display: block; }
.cover-express { position: absolute; bottom: 5%; left: 2%; right: 5%; display: flex; align-items: end; gap: 8px; }
.cover-express .thomas-engine { width: 25%; }
.cover-express .rail-track { width: 65%; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; padding-bottom: 5px; border: 0; }
.cover-express .rail-car { min-height: 60px; font-size: 25px; padding: 6px 12px 10px; }
.cover-express .car-number { min-height: 30px; }
.rail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 24px 0; }
.rail-stats > div { background: #fffefa; border: 1px solid #cde0d6; padding: 18px; border-radius: 8px; display: grid; }
.rail-stats strong { font-size: 38px; color: #337959; }
.rail-stats span { font-size: 15px; }
.rail-finish-actions { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.rail-confetti { position: absolute; inset: 0; pointer-events: none; }
.rail-confetti i { position: absolute; top: 0; left: calc(var(--i) * 5.4%); width: 7px; height: 12px; background: #efb64c; animation: confetti 1.7s both; animation-delay: calc(var(--i) * 30ms); }
.rail-confetti i:nth-child(3n) { background: #70bfbc; }
.rail-confetti i:nth-child(3n + 1) { background: #c392c7; }
.train-success .rail-track { animation: express-move 1.2s ease-out; }
.train-success .car-wheels { animation: wheel-turn .7s linear 2; }
.train-success .thomas-engine { animation: express-move 1.2s ease-out; }
.rail-track [data-slot]:not(.empty-car) { animation: car-join .3s ease-out; }
@keyframes car-join { from { transform: translateY(-8px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
@keyframes express-move { 50% { transform: translateX(12px); } }
@keyframes wheel-turn { to { transform: rotate(360deg); } }
@keyframes confetti { from { opacity: 1; transform: translateY(0) rotate(0); } to { opacity: 0; transform: translateY(170px) rotate(200deg); } }
@media (max-width: 760px) {
  .rail-toolbar { grid-template-columns: minmax(0, 1fr) auto 48px; gap: 8px; }
  .rail-toolbar > div { grid-column: 1 / -1; grid-row: 2; }
  .rail-toolbar h1 { font-size: 19px; }
  .rail-toolbar a { font-size: 14px; justify-self: start; }
  .rail-route { gap: 6px; margin-bottom: 8px; }
  .rail-route li { padding: 6px 2px; font-size: 12px; gap: 5px; flex-wrap: wrap; }
  .rail-route li small { display: none; }
  .rail-route li > span { width: 23px; height: 23px; }
  .rail-task-heading { padding: 14px 14px 8px; flex-direction: column; align-items: start; gap: 4px; }
  .rail-task-heading h2 { font-size: 22px; }
  .rail-task-heading > span { font-size: 12px; }
  .rail-learning { padding: 8px 14px 18px; }
  .rail-track, .rail-pool { gap: 10px; }
  .rail-car { padding: 6px 4px 12px; font-size: 27px; min-height: 74px; }
  .rail-car .car-wheels { left: 7%; width: 15px; height: 15px; border-width: 4px; bottom: -14px; }
  .rail-car .car-wheels:after { width: 15px; height: 15px; border-width: 4px; top: -4px; left: 35px; }
  .rail-car:after { width: 12px; right: -15px; }
  .rail-feedback { padding: 8px 14px; gap: 10px; }
  .rail-feedback > .thomas-engine { width: 80px; }
  .rail-feedback p { font-size: 16px; }
  .rail-board { grid-template-rows: auto minmax(250px, 1fr) 128px minmax(72px, auto); min-height: 0; }
  .rail-actions { padding: 10px 14px; gap: 8px; }
  .rail-actions button { font-size: 15px; padding: 10px 12px; }
  .rail-cover h1, .rail-finish h1 { font-size: 30px; }
  .rail-intro { padding: 20px 14px; }
  .rail-intro h2 { font-size: 24px; }
}
@media (max-width: 480px) {
  body.thomas-game #app { width: calc(100% - 24px); }
  .rail-track, .rail-pool { gap: 7px; }
  .rail-car { font-size: 24px; padding-inline: 3px; min-height: 70px; border-width: 2px; border-bottom-width: 8px; }
  .rail-car .car-number { min-height: 40px; }
  .rail-car .car-wheels:after { left: 24px; }
  .rail-track { padding-bottom: 12px; }
  .rail-learning { padding-inline: 8px; }
  .rail-pool { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 22px; }
  .rail-pool:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .rail-pool:has(> :nth-child(5):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .rail-direction { font-size: 13px; margin-bottom: 10px; }
  .rail-task-heading h2 { font-size: 21px; }
  .rail-feedback > .thomas-engine { width: 58px; }
  .rail-board { grid-template-rows: auto minmax(250px, auto) 152px minmax(72px, auto); }
  .rail-steps ol { grid-template-columns: 1fr; }
  .rail-stats { grid-template-columns: 1fr; }
  .rail-stats > div { display: flex; align-items: center; gap: 20px; padding: 12px 18px; text-align: left; }
  .cover-express .rail-car { min-height: 42px; padding: 3px 5px 6px; font-size: 18px; }
  .cover-express .car-number { min-height: 24px; }
  .cover-express .car-wheels { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .thomas-game *, .thomas-game *:before, .thomas-game *:after { animation: none !important; transition: none !important; }
}
