:root {
  color-scheme: dark;
  --ink: #101e2a;
  --surface: #192d3d;
  --surface-light: #20384a;
  --paper: #f0f5f6;
  --subtle: #b0c1ca;
  --sky: #92d7ff;
  --amber: #f5bd71;
  --rule: #96bac82e;
  --red: #b8e4ff;
  --cream: #213848;
  --line: #567080;
}
body { background: var(--ink); color: var(--paper); }
#room { isolation: isolate; color: var(--paper); background: #111f2d; }
button, .link-button, .trial-back { border-color: #718b9a80; color: #edf5f8; background: #203546; }
button:hover, .secondary:hover, .trial-back:hover { background: #29465a; }
button:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #91d5ff; outline-offset: 3px;
}
.primary, .feature-start, .link-button.primary { color: #102131; background: #b5e3ff; border-color: #b5e3ff; box-shadow: none; }
.primary:hover, .feature-start:hover, .link-button.primary:hover { color: #0a1b29; background: #dcf3ff; border-color: #dcf3ff; }
#room .room-top {
  left: max(14px, env(safe-area-inset-left)); right: max(14px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top));
  padding: 0; z-index: 8; gap: 8px;
}
.room-top .brand { color: white; text-shadow: none; gap: .65rem; letter-spacing: -.065em; }
.room-top .brand img { width: 38px; height: 38px; border-radius: 10px; }
.room-top .brand, .room-top nav { border-radius: .9rem; background: #142330eb; border: 1px solid var(--rule); box-shadow: 0 3px 18px #06132227; }
.room-top .brand { padding: 3px 13px 3px 4px; }
.room-top nav { gap: 0; padding: 0 2px; }
.room-top button, .room-top #fullscreen { border: 0; color: #e8f3f9; background: transparent; box-shadow: none; backdrop-filter: none; }
.room-top button:hover { background: #365169; }
.room-top .trial-back { background: #142737eb; color: #f1f8fb; border-color: #8fa6b470; }

#room:has(#welcome:not([hidden])) { background: #101d29; }
#room:has(#welcome:not([hidden])) .room-top { left: max(3.6vw, env(safe-area-inset-left)); right: max(3.6vw, env(safe-area-inset-right)); }
#room:has(#welcome:not([hidden])) .room-bottom,
#room:has(#welcome:not([hidden])) .session-status,
#room:has(#welcome:not([hidden])) >canvas { visibility: hidden; }
#room .welcome {
  position: absolute; inset: 0; z-index: 2; width: 100%; max-width: none; max-height: none;
  display: block; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; backdrop-filter: none;
  color: var(--paper); background: linear-gradient(#111d28,#152735 75%,#101f2a);
  overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain;
}
.game-launch { width: min(1440px,100%); padding: max(4.3rem,calc(env(safe-area-inset-top) + 3.65rem)) 3.6% 2.4rem; margin: 0 auto; }
.game-feature {
  position: relative; isolation: isolate; display: grid; align-items: center; overflow: hidden;
  min-height: clamp(16rem,37vh,32rem); color: white; background: #20394a url('/assets/modellino-studio.webp') center 54% / cover;
  border: 1px solid #8fb6cb51; border-radius: 1.25rem;
}
.game-feature::before { content: ''; position: absolute; z-index: -1; inset: 0; background: linear-gradient(90deg,#09141eee 0,#0c1c2cc4 27%,#17283835 60%,#21354704 82%); }
.game-feature:has(+ #privateRevueltoFeature) { display: none; }
.game-feature .feature-model {
  position: absolute; right: 1%; top: 50%; width: 55%; height: 102%; object-fit: contain; transform: translateY(-43%);
  pointer-events: none; filter: drop-shadow(0 13px 8px #10172095);
}
.game-feature .feature-model.feature-revuelto { width: 66%; right: -3%; height: 124%; transform: translateY(-45%); }
.game-feature-copy { position: relative; width: 49%; padding: clamp(1.2rem,3.3vw,3.5rem); }
.welcome .game-feature-copy h1 { margin: 0; color: #fff; font-size: clamp(2.15rem,4.4vw,4.8rem); line-height: .99; letter-spacing: -.064em; font-weight: 750; }
.welcome .game-feature-copy h1 em { color: #b4e3ff; font-style: normal; font-weight: 580; }
.welcome .game-feature-copy p { margin: .9rem 0 1.15rem; max-width: 30ch; color: #e0e8ed; font-size: clamp(.9rem,1.1vw,1.05rem); line-height: 1.45; }
.feature-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; }
.feature-actions a, .game-feature .feature-start { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; text-decoration: none; font-weight: 750; border-radius: .6rem; line-height: 1.15; font-size: .93rem; }
.feature-actions a:not(.feature-start) { color: white; text-decoration: underline; text-underline-offset: .25rem; text-decoration-color: #91bad0; }
.game-feature .feature-start { border: 1px solid #b5e3ff; padding: .72rem 1.1rem; }
.mode-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: clamp(1.2rem,2vw,2rem) 0 .7rem; }
.welcome .mode-heading h2 { margin: 0; color: #f0f6fa; font-size: clamp(1.25rem,2.2vw,2rem); line-height: 1.08; letter-spacing: -.045em; }
.welcome .garage-choice { width: auto; padding: .5rem .9rem; min-height: 44px; color: #ceebfc; border-radius: .65rem; background: #203749; }
.welcome .demo-choices { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: clamp(.6rem,1.2vw,1.2rem); margin: 0; }
.welcome .demo-choices button {
  position: relative; isolation: isolate; overflow: hidden; display: flex; justify-content: end; align-items: stretch; text-align: left; min-width: 0;
  padding: clamp(.8rem,1.5vw,1.5rem); border: 1px solid #82adbe4d; border-radius: .95rem; color: #fff;
  min-height: clamp(9.8rem,18vh,14rem); background: radial-gradient(ellipse at 58% 10%,#355369,#21394d 65%,#192e3f);
  transition: border-color .16s ease, background .16s ease;
}
.welcome .demo-choices [data-demo=train] { background: radial-gradient(ellipse at 65% 8%,#56636a,#344248 61%,#24333c); }
.welcome .demo-choices [data-demo=plane] { background: radial-gradient(ellipse at 62% 10%,#47677b,#294450 68%,#1b3541); }
.welcome .demo-choices button::after {
  content: ''; position: absolute; right: 1rem; bottom: 1.1rem; width: .42rem; height: .42rem;
  border: solid #bce4fb; border-width: 2px 2px 0 0; transform: rotate(45deg);
}
.welcome .demo-choices button:hover { border-color: #93d8f8; }
.welcome .demo-choices img {
  display: block; align-self: center; width: 85%; height: clamp(5.5rem,10vh,8.7rem); object-fit: contain;
  margin: -.35rem 0 0; filter: drop-shadow(0 5px 5px #09172499); transition: transform .2s ease;
}
@media(hover:hover) { .welcome .demo-choices button:hover img { transform: translateY(-3px); } }
.mode-title { display: grid; gap: 3px; padding-right: 1rem; }
.welcome .demo-choices strong { font-size: clamp(1.05rem,1.6vw,1.48rem); line-height: 1.15; letter-spacing: -.035em; }
.welcome .demo-choices small { color: #c6d6dc; font-size: .87rem; font-weight: 450; line-height: 1.35; }
.game-journeys { display: grid; grid-template-columns: minmax(0,.7fr) minmax(0,1.65fr); gap: 1rem; margin-top: 1.2rem; }
.game-journeys .journey-panel { margin: 0; padding: 1rem 1.15rem; background: #142735; border-color: var(--rule); border-radius: .85rem; }
.game-journeys strong { font-size: 1rem; color: #edf3f7; }
.game-journeys .journey-panel p, .game-journeys .journey-panel small { color: var(--subtle); line-height: 1.4; font-size: .87rem; }
.game-journeys .journey-actions { margin-bottom: 0; gap: .45rem .65rem; }
.game-journeys .journey-actions button { border-radius: .6rem; padding: .5rem .75rem; font-size: .85rem; }
.game-journeys .journey-actions a { color: #b5dff5; }

#room.is-lineup { background: #22323c url('/assets/modellino-studio.webp') 50% 57% / cover; }
#room.is-lineup::before { content: ''; pointer-events: none; position: absolute; inset: 0; background: linear-gradient(0deg,#09162275,transparent 24%,transparent 78%,#07141e44); }
#room.is-lineup.lineup-webgl::after, #room.is-lineup.has-lineup-poster::after {
  content: ''; position: absolute; pointer-events: none; z-index: 0; width: min(53%,68vh); height: 7%;
  top: 62%; left: 50%; transform: translate(-50%,-50%); background: radial-gradient(ellipse, #0b111852 0%,transparent 70%);
}
#room.is-lineup #world { position: relative; z-index: 1; }
.lineup-poster { position: absolute; pointer-events: none; top: 49%; left: 50%; z-index: 1; transform: translate(-50%,-50%); width: min(78vw,100vh); height: min(65vh,65vw); object-fit: contain; filter: drop-shadow(0 6px 4px #10202c5e); }
#room.is-lineup.has-lineup-poster #mapWorld { visibility: hidden; }
#room.is-lineup :is(.game-hud,.map-panel,.drive-controls,.route-hint,.lever,.rail-controls,.station-board,.altitude-toggle) { visibility: hidden; }
#room .room-bottom {
  left: max(14px,env(safe-area-inset-left)); right: max(14px,env(safe-area-inset-right));
  min-height: 56px; padding: .75rem clamp(.85rem,1.5vw,1.35rem); background: #101f2dea;
  border: 1px solid #aec7d456; border-radius: .95rem; box-shadow: 0 8px 28px #0d192e3b;
}
#room .model-caption { max-width: none; }
#room .model-caption strong { color: #fff; font-size: clamp(1.1rem,1.8vw,1.55rem); letter-spacing: -.025em; }
#room .model-caption>span { display: block; color: #a8c6d9; font-size: .68rem; letter-spacing: .105em; }
#room .room-bottom .primary { border-radius: .6rem; }
#room .session-status { color: #eef6fa; background: #132537e8; }
#room .game-status, #room .pause-state, .altitude-toggle { color: #edf5f8; border: 1px solid #647d8e; background: #132735f0; }
#room .route-hint, #room .mission-card, #room .station-board, #room .map-panel { border: 1px solid #92acba73; background: #122736eb; color: #f2f8fd; }
#room .route-hint b, #room .route-hint small, #room .station-board #stationDistance { color: #b7def6; }
#room .station-board #stationState { color: var(--amber); }
#room .speed-card { --instrument-accent: #89d5fc; background: radial-gradient(circle at 45% 25%,#315064ed,#101e2ae8); }
#room .speed-dial .dial-needle { stroke: #ffb36a; }
#room .mission-progress i { background: #94d8ff; }
#room .race-countdown { background: #112434ef; border: 1px solid #a5c3d388; box-shadow: 0 8px 36px #09131e36; }
#room .race-countdown.go .lights { color: #8ee9c5; }
#room #resultCard, dialog.drawer, dialog.settings { background: #152936; color: #eef6f9; border: 1px solid #698493a6; box-shadow: 0 25px 80px #06111ac7; }
dialog::backdrop { background: #06101bb5; }
.drawer p, .settings p, #resultCard .eyebrow, .drawer .eyebrow { color: #bed0db; }
.drawer .storage-note, .settings .storage-note, #settings #rendererNote { color: #b0c4ce!important; }
dialog a, .drawer a:not(.primary), #resultMarket a { color: #a9ddfb; }
dialog .model-row { background: #1e3646; border-color: #537081; }
dialog .model-row.selected, dialog .room-filters [aria-pressed=true] { color: white; background: #29485b; border-color: #8dd0ed; }
dialog .model-row .pick small { color: #bfd1db; }
dialog .model-row .pick { color: #fff; }
dialog .link-button.primary, dialog .drawer a.primary { color: #102131; }
dialog.settings select, dialog form input { color: #fff; border-color: #7893a2; background: #1b3344; }
#resultMarket, #room .rotate-hint { color: #eee; background: #162d3c; }
#resultCard .eyebrow, dialog .eyebrow { color: #a8d1e8; }
@media(max-width:650px) {
  .game-launch { padding-inline: max(12px,env(safe-area-inset-left)); }
  .game-feature { min-height: 18rem; background-position: 60% center; }
  .game-feature::before { background: linear-gradient(90deg,#091723e3 0,#112536bd 24%,#1b2a363d 63%,transparent); }
  .game-feature-copy { width: 52%; padding: 1.1rem; }
  .welcome .game-feature-copy h1 { font-size: clamp(2rem,7.8vw,3.15rem); }
  .welcome .game-feature-copy p { margin: .65rem 0 .8rem; font-size: .89rem; }
  .game-feature .feature-model { right: -9%; width: 69%; height: 74%; }
  .game-feature .feature-model.feature-revuelto { right: -14%; width: 80%; height: 96%; }
  .feature-actions { gap: 0 .65rem; }
  .game-journeys { grid-template-columns: 1fr; gap: .55rem; }
  .welcome .demo-choices { gap: .45rem; }
  .welcome .demo-choices button { padding: .6rem .55rem .75rem; min-height: 8rem; border-radius: .7rem; }
  .welcome .demo-choices button::after { display:none; }
  .welcome .demo-choices img { width: 100%; height: 3.6rem; }
  .welcome .demo-choices strong { font-size: clamp(.89rem,3.4vw,1.1rem); }
  .welcome .demo-choices small { font-size: .75rem; }
  .mode-title { padding-right: 0; gap: 5px; }
  .mode-heading { margin-top: 1rem; }
  #room .room-bottom { gap: 8px; }
  #room .room-bottom .primary, #room .room-bottom #publishTrial { min-width: 0; }
  #room .room-bottom:has(#publishTrial:not([hidden])) { flex-wrap: wrap; }
}
@media(max-height:520px) and (orientation:landscape) {
  .game-launch { padding: max(3.55rem,calc(env(safe-area-inset-top) + 3rem)) max(14px,4vw) 1rem; }
  .game-feature { min-height: clamp(10rem,40vh,13rem); }
  .game-feature-copy { width: 57%; padding: .85rem 1.2rem; }
  .welcome .game-feature-copy h1 { font-size: clamp(1.8rem,5.7vh,2.25rem); margin: 0; }
  .welcome .game-feature-copy h1 br { display: none; }
  .welcome .game-feature-copy h1 em::before { content: ' '; }
  .welcome .game-feature-copy p { margin: .4rem 0; max-width: 36ch; font-size: .87rem; }
  .game-feature .feature-start { min-height: 42px; padding: .45rem .8rem; }
  .game-feature .feature-model { right: 0; width: 48%; height: 108%; }
  .game-feature .feature-model.feature-revuelto { right: -2%; width: 58%; height: 132%; }
  .mode-heading { margin: .55rem 0 .3rem; }
  .welcome .garage-choice { padding-block: .45rem; }
  .welcome .demo-choices button { min-height: 6.3rem; padding: .5rem .7rem; }
  .welcome .demo-choices img { height: 3.3rem; margin: 0; }
  .welcome .demo-choices strong { font-size: .95rem; }
  .welcome .demo-choices small { font-size: .75rem; }
  .game-journeys { grid-template-columns: .8fr 1.4fr; margin-top: .7rem; gap: .5rem; }
  .game-journeys .journey-panel { padding: .7rem .8rem; }
  #room .room-bottom { min-height: 48px; padding: .35rem .7rem; }
  #room .model-caption strong { font-size: 1.1rem; }
}
@media(prefers-reduced-motion:reduce) {
  .welcome .demo-choices button, .welcome .demo-choices img { transition: none; }
}
.welcome .trial-upgrade { color: #c5d7e3; margin-top: .9rem; border: 0; padding: 0; }
.welcome .trial-upgrade summary { width: fit-content; min-height: 44px; padding: .65rem 0; color: #c5e5f7; font-weight: 650; font-size: .92rem; cursor: pointer; }
.welcome .trial-upgrade p { color: #c3d4df; margin: .4rem 0; }
.welcome .trial-upgrade a { display: inline-flex; align-items: center; min-height: 44px; color: #b5e4fe; }
