:root {
  --ink: #3b2e5a;
  --lav: #dccbf7;
  --purple: #6e5ac8;
  --red: #ee4b5e;
  --green: #3ddc84;
  --yellow: #ffd45e;
  --bg: #b9a3e8;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg);
  font-family: "Trebuchet MS", "Avenir Next", system-ui, sans-serif; color: var(--ink);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
}
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { pointer-events: none; }
.hidden { display: none !important; }

#hud { position: fixed; inset: 0; pointer-events: none; padding: max(10px, env(safe-area-inset-top)) 12px 12px; }
.hud-top { display: flex; justify-content: space-between; gap: 8px; }
.pill {
  background: #fffdf8ee; border: 3px solid var(--ink); border-radius: 999px; padding: 4px 14px;
  font-weight: 800; font-size: 22px; display: flex; gap: 6px; align-items: baseline;
  box-shadow: 0 4px 0 var(--ink);
}
.pill .lbl { font-size: 12px; letter-spacing: 1px; opacity: .7; }
.pill.cash .val { color: #2f9e62; }
.pill.warn { background: #ffe0e4; animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }

.hud-top { align-items: flex-start; }
.nav { display: flex; flex-direction: column; align-items: center; margin-top: -2px; }
.nav svg { filter: drop-shadow(0 3px 0 var(--ink)); }
.nav .ring { fill: #fffdf8; stroke: var(--ink); stroke-width: 6; }
.nav .arrow { stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; transition: fill .2s; }
.nav.pickup .arrow { fill: var(--green); }
.nav.drop .arrow { fill: var(--red); }
.nav.none { opacity: .35; }
.nav-txt { display: flex; gap: 5px; font-weight: 900; font-size: 12px; margin-top: 2px;
  background: #fffdf8ee; border: 2px solid var(--ink); border-radius: 8px; padding: 0 6px; }
.nav.pickup #nav-label { color: #1f9d58; } .nav.drop #nav-label { color: var(--red); }
.nav.near svg { animation: pulse .35s infinite alternate; }
.fare {
  margin: 10px auto 0; max-width: 360px; background: #fffdf8ee; border: 3px solid var(--ink);
  border-radius: 14px; padding: 6px 10px; box-shadow: 0 4px 0 var(--ink); font-weight: 700;
}
.fare-row { display: flex; justify-content: space-between; font-size: 15px; }
.bar { height: 8px; background: #e7def8; border-radius: 6px; overflow: hidden; margin-top: 4px; }
.bar > div { height: 100%; width: 0; background: var(--green); transition: width .1s linear; }
.side { position: absolute; left: 12px; top: 200px; display: flex; gap: 8px; }
.meter { display: flex; flex-direction: column; align-items: center; font-size: 10px; font-weight: 800; gap: 3px; }
.bar.v { width: 12px; height: 90px; display: flex; align-items: flex-end; border: 2px solid var(--ink); }
.bar.v > div { width: 100%; height: 0; transition: height .1s linear; }
#dmg-bar { background: var(--red); }
#boost-bar { background: linear-gradient(#3f7dff, #ff3d52); }

#toasts { position: absolute; left: 0; right: 0; top: 34%; text-align: center; }
.toast {
  display: inline-block; margin: 3px; padding: 6px 16px; border-radius: 12px; font-weight: 900;
  font-size: 22px; background: var(--yellow); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  animation: toast 1.6s ease-out forwards;
}
.toast.good { background: #b9f5cf; } .toast.bad { background: #ffc4cc; } .toast.big { font-size: 30px; }
@keyframes toast { 0% { transform: scale(.4); opacity: 0 } 12% { transform: scale(1.1); opacity: 1 }
  20% { transform: scale(1) } 80% { opacity: 1 } 100% { transform: translateY(-30px); opacity: 0 } }

.corner-btns { position: absolute; right: 12px; top: calc(max(10px, env(safe-area-inset-top)) + 150px);
  display: flex; flex-direction: column; gap: 10px; }
.mini {
  pointer-events: auto; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink);
  background: #fffdf8; font-weight: 900; font-size: 18px; color: var(--ink); box-shadow: 0 3px 0 var(--ink);
}
.mini:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

/* right-thumb driving pad */
.pad { position: absolute; right: 14px; bottom: max(18px, env(safe-area-inset-bottom)); width: 190px; height: 190px; }
.pbtn {
  pointer-events: auto; position: absolute; border-radius: 50%; border: 3px solid var(--ink);
  font: inherit; font-weight: 900; color: var(--ink); letter-spacing: .5px; box-shadow: 0 4px 0 var(--ink);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.pbtn.down { transform: translateY(3px) scale(.96); box-shadow: 0 1px 0 var(--ink); filter: brightness(1.08); }
.pbtn.drift { right: 0; bottom: 0; width: 96px; height: 96px; background: var(--yellow); font-size: 17px; }
.pbtn.brake { right: 104px; bottom: 6px; width: 74px; height: 74px; background: #ffc4cc; font-size: 13px; }
.pbtn.boost { right: 10px; bottom: 106px; width: 74px; height: 74px; font-size: 13px;
  background: linear-gradient(#8fb4ff, #ff8a98); }
.pizza-row { font-size: 13px; margin-top: 4px; color: #b35f12; }
.nav.pizza .arrow { fill: #ffa23f; }
.nav.pizza #nav2-dist { color: #b35f12; }
.card .o { color: #e07b12; font-weight: 800; }

.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #e9ddffcc, #b9a3e8ee); padding: 16px;
}
.card {
  background: #fffdf8; border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 8px 0 var(--ink);
  padding: 22px 22px 16px; max-width: 400px; width: 100%; text-align: center;
}
.card h1 { margin: 0; font-size: 44px; line-height: .95; letter-spacing: 1px; color: var(--purple); }
.card h1 span { color: var(--red); }
.card .tag { font-weight: 700; margin: 10px 0; }
.card .how { text-align: left; padding-left: 18px; margin: 8px 0 14px; font-size: 13.5px; line-height: 1.45; }
.card .g { color: #1f9d58; font-weight: 800; } .card .r { color: var(--red); font-weight: 800; }
.card button {
  font: inherit; font-weight: 900; font-size: 22px; padding: 12px 28px; border-radius: 16px;
  border: 3px solid var(--ink); background: var(--yellow); color: var(--ink); box-shadow: 0 5px 0 var(--ink);
}
.card button:disabled { opacity: .6; }
.card button:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.card .small { font-size: 12px; opacity: .7; min-height: 1em; }
.card .stats { font-size: 18px; font-weight: 800; line-height: 1.6; }
