:root {
    color-scheme: light;
    font: 100%/1.45 "Inter", "Segoe UI", system-ui, sans-serif;
    -webkit-text-size-adjust: 100%;
}

body { margin: 0; background: #e7e9df; }

.drive {
    --ink: #193b32;
    --green: #153e35;
    --muted: #52635b;
    --paper: #fbfaf4;
    --soft: #efefe5;
    --line: #d5d8ca;
    --orange: #f5804a;
    --route: #168375;
    --shadow: 0 2px 8px #17352b1a, 0 12px 32px #17352b12;
    --serif: "Baskervville", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --brief-width: clamp(19.75rem, 31vw, 26rem);
    --bar-height: calc(clamp(3.75rem, 8vh, 4.5rem) + env(safe-area-inset-top, 0px));
    --gap: clamp(.85rem, 2vw, 1.75rem);
    --top: calc(var(--gap) + env(safe-area-inset-top, 0px));
    --left: calc(var(--gap) + env(safe-area-inset-left, 0px));
    --right: calc(var(--gap) + env(safe-area-inset-right, 0px));
    --bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px));
    --pad-height: clamp(3.1rem, 8vmin, 4.15rem);
    position: fixed;
    inset: 0;
    height: 100%;
    height: 100dvh;
    isolation: isolate;
    overflow: hidden;
    background: #e5e8dc;
    color: var(--ink);
}

.drive *, .drive *::before, .drive *::after { box-sizing: border-box; }
.drive [hidden] { display: none !important; }
.drive :where(h1, h2, p, figure, dl, dd, ol) { margin: 0; }
.drive button, .drive a { color: inherit; font: inherit; }
.drive button { cursor: pointer; }
.drive button:disabled { cursor: wait; }
.drive :focus-visible { outline: 3px solid #a34015; outline-offset: 3px; }
.drive #scene:focus-visible { outline-offset: -4px; }
.drive button, .drive summary, .drive a { -webkit-tap-highlight-color: transparent; }

#scene {
    position: absolute;
    inset: 0 auto auto 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}


