:root {
  --yellow: #ffc400;
  --yellow-d: #d99a00;
  --black: #151515;
  --ink: #fff8e6;
  --green: #1fbf5b;
  --red: #ff3b3b;
  --panel: rgba(18, 16, 12, 0.86);
  --edge: rgba(255, 196, 0, 0.35);
  --font-display: 'Bungee', 'Impact', system-ui, sans-serif;
  --font-body: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0d0c0a; color: var(--ink); font-family: var(--font-body); overflow: hidden; overscroll-behavior: none; }
#app { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; padding: max(10px, env(safe-area-inset-top)) 12px 0; }
.hud-row { display: flex; justify-content: center; gap: 8px; align-items: stretch; }
.hud-row.small { margin-top: 6px; }
.pill {
  background: var(--panel); border: 2px solid var(--edge); border-radius: 12px;
  padding: 6px 12px; display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-size: 20px; letter-spacing: .5px;
  box-shadow: 0 4px 0 rgba(0,0,0,.45); backdrop-filter: blur(4px);
}
.pill .lbl { font-family: var(--font-body); font-weight: 800; font-size: 10px; color: var(--yellow); letter-spacing: 1.5px; }
.pill.mini { font-size: 13px; padding: 4px 10px; }
.pill.cash #hud-cash { color: #8dffb0; min-width: 80px; }
.mult { font-size: 13px; background: var(--yellow); color: var(--black); border-radius: 6px; padding: 1px 6px; transition: transform .15s; }
.mult.bump { transform: scale(1.35); }
.timer #hud-time { min-width: 36px; text-align: center; }
.timer.low { border-color: var(--red); animation: pulse .5s infinite alternate; }
.timer.low #hud-time { color: var(--red); }
@keyframes pulse { to { transform: scale(1.08); } }
.lives { font-size: 16px; letter-spacing: 2px; }
.icon-btn {
  pointer-events: auto; background: var(--panel); color: var(--ink); border: 2px solid var(--edge);
  border-radius: 10px; font-size: 12px; padding: 0 12px; cursor: pointer; font-weight: 800;
}
#toast {
  position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%);
  font-family: var(--font-display); font-size: clamp(22px, 6vw, 40px); color: var(--yellow);
  text-shadow: 0 3px 0 #000, 0 0 18px rgba(0,0,0,.6); white-space: nowrap; opacity: 0;
  transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, -60%); }

