/* ==========================================================================
   UberBeats UI — clean black / white / green, delivery-app inspired.
   Colours and sizes live in the variables below: tweak them here.
   ========================================================================== */
:root {
  --black: #000000;
  --white: #FFFFFF;
  --green: #06C167;
  --grey-50: #F6F6F6;
  --grey-200: #E2E2E2;
  --grey-500: #757575;
  --red: #E11900;
  --radius: 16px;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #FFFFFF; font-family: var(--font); color: var(--black); user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 16px; font: 600 17px var(--font); cursor: pointer; margin-top: 10px; position: relative; overflow: hidden; }
.btn.primary { background: var(--black); color: var(--white); }
.btn.primary:active { transform: scale(0.98); }
.btn.ghost { background: var(--grey-50); color: var(--black); }
.btn.big { font-size: 19px; padding: 18px; }
.btn.small { width: auto; padding: 10px 14px; margin: 0; font-size: 15px; }
.btn.primary-sm { background: var(--black); color: var(--white); }
.btn.disabled { background: var(--grey-200); color: var(--grey-500); cursor: default; }
.btn.accept { background: #333; }
.btn.accept .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: var(--black); transition: width 0.1s linear; }
.btn.accept .label { position: relative; }

/* ---------- title screen ---------- */
.menu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.35); backdrop-filter: blur(2px); padding: 20px; }
.menu-card { background: var(--white); border-radius: 24px; padding: 32px 28px 24px; width: min(420px, 100%); box-shadow: var(--shadow); text-align: center; }
.logo { font-size: 52px; font-weight: 800; letter-spacing: -2px; }
.logo span { color: var(--green); }
.tagline { color: var(--grey-500); margin: 2px 0 22px; font-size: 17px; }
.controls { margin-top: 20px; font-size: 13px; color: var(--grey-500); line-height: 2; }
.controls .phone { display: none; }
kbd { display: inline-block; background: var(--grey-50); border: 1px solid var(--grey-200); border-radius: 6px; padding: 0 6px; font: 600 12px var(--font); color: var(--black); margin: 0 1px; line-height: 20px; }
.disclaimer { margin-top: 16px; font-size: 11px; color: #AAA; }

/* ---------- HUD ---------- */
.topbar { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; gap: 10px; justify-content: space-between; pointer-events: none; }
.pill { background: var(--white); border-radius: 999px; padding: 10px 16px; box-shadow: var(--shadow); font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.pill.status { overflow: hidden; min-width: 0; flex: 0 1 auto; }
.pill.status #statusText { overflow: hidden; text-overflow: ellipsis; }
.pill.cash { background: var(--black); color: var(--white); font-size: 17px; flex-shrink: 0; }
.pill.cash::before { content: "£"; }
.eta { background: var(--black); color: var(--white); border-radius: 999px; padding: 2px 10px; font-variant-numeric: tabular-nums; }
.eta:empty { display: none; }
.eta.warn { background: #F2A541; }
.eta.late { background: var(--red); animation: pulse 0.6s infinite alternate; }
@keyframes pulse { to { opacity: 0.6; } }

.pill.temp { position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 54px); left: 12px; padding: 8px 14px; }
.pill.temp .bar { width: 110px; height: 8px; background: var(--grey-200); border-radius: 4px; overflow: hidden; }
#tempBar { height: 100%; width: 100%; background: #FF5A1F; transition: width 0.2s; }
#tempText { font-variant-numeric: tabular-nums; min-width: 44px; }

.speedo { position: fixed; left: 16px; bottom: max(16px, env(safe-area-inset-bottom)); background: var(--black); color: var(--white); border-radius: 18px; padding: 10px 16px 12px; text-align: center; min-width: 96px; box-shadow: var(--shadow); }
#speed { font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.unit { font-size: 11px; color: #AAA; letter-spacing: 1px; text-transform: uppercase; }
.boostbar { height: 6px; background: #333; border-radius: 3px; margin-top: 8px; overflow: hidden; }
#driftBar { height: 100%; width: 0; background: #BBB; transition: width 0.08s; }
#driftBar.lvl1 { background: #3FA9F5; }
#driftBar.lvl2 { background: #FF8A00; }
#driftBar.lvl3 { background: #C04BFF; }
#driftBar.boosting { background: var(--green); }

.side-buttons { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.iconbtn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--white); box-shadow: var(--shadow); font-size: 20px; cursor: pointer; }
.iconbtn.off { opacity: 0.4; }

/* ---------- toast (big centre messages) ---------- */
#toast { position: fixed; top: 32%; left: 50%; transform: translate(-50%, -50%) scale(0.6); opacity: 0; pointer-events: none; background: var(--black); color: var(--white); font-weight: 800; font-size: 22px; padding: 12px 22px; border-radius: 14px; transition: transform 0.18s cubic-bezier(.2, 1.6, .4, 1), opacity 0.18s; white-space: nowrap; }
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#toast.green { background: var(--green); color: var(--black); }
#toast.red { background: var(--red); }
#toast.turbo1 { background: #3FA9F5; }
#toast.turbo2 { background: #FF8A00; }
#toast.turbo3 { background: #C04BFF; font-size: 28px; }

/* ---------- bottom sheet ---------- */
.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(440px, 100%); background: var(--white); border-radius: 24px 24px 0 0; padding: 10px 20px max(20px, env(safe-area-inset-bottom)); box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.2); animation: slideUp 0.28s cubic-bezier(.2, .9, .3, 1); max-height: 85vh; overflow-y: auto; z-index: 10; }
@keyframes slideUp { from { transform: translate(-50%, 100%); } }
.sheet-handle { width: 40px; height: 5px; background: var(--grey-200); border-radius: 3px; margin: 0 auto 14px; }
.offer-head { display: flex; gap: 8px; margin-bottom: 10px; }
.tag { background: var(--green); color: var(--black); font-weight: 700; font-size: 12px; padding: 4px 10px; border-radius: 999px; }
.tag.ghost { background: var(--grey-50); }
.pay { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
.sub { color: var(--grey-500); font-size: 14px; }
.sub.center { text-align: center; margin-top: 12px; }
.meta { margin: 10px 0 14px; font-size: 16px; }
.stops { border-top: 1px solid var(--grey-200); padding-top: 12px; position: relative; }
.stop { display: flex; gap: 14px; align-items: center; padding: 6px 0; }
.stop b { display: block; font-size: 16px; }
.stop small { color: var(--grey-500); }
.dot { width: 10px; height: 10px; background: var(--black); border-radius: 50%; flex-shrink: 0; }
.dot.sq { border-radius: 2px; }
.result-title { font-size: 26px; font-weight: 800; }
.stars { font-size: 30px; color: var(--black); letter-spacing: 2px; margin: 4px 0; }
.stars .off { color: var(--grey-200); }
.review { font-style: italic; color: var(--grey-500); margin-bottom: 10px; }
.lines div { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--grey-50); font-size: 15px; }
.lines .total { font-weight: 800; font-size: 18px; border-bottom: 0; }
.shop { margin: 12px 0; }
.upg { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--grey-50); }
.upg .ico { font-size: 28px; width: 44px; height: 44px; background: var(--grey-50); border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.upg .info { flex: 1; }
.upg .info b { display: block; }
.upg .info small { color: var(--grey-500); }
.pips { display: flex; gap: 4px; margin-top: 4px; }
.pips i { width: 18px; height: 5px; border-radius: 3px; background: var(--grey-200); }
.pips i.on { background: var(--green); }

/* ---------- touch controls ---------- */
.touch { position: fixed; left: 0; right: 0; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 92px); display: none; justify-content: space-between; padding: 0 14px; pointer-events: none; }
.touch button { pointer-events: auto; width: 76px; height: 76px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow); font: 800 22px var(--font); margin: 0 4px; }
.touch button.down { background: var(--black); color: var(--white); transform: scale(0.94); }
.touch .drift { background: var(--green); font-size: 14px; }
.touch .brake { font-size: 13px; }
body.touch-mode .touch { display: flex; }
body.touch-mode .touch.hidden { display: none; }
body.touch-mode .controls .phone { display: block; }

