:root {
  --ink: #1f2a24;
  --paper: rgba(250, 247, 238, 0.86);
  --paper-solid: #faf7ee;
  --accent: #3f6b3a;
  --accent-2: #c9893a;
  --line: rgba(31, 42, 36, 0.14);
  --shadow: 0 10px 30px rgba(20, 30, 25, 0.22);
  --radius: 16px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fbfdc; color: var(--ink); }
body { -webkit-user-select: none; user-select: none; touch-action: none; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--paper-solid); color: var(--ink); border-radius: 999px; padding: 8px 16px; transition: transform .15s ease, background .2s ease, box-shadow .2s ease; }
button:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.12); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
button.primary { background: var(--accent); color: #fff; border-color: transparent; padding: 12px 28px; font-size: 1.05rem; letter-spacing: .02em; }
kbd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .78em; background: rgba(255,255,255,.7); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; margin: 0 1px; }

/* loading */
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: linear-gradient(#a9c8e4, #e9dcc0); z-index: 50; transition: opacity .6s ease; }
.loading.fade { opacity: 0; pointer-events: none; }
.loading-inner { text-align: center; }
.brand-mark { font-size: clamp(2rem, 6vw, 3.4rem); font-style: italic; letter-spacing: .01em; color: #2c3e30; }
.loading-text { margin: 10px 0 14px; opacity: .75; }
.loading-bar { width: 220px; height: 4px; border-radius: 4px; background: rgba(0,0,0,.1); overflow: hidden; margin: 0 auto; }
.loading-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }

/* title */
.screen { position: fixed; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 24px; z-index: 20; pointer-events: none;
  background: linear-gradient(to top, rgba(18, 28, 22, .35), rgba(0,0,0,0) 55%); }
.title-card { pointer-events: auto; background: var(--paper); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 22px; box-shadow: var(--shadow); padding: 16px 22px 14px; max-width: 1180px; width: 100%; text-align: center; }
.title-card h1 { margin: 0; font-size: clamp(2rem, 4.4vw, 3rem); font-weight: 600; font-style: italic; letter-spacing: .01em; }
.tagline { margin: 2px 0 10px; opacity: .8; font-size: 1.05rem; }
.pick { font-size: .8rem; text-transform: uppercase; letter-spacing: .14em; margin: 0 0 10px; opacity: .6; font-family: system-ui, sans-serif; font-weight: 600; }
.vehicle-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 12px; }
@media (max-width: 1100px) { .vehicle-cards { grid-template-columns: repeat(4, 1fr); } }
.vcard { display: flex; flex-direction: column; justify-content: flex-start; border-radius: 14px; padding: 8px 10px 9px; text-align: left; background: rgba(255,255,255,.6); border: 2px solid transparent; }
.vcard[aria-checked="true"] { border-color: var(--accent); background: #fff; }
.vcard .swatch { width: 100%; height: 6px; border-radius: 6px; margin-bottom: 8px; }
.vcard .vname { font-weight: 700; font-size: 1.05rem; }
.vcard .vkind { font-family: system-ui, sans-serif; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; opacity: .65; }
.vcard .vstats { font-family: system-ui, sans-serif; font-size: .74rem; font-variant-numeric: tabular-nums; opacity: .8; margin-top: 3px; }
.vcard .vblurb { font-size: .84rem; opacity: .8; margin-top: 4px; line-height: 1.3; }
.world-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.wcard { display: flex; flex-direction: column; text-align: left; border-radius: 14px; padding: 8px 12px 9px; background: rgba(255,255,255,.6); border: 2px solid transparent; }
.wcard[aria-checked="true"] { border-color: var(--accent); background: #fff; }
.wcard .swatch { width: 100%; height: 6px; border-radius: 6px; margin-bottom: 8px; }
.wcard .vname { font-weight: 700; font-size: 1.05rem; }
.wcard .vblurb { font-size: .84rem; opacity: .8; margin-top: 2px; line-height: 1.3; }
.junction { position: absolute; top: 64px; left: 18px; min-width: 210px; max-width: 300px; background: #1d4f9c; color: #fff; border: 2px solid #fff; border-radius: 8px; padding: 7px 10px 8px; font-family: "Helvetica Neue", Arial, system-ui, sans-serif; box-shadow: 0 6px 18px rgba(0,0,0,.25); pointer-events: none; }
.junction .jhead { display: flex; align-items: center; gap: 8px; font-size: .78rem; letter-spacing: .04em; margin-bottom: 4px; opacity: .95; }
.junction .jnum { background: #000; color: #fff; border: 1.5px solid #fff; border-radius: 3px; padding: 0 6px; font-weight: 700; font-size: .9rem; }
.junction .jline { display: flex; align-items: center; gap: 7px; font-size: 1rem; font-weight: 600; line-height: 1.5; }
.junction .jroute { background: #1d4f9c; border: 1.5px solid #fff; border-radius: 3px; padding: 0 5px; font-size: .85rem; }
.junction .jroute.services { background: #fff; color: #1d4f9c; }
body.idle .junction { opacity: .8; }
.keys-hint { font-family: system-ui, sans-serif; font-size: .76rem; opacity: .7; margin: 8px 0 0; line-height: 1.8; }

/* HUD */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; transition: opacity 1.2s ease; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.hud > * { pointer-events: auto; }
.hud-top-left { position: absolute; top: 16px; left: 18px; pointer-events: none; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.35); }
.brand-small { font-family: Georgia, serif; font-style: italic; font-size: 1.25rem; }
.place { font-size: .85rem; opacity: .9; min-height: 1em; }
.hud-top-right { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; }
.icon-btn { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; background: rgba(250, 247, 238, .9); line-height: 0; }
/* no backdrop-filter on the small round buttons: WebKit can smear it over the WebGL canvas */
.icon-btn svg { width: 22px; height: 22px; display: block; overflow: visible; shape-rendering: geometricPrecision; }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 16px; height: 16px; }
.icon-btn.on { background: var(--accent); color: #fff; }
#btn-mute .cross { display: none; }
#btn-mute.muted .cross { display: inline; }
#btn-mute.muted .wave { display: none; }
.hud-bottom-left { position: absolute; left: 18px; bottom: 18px; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,.4); pointer-events: none; }
.speed { font-size: 2.6rem; font-weight: 300; line-height: 1; font-variant-numeric: tabular-nums; }
.speed small { font-size: .9rem; margin-left: 6px; opacity: .85; }
.meta { font-size: .85rem; opacity: .9; margin-top: 4px; font-variant-numeric: tabular-nums; }
.toast { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); color: #fff; font-family: Georgia, serif; font-style: italic; font-size: clamp(1.4rem, 3.4vw, 2.3rem); text-shadow: 0 2px 14px rgba(0,0,0,.45); opacity: 0; transition: opacity 1.4s ease; pointer-events: none; text-align: center; }
.toast small { display: block; font-family: system-ui, sans-serif; font-style: normal; font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; opacity: .85; }
.toast.show { opacity: 1; }
.fps { position: absolute; right: 16px; bottom: 16px; font: 12px ui-monospace, monospace; color: #fff; background: rgba(0,0,0,.35); padding: 4px 8px; border-radius: 6px; pointer-events: none; }
body.idle .hud-top-right, body.idle .panel, body.idle .hud-top-left, body.idle .touch { opacity: 0; transition: opacity 1.4s ease; }
body.idle .hud-bottom-left { opacity: .55; }
body.zen .hud, body.hide-ui .hud, body.hide-ui .panel, body.hide-ui .touch { opacity: 0 !important; pointer-events: none !important; }
body.zen .panel { opacity: 0; pointer-events: none; }
body.idle { cursor: none; }

/* panel */
.panel { position: fixed; top: 66px; right: 14px; width: min(360px, calc(100vw - 28px)); max-height: calc(100vh - 90px); overflow: auto; z-index: 15; background: var(--paper); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px 10px; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: .88rem; transition: opacity .6s ease; }
.panel-head { display: flex; justify-content: space-between; align-items: center; font-family: Georgia, serif; font-style: italic; font-size: 1.15rem; margin-bottom: 6px; }
.row { padding: 8px 0; border-top: 1px solid var(--line); }
.row > label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.row > label span { text-transform: none; font-weight: 400; letter-spacing: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 5px; }
.seg button { padding: 5px 11px; font-size: .84rem; font-family: inherit; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: transparent; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; font-size: .86rem; text-transform: none !important; letter-spacing: 0 !important; font-weight: 400 !important; opacity: 1 !important; }
.checks { display: flex; flex-wrap: wrap; }
.small-print { font-size: .72rem; opacity: .55; }

/* photo */
.photo-bar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 25; display: flex; flex-direction: column; gap: 6px; align-items: stretch; background: var(--paper); backdrop-filter: blur(10px); padding: 8px 12px; border-radius: 18px; box-shadow: var(--shadow); font-family: system-ui, sans-serif; font-size: .8rem; max-width: calc(100vw - 20px); }
.photo-bar .pb-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.photo-bar .pb-lab { font-weight: 600; opacity: .8; white-space: nowrap; }
.photo-bar .pb-check { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.photo-bar .seg.small button { padding: 4px 9px; font-size: .78rem; }
.photo-bar kbd { font-size: .68rem; padding: 0 4px; border: 1px solid currentColor; border-radius: 4px; opacity: .6; margin-left: 2px; }
.photo-bar .photo-hint { opacity: .7; font-size: .74rem; }
@media (max-width: 720px), (pointer: coarse) { .photo-bar kbd, .photo-bar .photo-hint { display: none; } .photo-bar .seg.small button { padding: 7px 10px; } }
/* postcard looks: a live preview; the saved PNG is graded pixel by pixel */
canvas.look-film { filter: sepia(.16) contrast(.95) saturate(.88) brightness(1.03); }
canvas.look-summer { filter: sepia(.22) saturate(1.3) brightness(1.05); }
canvas.look-winter { filter: saturate(.72) hue-rotate(-10deg) brightness(1.04) contrast(.97); }
canvas.look-mono { filter: grayscale(1) contrast(1.12); }
.postcard-frame { position: fixed; inset: 0; z-index: 8; pointer-events: none; display: grid; place-items: center; }
.postcard-frame .pf-inner { position: relative; width: min(100vw, 150vh); aspect-ratio: 3 / 2; box-shadow: 0 0 0 200vmax rgba(20, 16, 10, .35); border-radius: 4px; }
.postcard-frame.bordered .pf-inner { box-shadow: 0 0 0 200vmax rgba(20, 16, 10, .35), inset 0 0 0 clamp(8px, 2.6vmin, 26px) #f4ecd8; }
.postcard-frame:not(.bordered) .pf-greet, .postcard-frame:not(.bordered) .pf-place { display: none; }
.postcard-frame .pf-greet { position: absolute; left: 6%; top: 49%; font: italic 700 clamp(14px, 5.4vmin, 56px) Georgia, serif; color: #fff6e0; text-shadow: 0 2px 4px rgba(40, 30, 20, .8); }
.postcard-frame .pf-place { position: absolute; left: 4%; right: 4%; top: 57%; text-align: center; font: 900 clamp(22px, 15vmin, 170px)/1 Impact, "Arial Black", sans-serif; color: rgba(255, 246, 224, .92); -webkit-text-stroke: 2px #2b2118; text-transform: uppercase; white-space: nowrap; overflow: hidden; }
/* album in the drive log */
.lalbum { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin: 6px 0 8px; }
.lcard { position: relative; margin: 0; background: #f4ecd8; border-radius: 6px; padding: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.lcard img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 3px; cursor: zoom-in; }
.lcard.big { grid-column: 1 / -1; }
.lcard.big img { cursor: zoom-out; }
.lcard figcaption { font-size: .72rem; line-height: 1.25; padding: 3px 2px 0; color: #4a3d2c; }
.lcard .ldel { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(20,16,10,.6); color: #fff; font-size: 14px; line-height: 22px; padding: 0; cursor: pointer; }
.photo-bar .fov { display: flex; align-items: center; gap: 6px; }
.photo-bar .fov input { width: 110px; }
body.photo-clean .photo-bar { opacity: 0; }

/* touch */
.touch { position: fixed; inset: auto 0 0 0; height: 150px; z-index: 12; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 18px 22px; pointer-events: none; }
.touch button { pointer-events: auto; touch-action: none; width: 76px; height: 76px; border-radius: 50%; background: rgba(250,247,238,.55); backdrop-filter: blur(6px); display: grid; place-items: center; font-family: system-ui, sans-serif; font-weight: 700; }
.touch button svg { width: 34px; height: 34px; }
.touch button.down { background: rgba(63,107,58,.85); color: #fff; }
.touch-left, .touch-right { display: flex; gap: 14px; }
.touch .pedal { border-radius: 18px; width: 78px; height: 96px; }
.touch .pedal.gas { height: 112px; }
body.touch-mode .hud-bottom-left { bottom: 170px; }

@media (max-width: 820px) {
  .world-cards .vblurb { display: none; }
  .junction { top: 58px; transform: scale(.9); transform-origin: top left; }
  .vehicle-cards { grid-template-columns: repeat(10, minmax(118px, 1fr)); overflow-x: auto; }
  .vcard .vblurb { display: none; }
  .keys-hint { display: none; }
  .title-card { padding: 16px; }
}
.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: #faf7ee; margin: 0; font-size: 1.2rem; }

/* v0.5 drive log */
.title-actions { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.log-row, .log-foot { display: flex; gap: 8px; flex-wrap: wrap; }
.log-panel { right: auto; left: 14px; width: min(420px, calc(100vw - 28px)); z-index: 16; }
.log-body h3 { font-family: Georgia, serif; font-style: italic; font-weight: 600; font-size: 1.02rem; margin: 10px 0 6px; }
.lsec { border-top: 1px solid var(--line); padding-top: 2px; }
.lsec:first-child { border-top: 0; }
.lsec.now { background: rgba(63, 107, 58, .07); border-radius: 12px; padding: 2px 10px 8px; margin: 8px -4px; border-top: 0; }
.lstats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 6px; }
.lstat { display: flex; flex-direction: column; min-width: 64px; }
.lval { font-family: Georgia, serif; font-size: 1.22rem; line-height: 1.15; }
.llab { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; opacity: .6; }
.lmeta { font-size: .8rem; opacity: .75; margin: 2px 0; }
.lplaces { font-size: .82rem; margin: 2px 0 4px; }
.lprow { display: flex; gap: 8px; margin: 2px 0; }
.lpk { flex: 0 0 74px; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; opacity: .55; padding-top: 2px; }
.lpv { flex: 1; }
.quiet { opacity: .6; font-style: italic; }
.lnote { font-size: .82rem; opacity: .75; margin: 4px 0 8px; }
.ldrive { padding: 6px 0 8px; border-top: 1px dashed var(--line); }
.ldrive:first-of-type { border-top: 0; }
.ldhead { display: flex; justify-content: space-between; gap: 8px; font-size: .84rem; }
.ldwhen { font-weight: 600; }
.ldsum { opacity: .8; white-space: nowrap; }
.quiet-btn { background: transparent; opacity: .7; }
.summary-card { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 18; width: min(520px, calc(100vw - 28px)); background: var(--paper); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 20px; box-shadow: var(--shadow); padding: 14px 20px 14px; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; animation: sc-in 1.2s ease both; }
@keyframes sc-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.sc-kicker { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; opacity: .6; }
.sc-title { font-family: Georgia, serif; font-style: italic; font-size: 1.5rem; margin: 2px 0 4px; }
.sc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sc-actions button { padding: 8px 16px; font-size: .9rem; }
body.zen .summary-card, body.hide-ui .summary-card { opacity: 0; pointer-events: none; }
.log-panel { z-index: 25; }
body.idle .log-panel { opacity: 1; }