.start-layout {
    display: grid;
    position: absolute;
    inset: 0;
    grid-template: var(--bar-height) minmax(0, 1fr) / var(--brief-width) minmax(0, 1fr);
    background: var(--paper);
}
.station-bar {
    grid-area: 1 / 1 / 2 / 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: env(safe-area-inset-top, 0px) var(--right) 0 var(--left);
    border-bottom: 1px solid var(--line);
    background: var(--paper);
}
.station-brand, .dialog-station { display: inline-flex; align-items: center; gap: .65rem; font-weight: 760; letter-spacing: -.05em; }
.station-brand small { display: block; font-size: .68rem; line-height: 1; letter-spacing: 0; }
.station-brand { font-size: clamp(1.13rem, 2vw, 1.52rem); white-space: nowrap; }
.station-mark {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: .48rem;
    background: var(--green);
}
.station-mark i { width: 3px; height: .45rem; border-radius: 3px; background: #f8f3d5; }
.station-mark i:nth-child(2), .station-mark i:nth-child(4) { height: .86rem; }
.station-mark i:nth-child(3) { height: 1.33rem; background: var(--orange); }
.pin-icon { position: relative; display: inline-block; width: .8rem; height: .8rem; border: 1.8px solid currentColor; border-radius: 50% 50% 50% 0; transform: translateY(-.12rem) rotate(-45deg); }
.pin-icon::after { content: ""; position: absolute; inset: 29%; border-radius: 50%; background: currentColor; }

.mode-switch, .style-options { display: inline-flex; align-items: stretch; gap: .18rem; padding: .18rem; border: 1px solid var(--line); border-radius: .6rem; background: #edeee5; }
.mode-switch button, .style-options button { min-height: 44px; padding: .45rem .95rem; border: 1px solid transparent; border-radius: .4rem; background: transparent; font-size: .83rem; font-weight: 630; white-space: nowrap; }
.mode-switch button[aria-pressed="true"] { background: var(--green); color: #fffdf1; }
.style-options { display: flex; width: 100%; }
.style-options button { display: inline-flex; align-items: center; justify-content: center; flex: 1; gap: .55rem; min-width: 0; padding: .36rem .55rem; }
.style-options button[aria-pressed="true"] { border-color: #b7c3ac; background: var(--paper); box-shadow: 0 1px 3px #283d2d16; }
.style-sample { flex: none; width: 1.35rem; height: 1.35rem; border: 1px solid #9fa994; border-radius: .22rem; }
.illustrated-sample { background: linear-gradient(37deg, #436653 0 39%, #dec89e 40% 51%, #8aa77e 52%); }
.atlas-sample { background: repeating-linear-gradient(90deg, transparent 0 5px, #fcfaf3 5px 9px), repeating-linear-gradient(-25deg, #b9c7ad 0 5px, #fcfaf3 5px 9px); }
.trip-brief {
    grid-area: 2 / 1;
    display: flex;
    flex-direction: column;
    gap: clamp(1.3rem, 4.1vh, 2.8rem);
    min-width: 0;
    padding: clamp(1.6rem, 6vh, 4.5rem) clamp(1.4rem, 2.8vw, 2.65rem) max(1rem, env(safe-area-inset-bottom, 0px));
    padding-left: max(clamp(1.4rem, 2.8vw, 2.65rem), env(safe-area-inset-left, 0px));
    overflow: auto;
    overscroll-behavior: contain;
    border-right: 1px solid var(--line);
    scrollbar-width: thin;
}
.trip-brief > * { flex: none; }
.section-label, .objective-leg {
    display: flex;
    align-items: center;
    gap: .55rem;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 760;
    line-height: 1.3;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.signal-line { width: 1.35rem; height: 3px; background: #d56835; }
.trip-intro h1, .drive-dialog h2 { font: 600 clamp(3.2rem, 5.1vw, 5.5rem)/.99 var(--serif); letter-spacing: -.055em; }
.trip-intro h1 { margin: 0 0 .85rem; }
.trip-intro h1 em, .drive-dialog h2 em { display: block; color: #416756; font-weight: 400; }
.trip-description { max-width: 24rem; color: var(--muted); font-size: clamp(.95rem, 1.25vw, 1.06rem); line-height: 1.55; }
.stop-symbol { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; flex: none; font-size: .73rem; font-weight: 760; line-height: 1; font-style: normal; }
.studio-stop { background: var(--green); color: #fff; border-radius: 50%; }
.market-stop { background: #f3b18b; color: #58331f; border: 1px solid #c87e54; border-radius: .34rem; }
.start-actions { margin-top: auto; }
.game-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem 1rem; }
.game-links .atlas-link { margin-block: .2rem; }
.cloud-status { margin: .4rem 0; font-size: .86rem; line-height: 1.4; }
.cloud-status:empty { display: none; }
.save-picker select { display: block; width: 100%; margin: .3rem 0 .55rem; min-height: 44px; color: var(--green); background: var(--paper); }
#radio-continue:not([hidden]) { margin-bottom: .45rem; }
.action-button, .text-button, .map-toggle, .map-close, .pause-button, #touch-controls button {
    min-height: 44px;
    border: 0;
    border-radius: .55rem;
    user-select: none;
    -webkit-user-select: none;
}
.drive .action-button { display: flex; width: 100%; align-items: center; justify-content: center; gap: .75rem; padding: .8rem 1.1rem; font-size: .96rem; font-weight: 720; }
.drive .primary-action { justify-content: space-between; min-height: 3.3rem; color: #252b22; background: var(--orange); }
.drive .primary-action:disabled { background: #e6ddcb; color: #616658; }
.action-arrow { font-size: 1.4rem; line-height: 1; }
.start-actions:has(#retry:not([hidden])) #start { display: none; }
#load-status { margin-top: .55rem; color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
#load-status:empty { display: none; }
.controls-guide { margin-top: .65rem; }
.controls-guide summary { display: flex; align-items: center; gap: .5rem; width: fit-content; min-height: 44px; padding: .35rem .15rem .35rem 0; cursor: pointer; font-size: .84rem; font-weight: 630; list-style: none; }
.controls-guide summary::-webkit-details-marker { display: none; }
.keys-icon { position: relative; width: 1.15rem; height: .8rem; border: 1.5px solid currentColor; border-radius: .18rem; }
.keys-icon::before, .keys-icon::after { content: ""; position: absolute; left: 17%; right: 17%; }
.keys-icon::before { top: 24%; height: 2px; background: repeating-linear-gradient(to right, currentColor 0 2px, transparent 2px 4px); }
.keys-icon::after { bottom: 17%; height: 1px; background: currentColor; }
.disclosure-icon { width: .43rem; height: .43rem; margin-left: .2rem; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.controls-guide[open] .disclosure-icon { transform: rotate(225deg) translate(-1px, -2px); }
.key-list { border-top: 1px solid var(--line); padding-top: .4rem; }
.key-list > div { display: flex; align-items: center; justify-content: space-between; gap: .65rem; padding: .28rem 0; font-size: .77rem; }
.key-list dd { white-space: nowrap; color: var(--muted); }
.drive kbd { display: inline-block; min-width: 1.35em; border: 1px solid #c6ccbd; border-radius: .2rem; padding: .03em .25em; background: #f3f3e9; color: var(--ink); font: 650 .92em/1.4 "Inter", system-ui, sans-serif; text-align: center; }
.drive :is(.guide-tip, .touch-help) { margin-top: .55rem; color: var(--muted); font-size: .8rem; }


.drive[data-mode="free"] .course-only, .drive[data-mode="course"] .free-only { display: none !important; }
.field-label, .selected-place small { display: block; margin: 0 0 .48rem; color: var(--muted); font-size: .78rem; font-weight: 650; }
.selected-place { display: flex; align-items: center; gap: .83rem; padding-block: 1.15rem; border-block: 1px solid var(--line); }
.selected-icon { display: grid; place-items: center; flex: none; width: 2.7rem; height: 2.7rem; border-radius: .65rem; color: var(--green); background: #e5eadd; }
.selected-icon .pin-icon { width: 1rem; height: 1rem; }
.selected-place > div { min-width: 0; }
.selected-place small { margin-bottom: .12rem; }
.selected-place strong { display: block; overflow-wrap: anywhere; font-size: 1.14rem; letter-spacing: -.025em; }
#selected-coords { display: block; margin-top: .16rem; color: var(--muted); font-size: .73rem; font-variant-numeric: tabular-nums; }
.atlas-link { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; margin-top: .3rem; font-size: .82rem; text-underline-offset: .2em; }
.scene-preview { grid-area: 2 / 2; }
.map-field { position: relative; isolation: isolate; min-width: 0; min-height: 0; overflow: hidden; background: #e6e9dd; }
.geo-map, .geo-tiles { position: absolute; inset: 0; overflow: hidden; }
.geo-map { outline-offset: -4px !important; cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none; }
.geo-map.dragging { cursor: grabbing; }
.geo-tiles img { position: absolute; inset: 0 auto auto 0; display: block; visibility: hidden; max-width: none; pointer-events: none; }
.geo-tiles img.loaded { visibility: visible; }
.geo-pin { display: flex; position: absolute; z-index: 1; align-items: center; flex-direction: column; transform: translate(-50%, -100%); pointer-events: none; }
.geo-pin i { display: block; position: relative; width: 1.72rem; height: 1.72rem; margin-bottom: .32rem; transform: rotate(-45deg); border: 2px solid #fffbee; border-radius: 50% 50% 50% 0; background: #dc6c35; box-shadow: -1px 2px 4px #23381b55; }
.geo-pin i::after { position: absolute; inset: 30%; border-radius: 50%; background: #fffbee; content: ""; }
.geo-pin b { max-width: min(48vw, 15rem); margin-bottom: .24rem; padding: .24rem .6rem; overflow: hidden; border: 1px solid #33543c; border-radius: .32rem; background: #204735; color: #fffcee; font-size: .78rem; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; }
.geo-map[data-aim="true"]::after { position: absolute; top: 50%; left: 50%; width: 1rem; height: 1rem; transform: translate(-50%, -50%); border: 2px solid var(--green); outline: 2px solid white; border-radius: 50%; content: ""; pointer-events: none; }
.geo-tools { position: absolute; z-index: 2; top: var(--gap); right: var(--gap); display: grid; overflow: hidden; border: 1px solid #b7c2b3; border-radius: .56rem; background: var(--paper); box-shadow: var(--shadow); }
.geo-tools button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 0; background: var(--paper); color: var(--green); font-size: 1.35rem; font-weight: 570; line-height: 1; }
.geo-tools button + button { border-top: 1px solid var(--line); }
.geo-tools button:disabled { color: #929d8f; cursor: default; }
.geo-tools button:focus-visible { outline-offset: -3px; }
.recenter-glyph { position: relative; width: .89rem; height: .89rem; border: 1.8px solid currentColor; border-radius: 50%; outline: 1px solid transparent; }
.recenter-glyph::before, .recenter-glyph::after { position: absolute; top: 50%; left: 50%; width: 1.33rem; height: 1.33rem; transform: translate(-50%, -50%); background: linear-gradient(currentColor, currentColor) top center / 2px 3px no-repeat, linear-gradient(currentColor, currentColor) bottom center / 2px 3px no-repeat; content: ""; }
.recenter-glyph::after { transform: translate(-50%, -50%) rotate(90deg); }
.geo-scale { position: absolute; bottom: 1.45rem; left: var(--gap); display: grid; justify-items: start; padding: .2rem .35rem; border-radius: .2rem; background: #fbfaf4d9; color: #34483b; font-size: .61rem; font-variant-numeric: tabular-nums; pointer-events: none; }
.geo-scale i { display: block; height: .29rem; border: solid currentColor; border-width: 0 1px 1px; }
.tile-status { position: absolute; z-index: 2; right: var(--gap); bottom: 1.45rem; display: flex; align-items: center; gap: .5rem; max-width: calc(100% - 6rem); padding: .4rem .62rem; border-radius: .35rem; background: #fbfaf4ef; color: #425444; font-size: .71rem; }
.tile-status button { min-height: 34px; padding: .15rem .4rem; border: 1px solid var(--line); border-radius: .25rem; background: var(--paper); font-size: .72rem; }
.map-search { position: absolute; z-index: 2; top: var(--gap); left: var(--gap); width: min(20rem, calc(100% - 44px - 3 * var(--gap))); margin: 0; }
.search-box, .search-message, .place-results { border: 1px solid #b7c2b3; border-radius: .58rem; background: var(--paper); box-shadow: var(--shadow); }
.search-box { display: flex; align-items: center; gap: .72rem; padding: 0 .9rem; }
.search-box:focus-within { outline: 2px solid #37684c; outline-offset: 1px; }
.search-icon { position: relative; flex: none; width: .83rem; height: .83rem; margin-top: -.14rem; border: 1.65px solid var(--muted); border-radius: 50%; }
.search-icon::after { position: absolute; right: -.29rem; bottom: -.18rem; width: .41rem; height: .1rem; transform: rotate(46deg); border-radius: 2px; background: var(--muted); content: ""; }
.search-box input { width: 100%; min-width: 0; height: 46px; padding: 0; border: 0; outline: 0 !important; background: transparent; color: var(--ink); font: 530 1rem/1.3 "Inter", system-ui, sans-serif; }
.search-box input::placeholder { color: var(--muted); opacity: 1; }
.place-results, .search-message { margin-top: .32rem !important; }
.place-results { max-height: min(35dvh, 18rem); padding: .18rem; overflow-y: auto; overscroll-behavior: contain; }
.place-results button { display: grid; gap: .07rem; min-height: 44px; width: 100%; padding: .44rem .6rem; border: 0; border-radius: .35rem; background: transparent; text-align: left; }
.place-results button:hover, .place-results button[aria-selected="true"] { background: var(--soft); }
.place-results strong, .place-results small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-results strong { font-size: .84rem; }
.place-results small { color: var(--muted); font-size: .73rem; }
.search-message { padding: .55rem .75rem; color: var(--muted); font-size: .8rem; }
.map-credit { position: absolute; right: 0; bottom: 0; padding: .14rem max(.46rem, env(safe-area-inset-right, 0px)) max(.14rem, env(safe-area-inset-bottom, 0px)) .46rem; border-radius: .22rem 0 0; background: #fbfaf4ed; color: #364f43; font-size: .62rem; line-height: 1.25; }
.map-credit a { text-decoration-thickness: 1px; text-underline-offset: .12em; pointer-events: auto; }

#hud { position: absolute; inset: 0; pointer-events: none; }
.route-overlay { position: absolute; top: var(--top); left: var(--left); display: grid; justify-items: start; gap: .4rem; max-width: min(calc(100% - var(--left) - var(--right) - 4.2rem), 27rem); }
.objective-widget { display: flex; align-items: center; gap: .75rem; max-width: 100%; border-radius: .6rem; padding: .75rem .95rem .75rem .72rem; }
.objective-icon { display: grid; place-items: center; width: 2rem; height: 2rem; flex: none; border-radius: .45rem; color: var(--green); background: #e1e9d9; }
.objective-icon .pin-icon { width: .94rem; height: .94rem; }
.objective-body { min-width: 0; }
.objective-leg { flex-wrap: wrap; gap: .37rem; font-size: .61rem; letter-spacing: .07em; }
.leg-divider { width: .23rem; height: .23rem; border-radius: 50%; background: #9aab9b; }
.objective-leg:has(#distance:empty) .leg-divider { display: none; }
#distance { text-transform: none; letter-spacing: normal; font-variant-numeric: tabular-nums; }
#objective { margin-top: .19rem; font-size: clamp(.87rem, 1.5vw, 1.12rem); line-height: 1.25; font-weight: 720; letter-spacing: -.025em; }
#parking-progress { display: block; appearance: none; width: 100%; height: .28rem; margin-top: .45rem; overflow: hidden; border: 0; border-radius: 1rem; accent-color: var(--route); background: var(--line); }
#parking-progress::-webkit-progress-bar { border-radius: inherit; background: var(--line); }
#parking-progress::-webkit-progress-value { border-radius: inherit; background: var(--route); }
#parking-progress::-moz-progress-bar { border-radius: inherit; background: var(--route); }
.drive .pause-button { position: absolute; top: var(--top); right: var(--right); display: flex; align-items: center; justify-content: center; gap: .52rem; min-width: 44px; padding: .65rem .82rem; border: 1px solid #bdc7b8; font-size: .83rem; font-weight: 680; pointer-events: auto; }
.pause-icon { display: block; width: .65rem; height: .85rem; border-inline: 3px solid currentColor; }

.drive-instruments { position: absolute; left: var(--left); bottom: calc(var(--bottom) + .45rem); display: flex; align-items: center; gap: .8rem; padding: .6rem .92rem; border: 1px solid #f3f4e94a; border-radius: .55rem; background: #173c32f5; box-shadow: var(--shadow); color: #fffdf0; }
.speed-reading { display: flex; align-items: baseline; gap: .29rem; }
.speed-reading strong { font-size: clamp(1.6rem, 3.5vw, 2.45rem); line-height: 1; font-weight: 680; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.speed-reading span, .collision-reading span { color: #d5dece; font-size: .66rem; }
.collision-reading { display: flex; flex-direction: column; padding-left: .75rem; border-left: 1px solid #93a79874; }
.collision-reading strong { font-size: .84rem; line-height: 1.2; font-variant-numeric: tabular-nums; }

.nav-card { position: absolute; right: var(--right); bottom: calc(var(--bottom) + .45rem); width: clamp(10.5rem, 16vw, 14rem); overflow: hidden; border-radius: .56rem; pointer-events: auto; }
.nav-toolbar { flex: none; }
.drive .map-toggle { display: flex; align-items: center; gap: .47rem; width: 100%; padding: .4rem .65rem; background: var(--paper); font-size: .77rem; font-weight: 670; }
.map-toggle::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: .55rem; }
.map-toggle:focus-visible::after { outline: 3px solid #a34015; outline-offset: -3px; }
.map-glyph { position: relative; display: inline-block; width: .95rem; height: .81rem; background: currentColor; clip-path: polygon(0 20%, 33% 0, 67% 20%, 100% 0, 100% 80%, 67% 100%, 33% 80%, 0 100%); }
.map-glyph::before, .map-glyph::after { content: ""; position: absolute; inset-block: 0; width: 1px; background: var(--paper); }
.map-glyph::before { left: 32%; }
.map-glyph::after { left: 66%; }
.expand-icon { position: relative; width: .79rem; height: .79rem; margin-left: auto; }
.expand-icon::before, .expand-icon::after { content: ""; position: absolute; width: .35rem; height: .35rem; }
.expand-icon::before { top: 0; right: 0; border-right: 1.5px solid; border-top: 1.5px solid; }
.expand-icon::after { left: 0; bottom: 0; border-left: 1.5px solid; border-bottom: 1.5px solid; }
.nav-surface { position: relative; aspect-ratio: 1.5; border-top: 1px solid var(--line); background: #e8eade; overflow: hidden; }
#nav-map { display: block; width: 100%; height: 100%; }
.nav-north { position: absolute; top: .42rem; right: .42rem; display: grid; justify-items: center; gap: 2px; padding: .24rem; border-radius: .2rem; background: #fbfaf4d9; }
.nav-north { font-size: .62rem; font-weight: 750; line-height: 1; }
.nav-north i { display: block; width: .47rem; height: .67rem; background: linear-gradient(90deg, #254b3b 50%, #91a195 50%); clip-path: polygon(50% 0, 100% 100%, 50% 79%, 0 100%); }
.expanded-map-title, .drive .map-close, .map-legend { display: none; }
.map-expanded #hud::before { content: ""; position: absolute; inset: 0; z-index: 2; background: #1d302ac9; pointer-events: auto; }
.map-expanded .nav-card { z-index: 3; inset: var(--top) var(--right) var(--bottom) var(--left); width: auto; max-width: 64rem; max-height: 54rem; margin: auto; display: flex; flex-direction: column; }
.map-expanded .nav-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .45rem .8rem .45rem 1.15rem; }
.map-expanded .expanded-map-title { display: block; font: 600 clamp(1.4rem, 3vw, 2rem)/1.15 var(--serif); letter-spacing: -.045em; }
.map-expanded .map-toggle { display: none; }
.map-expanded .map-close { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .65rem; background: var(--soft); font-size: .82rem; font-weight: 640; }
.map-close span { font-size: 1.35rem; line-height: 1; }
.map-expanded .nav-surface { flex: 1; min-height: 0; aspect-ratio: auto; }
.map-expanded .map-legend { display: flex; flex: none; align-items: center; flex-wrap: wrap; gap: .4rem 1rem; padding: .7rem 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; }
.map-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.map-legend .stop-symbol { width: 1.17rem; height: 1.17rem; font-size: .58rem; }
.legend-car { display: inline-block; width: .74rem; height: .9rem; background: #c15d31; clip-path: polygon(50% 0, 100% 100%, 50% 79%, 0 100%); }
.map-expanded :is(.route-overlay, .pause-button, .drive-instruments, .location-chip, #touch-controls, .in-game-credit) { visibility: hidden; }

#notice, #failure { max-width: 100%; border-radius: .45rem; padding: .52rem .82rem; color: var(--ink); font-size: .82rem; line-height: 1.4; overflow-wrap: anywhere; }
#notice:empty, #failure:empty { display: none; }
#failure { position: absolute; z-index: 5; top: var(--top); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(31rem, calc(100% - 2rem)); border: 1px solid #b26d4d; background: #fff5e7; color: #773719; box-shadow: var(--shadow); text-align: center; pointer-events: none; }
.drive:is([data-state="loading"], [data-state="ready"], [data-state="error"]) #failure { display: none; }
.drive:has(#failure:not([hidden]):not(:empty)) .dialog-layer { padding-top: calc(var(--top) + 3.5rem); }

#touch-controls { position: absolute; left: var(--left); right: var(--right); bottom: calc(var(--bottom) + .46rem); display: none; justify-content: space-between; gap: .5rem; pointer-events: none; }
.steer-pad, .pedal-pad { display: flex; gap: .4rem; }
#touch-controls button { display: grid; place-items: center; min-width: max(44px, var(--pad-height)); min-height: max(44px, var(--pad-height)); padding: .2rem .48rem; border: 1px solid #b7c1b2; border-radius: .6rem; background: #fbfaf4f5; box-shadow: var(--shadow); font-size: .78rem; font-weight: 750; touch-action: none; -webkit-touch-callout: none; pointer-events: auto; }
#touch-controls [data-drive="gas"] { border-color: #9e502e; background: var(--orange); color: #252b22; }
.turn-arrow { width: .75rem; height: .75rem; border-top: 2px solid; border-right: 2px solid; }
.turn-left { transform: translateX(.13rem) rotate(-135deg); }
.turn-right { transform: translateX(-.13rem) rotate(45deg); }
#touch-controls button:is(:active, [aria-pressed="true"]) { background: var(--green); border-color: #b4d7b7; color: #fffdf0; box-shadow: inset 0 2px 5px #001d184a; }

.dialog-layer { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; align-items: safe center; overflow: auto; padding: var(--top) var(--right) var(--bottom) var(--left); background: #1d302ab5; overscroll-behavior: contain; }
.drive-dialog { width: min(100%, 25rem); border: 1px solid #d0d3c3; border-radius: .85rem; padding: clamp(1.3rem, 4vw, 2.35rem); background: var(--paper); box-shadow: 0 15px 70px #10201e33; }
.dialog-station { color: var(--muted); font-size: .83rem; }
.dialog-station .station-mark { width: 1.72rem; height: 1.72rem; gap: 1.5px; border-radius: .35rem; }
.dialog-station .station-mark i { width: 2px; }
.drive-dialog h2 { margin: 1.15rem 0 .8rem; font-size: clamp(2.5rem, 6vw, 3.8rem); }
.drive-dialog :is(.pause-help, .pause-touch-help, #summary) { color: var(--muted); font-size: .93rem; line-height: 1.6; }
.pause-touch-help { display: none; }
.dialog-actions { display: grid; gap: .55rem; margin-top: 1.45rem; }
.drive .secondary-action { border: 1px solid #a8b5a4; background: var(--soft); }
.drive .text-button { background: transparent; color: #3c584b; font-size: .86rem; font-weight: 620; text-decoration: underline; text-underline-offset: .21em; }
.boot-error .text-button { display: grid; place-items: center; }
.boot-error p { overflow-wrap: anywhere; }
.drive:has(.boot-error) .start-layout { visibility: hidden; }

@media (hover: hover) {
    .drive .primary-action:not(:disabled):hover { background: #fa945e; }
    .drive :is(.secondary-action, .pause-button, .map-toggle, .map-close):hover { background: #e4e9dc; }
    .drive :is(.atlas-link, .controls-guide summary, .text-button):hover { color: #88502f; }
}

@media (any-pointer: coarse), (max-width: 44rem) {
    .drive:not(.map-expanded) #hud { display: grid; grid-template: minmax(0, 1fr) auto auto / minmax(0, 1fr); row-gap: .5rem; }
    #touch-controls { position: static; grid-row: 2; display: flex; margin-inline: var(--left) var(--right); }
    .in-game-credit { position: static; grid-row: 3; justify-self: end; padding-left: max(.46rem, env(safe-area-inset-left, 0px)); }
    .drive-instruments, .nav-card { grid-area: 1 / 1 / 2 / 2; bottom: 0; }
    .pause-touch-help { display: block; }
    .pause-help { display: none; }
    .nav-card { width: clamp(7.75rem, 22vw, 11rem); }
    .drive .map-toggle { padding-inline: .5rem; font-size: .7rem; }
    .nav-surface { aspect-ratio: 1.7; }
    .drive-instruments { gap: .55rem; padding: .48rem .65rem; }
    .collision-reading { padding-left: .55rem; }
}


/* Status and controls anchored to the actual driving view. */
.objective-widget, .pause-button, .nav-card, #notice, .score-widget, #score-event {
    border: 1px solid #bdc7b8; background: var(--paper); box-shadow: var(--shadow);
}
.score-widget { display: flex; align-items: center; gap: 1rem; padding: .5rem .8rem; border-radius: .58rem; }
.score-widget > div { display: flex; align-items: baseline; gap: .38rem; }
.score-widget > div + div { padding-left: .8rem; border-left: 1px solid var(--line); }
.score-widget span { color: var(--muted); font-size: .75rem; font-weight: 570; }
.score-widget strong { font: 690 1.26rem/1.1 "Inter", system-ui, sans-serif; font-variant-numeric: tabular-nums; }
#score-event { max-width: 100%; padding: .4rem .65rem; border-radius: .4rem; color: var(--ink); font-size: .79rem; font-weight: 620; }
#score-event:empty, .drive[data-mode="free"]:not([data-navigation="true"]) .objective-widget { display: none; }
.location-chip { position: absolute; left: var(--left); bottom: calc(var(--bottom) + 4.6rem); display: grid; gap: .12rem; max-width: min(19rem, 45%); padding: .39rem .64rem; border: 1px solid #bdc7b8; border-radius: .42rem; background: #fbfaf4f0; color: var(--green); font-size: .75rem; line-height: 1.3; overflow-wrap: anywhere; }
.location-label, #stream-status, #detail-status { color: var(--muted); font-size: .68rem; }
#stream-status:empty, #detail-status:empty { display: none; }
.legend-icon { display: block; width: 1.1rem; height: 1.1rem; object-fit: contain; }
.nav-footways { stroke: #bfc7b9; }
.nav-roads { stroke: #9aaea0; }
.nav-signals { fill: #328f83; stroke: #f5fff1; stroke-width: 1; }
.nav-noise { fill: none; stroke: #b64735; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
#nav-map[data-style="atlas"] .nav-roads { stroke: #839797; }
.nav-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem .8rem; margin-left: auto; }
.drive .nav-actions .action-button, .drive .destination-foot .action-button { width: auto; padding: .42rem .85rem; font-size: .82rem; }
.drive .nav-actions .text-button { font-size: .78rem; }
.destination-panel { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.nav-card:has(.destination-panel:not([hidden])) > :is(.nav-toolbar, .nav-surface, .map-legend) { display: none; }
.destination-panel .map-field { flex: 1; }
.destination-head, .destination-foot { display: flex; align-items: center; justify-content: space-between; flex: none; gap: .75rem; padding: .45rem .85rem; border-bottom: 1px solid var(--line); }
.destination-foot { padding: .67rem .85rem; border: 0; border-top: 1px solid var(--line); }
.destination-foot > div { min-width: 0; }
#destination-name { display: block; font-size: .84rem; overflow-wrap: anywhere; }
#destination-status { color: var(--muted); font-size: .74rem; overflow-wrap: anywhere; }
.drive .destination-foot .action-button { flex: none; }
.personal-record { margin: 0 0 .7rem !important; color: var(--muted); font-size: .83rem; }
.personal-record strong { color: var(--green); font-variant-numeric: tabular-nums; }
.world-details { margin-top: .6rem; border-block: 1px solid var(--line); }
.world-details summary { width: 100%; }
#world-metrics { padding: 0 0 .7rem; color: var(--muted); font-size: .74rem; font-variant-numeric: tabular-nums; white-space: pre-line; overflow-wrap: anywhere; }
.drive-dialog .style-choice { margin: .35rem 0 1.1rem; }
.map-credit { z-index: 2; }
@media (hover: hover) {
    .drive :is(.mode-switch button, .style-options button):not([aria-pressed="true"]):hover, .geo-tools button:not(:disabled):hover { background: #dfe5d7; }
}
@media (any-pointer: coarse), (max-width: 44rem) {
    .location-chip { grid-area: 1 / 1 / 2 / 2; bottom: 3.2rem; }
}
@media (max-width: 47rem) and (orientation: portrait) {
    .drive { --bar-height: calc(3.7rem + env(safe-area-inset-top, 0px)); }
    .start-layout { grid-template: var(--bar-height) minmax(11rem, 1fr) minmax(0, auto) / minmax(0, 1fr); }
    .station-bar { grid-area: 1 / 1; gap: .45rem; padding-inline: max(.72rem, env(safe-area-inset-left)) max(.72rem, env(safe-area-inset-right)); }
    .station-brand { gap: .42rem; font-size: 1.05rem; }
    .station-mark { width: 1.78rem; height: 1.78rem; }
    .mode-switch { gap: 0; padding: 2px; }
    .mode-switch button { padding-inline: .58rem; font-size: .74rem; }
    .scene-preview { grid-area: 2 / 1; }
    .trip-brief { grid-area: 3 / 1; display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: .74rem 1rem; max-height: 52dvh; padding: .95rem var(--right) max(.5rem, env(safe-area-inset-bottom)) var(--left); border: 0; border-top: 1px solid var(--line); }
    .trip-intro, .start-actions { grid-column: 1 / -1; }
    .trip-intro h1 { margin: 0; font-size: clamp(2rem, 8.2vw, 3rem); }
    .trip-intro h1 em { display: inline; }
    .trip-description { max-width: none; margin-top: .3rem !important; font-size: .8rem; line-height: 1.4; }
    .selected-place { padding: 0; border: 0; }
    .selected-icon { display: none; }
    .field-label, .selected-place small { margin-bottom: .22rem; font-size: .7rem; }
    .selected-place strong { font-size: .96rem; }
    #selected-coords { font-size: .63rem; }
    .style-options button { gap: .25rem; padding-inline: .26rem; font-size: .72rem; }
    .style-sample { width: .85rem; height: .85rem; }
    .start-actions { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 0 .55rem; }
    .start-actions #load-status { grid-row: 2; grid-column: 1 / -1; }
    .start-actions .controls-guide { grid-area: 1 / 2; margin: 0; }
    .start-actions .controls-guide[open] { grid-area: 3 / 1 / 4 / -1; }
    .controls-guide summary { min-height: 3.05rem; font-size: .73rem; }
    .drive .start-actions .primary-action { min-height: 3.05rem; padding: .65rem .85rem; }
    .drive[data-mode="course"] .trip-brief { display: flex; gap: .7rem; }
    .atlas-link { margin: 0; min-height: 36px; }
    .pause-word { display: none; }
    .objective-widget { gap: .5rem; padding: .45rem .6rem; }
    .objective-icon { width: 1.65rem; height: 1.65rem; }
    .nav-actions { width: 100%; margin: 0; }
    .map-expanded .map-legend { gap: .22rem .7rem; padding-block: .45rem; }
}
@media (max-width: 24rem) and (orientation: portrait) {
    .station-brand { gap: .3rem; font-size: .93rem; }
    .station-mark { width: 1.48rem; height: 1.55rem; }
    .mode-switch button { padding-inline: .42rem; font-size: .7rem; }
    .trip-brief { gap: .64rem; }
    .style-sample { display: none; }
}
@media (max-height: 42rem) and (orientation: landscape) {
    .drive { --bar-height: calc(3.35rem + env(safe-area-inset-top, 0px)); --brief-width: clamp(16.5rem, 35vw, 22rem); }
    .trip-brief { gap: .9rem; padding: 1.2rem var(--gap) var(--bottom) var(--left); }
    .trip-intro h1 { margin-bottom: .52rem; font-size: clamp(2.15rem, 4.4vw, 3.3rem); }
    .trip-intro h1 em { display: inline; }
    .trip-description { font-size: .83rem; line-height: 1.4; }
    .selected-place { padding-block: .67rem; }
    .drive-dialog { padding: 1.05rem 1.4rem; }
    .drive-dialog h2 { margin: .55rem 0; font-size: 2.4rem; }
    .dialog-actions { margin-top: .7rem; gap: .35rem; }
}
@media (max-height: 31rem) and (orientation: landscape) {
    .drive { --gap: .55rem; }
    .trip-brief { gap: .7rem; padding-top: .8rem; }
    .trip-intro h1 { font-size: 2rem; }
    .drive .primary-action { min-height: 44px; padding-block: .45rem; }
    .controls-guide { margin-top: .1rem; }
    .pause-word { display: none; }
    .drive:not(.map-expanded) .nav-card { top: var(--top); right: calc(var(--right) + 3.2rem); bottom: auto; width: auto; }
    .drive:not(.map-expanded) .nav-surface { display: none; }
    .route-overlay { max-width: 50%; }
}
