:root {
  --bg: #2b1d14; --panel: #2c1f17ee; --panel-2: #4a3526; --panel-3: #5d4532; --line: #ffffff24;
  --ink: #fff6e8; --soft: #dcc9b2; --sun: #f7b73d; --go: #5ec48a; --bad: #ee6b5f;
  --serif: "Fraunces", Georgia, serif; --sans: "DM Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); margin: 0; }
[hidden] { display: none !important; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 13px; padding: 11px 18px; font-weight: 700; min-height: 46px; }
.btn.primary { background: var(--sun); color: #33210a; border-color: transparent; box-shadow: 0 4px 0 #b57d16; }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #b57d16; }
.btn:disabled { opacity: .45; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ── Home ── */
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.home { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
.home * { pointer-events: auto; }
.brand h1 { font-size: clamp(2.5rem, 9vh, 4.4rem); line-height: .95; color: #fff; text-shadow: 0 3px 0 #7a4a1c, 0 8px 22px #0007; }
.brand p { margin: 6px 0 0; max-width: 21rem; font-weight: 600; color: #fff; text-shadow: 0 1px 6px #000a; line-height: 1.3; }
.topbar { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.purse { display: flex; gap: 8px; font-weight: 800; }
.pill { background: var(--panel); border-radius: 12px; padding: 7px 11px; white-space: nowrap; }
.menu { display: flex; flex-direction: column; gap: 8px; width: min(260px, 100%); }
.menu .btn { text-align: left; background: var(--panel); }
.menu .btn.primary { background: var(--sun); font-size: 1.1rem; }
.menu small { display: block; font-weight: 600; opacity: .8; font-size: .76rem; }
@media (orientation: portrait) {
  .brand { text-align: center; } .brand p { margin-inline: auto; }
  .topbar { flex-direction: column; align-items: center; }
  .menu { width: 100%; }
}
.dock { display: flex; gap: 8px; flex-wrap: wrap; }
.dock .btn { flex: 1 1 0; background: var(--panel); min-width: 0; padding-inline: 8px; }

/* ── Panels ── */
.panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(600px, 66vw); background: var(--panel); backdrop-filter: blur(6px); padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 16px 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
@media (orientation: portrait) { .panel { top: 34%; left: 0; width: 100%; border-radius: 20px 20px 0 0; } }
.phead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.phead h2 { font-size: 1.45rem; }
.back { background: var(--panel-2); border: 0; border-radius: 10px; min-height: 40px; padding: 0 12px; font-weight: 700; }
.sub { color: var(--soft); font-size: .85rem; margin: 2px 0 8px; line-height: 1.35; }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; }
.tab { flex: 1 0 auto; background: var(--panel-2); border: 2px solid transparent; border-radius: 11px; padding: 7px 10px; font-weight: 700; min-height: 42px; font-size: .86rem; }
.tab[aria-pressed="true"] { border-color: var(--sun); }
.tab:disabled { opacity: .45; }
.routes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.route { background: var(--panel-2); border: 1px solid var(--line); border-radius: 13px; padding: 8px 4px; min-height: 74px; text-align: center; }
.route b { display: block; font-size: 1.1rem; } .route small { color: var(--sun); letter-spacing: 1px; display: block; }
.route .rname { display: block; font-style: normal; font-size: .74rem; font-weight: 700; line-height: 1.15; margin: 1px 0 2px; }
.route em { font-style: normal; color: var(--soft); font-size: .72rem; display: block; }
.route:disabled { opacity: .4; }
.route.express em { color: var(--go); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.truck { text-align: left; background: var(--panel-2); border: 2px solid transparent; border-radius: 13px; padding: 9px; min-height: 92px; }
.truck[aria-pressed="true"] { border-color: var(--sun); }
.truck b { display: block; font-family: var(--serif); }
.truck small { color: var(--soft); display: block; line-height: 1.25; margin-top: 2px; }
.truck .price { color: var(--sun); font-weight: 800; display: block; margin-top: 4px; }
.up { display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; align-items: center; background: var(--panel-2); border-radius: 12px; padding: 9px 10px; margin-top: 7px; }
.up small { color: var(--soft); line-height: 1.25; grid-column: 1; }
.up .pips { color: var(--sun); letter-spacing: 2px; font-size: .74rem; grid-column: 1; }
.up button { grid-row: 1 / span 3; grid-column: 2; min-width: 84px; }
h3.small { font-size: 1.02rem; margin: 12px 0 2px; }
.goal { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.goal.done { opacity: .62; }
.goal span.ic { font-size: 1.3rem; grid-row: 1 / span 2; }
.goal small { color: var(--soft); grid-column: 2; }
.goal em { font-style: normal; color: var(--sun); font-weight: 800; grid-row: 1 / span 2; grid-column: 3; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; text-align: center; }
.stats div { background: var(--panel-2); border-radius: 10px; padding: 7px 2px; }
.stats b { display: block; } .stats span { color: var(--soft); font-size: .72rem; }
.set { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.set div.opts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.set .tab { flex: 0 0 auto; min-height: 40px; }
.note { color: var(--soft); font-size: .82rem; text-align: center; margin: 12px 0 0; line-height: 1.4; }

/* ── Driving ── */
#drive { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; pointer-events: none; }
#drive button { pointer-events: auto; }
.hud { position: absolute; top: max(8px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); display: flex; gap: 6px; align-items: center; font-weight: 800; }
.chip { background: #fff8ebe6; color: #2d1b0c; border-radius: 10px; padding: 5px 8px; font-size: .86rem; white-space: nowrap; }
.chip.warn { background: var(--bad); color: #fff; }
.chip.gap { font-variant-numeric: tabular-nums; min-width: 3.6em; text-align: center; }
.chip.gap.ahead { background: #2f9e57; color: #fff; }
.chip.gap.behind { background: #c9482e; color: #fff; }
.fuel { flex: 1; max-width: 220px; min-width: 40px; height: 16px; background: #fff8ebe6; border-radius: 8px; overflow: hidden; padding: 2px; }
.fuel i { display: block; height: 100%; background: var(--go); border-radius: 6px; }
.fuel i.low { background: var(--bad); }
.pause { margin-left: auto; background: #fff8ebe6; color: #2d1b0c; border: 0; border-radius: 10px; min-width: 44px; min-height: 40px; font-weight: 800; }
.progress { position: absolute; top: max(54px, calc(env(safe-area-inset-top) + 48px)); left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); height: 6px; background: #00000038; border-radius: 3px; }
.progress i { display: block; height: 100%; width: 0; background: #fff; border-radius: 3px; }
.toast { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); font-family: var(--serif); font-weight: 800; font-size: 1.5rem; color: #fff; text-shadow: 0 2px 7px #000c; opacity: 0; transition: opacity .2s; text-align: center; white-space: nowrap; }
.toast.on { opacity: 1; }
.hint { position: absolute; top: 76px; left: 50%; transform: translateX(-50%); width: min(420px, calc(100vw - 32px)); background: #2c1f17e6; border: 1px solid var(--sun); border-radius: 13px; padding: 8px 12px; font-weight: 700; font-size: .92rem; text-align: center; opacity: 0; transition: opacity .25s; }
.hint.on { opacity: 1; }
.stop { position: absolute; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 6px); left: 50%; transform: translateX(-50%); background: #fff8ebe6; color: #2d1b0c; font-weight: 800; border-radius: 12px; padding: 6px 12px; overflow: hidden; }
.stop i { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: var(--go); }
.pedal { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); width: min(30vw, 150px); height: min(30vh, 130px); min-height: 92px; border-radius: 22px; border: 3px solid #ffffffa6; background: #00000048; color: #fff; font-size: 1.02rem; touch-action: none; text-shadow: 0 1px 3px #000; }
.pedal.on { background: #ffffff70; }
#brake { left: max(14px, env(safe-area-inset-left)); }
#gas { right: max(14px, env(safe-area-inset-right)); }

/* ── Result and dialogs ── */
.veil { position: fixed; inset: 0; background: #1a0f08a8; display: none; place-items: center; padding: 12px; overflow-y: auto; z-index: 10; }
.veil.on { display: grid; }
.sheet { background: #2c1f17f5; border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; width: min(430px, 100%); text-align: center; animation: pop .22s ease-out; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { font-size: 1.55rem; }
.sheet p { color: var(--soft); line-height: 1.4; margin: 6px 0; }
.stars { color: var(--sun); font-size: 2rem; letter-spacing: 4px; line-height: 1.2; }
.stars span { display: inline-block; animation: star .4s ease-out backwards; }
.stars span:nth-child(2) { animation-delay: .16s; } .stars span:nth-child(3) { animation-delay: .32s; }
@keyframes star { from { transform: scale(2.2) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.lines { list-style: none; padding: 0; margin: 8px 0; text-align: left; }
.lines li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.lines li.total { font-weight: 800; color: var(--sun); border: 0; }
.unlocked { background: var(--panel-2); border-radius: 10px; padding: 6px 9px; margin: 6px 0; font-size: .86rem; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Authored icons and art (assets/ui, assets/art). Each falls back to text. */
.ico { width: 1.3em; height: 1.3em; vertical-align: -0.3em; object-fit: contain; }
.ico.star { width: 1.5em; height: 1.5em; }
.ico.badge { width: 34px; height: 34px; vertical-align: middle; }
.ico.pedal-ico { width: 46px; height: 46px; display: block; margin: 0 auto 2px; opacity: .92; }
.brand h1 .logo { display: block; width: min(32vw, 300px); height: auto; filter: drop-shadow(0 6px 14px #0006); }
.truck .portrait { display: block; width: 100%; max-height: 58px; object-fit: contain; margin-bottom: 4px; }
.banner { height: 78px; border-radius: 13px; background-size: cover; background-position: center 62%; margin-bottom: 8px; display: flex; align-items: flex-end; justify-content: flex-end; padding: 6px 8px; }
.banner span { background: #2b1d14cc; border-radius: 10px; padding: 3px 6px; }
.banner .ico { width: 26px; height: 26px; vertical-align: middle; }
.pause .ico { width: 22px; height: 22px; vertical-align: middle; }
.set .opts { flex-wrap: wrap; }
.nextbest { color: var(--sun); font-weight: 700; margin: 6px 0 0; }
.route .ch { display: inline-block; font-size: .7rem; opacity: .45; } .route .ch.on { opacity: 1; color: var(--sun); } .route .ch .ico { width: 14px; height: 14px; vertical-align: -2px; }
.challenge { color: var(--soft); margin: 6px 0 0; }
.customer { background: rgba(255,255,255,.06); border-radius: 14px; padding: 10px; margin: 10px 0; }
.customer.locked { opacity: .55; } .customer.locked b, .customer.locked small { display: block; }
.customer .who { display: flex; align-items: center; gap: 10px; }
.customer .face { font-size: 1.9rem; width: 44px; height: 44px; display: grid; place-items: center; background: rgba(255,255,255,.1); border-radius: 50%; }
.customer .who small { display: block; color: var(--soft); font-size: .78rem; }
.customer .rep { margin-left: auto; text-align: right; color: var(--sun); letter-spacing: 1px; }
.customer .rep small { letter-spacing: 0; }
.customer .orders { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 8px; }
.order { text-align: left; background: rgba(0,0,0,.18); color: inherit; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 7px 9px; font: inherit; cursor: pointer; }
.order b { display: block; font-size: .86rem; } .order small { display: block; color: var(--soft); font-size: .72rem; line-height: 1.2; }
.order.done { border-color: var(--sun); } .order:disabled { opacity: .45; cursor: default; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--sun); vertical-align: 2px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin: 6px 0; }
.swatch { background: var(--panel-2); border: 2px solid transparent; border-radius: 10px; padding: 5px; font-size: .68rem; font-weight: 700; line-height: 1.15; display: grid; justify-items: center; gap: 3px; min-height: 58px; }
.swatch i { display: block; width: 30px; height: 22px; border-radius: 6px; border: 1px solid #0004; }
.swatch[aria-pressed="true"] { border-color: var(--sun); } .swatch:disabled { opacity: .45; }
.swatch .ico { width: 14px; height: 14px; }
.truck .mastery { color: var(--sun); }
.set.paintset { display: block; } .set.paintset .swatches { width: 100%; } .set.paintset small.sub { display: block; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 6px 0 8px; }
.cal .day { font-style: normal; text-align: center; padding: 7px 0; border-radius: 9px; background: var(--panel-2); font-weight: 700; font-size: .78rem; color: var(--soft); }
.cal .day.on { background: var(--sun); color: #2b1d14; } .cal .day.big { border: 1px dashed var(--sun); }
/* Short landscape phones (about 450 CSS px tall): the logo follows the screen
   height and the menu tightens, so Drive, the three modes and the dock all fit. */
@media (max-height: 560px) {
  .brand h1 .logo { width: auto; height: min(22vh, 120px); max-width: 32vw; }
  .brand p { font-size: .82rem; margin-top: 2px; }
  .menu { gap: 6px; }
  .menu .btn { min-height: 0; padding: 6px 14px; }
  .menu .btn.primary { font-size: 1rem; }
  .menu small { font-size: .7rem; }
  .menu { width: min(300px, 100%); }
  .dock .btn { min-height: 38px; padding: 6px 4px; font-size: .78rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; }
}
button.customer.locked { display: block; width: 100%; text-align: left; color: inherit; border: 0; font: inherit; cursor: pointer; }
.unlock-hero { height: 96px; margin: -4px -4px 10px; border-radius: 12px; background-size: cover; background-position: center; position: relative; }
.unlock-hero .badge-one { position: absolute; top: 8px; left: 8px; background: var(--sun); color: #33210a; font-weight: 800; font-size: .72rem; border-radius: 8px; padding: 3px 8px; }
/* Sheets never run off a short landscape phone: they scroll, and the unlock sheet tightens. */
.sheet { max-height: calc(100vh - 24px); overflow-y: auto; }
@media (max-height: 560px) {
  .unlock-hero { height: 64px; margin-bottom: 6px; }
  .sheet h2 { font-size: 1.3rem; }
  .sheet .lines li { padding: 2px 0; font-size: .86rem; }
  .sheet .row .btn { min-height: 40px; padding-block: 7px; }
  .sheet .note { margin: 6px 0 0; }
}

/* Winter Haul */
.menu .winter-entry { background: #263653; border-color: #789ab7; color: #eef4fb; }
.winter-heading { margin: 8px 0 10px; padding: 10px 13px; border-radius: 12px; background: #263653; color: #eef4fb; }
.winter-heading h3, .winter-heading p { margin: 0 0 5px; }
.winter-tile { min-height: 52px; padding: 7px; }
.winter-tile b { font-size: .88rem; }
.winter-doors { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 5px; margin-bottom: 10px; }
.winter-doors .route { min-width: 0; }
.winter-doors .route small { font-size: .69rem; }
@media (max-height: 420px) and (min-aspect-ratio: 6/5) {
  .menu:has(.winter-entry) { gap: 4px; }
  .menu:has(.winter-entry) > .btn { padding-block: 5px; }
}
@media (max-width: 430px) {
  .winter-doors { grid-template-columns: repeat(4,minmax(0,1fr)); }
}
