:root {
  --navy: #13294b;
  --navy-2: #1f3b5c;
  --ink: #17202e;
  --muted: #5d6879;
  --line: #dfe4ec;
  --paper: #ffffff;
  --paper-2: #f5f7fb;
  --road: #ffc233;
  --go: #1fae64;
  --stop: #d7263d;
  --amber: #f59f00;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(10, 25, 50, 0.28), 0 3px 10px rgba(10, 25, 50, 0.12);
  --font: "Nunito", "SF Pro Rounded", ui-rounded, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe3ff; color: var(--ink); font-family: var(--font); }
button, input, select { font: inherit; }
#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

/* ---------- shared ---------- */
.panel { background: rgba(255, 255, 255, 0.93); border-radius: 16px; box-shadow: 0 8px 24px rgba(10, 25, 50, 0.18); backdrop-filter: blur(6px); }
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 800; cursor: pointer; background: var(--paper-2); color: var(--navy); box-shadow: inset 0 0 0 2px var(--line); transition: transform .08s ease, box-shadow .15s ease, background .15s; }
.btn:hover { background: #eef2f8; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .opt:focus-visible, .icon-btn:focus-visible { outline: 3px solid #4c8fe8; outline-offset: 2px; }
.btn.primary { background: var(--navy); color: #fff; box-shadow: 0 6px 0 #0a1830; }
.btn.primary:hover { background: #1b3762; }
.btn.primary:active { box-shadow: 0 2px 0 #0a1830; transform: translateY(4px); }
.btn.big { font-size: 1.2rem; padding: 16px 26px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--stop); }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(255,255,255,.93); box-shadow: 0 6px 16px rgba(10,25,50,.18); cursor: pointer; font-size: 20px; }
.muted { color: var(--muted); }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 6px; background: #fff; border: 1px solid #c9d1dd; border-bottom-width: 3px; font-size: .85em; font-family: inherit; font-weight: 800; text-align: center; margin-right: 2px; }

.layer { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; }
.screen.dim { background: rgba(12, 22, 40, 0.55); backdrop-filter: blur(3px); }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#permit { position: absolute; top: 14px; left: 14px; width: 252px; padding: 12px 14px 10px; }
#permit header { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.permit-badge { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--navy), #2f6fa3); color: var(--road); font-weight: 900; display: grid; place-items: center; letter-spacing: .5px; }
.permit-kicker { font-size: 11px; font-weight: 900; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
.permit-name { font-weight: 900; font-size: 16px; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
#creditRows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#creditRows li { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 800; }
#creditRows li .ic { font-size: 15px; text-align: center; }
#creditRows li.done .lbl::after { content: " ✓"; color: var(--go); }
.boxes { display: flex; gap: 4px; }
.box { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--c); background: #fff; transition: background .3s, transform .3s; }
.box.on { background: var(--c); transform: scale(1.05); }
.box.on::after { content: "✓"; display: block; color: #fff; font-size: 12px; line-height: 14px; text-align: center; font-weight: 900; }
.box.pop { animation: pop .7s ease; }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.7); } 100% { transform: scale(1.05); } }
#permit footer { display: flex; justify-content: space-between; margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 12.5px; font-weight: 800; color: var(--muted); }

#mapbox { position: absolute; top: 14px; right: 14px; padding: 8px; width: 236px; }
#minimap { width: 220px; height: 220px; border-radius: 12px; display: block; background: #8fbf73; }
#street { font-weight: 900; font-size: 13.5px; text-align: center; padding: 6px 2px 2px; color: var(--navy); }

#objective { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 9px 16px; border-radius: 999px; font-weight: 800; font-size: 14px; box-shadow: 0 8px 22px rgba(10,25,50,.28); white-space: nowrap; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 540px); overflow: hidden; text-overflow: ellipsis; }
#objective { flex-direction: column; align-items: center; gap: 2px; padding: 8px 18px 9px; border-radius: 18px; }
#objective .obj-title { font-size: 11.5px; font-weight: 900; letter-spacing: 1.1px; text-transform: uppercase; color: var(--road); }
#objective .obj-step { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 900; }
#objective .obj-step .turn { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: #34e2ff; color: var(--navy); font-size: 19px; }
#objective .obj-step em { font-style: normal; font-weight: 800; opacity: .75; font-variant-numeric: tabular-nums; }
#objective.gold .obj-title { color: #fff6d6; }
#creditBadge { position: absolute; top: 12px; right: 12px; color: var(--navy); background: #fff1c7; border-radius: 8px; padding: 2px 7px; font-size: 13px; letter-spacing: 0; }
#permit footer { gap: 6px; }
#permit header > div { padding-right: 48px; min-width: 0; }
#permit .permit-kicker { white-space: nowrap; font-size: 10.5px; letter-spacing: 1px; }
#confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation-name: fall; animation-timing-function: cubic-bezier(.3,.6,.6,1); animation-fill-mode: forwards; }
@keyframes fall { to { top: 105vh; transform: translateX(var(--drift)) rotate(720deg); } }
#objective .arrow { display: inline-block; width: 22px; height: 22px; border-radius: 50%; background: var(--road); color: var(--navy); text-align: center; line-height: 22px; font-weight: 900; }
#objective.gold { background: linear-gradient(90deg, #a9740b, #e3a514); }

#alert { position: absolute; top: 92px; left: 50%; transform: translateX(-50%) scale(.9); display: flex; align-items: center; gap: 12px; padding: 10px 20px 10px 12px; border-radius: 999px; background: #fff; box-shadow: 0 10px 26px rgba(10,25,50,.28); font-weight: 900; font-size: 18px; color: var(--ink); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; white-space: nowrap; }
#alert.show { opacity: 1; transform: translateX(-50%) scale(1); }
#alert.stop, #alert.red { box-shadow: 0 0 0 4px rgba(215,38,61,.35), 0 10px 26px rgba(10,25,50,.28); animation: alertPulse 1s infinite; }
#alert.green { box-shadow: 0 0 0 4px rgba(31,174,100,.35), 0 10px 26px rgba(10,25,50,.28); }
#alert.yellow { box-shadow: 0 0 0 4px rgba(245,159,0,.4), 0 10px 26px rgba(10,25,50,.28); }
@keyframes alertPulse { 50% { box-shadow: 0 0 0 9px rgba(215,38,61,.15), 0 10px 26px rgba(10,25,50,.28); } }
#alert .oct { font-style: normal; width: 40px; height: 40px; display: grid; place-items: center; background: #c8102e; color: #fff; font-size: 10px; clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
#alert .lamp { width: 22px; height: 46px; border-radius: 8px; background: #1d2733; position: relative; display: block; }
#alert .lamp::after { content: ""; position: absolute; left: 4px; width: 14px; height: 14px; border-radius: 50%; }
#alert .lamp.red::after { top: 4px; background: #ff3b30; box-shadow: 0 0 10px #ff3b30; }
#alert .lamp.yellow::after { top: 16px; background: #ffc21a; box-shadow: 0 0 10px #ffc21a; }
#alert .lamp.green::after { top: 28px; background: #22e07a; box-shadow: 0 0 10px #22e07a; }
.read-btn { border: 0; border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 900; background: #fff; color: var(--navy); cursor: pointer; }
.read-btn:hover { background: #f1f4f9; }
#minimap { border-radius: 50%; background: transparent; }
#mapbox { background: transparent; box-shadow: none; backdrop-filter: none; }
#street { background: rgba(255,255,255,.93); border-radius: 10px; margin-top: 6px; box-shadow: 0 6px 16px rgba(10,25,50,.15); }
@media (max-width: 900px) { #alert { top: auto; bottom: 150px; font-size: 15px; } }
#hudButtons { position: absolute; top: 290px; right: 14px; display: flex; flex-direction: column; gap: 8px; }

#instructor { position: absolute; left: 14px; bottom: 18px; display: flex; align-items: flex-end; gap: 10px; max-width: min(460px, calc(50vw - 140px)); opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; pointer-events: none; }
#instructor.show { opacity: 1; transform: none; }
#instructor .avatar { width: 52px; height: 52px; border-radius: 50%; background: #fff; box-shadow: 0 6px 16px rgba(10,25,50,.25); flex: none; overflow: hidden; display: grid; place-items: center; }
#instructor .avatar svg { width: 46px; height: 46px; }
#instructor .bubble { background: #fff; border-radius: 16px 16px 16px 4px; padding: 10px 14px; box-shadow: 0 8px 22px rgba(10,25,50,.22); font-size: 15px; font-weight: 700; line-height: 1.35; border-left: 5px solid #2f6fa3; }
#instructor .bubble b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1.1px; color: var(--muted); margin-bottom: 2px; }
#instructor.warn .bubble { border-left-color: var(--stop); }
#instructor.good .bubble { border-left-color: var(--go); }
#instructor.tip .bubble { border-left-color: var(--amber); }
#instructor.info .bubble { border-left-color: #6b4e9a; }

#dash { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; background: rgba(19, 41, 75, .92); color: #fff; padding: 10px 16px; border-radius: 22px; box-shadow: 0 10px 28px rgba(10,25,50,.35); }
#dash .speed { display: flex; align-items: baseline; gap: 4px; min-width: 112px; justify-content: center; position: relative; }
#dash .speed span { font-size: 44px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; transition: color .2s; }
#dash .speed small { font-weight: 800; opacity: .75; }
#dash .speed em { position: absolute; top: -6px; right: -8px; font-style: normal; font-weight: 900; font-size: 12px; background: rgba(255,255,255,.15); border-radius: 6px; padding: 1px 6px; }
#dash.over .speed span { color: #ff6b6b; }
#dash .limit { background: #fff; color: #111; border: 3px solid #111; border-radius: 7px; width: 56px; padding: 3px 2px 2px; text-align: center; line-height: 1; }
#dash .limit small { display: block; font-size: 8.5px; font-weight: 900; letter-spacing: .4px; }
#dash .limit b { font-size: 26px; font-weight: 900; }
#dash.over .limit { box-shadow: 0 0 0 4px #ff6b6b; animation: throb .8s infinite; }
@keyframes throb { 50% { box-shadow: 0 0 0 7px rgba(255,107,107,.35); } }
.blink { font-size: 22px; color: rgba(255,255,255,.2); width: 22px; text-align: center; }
.blink.on { color: #3ee07f; }

#toasts { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #fff; color: var(--ink); border-radius: 14px; padding: 9px 16px; font-weight: 900; box-shadow: 0 10px 26px rgba(10,25,50,.25); border-left: 6px solid var(--c, var(--go)); animation: toastIn .3s ease, toastOut .4s ease 2.6s forwards; }
.toast.bad { --c: var(--stop); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

#touchTools, #touchGuide, .touch-help { display: none; }

/* ---------- cards ---------- */
/* Paint (colors, type, shapes) lives here and is shared with phones.
   Layout and motion for laptops live in the "card stage" block below. */
#cardLayer { background: radial-gradient(ellipse at 50% 42%, rgba(12,22,40,.36), rgba(8,16,32,.74)); backdrop-filter: blur(3px); animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.card { width: min(760px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--paper); border-radius: 24px; box-shadow: 0 0 0 1px rgba(255,255,255,.45), 0 30px 70px rgba(6,14,30,.5), 0 6px 16px rgba(6,14,30,.22); animation: cardIn .42s cubic-bezier(.2,.9,.3,1.12); position: relative; }
@keyframes cardIn { from { opacity: 0; transform: translateY(46px) scale(.97); } }
.card-band { position: relative; display: flex; align-items: center; gap: 14px; padding: 15px 22px 21px; color: #fff; background: linear-gradient(115deg, rgba(255,255,255,.16), rgba(255,255,255,0) 42%, rgba(0,0,0,.22)), var(--c); }
/* a strip of road along the bottom of the band */
.card-band::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 8px; background: repeating-linear-gradient(90deg, var(--road) 0 24px, transparent 24px 42px) center / 100% 2px no-repeat, #1c2531; }
.card-band .trigger { width: 42px; height: 46px; flex: none; display: grid; place-items: center; }
.card-band .band-text { min-width: 0; }
.card-band .kicker { font-size: 11.5px; font-weight: 900; letter-spacing: 1.4px; text-transform: uppercase; opacity: .92; }
.card-band h2 { margin: 1px 0 0; font-size: 23px; font-weight: 900; line-height: 1.12; letter-spacing: -.2px; }
.card-band .chips { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.chip { background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.36); padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 900; white-space: nowrap; }
.chip.stake { display: inline-flex; align-items: center; gap: 7px; background: rgba(8,16,32,.28); border-color: rgba(255,255,255,.28); }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 12px; height: 12px; border-radius: 3.5px; border: 1.5px solid rgba(255,255,255,.9); }
.pips i.on { background: #fff; }
.pips i.at { animation: pipWait 1.2s ease-in-out infinite; }
.pips i.pop { animation: pop .7s ease; }
.card.answered .pips i.at { animation: none; }
@keyframes pipWait { 50% { background: rgba(255,255,255,.5); } }

/* the card's own traffic light: red while the question is open, green once it is answered */
.signal { width: 22px; height: 46px; border-radius: 8px; background: #141c26; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.2), 0 3px 8px rgba(0,0,0,.32); display: grid; grid-template-rows: repeat(3, 1fr); place-items: center; padding: 3px 0; }
.signal i { width: 10px; height: 10px; border-radius: 50%; background: #40221f; transition: background .25s, box-shadow .25s; }
.signal i:nth-child(2) { background: #3f3615; }
.signal i:nth-child(3) { background: #15382a; }
.card:not(.answered) .signal i:nth-child(1) { background: #ff3b30; box-shadow: 0 0 10px 2px rgba(255,59,48,.85); }
.card.answered .signal i:nth-child(3) { background: #22e07a; box-shadow: 0 0 10px 2px rgba(34,224,122,.85); }

.card-body { padding: 20px 24px 22px; }
.question { font-size: 21px; font-weight: 800; line-height: 1.36; margin: 0 0 16px; text-wrap: pretty; }
.second-look { display: inline-flex; align-items: center; gap: 6px; background: #fff3e0; color: #8a5300; border-radius: 999px; padding: 3px 11px; font-size: 12.5px; font-weight: 900; margin-bottom: 10px; }

/* exhibits: the thing the question is about, dressed as what it is */
.exhibit { position: relative; background: var(--paper-2); border: 1px solid #d5dce8; border-radius: 14px; padding: 11px 14px; margin-bottom: 14px; }
.exhibit .ex-label { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: 1.1px; color: var(--muted); margin-bottom: 4px; }
.exhibit .ex-content { font-size: 15.5px; font-weight: 700; line-height: 1.4; white-space: pre-wrap; }
.ex-items { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ex-items li { background: #fff; border: 1px solid #d5dce8; border-radius: 8px; padding: 3px 9px; font-size: 14px; font-weight: 800; line-height: 1.3; }
.exhibit.prompt { background: var(--cl); border-color: transparent; border-left: 5px solid var(--c); border-radius: 6px 14px 14px 6px; }
.exhibit.prompt .ex-content { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14.5px; font-weight: 600; }
.exhibit.prompt.typed .ex-content::after { content: ""; display: inline-block; width: 8px; height: 1.05em; margin-left: 3px; vertical-align: -3px; background: var(--c); animation: caret 1.1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.exhibit.record { background: #fffbea; border-color: #e6dcb6; border-left: 5px solid #e7a3a3; border-radius: 4px 12px 12px 4px; }
.exhibit.record .ex-label { color: #8a7a45; }
.exhibit.record .ex-items li { background: #fff; border-color: #e6dcb6; }
.exhibit.headline { background: #fff; border: 1px solid #cfd6e2; border-top: 5px solid var(--ink); border-radius: 4px 4px 12px 12px; }
.exhibit.headline .ex-content { font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 18px; line-height: 1.25; letter-spacing: -.1px; }
.exhibit.photo { background: #fff; border: 1px solid #cfd6e2; box-shadow: 0 2px 0 #e6eaf1; padding-left: 62px; min-height: 58px; }
.exhibit.photo::before { content: ""; position: absolute; left: 11px; top: 11px; width: 40px; height: 36px; border-radius: 6px; background: radial-gradient(circle at 72% 30%, #ffe08a 0 5px, transparent 6px), linear-gradient(155deg, transparent 58%, #7fb58a 59%), linear-gradient(205deg, transparent 52%, #5f9a78 53%), linear-gradient(#bfe0f5, #dff0fa); }
.exhibit.photo .ex-content { font-style: italic; }

.opts { display: grid; gap: 9px; }
.opt { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); border-bottom-width: 4px; background: #fff; cursor: pointer; font-weight: 700; font-size: 16.5px; line-height: 1.32; color: var(--ink); transition: border-color .15s, background .15s, transform .1s; }
.opt:hover:not(:disabled) { border-color: var(--c); background: var(--cl); transform: translateY(-1px); }
.opt:active:not(:disabled) { transform: translateY(2px); }
.opt .key { width: 32px; height: 32px; border-radius: 10px; background: var(--cl); display: grid; place-items: center; font-weight: 900; color: var(--c); transition: background .15s, color .15s; }
.opt:hover:not(:disabled) .key { background: var(--c); color: #fff; }
.opt:disabled { cursor: default; }
.opt .tag { font-style: normal; font-size: 11.5px; font-weight: 900; letter-spacing: .7px; text-transform: uppercase; white-space: nowrap; padding: 3px 9px; border-radius: 999px; }
.opt.correct { border-color: var(--go); background: #e5f7ec; }
.opt.correct .key { background: var(--go); color: #fff; font-size: 0; }
.opt.correct .key::after { content: "✓"; font-size: 18px; }
.opt.correct .tag { background: var(--go); color: #fff; }
.opt.wrong { border-color: var(--stop); background: #fdecee; }
.opt.wrong .key { background: var(--stop); color: #fff; font-size: 0; }
.opt.wrong .key::after { content: "✕"; font-size: 16px; }
.opt.wrong .tag { background: #fff; color: var(--stop); box-shadow: inset 0 0 0 1.5px var(--stop); }
.opt.faded { opacity: .55; }

.verdict { margin-top: 14px; border-radius: 16px; padding: 14px 16px; display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.verdict.good { background: #e5f7ec; box-shadow: inset 0 0 0 2px #bfe8cf; }
.verdict.bad { background: #fff3e0; box-shadow: inset 0 0 0 2px #f6dcae; }
.verdict b { display: block; font-size: 17px; margin-bottom: 3px; }
.verdict.good b { color: #0d6b3a; }
.verdict.bad b { color: #7a4a00; }
.verdict p { margin: 0; font-weight: 700; line-height: 1.42; font-size: 16px; }
.verdict .v-rule { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(23,32,46,.2); font-size: 13.5px; font-weight: 700; color: #45505f; line-height: 1.4; }
.verdict .v-rule strong { font-weight: 900; color: var(--c); }
.verdict .v-note { margin-top: 6px; font-size: 13.5px; font-weight: 800; color: #8a5300; }
/* the stamp that lands when the answer is in */
.seal { width: 66px; height: 66px; border-radius: 50%; display: grid; place-content: center; text-align: center; line-height: 1; font-weight: 900; color: #fff; background: var(--go); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--go), 0 6px 14px rgba(10,25,50,.2); transform: rotate(-9deg); }
.seal span { font-size: 25px; }
.seal small { font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; }
.seal.retry { background: var(--amber); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--amber), 0 6px 14px rgba(10,25,50,.2); }
.seal.retry span { font-size: 30px; }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.card-foot .hint { color: var(--muted); font-size: 13px; font-weight: 700; }
.card.answered #cardContinue, .card.go #cardContinue { background: #14804a; box-shadow: 0 6px 0 #0b5530; }
.card.answered #cardContinue:hover, .card.go #cardContinue:hover { background: #17915a; }
.card.answered #cardContinue:active, .card.go #cardContinue:active { box-shadow: 0 2px 0 #0b5530; }

/* Road Notes: a page for the logbook */
.note-head { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; margin-bottom: 12px; }
.note-glyph { width: 68px; height: 68px; border-radius: 20px; background: var(--cl); display: grid; place-items: center; font-size: 36px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.7), 0 0 0 2px var(--cl); transform: rotate(-4deg); }
.note-tag { display: inline-block; font-size: 12px; font-weight: 900; letter-spacing: 1.3px; text-transform: uppercase; color: #fff; background: var(--c); border-radius: 7px; padding: 2px 9px; margin-bottom: 5px; }
.note-tag.fact { background: var(--go); margin: 0 0 6px; }
.note-title { font-size: 27px; font-weight: 900; margin: 0; color: var(--c); line-height: 1.16; letter-spacing: -.3px; text-wrap: balance; }
.myth .note-title { text-decoration: line-through; text-decoration-color: rgba(162,64,47,.55); text-decoration-thickness: 3px; }
.note-body { font-size: 18px; line-height: 1.5; font-weight: 600; margin: 4px 0 6px; color: #2a3443; text-wrap: pretty; }
.note-body .lead { font-size: 20px; font-weight: 800; color: var(--ink); }
.note-fact { background: #eef9f2; border-radius: 14px; padding: 12px 16px 8px; box-shadow: inset 0 0 0 2px #cfeedd; }
.note-source { font-size: 12.5px; color: var(--muted); font-weight: 700; margin-top: 10px; }
.note-progress { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-top: 16px; padding: 10px 14px; border-radius: 12px; background: var(--paper-2); font-size: 13px; font-weight: 900; color: var(--navy); }
.np-bar { height: 8px; border-radius: 8px; background: #dfe4ec; overflow: hidden; }
.np-bar i { display: block; height: 100%; border-radius: 8px; background: var(--c); }
.np-count { font-variant-numeric: tabular-nums; color: var(--muted); }

/* Scenic overlook: a postcard */
.reflect-view { display: block; width: 100%; height: 92px; }
.reflect-prompt { font-size: 23px; font-weight: 900; line-height: 1.32; margin: 2px 0 12px; text-wrap: balance; }
.reflect-nudge { background: #e8f5f5; border-radius: 14px; padding: 11px 15px; font-weight: 800; color: #1d5c5e; border-left: 5px solid #31777A; }
.reflect-nudge small { display: block; font-size: 11px; letter-spacing: 1.1px; text-transform: uppercase; opacity: .8; margin-bottom: 2px; }

/* card stage: layout and motion for laptops and desktops (phones keep their compact sheet) */
@media not all and (pointer: coarse) {
  .card:not(.answered) .opt { animation: optIn .36s cubic-bezier(.2,.8,.3,1) both; animation-delay: calc(.16s + var(--i, 0) * .07s); }
  @keyframes optIn { from { opacity: 0; transform: translateY(10px); } }
  .card:not(.answered) .question-context { animation: optIn .36s cubic-bezier(.2,.8,.3,1) .05s both; }
  /* after answering, only "your pick" and the best answer stay on the card */
  .opts { display: flex; flex-direction: column; gap: 0; margin-bottom: -9px; }
  .opt { margin-bottom: 9px; }
  .card.answered .opt.faded { animation: optOut .32s ease forwards; pointer-events: none; }
  @keyframes optOut { to { opacity: 0; max-height: 0; min-height: 0; padding-block: 0; border-width: 0; margin-bottom: 0; } }
  .card.answered .opt { max-height: 160px; overflow: hidden; }
  .card.answered .opt.wrong { animation: nope .4s ease; }
  @keyframes nope { 20% { transform: translateX(-7px); } 45% { transform: translateX(6px); } 70% { transform: translateX(-3px); } }
  .card.answered .opt.correct { animation: yep .5s ease; }
  @keyframes yep { 40% { transform: scale(1.02); } }
  .verdict { animation: verdictIn .4s cubic-bezier(.2,.9,.3,1.1) .12s both; }
  @keyframes verdictIn { from { opacity: 0; transform: translateY(12px); } }
  .seal { animation: sealIn .45s cubic-bezier(.3,1.5,.5,1) .3s both; }
  @keyframes sealIn { from { opacity: 0; transform: rotate(14deg) scale(2.1); } }
  .note-glyph { animation: sealIn .5s cubic-bezier(.3,1.4,.5,1) .15s both; }
  .np-bar i { animation: barIn .8s cubic-bezier(.2,.8,.3,1) .35s both; transform-origin: left; }
  @keyframes barIn { from { transform: scaleX(.02); } }
}
/* short laptop screens (Chromebooks): tighten the card so "Drive on" stays in view */
@media not all and (pointer: coarse) {
  @media (max-height: 720px) {
    .card-band { padding: 10px 20px 16px; }
    .card-band h2 { font-size: 20px; }
    .card-body { padding: 14px 20px 16px; }
    .question { font-size: 19px; margin-bottom: 12px; }
    .exhibit { padding: 8px 12px; margin-bottom: 10px; }
    .opt { padding: 9px 12px; font-size: 15.5px; margin-bottom: 7px; }
    .opts { margin-bottom: -7px; }
    .verdict { margin-top: 10px; padding: 11px 14px; }
    .seal { width: 56px; height: 56px; }
    .seal span { font-size: 21px; }
    .card-foot { margin-top: 12px; }
    .note-title { font-size: 24px; }
    .reflect-view { height: 64px; }
    .card.answered .second-look { display: none; }
  }
}

/* ---------- title ---------- */
#titleScreen { background: linear-gradient(90deg, rgba(12,26,50,.86) 0%, rgba(12,26,50,.62) 46%, rgba(12,26,50,.12) 100%); align-items: center; overflow: auto; }
.title-wrap { width: min(1120px, 100%); display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; color: #fff; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 900; letter-spacing: 1.4px; text-transform: uppercase; font-size: 13px; color: var(--road); }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--road); box-shadow: 0 0 0 4px rgba(255,194,51,.25); }
h1 { font-size: clamp(42px, 6vw, 76px); line-height: .95; margin: 12px 0 14px; font-weight: 900; letter-spacing: -1.5px; }
h1 span { display: block; color: var(--road); font-size: .6em; letter-spacing: -0.5px; margin-top: 6px; }
.lede { font-size: 18px; line-height: 1.5; max-width: 540px; font-weight: 600; opacity: .95; margin: 0 0 22px; }
.how { display: grid; gap: 10px; max-width: 560px; }
.how-item { padding: 10px 14px !important; }
.how-item { display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: center; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); border-radius: 16px; padding: 12px 14px; }
.how-item b { display: block; font-size: 16.5px; }
.how-item span { font-size: 14.5px; opacity: .88; font-weight: 600; line-height: 1.4; }
.how-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-weight: 900; }
.how-icon.light { background: #1d2733; grid-template-rows: repeat(3, 1fr); padding: 5px 0; width: 30px; justify-self: center; border-radius: 9px; height: 56px; }
.how-icon.light i { width: 13px; height: 13px; border-radius: 50%; display: block; }
.how-icon.light i:nth-child(1) { background: #ff3b30; box-shadow: 0 0 10px #ff3b30; }
.how-icon.light i:nth-child(2) { background: #4a3a10; }
.how-icon.light i:nth-child(3) { background: #0f3a22; }
.how-icon.stop { background: #c8102e; color: #fff; font-size: 12px; clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
.how-icon.shield { background: rgba(255,255,255,.14); font-size: 26px; }
.id-card { background: linear-gradient(140deg, #eaf4ff 0%, #ffffff 45%, #e7f0fa 100%); color: var(--ink); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; transform: rotate(-1.5deg); }
.id-top { display: flex; justify-content: space-between; background: var(--navy); color: #fff; padding: 12px 18px; font-weight: 900; letter-spacing: 1.4px; font-size: 13px; }
.id-state { color: var(--road); }
.id-body { display: grid; grid-template-columns: 96px 1fr; gap: 16px; padding: 18px; }
.id-photo { width: 96px; height: 116px; border-radius: 12px; background: #dde8f3; display: grid; place-items: end center; overflow: hidden; border: 2px solid #c6d6e8; }
.id-photo svg { width: 88px; }
.id-fields label { font-size: 11px; font-weight: 900; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted); }
.id-fields input { width: 100%; border: 0; border-bottom: 2px solid var(--navy); background: transparent; font-size: 22px; font-weight: 900; padding: 4px 0 6px; margin-bottom: 10px; color: var(--navy); outline: none; }
.id-fields input::placeholder { color: #9aa7b8; font-weight: 800; }
.id-row { display: flex; justify-content: space-between; font-size: 12.5px; border-top: 1px dashed #c6d3e2; padding: 6px 0; }
.id-row span { color: var(--muted); font-weight: 800; letter-spacing: .6px; }
.id-goal { background: #fff7df; padding: 10px 18px; font-weight: 900; color: #7a5600; font-size: 14px; }
.title-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.title-actions .btn.ghost { color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); }
.controls { margin-top: 14px; background: rgba(255,255,255,.1); border-radius: 14px; padding: 10px 14px; }
.controls summary { cursor: pointer; font-weight: 900; }
.controls table { margin-top: 8px; font-size: 14px; border-spacing: 0 5px; }
.controls td:first-child { padding-right: 14px; white-space: nowrap; }
.controls kbd { color: var(--ink); }

/* ---------- sheets ---------- */
.sheet { background: #fff; border-radius: 22px; box-shadow: var(--shadow); padding: 24px 26px; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.sheet.wide { width: min(860px, 100%); }
.sheet h2 { margin: 0 0 14px; font-size: 26px; font-weight: 900; color: var(--navy); }
.sheet h3 { margin: 20px 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; }
.sheet-grid { display: grid; gap: 10px; }
.settings { display: grid; gap: 10px; font-weight: 800; }
.settings label { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.settings input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--navy); order: 2; }
.settings select { border-radius: 10px; border: 2px solid var(--line); padding: 6px 10px; font-weight: 700; }
.sheet-foot { margin-top: 18px; display: flex; justify-content: flex-end; }
#bigmap { width: 100%; max-width: 760px; aspect-ratio: 1; display: block; margin: 0 auto; border-radius: 14px; background: #8fbf73; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 12px; font-weight: 800; font-size: 14px; }
.lg { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-right: 6px; vertical-align: -2px; }
.lg.you { background: #fff; border: 3px solid var(--navy); }
.lg.sig { background: #1d2733; border-radius: 4px; box-shadow: inset 0 0 0 3px #ffc233; }
.lg.stop { background: #c8102e; clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); border-radius: 0; }
.lg.office { background: var(--road); border: 2px solid #8a5d00; }
.lg.look { background: #37c3c3; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 14px; }
.help-grid div { background: var(--paper-2); border-radius: 14px; padding: 12px 14px; }
.help-grid b { display: block; font-size: 16px; margin-bottom: 4px; color: var(--navy); }
.help-grid span { font-size: 14px; font-weight: 600; line-height: 1.4; color: #3a4556; }
.notes-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
/* logbook header: how many are collected, and topic chips that filter the list */
.notes-progress { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px 14px; padding: 12px 14px; border-radius: 16px; background: var(--paper-2); --c: var(--navy); }
.notes-count { display: flex; align-items: baseline; gap: 7px; font-weight: 800; color: var(--muted); font-size: 14px; }
.notes-count b { font-size: 30px; line-height: 1; font-weight: 900; color: var(--navy); font-variant-numeric: tabular-nums; }
.notes-filters { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.nf { --c: var(--navy); --cl: #e3e9f3; display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--cl); border-radius: 999px; background: #fff; color: var(--c); padding: 5px 12px; font-weight: 900; font-size: 13.5px; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.nf em { font-style: normal; font-weight: 800; font-size: 12px; opacity: .75; font-variant-numeric: tabular-nums; }
.nf:hover { background: var(--cl); }
.nf.on { background: var(--c); border-color: var(--c); color: #fff; }
.nf:focus-visible { outline: 3px solid #4c8fe8; outline-offset: 2px; }
.notes-more { grid-column: 1 / -1; text-align: center; color: var(--muted); font-weight: 800; font-size: 13.5px; padding: 2px 0 4px; }
.note-tile { border-radius: 16px; padding: 12px 14px; background: #fff; border: 2px solid var(--cl); border-top: 5px solid var(--c); }
.nt-head { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; margin-bottom: 7px; }
.nt-glyph { width: 38px; height: 38px; border-radius: 12px; background: var(--cl); display: grid; place-items: center; font-size: 20px; flex: none; }
.note-tile .k { font-size: 11px; font-weight: 900; letter-spacing: 1.1px; text-transform: uppercase; color: var(--c); }
.note-tile b { display: block; margin: 1px 0 0; font-size: 16px; line-height: 1.2; color: var(--ink); text-wrap: balance; }
.note-tile.myth b { text-decoration: line-through; text-decoration-color: rgba(162,64,47,.55); text-decoration-thickness: 2px; }
.note-tile p { margin: 0; font-size: 13.5px; line-height: 1.45; font-weight: 600; color: #3a4556; }
.note-tile .lead { font-weight: 800; color: var(--ink); }
.note-tile .note-tag.fact { font-size: 10.5px; padding: 1px 7px; margin: 0 2px 0 0; vertical-align: 1px; }
.note-tile.locked { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; min-height: 66px; border: 2px dashed #cdd5e1; background: var(--paper-2); color: #8a95a5; font-weight: 800; font-size: 13.5px; }
.note-tile.locked .nt-glyph { background: #e6eaf1; color: #9aa4b2; font-weight: 900; }
.note-tile.locked .k { color: #8a95a5; }
/* phones: topic chips sit on one swipeable row so the notes start sooner */
@media (pointer: coarse) {
  .notes-progress { padding: 8px 10px; gap: 6px 12px; }
  .notes-count b { font-size: 24px; }
  .notes-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -10px; padding: 0 10px; }
  .notes-filters::-webkit-scrollbar { display: none; }
  .nf { flex: none; white-space: nowrap; }
}

/* ---------- driving log ---------- */
.sheet.log { width: min(820px, 100%); padding: 0; overflow: auto; }
.log-head { background: var(--navy); color: #fff; padding: 22px 26px; border-radius: 22px 22px 0 0; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.log-head h2 { color: #fff; margin: 0; font-size: 28px; }
.log-head .kicker { color: var(--road); font-weight: 900; letter-spacing: 1.4px; font-size: 12px; text-transform: uppercase; }
.log-seal { width: 84px; height: 84px; border-radius: 50%; background: var(--road); color: var(--navy); display: grid; place-items: center; text-align: center; font-weight: 900; font-size: 12px; line-height: 1.1; box-shadow: 0 0 0 5px rgba(255,194,51,.3); transform: rotate(-10deg); flex: none; }
.log-body { padding: 20px 26px 24px; }
.log-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.log-box { border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.log-box h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.log-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-weight: 700; font-size: 14.5px; }
.log-row:last-child { border-bottom: 0; }
.log-row b { font-variant-numeric: tabular-nums; }
.log-credit { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 5px 0; font-weight: 800; }
.log-next { margin-top: 16px; background: #fff7df; border-radius: 16px; padding: 14px 18px; display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.log-next .big { font-size: 34px; }
.log-next b { display: block; font-size: 17px; color: #6b4b00; }
.log-next span { font-weight: 700; color: #7a5a10; }
.log-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.rating { font-size: 22px; letter-spacing: 2px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .title-wrap { grid-template-columns: 1fr; gap: 22px; }
  .how { display: none; }
  #objective { max-width: calc(100vw - 32px); top: auto; bottom: 108px; font-size: 13px; }
  #mapbox { width: 152px; padding: 6px; }
  #minimap { width: 140px; height: 140px; }
  #hudButtons { top: 204px; }
  #permit { width: 210px; padding: 10px; }
  #creditRows li { font-size: 12px; }
  .box { width: 15px; height: 15px; }
  #instructor { max-width: calc(100vw - 32px); bottom: 104px; }
  .log-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .card-band .chips { display: none; }
  .question { font-size: 17px; }
  .opt { font-size: 15px; }
  #dash .speed span { font-size: 34px; }
}

/* Phone play leaves the windshield clear. The road itself is the accelerator. */
.mobile-only, .mobile-intro { display: none; }
@media (pointer: coarse) {
  #app {
    container: game / size;
    --top: max(10px, env(safe-area-inset-top));
    --right: max(12px, env(safe-area-inset-right));
    --bottom: max(10px, env(safe-area-inset-bottom));
    --left: max(12px, env(safe-area-inset-left));
    -webkit-text-size-adjust: 100%;
  }
  #app.sideways {
    inset: 0 auto auto 100%;
    width: 100vh; height: 100vw;
    width: 100dvh; height: 100dvw;
    transform: rotate(90deg); transform-origin: top left;
    --top: max(10px, env(safe-area-inset-right));
    --right: max(12px, env(safe-area-inset-bottom));
    --bottom: max(10px, env(safe-area-inset-left));
    --left: max(12px, env(safe-area-inset-top));
  }
  #scene { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  .layer, #hud { padding: var(--top) var(--right) var(--bottom) var(--left); }
  #app .keyboard-help, #app .how, #app .lede, #app .controls, .help-grid { display: none; }
  .mobile-only, .touch-help, .mobile-intro { display: block; }
  #titleScreen { background: linear-gradient(115deg, rgba(10,26,45,.93), rgba(13,36,63,.70)); }
  .title-wrap { width: min(92%, 760px); margin: auto; grid-template-columns: 1fr; gap: 22px; }
  .title-wrap .brand { display: none; }
  .title-wrap h1 { font-size: 18px; letter-spacing: .02em; }
  .title-wrap h1 span { color: var(--road); font-size: clamp(40px, 7cqw, 62px); letter-spacing: -.04em; }
  .mobile-intro { font-weight: 600; font-size: 17px; line-height: 1.42; max-width: 32ch; margin: 0; }
  .id-card { background: transparent; transform: none; box-shadow: none; color: white; overflow: visible; border-radius: 0; }
  .id-row, .id-goal, .id-photo, .id-top { display: none; }
  .id-body { display: block; padding: 0; }
  .id-fields label { display: block; color: white; font-size: 14px; text-transform: none; letter-spacing: 0; }
  .id-fields label span { display: inline; font-weight: 500; opacity: .85; }
  .id-fields input {
    color: white; border: 1px solid rgba(255,255,255,.45); border-radius: 10px;
    font-size: 16px; min-height: 44px; padding: 8px 12px; margin: 5px 0 0; background: rgba(6,20,34,.42);
  }
  .id-fields input::placeholder { color: #c2cfd8; font-weight: 500; }
  .id-fields input:focus-visible { outline: 2px solid white; outline-offset: -3px; }
  .title-actions { margin-top: 12px; }
  .title-actions .primary, .title-actions:has(#resumeBtn:not([hidden])) #resumeBtn {
    background: var(--road); color: #162b43; box-shadow: none; min-height: 48px; font-size: 17px;
  }
  .title-actions:has(#resumeBtn:not([hidden])) #resumeBtn { order: -1; }
  .title-actions:has(#resumeBtn:not([hidden])) #startBtn { background: transparent; color: white; box-shadow: inset 0 0 0 1px rgba(255,255,255,.5); min-height: 44px; padding: 8px; }
  #startBtn:disabled { opacity: .65; }
  #hud {
    display: grid; grid-template: auto 1fr auto / auto auto 1fr auto;
    align-items: center; gap: 5px; pointer-events: none;
  }
  #hud > * { pointer-events: none; }
  #hud #permit, #hud #mapbox, #hud #objective, #hud #instructor, #hud #toasts, #hud #confetti { display: none; }
  #hudButtons, #alert, #dash, #touchGuide { position: static; transform: none; }
  #hudButtons { grid-area: 1 / 4; }
  /* Next turn: a small pill beside the pause button. The stop alert keeps the left side. */
  #app #hud #objective {
    display: flex; position: static; transform: none; grid-area: 1 / 1 / 2 / 4; justify-self: end;
    max-width: min(100%, 64cqw); padding: 5px 10px 5px 6px; border-radius: 12px;
    background: rgba(15,33,52,.88); box-shadow: none; font-size: 15px;
  }
  #app #hud #objective:empty { display: none; }
  #app #hud #objective.gold { background: rgba(138,93,0,.92); }
  #objective .obj-step { font-size: 15px; gap: 8px; min-width: 0; }
  #objective .obj-step .turn, #objective .obj-step em { flex: none; }
  #objective .obj-step .txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  /* While the stop alert is up it gets the room it needs: the pill shortens its street
     name, and on a narrow screen it shows only the turn arrow and the distance. */
  #app #hud:has(#alert.show) #objective { max-width: calc(100% - 212px); }
  @container game (max-width: 520px) {
    #app #hud:has(#alert.show) #objective { max-width: 100%; }
    #app #hud:has(#alert.show) #objective .txt { display: none; }
  }
  #pauseBtn { width: 46px; height: 46px; font-size: 23px; background: rgba(15,33,52,.88); color: white; pointer-events: auto; touch-action: manipulation; }
  #alert {
    display: none; grid-area: 1 / 1 / 2 / 4; justify-self: start; gap: 8px;
    color: white; background: rgba(15,33,52,.88); border-radius: 12px; padding: 5px 10px 5px 6px;
    font-size: 15px; box-shadow: none; animation: none; transition: none;
  }
  #alert.show { display: flex; transform: none; }
  #alert .oct { width: 31px; height: 31px; }
  #alert .lamp { transform: scale(.7); margin: -7px -2px; }
  #dash, #touchGuide { align-self: end; background: rgba(15,33,52,.88); color: white; border-radius: 12px; box-shadow: none; }
  #dash { grid-area: 3 / 1; padding: 5px 9px; gap: 8px; }
  #dash .speed { min-width: 0; gap: 3px; }
  #dash .speed span { font-size: 26px; }
  #dash .speed small { font-size: 12px; }
  #dash .speed em { position: static; align-self: center; font-size: 11px; padding: 2px 4px; }
  #dash .blink { display: none; }
  #dash .limit { width: 32px; border-width: 1px; border-radius: 5px; padding: 2px; }
  #dash .limit small { display: block; font-size: 0; line-height: 0; }
  #dash .limit small::after { content: 'LIMIT'; font-size: 9px; line-height: 1; }
  #dash .limit b { font-size: 17px; }
  #touchGuide { grid-area: 3 / 2; width: 58px; display: grid; gap: 4px; padding: 6px 8px 8px; font-size: 13px; text-align: center; font-weight: 800; }
  .touch-track { position: relative; height: 3px; background: rgba(255,255,255,.48); border-radius: 3px; }
  .touch-track::after {
    content: ""; position: absolute; left: var(--steer-position, 50%); top: 50%; width: 7px; height: 7px;
    transform: translate(-50%,-50%); background: white; border-radius: 50%;
  }
  #touchGuide.driving .touch-track::after { background: #34e2ff; }
  .sheet, .card { max-height: 100%; overscroll-behavior: contain; }
  #mobileSetup .sheet { width: min(100%, 420px); padding: 22px; }
  #setupTitle:focus { outline: none; }
  #setupMessage { font-size: 16px; line-height: 1.4; margin: 4px 0 16px; }
  .setup-actions, .steering-options { display: flex; flex-wrap: wrap; gap: 8px; }
  .sheet button, .read-btn { min-height: 44px; touch-action: manipulation; }
  #pauseScreen .sheet { width: min(100%, 550px); padding: 18px; }
  #pauseScreen .sheet-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .steering-settings { display: grid; gap: 8px; margin-bottom: 12px; }
  .steering-row { display: flex; align-items: center; justify-content: space-between; }
  .steering-options .btn { min-width: 70px; transition: none; }
  #pauseScreen button[aria-pressed="true"] { background: var(--navy); color: white; }
  #steeringStatus { margin: 0; font-size: 15px; }
  #centerTiltBtn { justify-self: start; }
  #mobileTools, #touchTools { display: flex; flex-wrap: wrap; gap: 6px; }
  #mobileTools { margin-top: 6px; }
  #touchTools .btn:disabled { opacity: .55; }
  #app:has(#cardLayer:not([hidden])) #hud { visibility: hidden; }
  #cardLayer, .verdict { animation: none; }
  #card { width: min(100%, 820px); animation: none; }
  .card-band { padding: 6px 14px; gap: 8px; }
  .card-band .trigger, .card-band .trigger svg { width: 31px; height: 31px; }
  .card-band .kicker { font-size: 11px; }
  .card-band h2 { font-size: 18px; }
  .card-band .chips { display: flex; }
  .read-btn { padding: 5px 10px; font-size: 13px; }
  .card-body { padding: 12px 15px; }
  .question { font-size: 17px; line-height: 1.33; margin-bottom: 10px; }
  .exhibit { padding: 7px 9px; margin-bottom: 8px; }
  .opts { gap: 5px; }
  .opt { grid-template-columns: 1fr; padding: 7px 12px; min-height: 44px; font-size: 16px; line-height: 1.25; touch-action: manipulation; }
  .opt .key, .card-foot .hint, .card:not(.answered) .answer-panel .card-foot, .card.answered .opts, .verdict .stamp { display: none; }
  .verdict { display: block; margin: 0; padding: 11px; }
  .card-foot { justify-content: flex-end; margin-top: 9px; }
  #cardContinue { min-height: 44px; touch-action: manipulation; }
  .card-band::after, .note-glyph, .note-progress, .reflect-view, .verdict .v-rule, .verdict .v-note { display: none; }
  .card-band .trigger { height: 31px; }
  .signal { width: 16px; height: 31px; border-radius: 6px; padding: 2px 0; }
  .signal i { width: 7px; height: 7px; }
  .opt { border-bottom-width: 2px; padding-block: 5px; }
  .second-look { display: inline-block; border-radius: 8px; padding: 2px 8px; font-size: 12px; margin-bottom: 8px; }
  .ex-items { gap: 4px; }
  .ex-items li { padding: 0 6px; font-size: 13px; }
  .exhibit .ex-content { font-size: 14px; line-height: 1.2; }
  .exhibit .ex-label { margin-bottom: 2px; line-height: 1.2; }
  .exhibit .ex-label span { display: none; }
  .exhibit.headline .ex-content { font-size: 15.5px; }
  .exhibit.photo { padding-left: 9px; min-height: 0; }
  .exhibit.prompt, .exhibit.record { border-left-width: 3px; padding-left: 7px; }
  .exhibit.prompt .ex-content { font-size: 14px; }
  .exhibit.photo::before { display: none; }
  .note-head { display: block; margin-bottom: 6px; }
  .note-title { font-size: 22px; }
  .note-body, .note-body .lead { font-size: 17px; }
  .note-fact { padding: 8px 11px 4px; }
  @container game (min-aspect-ratio: 1/1) {
    .title-wrap { grid-template-columns: 1.1fr 1fr; align-items: center; gap: 28px; }
    .question-body { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.12fr); align-items: start; gap: 16px; }
    .question { margin-bottom: 0; }
  }
  @container game (min-aspect-ratio: 1/1) and (max-height: 350px) {
    .card-band { padding-block: 2px; }
    .card:not(.answered) .question-body { display: block; padding: 8px 12px 10px; }
    .card:not(.answered) .question { margin-bottom: 8px; }
    .card:not(.answered) .question-context:has(.exhibit) {
      display: grid; grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr);
      gap: 4px 12px; align-items: start; margin-bottom: 8px;
    }
    .card:not(.answered) .question-context:has(.exhibit) :is(.exhibit, .question) { margin: 0; }
    .question-context .second-look { grid-column: 1 / -1; }
    .opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .opt { padding: 5px 9px; }
    .ex-items { display: block; margin: 0; }
    #card .ex-items li { display: inline; padding: 0; border: 0; background: none; font-size: 14px; }
    .ex-items li + li::before { content: " • "; }
    .exhibit .ex-label { margin-bottom: 0; }
    .note-title { font-size: 20px; margin-bottom: 6px; }
    .note-body { font-size: 17px; line-height: 1.4; }
    .note-source { margin-top: 6px; }
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- phone polish: pause, map, log, help and road messages ----------
   Sizes use the #app container (cqw / cqh, @container game) so the Play sideways layout matches a turned phone. */
.help-grid.touch-grid { display: none; }
@media (pointer: coarse) {
  html, body { overscroll-behavior: none; }
  #app { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  #hud { user-select: none; -webkit-user-select: none; }

  /* one short line under the top bar: hour logged, perfect stop, points lost */
  #hud #toasts { display: flex; position: static; transform: none; grid-area: 2 / 1 / 3 / 5; align-self: start; justify-self: center; margin-top: 2px; max-width: 100%; }
  #toasts .toast { background: rgba(15,33,52,.9); color: #fff; border-radius: 12px; border-left-width: 4px; padding: 6px 12px; font-size: 14px; font-weight: 800; box-shadow: none; text-align: center; }

  /* sheets */
  .sheet { padding: 14px 16px; border-radius: 18px; }
  .sheet h2 { font-size: 22px; }
  .sheet .btn { padding: 8px 12px; font-size: 15px; line-height: 1.15; }
  .sheet-head { position: sticky; top: -14px; z-index: 1; margin: -14px 0 8px; padding: 14px 0 6px; background: #fff; }
  .sheet.wide { width: min(100%, 860px); }

  /* pause: progress up top, then screens / car controls / settings */
  #pauseScreen .sheet { width: min(100%, 560px); padding: 12px 14px; }
  .pause-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
  .pause-head h2 { margin: 0; }
  #pauseProgress { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
  #pauseProgress span { background: var(--paper-2); border-radius: 999px; padding: 4px 9px; font-size: 13px; font-weight: 800; color: var(--navy); white-space: nowrap; }
  .pause-cols { display: grid; gap: 12px; }
  .pause-col { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; align-content: start; min-width: 0; }
  #pauseScreen .sheet-grid, #touchTools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  #resumeDriveBtn { grid-column: 1 / -1; box-shadow: 0 3px 0 #0a1830; margin-bottom: 3px; }
  .steering-settings { margin: 0; gap: 6px; }
  #steeringStatus { font-size: 14px; }
  #centerTiltBtn { justify-self: stretch; }
  .pause-settings h3 { margin: 0; font-size: 13px; }
  .pause-settings .settings { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .pause-settings .settings label { min-height: 32px; font-size: 15px; }
  .pause-settings .settings select { min-height: 36px; min-width: 0; flex: 0 1 auto; max-width: 62%; font-size: 15px; padding: 4px 8px; }
  .pause-settings .sheet-foot { margin-top: 2px; }
  .pause-settings .sheet-foot .btn { flex: 1; }
  @container game (min-aspect-ratio: 1/1) {
    #pauseScreen .sheet { width: min(100%, 640px); }
    .pause-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pause-settings { grid-column: 1 / -1; }
    .pause-settings .settings { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
    #steeringStatus { display: none; }
  }
  @container game (min-aspect-ratio: 1/1) and (min-width: 660px) {
    #pauseScreen .sheet { width: min(100%, 780px); }
    .pause-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.12fr); gap: 14px; }
    #pauseScreen .sheet-grid { grid-template-columns: 1fr; }
    .pause-settings { grid-column: auto; }
    .pause-settings .settings { grid-template-columns: minmax(0, 1fr); }
    .steering-row { flex-wrap: wrap; gap: 4px; }
    .steering-options { flex: 1 1 100%; flex-wrap: nowrap; gap: 6px; }
    .steering-options .btn { flex: 1; min-width: 0; }
    #reverseBtn, #resetBtn { grid-column: 1 / -1; }
  }

  /* town map: always the whole town on screen */
  #bigmap { max-width: calc(100cqh - var(--top) - var(--bottom) - 150px); }
  .legend { gap: 6px 14px; margin-top: 8px; font-size: 13.5px; }
  @container game (min-aspect-ratio: 1/1) {
    #mapScreen .sheet { width: auto; max-width: 100%; padding: 10px; display: grid; grid-template-columns: auto minmax(128px, 180px); grid-template-rows: auto 1fr; column-gap: 14px; }
    #mapScreen #bigmap { grid-area: 1 / 1 / 3 / 2; margin: 0; width: calc(100cqh - var(--top) - var(--bottom) - 20px); max-width: calc(100cqw - var(--left) - var(--right) - 162px); }
    #mapScreen .sheet-head { grid-area: 1 / 2; position: static; flex-direction: column; align-items: stretch; margin: 0 0 10px; padding: 4px 0 0; }
    #mapScreen .legend { grid-area: 2 / 2; flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; gap: 8px; margin: 0; }
  }

  /* how to play: touch controls as tiles, like the keyboard version */
  .help-grid.touch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin: 0; }
  .touch-grid div { padding: 9px 11px; border-radius: 12px; }
  .touch-grid b { font-size: 15px; margin-bottom: 2px; }
  .touch-grid span { font-size: 13.5px; line-height: 1.35; }

  /* road notes logbook */
  #notesSummary { margin: 0 0 10px; font-size: 14.5px; }
  .notes-list { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
  .note-tile { padding: 10px 12px; }
  .note-tile.locked { min-height: 60px; }

  /* driving log: compact header, two columns when there is room, buttons always in reach */
  .log-head { padding: 12px 16px; border-radius: 18px 18px 0 0; }
  .log-head h2 { font-size: 20px; }
  .log-head .kicker { font-size: 11px; }
  .log-seal { width: 62px; height: 62px; font-size: 10px; }
  .log-body { padding: 12px 16px 0; }
  .log-grid { gap: 10px; }
  .log-box { padding: 10px 12px; border-radius: 14px; }
  .log-box h4 { margin-bottom: 6px; }
  .log-row { padding: 4px 0; font-size: 14px; }
  .log-credit { padding: 3px 0; font-size: 14.5px; }
  .log-next { margin-top: 10px; padding: 10px 14px; }
  .log-next .big { font-size: 28px; }
  .log-next b { font-size: 16px; }
  .log-actions { position: sticky; bottom: 0; margin-top: 6px; padding: 10px 0 12px; background: #fff; box-shadow: 0 -10px 12px -12px rgba(10,25,50,.35); }
  @container game (min-width: 560px) { .log-grid { grid-template-columns: 1fr 1fr; } }
}

/* ---------- print the driving log ---------- */
@media print {
  body, html { overflow: visible; background: #fff; }
  #scene, #hud, #cardLayer, #titleScreen, #pauseScreen, #mapScreen, #notesScreen { display: none !important; }
  #finishScreen { position: static; display: block !important; background: none; padding: 0; backdrop-filter: none; }
  .sheet.log { box-shadow: none; max-height: none; width: 100%; }
  .log-actions { display: none; }
  .log-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
