:root {
  --bg: #070a14;
  --panel: rgba(17, 23, 41, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8ecff;
  --muted: #8d96b8;
  --accent: #22d3ee;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---- HUD ---- */

.back {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 3;
}

.hud {
  position: fixed;
  top: calc(44px + env(safe-area-inset-top));
  left: 10px;
  display: flex;
  gap: 8px;
}
.stat {
  min-width: 74px;
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}
.label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: #b6bdd8; }
.big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat.hot .big { color: #f87171; }

.guide {
  position: fixed;
  top: calc(104px + env(safe-area-inset-top));
  left: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
}
.arrow {
  width: 30px;
  height: 30px;
  background: var(--accent);
  clip-path: polygon(50% 0, 100% 100%, 50% 75%, 0 100%);
  transition: transform 0.08s linear;
}
.dist { font-weight: 600; font-variant-numeric: tabular-nums; }

.map {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 10px;
  width: 160px;
  height: 160px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: #111;
  opacity: 0.92;
}

.speedo {
  position: fixed;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.5);
}
.speedo span { font-size: 38px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 66px; text-align: right; }
.speedo small { color: var(--muted); font-size: 13px; }

.clock {
  position: fixed;
  top: calc(176px + env(safe-area-inset-top));
  right: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  font-size: 12px;
}

.toast {
  position: fixed;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.7);
  font-size: 22px;
  font-weight: 700;
  pointer-events: none;
  text-align: center;
}

/* ---- touch controls ---- */

.touch {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(10px + env(safe-area-inset-bottom));
  padding: 0 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}
.touch-side { display: flex; gap: 10px; }
.touch button {
  pointer-events: auto;
  touch-action: none;
  width: 76px;
  height: 76px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font: 700 15px system-ui, sans-serif;
}
.touch button.gas { height: 100px; background: rgba(34, 197, 94, 0.45); }
.touch button.on { background: rgba(255, 255, 255, 0.35); }

/* ---- overlays ---- */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(3, 5, 12, 0.6);
  z-index: 4;
}
.card {
  width: min(520px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.card h1, .card h2 { margin: 0 0 6px; }
.card h1 { font-size: 40px; letter-spacing: 0.04em; }
.card p { color: var(--muted); margin: 8px auto; max-width: 44ch; }
.note { font-size: 12px; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.btn {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
.btn:disabled { opacity: 0.4; cursor: wait; }
.btn-primary { background: var(--accent); color: #04222a; border-color: transparent; font-weight: 700; }
.btn-primary:hover:not(:disabled) { background: #67e8f9; }

.controls { display: grid; gap: 4px; margin: 14px auto 6px; text-align: left; max-width: 400px; }
.controls div { display: flex; justify-content: space-between; gap: 18px; }
.controls dd { margin: 0; color: var(--muted); text-align: right; }
kbd {
  font: 12px ui-monospace, Menlo, monospace;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--line);
}

@media (pointer: coarse) {
  .touch:not([hidden]) { display: flex; }
  .speedo { bottom: calc(124px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .map { width: 120px; height: 120px; }
  .clock { top: calc(138px + env(safe-area-inset-top)); }
  .hud { gap: 6px; }
  .stat { min-width: 60px; padding: 4px 8px; }
  .big { font-size: 18px; }
}

/* ---- health and busted bars ---- */

.bars {
  position: fixed;
  top: calc(104px + env(safe-area-inset-top));
  left: 10px;
  display: grid;
  gap: 6px;
}
.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
}
.bar-label { width: 50px; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: #b6bdd8; }
.bar-track { width: 120px; height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.bar-fill { height: 100%; width: 100%; border-radius: 999px; background: linear-gradient(90deg, #22c55e, #84cc16); transition: width 0.15s linear; }
.bar-fill.low { background: #ef4444; }
.bar-fill.busted { width: 0; background: linear-gradient(90deg, #38bdf8, #6366f1); }

.guide { top: calc(184px + env(safe-area-inset-top)); }

.flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(220, 38, 38, 0.55));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease-out;
  z-index: 2;
}
.flash.on { opacity: 1; transition: none; }

.siren-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

/* a gentle darkening toward the corners, like a camera lens */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, 0.32) 100%);
}

/* ---- goal, prompt, power-ups ---- */
.goal {
  position: fixed;
  top: calc(44px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, 46vw);
  text-align: center;
  padding: 6px 12px 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.5);
}
.goal-text { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.goal-track { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.goal-fill { height: 100%; width: 0; background: linear-gradient(90deg, #22d3ee, #34d399); transition: width 0.3s; }
.goal.escape { background: rgba(120, 80, 0, 0.6); }
.goal.escape .goal-fill { background: linear-gradient(90deg, #fbbf24, #fb923c); }

.prompt {
  position: fixed;
  left: 50%;
  bottom: calc(110px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-weight: 700;
  font-size: 16px;
  pointer-events: none;
}

.effects {
  position: fixed;
  left: 10px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.fx { padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; background: rgba(0, 0, 0, 0.6); border: 2px solid; width: fit-content; }
.fx.nitro { border-color: #3b82f6; color: #93c5fd; }
.fx.shield { border-color: #facc15; color: #fde68a; }
.fx.cash2 { border-color: #34d399; color: #a7f3d0; }
.fx.bad { border-color: #ef4444; color: #fca5a5; }

.labels { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