/* ---------- 3D version additions ---------- */
.btn:disabled { background: var(--grey-200); color: var(--grey-500); cursor: default; }
.loadtext { margin-top: 10px; font-size: 12px; color: var(--grey-500); min-height: 16px; }
#minimap { position: fixed; right: 12px; top: calc(max(12px, env(safe-area-inset-top)) + 56px); width: 150px; height: 150px; border-radius: 50%; border: 4px solid var(--white); box-shadow: var(--shadow); background: #F1F3F4; }
.nav { position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 58px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; pointer-events: none; }
#navArrow { width: 46px; height: 46px; border-radius: 50%; background: var(--black); color: var(--green); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); }
#navDist { background: var(--white); border-radius: 999px; padding: 2px 10px; font: 700 13px var(--font); box-shadow: var(--shadow); }
.pill.street { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); font-size: 14px; padding: 8px 16px; pointer-events: none; }
.credit { position: fixed; right: 8px; bottom: 2px; font-size: 10px; color: rgba(0, 0, 0, 0.45); pointer-events: none; }
.side-buttons { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 6px); }
/* white streaks round the edge of the screen while boosting */
#speedfx { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.25s; background: repeating-conic-gradient(from 0deg at 50% 55%, rgba(255,255,255,0) 0deg 5deg, rgba(255,255,255,0.75) 5.4deg 6deg, rgba(255,255,255,0) 6.4deg 11deg); -webkit-mask-image: radial-gradient(ellipse at 50% 55%, transparent 38%, #000 85%); mask-image: radial-gradient(ellipse at 50% 55%, transparent 38%, #000 85%); }
#speedfx.on { opacity: 1; }
@media (max-width: 600px) {
  #minimap { width: 104px; height: 104px; }
  .pill.street { bottom: auto; top: calc(max(12px, env(safe-area-inset-top)) + 136px); font-size: 12px; padding: 5px 12px; }
}