/* ---------- Touch ---------- */
#touch { position: absolute; inset: 0; display: flex; }
.tzone { flex: 1; display: flex; align-items: flex-end; padding: 0 24px calc(28px + env(safe-area-inset-bottom)); }
.tzone.right { justify-content: flex-end; }
.tzone span {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 24px;
  background: rgba(0,0,0,.35); border: 2px solid rgba(255,196,0,.4); color: rgba(255,255,255,.8);
}
.tzone.active span { background: rgba(255,196,0,.45); }
@media (hover: hover) and (pointer: fine) { #touch { display: none !important; } }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.25), rgba(0,0,0,.7));
  animation: fade .3s ease;
}
@keyframes fade { from { opacity: 0; } }
.card {
  width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: linear-gradient(180deg, rgba(28,24,16,.94), rgba(14,12,9,.96));
  border: 3px solid var(--yellow); border-radius: 22px; padding: 22px 22px 20px;
  box-shadow: 0 10px 0 var(--yellow-d), 0 24px 60px rgba(0,0,0,.6);
  position: relative; text-align: center;
}
.card::before { /* danfo stripe */
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 10px; border-radius: 18px 18px 0 0;
  background: repeating-linear-gradient(90deg, var(--black) 0 18px, var(--yellow) 18px 36px);
}
h2 { font-family: var(--font-display); color: var(--yellow); margin: 10px 0 14px; font-size: 26px; font-weight: 400; }
h2 small { font-family: var(--font-body); font-size: 11px; color: #bba; letter-spacing: 1px; display: block; }
.muted { color: #cbbfa0; margin: 0 0 14px; }

.logo { margin: 8px 0 18px; }
.logo-top { font-weight: 800; letter-spacing: 6px; font-size: 12px; color: #cbbfa0; }
.logo-main {
  font-family: var(--font-display); font-size: clamp(46px, 13vw, 64px); line-height: .92; color: var(--yellow);
  text-shadow: 0 4px 0 #8a5a00, 0 8px 0 #000, 0 0 30px rgba(255,196,0,.25); margin: 6px 0 8px;
  transform: rotate(-3deg);
}
.logo-sub { display: inline-block; background: var(--green); color: #062; font-weight: 800; padding: 3px 10px; border-radius: 6px; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: #fff; }

.name-field { display: block; text-align: left; margin: 0 0 12px; }
.name-field span { font-size: 11px; font-weight: 800; letter-spacing: 1.5px; color: var(--yellow); text-transform: uppercase; }
.name-field input {
  width: 100%; margin-top: 4px; padding: 12px 14px; font: 600 16px var(--font-body); color: var(--ink);
  background: #0b0a08; border: 2px solid #3a3222; border-radius: 12px; outline: none;
}
.name-field input:focus { border-color: var(--yellow); }

.btn {
  width: 100%; padding: 13px 16px; margin: 6px 0; border-radius: 14px; cursor: pointer;
  font: 400 16px var(--font-display); letter-spacing: 1px; color: var(--ink);
  background: #2a2419; border: 2px solid #4a3f2a; box-shadow: 0 4px 0 #000; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.btn.primary { background: var(--yellow); color: var(--black); border-color: #fff1b0; box-shadow: 0 5px 0 #8a5a00; font-size: 19px; }
.btn.primary:hover { filter: brightness(1.06); }
.row { display: flex; gap: 8px; }
.row .btn { font-size: 13px; }
.toggles { justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.chip { background: #1b1811; border: 2px solid #3a3222; color: #8a8068; border-radius: 999px; padding: 6px 12px; font: 600 13px var(--font-body); cursor: pointer; }
.chip.on { color: var(--ink); border-color: var(--green); }
.best { margin-top: 10px; font-size: 13px; color: #cbbfa0; min-height: 1em; }

.how { text-align: left; padding-left: 18px; margin: 0 0 16px; line-height: 1.5; font-size: 14px; }
.how li { margin-bottom: 6px; }
.tag { font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 4px; }
.tag.green { background: var(--green); color: #fff; }

.board { list-style: none; padding: 0; margin: 0 0 14px; text-align: left; counter-reset: r; }
.board li {
  counter-increment: r; display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center;
  padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.03); margin-bottom: 4px; font-size: 14px;
}
.board li::before { content: counter(r); font-family: var(--font-display); color: #cbbfa0; text-align: center; }
.board li:nth-child(1)::before { content: '🥇'; }
.board li:nth-child(2)::before { content: '🥈'; }
.board li:nth-child(3)::before { content: '🥉'; }
.board li.me { background: rgba(255,196,0,.18); outline: 1px solid var(--yellow); }
.board .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .nm small { display: block; color: #8a8068; font-weight: 400; font-size: 11px; }
.board .sc { font-family: var(--font-display); color: #8dffb0; }
.board .empty { display: block; text-align: center; color: #8a8068; }
.board li.empty::before { content: none; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 12px; }
.stats div { background: rgba(255,255,255,.04); border-radius: 12px; padding: 10px; }
.stats span { display: block; font-size: 11px; letter-spacing: 1px; color: #cbbfa0; text-transform: uppercase; font-weight: 800; }
.stats b { font-family: var(--font-display); font-weight: 400; font-size: 20px; color: var(--ink); }
.rank { min-height: 22px; margin-bottom: 8px; color: var(--yellow); font-weight: 800; }

@media (max-height: 640px) {
  .logo-main { font-size: 40px; }
  .card { padding: 16px; }
  .btn { padding: 10px; }
}

/* route progress */
#hud, .screen { z-index: 3; }
.screen { z-index: 5; }
#touch { z-index: 2; }
.route { pointer-events: none; background: var(--panel); border: 2px solid var(--edge); border-radius: 12px; padding: 5px 10px 7px; width: min(300px, 60vw); box-shadow: 0 4px 0 rgba(0,0,0,.45); }
.route-top { display: flex; justify-content: space-between; font-size: 11px; font-weight: 800; letter-spacing: 1px; margin-bottom: 4px; }
#hud-stage { color: var(--yellow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.route-bar { position: relative; height: 8px; border-radius: 6px; background: repeating-linear-gradient(90deg, #2a2419 0 10px, #3a3222 10px 20px); }
#hud-prog { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; border-radius: 6px; background: linear-gradient(90deg, var(--green), var(--yellow)); }
.route-bar .flag { position: absolute; right: -6px; top: -9px; font-size: 14px; }
#hud-papers { color: #8dffb0; border-color: var(--green); }
.board .tm { font-family: var(--font-display); color: #8dffb0; text-align: right; }
.board .tm small { display: block; font-family: var(--font-body); color: #8a8068; font-size: 11px; }
.board .dnf { color: #cbbfa0; }
.win-title { color: var(--green) !important; }
.lives { white-space: nowrap; }
@media (max-width: 480px) {
  .hud-row { gap: 5px; }
  .pill { font-size: 15px; padding: 5px 8px; gap: 5px; }
  .pill.cash #hud-cash { min-width: 56px; }
  .lives { font-size: 12px; letter-spacing: 0; }
  .route { width: 64vw; }
}

/* ---------- incoming call ---------- */
#call {
  position: absolute; z-index: 4; left: 50%; top: calc(178px + env(safe-area-inset-top)); transform: translateX(-50%);
  width: min(360px, calc(100% - 32px)); display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: linear-gradient(180deg, rgba(20,34,24,.96), rgba(10,18,12,.96)); border: 2px solid var(--green); border-radius: 18px;
  box-shadow: 0 6px 0 #0b4a22, 0 16px 40px rgba(0,0,0,.6); animation: callIn .25s ease, shakeCall .5s .25s infinite;
}
@keyframes callIn { from { transform: translate(-50%, -30px); opacity: 0; } }
@keyframes shakeCall { 0%, 100% { margin-left: 0; } 25% { margin-left: -3px; } 75% { margin-left: 3px; } }
.call-avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; background: #1d3a26; border: 2px solid var(--green); flex: none; }
.call-info { flex: 1; min-width: 0; }
.call-lbl { font-size: 10px; font-weight: 800; letter-spacing: 1.5px; color: #8dffb0; }
.call-name { font-family: var(--font-display); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-bar { height: 5px; background: #2a2419; border-radius: 4px; margin-top: 5px; overflow: hidden; }
#call-timer { height: 100%; width: 100%; background: linear-gradient(90deg, var(--red), var(--yellow), var(--green)); }
.call-btn {
  flex: none; width: 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer; font-size: 24px; color: #fff;
  background: var(--green); box-shadow: 0 4px 0 #0b6b2f; display: grid; place-items: center; line-height: 1; animation: pulse .5s infinite alternate;
}
.call-btn small { display: block; font: 800 8px var(--font-body); letter-spacing: .5px; margin-top: -8px; }
.call-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0b6b2f; }
@media (hover: none) { .call-btn small { display: none; } }

/* ---------- delivery brief ---------- */
.brief { text-align: left; }
.brief-tag { display: inline-block; margin-top: 8px; background: var(--yellow); color: var(--black); font-weight: 800; font-size: 11px; letter-spacing: 1.5px; padding: 4px 10px; border-radius: 6px; }
.brief-who { display: flex; align-items: center; gap: 12px; margin: 14px 0 8px; }
.brief-avatar { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-size: 34px; background: #2a2419; border: 2px solid var(--yellow); flex: none; }
.brief-name { font-family: var(--font-display); font-size: 22px; color: var(--yellow); }
.brief-item { font-weight: 600; color: #cbbfa0; }
.brief-story { margin: 6px 0 12px; line-height: 1.5; font-size: 14px; }
.brief-route { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: rgba(255,255,255,.04); border-radius: 12px; padding: 10px 12px; }
.brief-route span, .brief-meta span { display: block; font-size: 10px; letter-spacing: 1.5px; font-weight: 800; color: #cbbfa0; }
.brief-route b { font-family: var(--font-display); font-weight: 400; font-size: 15px; }
.brief-route .arrow { color: var(--yellow); font-size: 13px; white-space: nowrap; }
.brief-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.brief-meta div { background: rgba(255,255,255,.04); border-radius: 12px; padding: 8px 12px; }
.brief-meta b { font-family: var(--font-display); font-weight: 400; font-size: 18px; color: #8dffb0; }
.brief-tip { font-size: 13px; color: #cbbfa0; margin: 8px 0 10px; }
.stats { grid-template-columns: 1fr 1fr 1fr; }
.stats b { font-size: 17px; }
@media (max-width: 400px) { .stats { grid-template-columns: 1fr 1fr; } }

/* route HUD: full stop names */
#hud-stage { max-width: none; overflow: visible; white-space: normal; }
.route-top { gap: 8px; align-items: flex-start; }
.route-top .km { white-space: nowrap; }
.route-next { margin-top: 5px; font-size: 10px; font-weight: 800; letter-spacing: .8px; color: #cbbfa0; }

/* gender */
.gender-row { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.gender-row span { font-size: 11px; font-weight: 800; letter-spacing: 1.5px; color: var(--yellow); text-transform: uppercase; margin-right: auto; }

/* brief additions */
.brief-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.brief-top .brief-tag { margin-top: 0; }
.brief-progress { font-size: 11px; font-weight: 800; color: #8dffb0; letter-spacing: .5px; }
.brief-route .r { text-align: right; }
.brief-stops-wrap { margin: 8px 0; background: rgba(17,116,58,.18); border: 1px solid rgba(31,191,91,.35); border-radius: 12px; padding: 8px 12px; }
.brief-stops-wrap span { font-size: 10px; letter-spacing: 1.5px; font-weight: 800; color: #8dffb0; }
.brief-stops { margin: 4px 0 0; font-weight: 600; font-size: 13px; line-height: 1.5; }
.small-route { font-size: 12px; margin: 0 0 6px; }

/* road challenge */
#challenge {
  position: absolute; z-index: 4; left: 50%; top: calc(178px + env(safe-area-inset-top)); transform: translateX(-50%);
  width: min(340px, calc(100% - 32px)); display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: linear-gradient(180deg, rgba(40,28,8,.95), rgba(20,14,4,.95)); border: 2px solid var(--yellow); border-radius: 16px;
  box-shadow: 0 5px 0 #8a5a00, 0 12px 30px rgba(0,0,0,.5); animation: callIn .25s ease; pointer-events: none;
}
.ch-icon { font-size: 26px; flex: none; }
.ch-info { flex: 1; min-width: 0; }
.ch-title { font-family: var(--font-display); font-size: 13px; color: var(--yellow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-desc { font-size: 11px; font-weight: 600; color: #cbbfa0; }
.ch-bar { height: 5px; background: #2a2419; border-radius: 4px; margin-top: 4px; overflow: hidden; }
#ch-timer { height: 100%; width: 100%; background: linear-gradient(90deg, var(--red), var(--yellow)); }
.ch-prog { font-family: var(--font-display); font-size: 18px; color: #fff; flex: none; }
#challenge.lower { top: calc(262px + env(safe-area-inset-top)); }
#toast { white-space: normal; width: max-content; max-width: 92vw; text-align: center; font-size: clamp(17px, 5.2vw, 38px); line-height: 1.15; }

/* levels */
.route-lvl { font-size: 10px; font-weight: 800; letter-spacing: .8px; color: #8dffb0; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brief .brief-name { margin: 12px 0 4px; font-size: 19px; line-height: 1.2; }
.brief-legs { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.brief-legs li { background: rgba(255,255,255,.04); border: 1px solid rgba(255,196,0,.18); border-radius: 12px; padding: 9px 11px; }
.leg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.leg-head b { font-family: var(--font-display); font-weight: 400; font-size: 14px; }
.leg-no { width: 22px; height: 22px; border-radius: 50%; background: var(--yellow); color: var(--black); display: grid; place-items: center; font-weight: 800; font-size: 12px; flex: none; }
.leg-meta { margin-left: auto; font-size: 11px; font-weight: 800; color: #8dffb0; white-space: nowrap; }
.leg-who { font-weight: 600; font-size: 13px; margin-top: 4px; }
.leg-story { font-size: 12px; color: #cbbfa0; margin-top: 2px; line-height: 1.4; }
.leg-stops { font-size: 12px; margin-top: 4px; color: #e8dcc0; line-height: 1.45; }
.tabs { display: flex; gap: 6px; justify-content: center; margin: -4px 0 12px; flex-wrap: wrap; }
.tab { background: #1b1811; border: 2px solid #3a3222; color: #cbbfa0; border-radius: 999px; padding: 5px 11px; font: 800 12px var(--font-body); cursor: pointer; }
.tab.on { background: var(--yellow); color: var(--black); border-color: #fff1b0; }

/* ride controls: brake red, horn yellow, gas blue */
#controls { position: absolute; z-index: 3; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; align-items: flex-end; padding: 0 14px; pointer-events: none; }
#controls .ctl { pointer-events: auto; }
.ctl {
  border-radius: 18px; border: 2px solid rgba(255,255,255,.35); cursor: pointer; touch-action: none; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #fff;
  font: 800 11px var(--font-body); letter-spacing: 1px; transition: transform .06s, box-shadow .06s;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.ctl span { font-size: 22px; line-height: 1; }
.ctl kbd { font: 800 9px var(--font-body); opacity: .75; }
.ctl.brake { background: linear-gradient(180deg, #ff5a52, #d32020); box-shadow: 0 5px 0 #7d1111; }
.ctl.gas { background: linear-gradient(180deg, #4d95ff, #1a5fd6); box-shadow: 0 5px 0 #0c3480; }
.ctl.horn { background: linear-gradient(180deg, #ffd84d, #f5b800); color: #151515; box-shadow: 0 5px 0 #8a5a00; }
.ctl.steer { background: rgba(20,18,14,.72); border-color: rgba(255,196,0,.6); box-shadow: 0 5px 0 rgba(0,0,0,.55); color: var(--yellow); }
.ctl.active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.6); filter: brightness(1.15); }

/* phones / tablets: left thumb steers, right thumb drives */
.ctl-left { display: flex; gap: 10px; }
.ctl-left .ctl { width: 74px; height: 74px; border-radius: 50%; }
.ctl-left .ctl span { font-size: 28px; }
.ctl-right { display: grid; grid-template-columns: 66px 78px; grid-template-areas: "horn horn" "brake gas"; gap: 10px; align-items: end; }
.ctl-right .horn { grid-area: horn; height: 46px; flex-direction: row; gap: 8px; border-radius: 999px; }
.ctl-right .horn span { font-size: 18px; }
.ctl-right .brake { grid-area: brake; height: 74px; }
.ctl-right .gas { grid-area: gas; height: 100px; border-radius: 20px 20px 22px 22px; }
.ctl-right .gas span { font-size: 28px; }
@media (hover: none) { .ctl kbd { display: none; } .tzone span { display: none; } }
@media (max-width: 380px) {
  #controls { padding: 0 10px; }
  .ctl-left .ctl { width: 64px; height: 64px; }
  .ctl-right { grid-template-columns: 58px 70px; gap: 8px; }
  .ctl-right .gas { height: 90px; } .ctl-right .brake { height: 66px; }
}
/* desktop (mouse): keyboard steers, pedals sit in one centred row */
@media (hover: hover) and (pointer: fine) {
  #controls { justify-content: center; }
  .ctl-left { display: none; }
  .ctl-right { grid-template-columns: 66px 66px 66px; grid-template-areas: "brake horn gas"; }
  .ctl-right .ctl { height: 66px; border-radius: 18px; flex-direction: column; gap: 2px; }
  .ctl-right .gas span, .ctl-right .horn span { font-size: 20px; }
}
.tag.blue { background: #1a5fd6; color: #fff; } .tag.red { background: #d32020; color: #fff; } .tag.yellow { background: #ffc400; color: #151515; }

.board li.dnf-row { opacity: .85; }
.board .tm.dnf { color: #ffcc80; font-size: 13px; }

/* live radio chip */
.radio-chip {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 7px; max-width: min(300px, 80vw);
  background: var(--panel); border: 2px solid var(--edge); border-radius: 999px; padding: 4px 12px; color: var(--ink);
  font: 800 11px var(--font-body); letter-spacing: .6px; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.45);
}
.radio-chip #radio-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.radio-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: #8a8068; flex: none; }
.radio-chip.playing .dot { background: #ff3b3b; box-shadow: 0 0 8px #ff3b3b; animation: pulse .8s infinite alternate; }
.radio-chip.tuning .dot { background: var(--yellow); }
.radio-chip .skip { color: var(--yellow); }

/* ---------- landscape phones: HUD in the side columns, road stays clear ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  #hud { display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto 1fr; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); }
  #hud > .hud-row:first-child { grid-column: 1; grid-row: 1 / span 2; flex-direction: column; align-items: flex-start; gap: 6px; }
  #hud > .hud-row.small { grid-column: 3; justify-content: flex-end; margin-top: 0; }
  #hud > .hud-row.small + .hud-row.small { grid-row: 2; margin-top: 6px; }
  .pill { font-size: 15px; padding: 4px 9px; }
  .route { width: min(280px, 34vw); }
  #toast { top: 40%; font-size: clamp(15px, 3.6vw, 26px); max-width: 44vw; }
  #call, #challenge { top: calc(8px + env(safe-area-inset-top)); width: min(320px, 40vw); padding: 6px 10px; }
  #challenge.lower { top: calc(84px + env(safe-area-inset-top)); }
  .call-btn { width: 52px; height: 52px; }
  #controls { bottom: calc(10px + env(safe-area-inset-bottom)); padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); }
  .ctl-left .ctl { width: 66px; height: 66px; }
  .ctl-right { grid-template-columns: 60px 72px; gap: 8px; }
  .ctl-right .horn { height: 40px; }
  .ctl-right .brake { height: 64px; }
  .ctl-right .gas { height: 86px; }
  .card { max-height: calc(100vh - 20px); padding: 14px 18px; }
  .screen { padding: 10px; }
  .logo { margin: 2px 0 10px; }
  .logo-main { font-size: 40px; }
}

.name-field input.shake { animation: shakeX .4s; border-color: var(--red); }
@keyframes shakeX { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.board-warn { margin: -4px 0 10px; font-size: 12px; font-weight: 600; color: #ffcc80; line-height: 1.4; }
.board-warn:empty { display: none; }

/* ---------- results screen ---------- */
.results h2 { margin-bottom: 6px; }
.results .muted { font-size: 13px; margin-bottom: 10px; }
.earned { background: linear-gradient(180deg, rgba(31,191,91,.22), rgba(31,191,91,.08)); border: 2px solid rgba(31,191,91,.55); border-radius: 16px; padding: 10px; margin-bottom: 8px; }
.earned span { display: block; font-size: 11px; font-weight: 800; letter-spacing: 2px; color: #8dffb0; }
.earned b { font-family: var(--font-display); font-weight: 400; font-size: clamp(30px, 9vw, 42px); color: #fff; text-shadow: 0 3px 0 #0b4a22; }
.res-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.res-chips div { background: rgba(255,255,255,.05); border-radius: 12px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; }
.res-chips span { font-size: 18px; line-height: 1; }
.res-chips b { font-family: var(--font-display); font-weight: 400; font-size: 17px; margin-top: 3px; }
.res-chips small { font-size: 10px; letter-spacing: 1px; color: #cbbfa0; text-transform: uppercase; font-weight: 800; }
.positions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.pos { background: rgba(255,196,0,.1); border: 2px solid rgba(255,196,0,.45); border-radius: 14px; padding: 8px; display: flex; flex-direction: column; align-items: center; }
.pos span { font-size: 10px; font-weight: 800; letter-spacing: 1.5px; color: var(--yellow); }
.pos b { font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1.1; }
.pos small { font-size: 11px; color: #cbbfa0; font-weight: 600; }
.results .rank { min-height: 18px; margin: 2px 0 4px; font-size: 13px; }
.tagline { font-family: var(--font-display); font-size: clamp(20px, 6vw, 26px); color: var(--yellow); margin: 6px 0 10px; transform: rotate(-2deg); text-shadow: 0 3px 0 #000; line-height: 1.15; }
.tagline.fail { color: #ffb36b; }
.stats.mini { grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 6px; }
.stats.mini div { padding: 6px 4px; }
.stats.mini span { font-size: 9px; letter-spacing: .5px; }
.stats.mini b { font-size: 15px; }
@media (max-width: 400px) { .stats.mini { grid-template-columns: repeat(3, 1fr); } }
@media (orientation: landscape) and (max-height: 560px) {
  .results { width: min(640px, 100%); display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; align-items: start; }
  .results > h2, .results > #over-reason { grid-column: 1 / -1; }
  .results .earned b { font-size: 30px; }
}

/* no browser zoom while playing: double-tap and pinch are disabled; inputs stay 16px so iOS doesn't zoom on focus */
/* pan-y (not "manipulation") — manipulation still lets Chrome pinch-zoom */
html, body, #app { touch-action: pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, .btn, .chip, .tab { touch-action: pan-y; }
canvas, #controls, #controls *, #touch, #touch *, #hud { touch-action: none; }
input { font-size: 16px !important; }

/* journey strip: every drop + bus stop on the level */
.journey { position: relative; display: flex; gap: 4px; height: 16px; margin: 1px 4px 0; }
.jleg { position: relative; flex: 1 1 0; height: 8px; margin-top: 4px; border-radius: 5px; background: repeating-linear-gradient(90deg, #2a2419 0 8px, #3a3222 8px 16px); }
.jfill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 5px; background: linear-gradient(90deg, var(--green), var(--yellow)); }
.jdot { position: absolute; top: 50%; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: #1b1811; border: 1.5px solid #cbbfa0; box-sizing: border-box; }
.jdot.bridge { border-radius: 1.5px; border-color: #7fb8ff; }
.jdot.passed { background: var(--yellow); border-color: #fff; }
.jend { position: absolute; right: -7px; top: -8px; font-size: 12px; filter: grayscale(.6); }
.jend.done { filter: none; }
.jrider { position: absolute; top: -10px; font-size: 14px; transform: translateX(-50%) scaleX(-1); transition: left .2s linear; pointer-events: none; }

#btn-board-all { margin: -6px 0 8px; font-size: 13px; padding: 10px; background: #1b1811; border-color: var(--edge); color: var(--yellow); }