.area { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; font-size: 14px; color: var(--grey-500); }
.area select { font: 600 14px var(--font); color: var(--black); background: var(--grey-50); border: 1px solid var(--grey-200); border-radius: 999px; padding: 8px 14px; }

.linkbtn { margin-top: 14px; background: none; border: 1px dashed var(--grey-200); border-radius: 10px; padding: 8px 12px; font: 600 12px var(--font); color: var(--grey-500); cursor: pointer; }
.linkbtn:hover { color: var(--black); border-color: var(--grey-500); }
.linkbtn:disabled { opacity: 0.5; cursor: default; }

/* ---------- compass (arrow + distance) sits under the mini-map, on the right ---------- */
.nav { left: auto; right: 12px; transform: none; width: 158px; top: calc(max(12px, env(safe-area-inset-top)) + 56px + 158px + 10px); flex-direction: row; justify-content: center; gap: 6px; }
#navArrow { width: 38px; height: 38px; }
#navArrow svg { width: 22px; height: 22px; }
#navDist { padding: 4px 10px; }
@media (max-width: 600px) { .nav { width: 112px; top: calc(max(12px, env(safe-area-inset-top)) + 56px + 112px + 8px); } #navArrow { width: 32px; height: 32px; } #navArrow svg { width: 18px; height: 18px; } #navDist { font-size: 12px; padding: 3px 8px; } }

/* ---------- phone layout: one row of four buttons along the bottom;
              speedometer (left), street name, and ♪ 🔧 (right) in the row above ---------- */
body.touch-mode .touch { display: flex; left: 0; right: 0; bottom: max(10px, env(safe-area-inset-bottom)); gap: 8px; padding: 0 10px; justify-content: stretch; }
body.touch-mode .touch.hidden { display: none; }
.touch .tleft, .touch .tright { display: contents; }
body.touch-mode .touch button { flex: 1; width: auto; height: 66px; border-radius: 18px; margin: 0; font-size: 24px; }
body.touch-mode .touch .brake, body.touch-mode .touch .drift { font-size: 14px; letter-spacing: 0.5px; }
body.touch-mode .speedo { left: 10px; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 76px); min-width: 78px; padding: 7px 12px 9px; border-radius: 16px; }
body.touch-mode #speed { font-size: 26px; }
body.touch-mode .boostbar { margin-top: 5px; }
body.touch-mode .side-buttons { right: 10px; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 80px); gap: 8px; }
body.touch-mode .pill.street { top: auto; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 88px); font-size: 12px; padding: 6px 12px; max-width: calc(100vw - 236px); overflow: hidden; text-overflow: ellipsis; display: block; }
body.touch-mode .pill.street.hidden { display: none !important; }
body.touch-mode .credit { bottom: auto; top: 0; right: 6px; font-size: 8px; }
body.touch-mode .sheet { z-index: 20; }
