* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0f19;
  font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #fff;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #162032 0%, #080c14 100%);
  overflow: hidden;
}

canvas#gameCanvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: block;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), 0 0 15px rgba(0, 200, 255, 0.2);
  border-radius: 6px;
  background: #000;
}

/* HUD elements */
.hud-layer {
  position: absolute;
  z-index: 20;
  pointer-events: none;
}

.hud-layer.hidden {
  display: none !important;
}

#hud-top {
  top: 15px;
  left: 15px;
  right: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.hud-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.location-pill {
  color: #e2e8f0;
  border-color: rgba(56, 189, 248, 0.4);
}

.money-pill {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.4);
}
.money-pill .val {
  color: #facc15;
  font-size: 17px;
  font-weight: 800;
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.5);
}

.hud-right-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.hud-btn {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.hud-btn:hover {
  background: rgba(56, 189, 248, 0.8);
  transform: scale(1.08);
}

/* Alert bar */
#hud-alert-bar {
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: min(450px, 90vw);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 25px rgba(239, 68, 68, 0.2);
}

.alert-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 800;
  color: #f87171;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.alert-progress-bg {
  width: 100%;
  height: 12px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#alert-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
  border-radius: 6px;
  transition: width 0.08s ease-out;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
}

/* Highway Getaway HUD */
#hud-highway {
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  align-items: center;
}

.highway-gauge {
  background: rgba(0, 60, 140, 0.9);
  border: 2px solid #38bdf8;
  padding: 6px 16px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}
.highway-gauge .hw-dest {
  font-size: 11px;
  letter-spacing: 2px;
  color: #bae6fd;
}
.highway-gauge .hw-dist {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
}

/* Car HP Gauge */
.hp-gauge {
  background: rgba(15, 23, 42, 0.9);
  border: 2px solid #ef4444;
  padding: 6px 14px;
  border-radius: 8px;
  min-width: 160px;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}
.hp-gauge .hp-label {
  font-size: 12px;
  font-weight: 800;
  color: #fca5a5;
  margin-bottom: 4px;
  text-align: center;
}
.hp-bar-bg {
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
#hp-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #eab308, #22c55e);
  transition: width 0.15s ease-out;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.7);
}

/* Static Helikopter-Erik Warning Card */
#hud-heli-warning {
  top: 130px;
  left: 20px;
  pointer-events: none;
  animation: pulseWarn 1.2s infinite alternate ease-in-out;
}

.heli-warning-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.94);
  border: 2px solid #ef4444;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 25px rgba(239, 68, 68, 0.5), 0 0 15px rgba(239, 68, 68, 0.3);
  backdrop-filter: blur(8px);
}

.heli-warn-icon {
  font-size: 32px;
  animation: heliBounce 0.4s infinite alternate;
}

@keyframes heliBounce {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}

@keyframes pulseWarn {
  from { transform: scale(1); box-shadow: 0 0 10px rgba(239, 68, 68, 0.4); }
  to { transform: scale(1.03); box-shadow: 0 0 25px rgba(239, 68, 68, 0.8); }
}

.heli-warn-title {
  font-family: 'Press Start 2P', cursive;
  font-size: 13px;
  color: #fca5a5;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.heli-warn-sub {
  font-size: 13px;
  font-weight: 700;
  color: #fecaca;
}

.speed-gauge {
  background: rgba(15, 23, 42, 0.9);
  border: 2px solid #22c55e;
  padding: 6px 16px;
  border-radius: 8px;
  text-align: center;
}
.speed-gauge .speed-val {
  font-size: 22px;
  font-weight: 900;
  color: #4ade80;
}
.speed-gauge .ev-badge {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #38bdf8;
  font-weight: 800;
}

/* Clear Persistent Bottom Controls Bar */
#hud-bottom-controls {
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(800px, 94vw);
  display: flex;
  justify-content: center;
  align-items: center;
}

.controls-hint-pill {
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(56, 189, 248, 0.5);
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 700;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.2);
}

.ctrl-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.k-badge {
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  color: #38bdf8;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
.k-badge.key-highlight {
  background: rgba(16, 185, 129, 0.25);
  border-color: #10b981;
  color: #34d399;
}
.ctrl-sep {
  color: #64748b;
  font-size: 16px;
}

.mobile-only-hint {
  display: none;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  color: #bae6fd;
  text-align: center;
}

@media (pointer: coarse), (max-width: 850px) {
  .controls-hint-pill {
    display: none;
  }
  .mobile-only-hint {
    display: block;
  }
}

/* Screen overlay & menus */
#screen-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

.screen-content {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 2px solid rgba(56, 189, 248, 0.3);
  padding: 28px;
  border-radius: 20px;
  max-width: 550px;
  width: 90vw;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(56, 189, 248, 0.15);
  pointer-events: auto;
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.screen-content.hidden {
  display: none;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.title-badge {
  display: inline-block;
  background: linear-gradient(135deg, #ec4899, #f43f5e);
  color: white;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.glitch-title {
  font-family: 'Press Start 2P', cursive;
  font-size: 20px;
  color: #38bdf8;
  text-shadow: 2px 2px 0px #e11d48, -2px -2px 0px #0284c7;
  letter-spacing: -0.5px;
  line-height: 1.3;
  margin-bottom: 6px;
}

.sub-title {
  font-size: 18px;
  font-weight: 800;
  color: #facc15;
  letter-spacing: 3px;
  margin-bottom: 18px;
}

.mission-briefing {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brief-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.4;
}
.brief-row .tag {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  flex-shrink: 0;
}
.brief-row .desc {
  color: #cbd5e1;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: white;
  border: none;
  font-family: 'Rajdhani', sans-serif;
  font-size: 20px;
  font-weight: 800;
  padding: 14px 28px;
  border-radius: 30px;
  cursor: pointer;
  letter-spacing: 1px;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
  transition: all 0.2s;
  width: 100%;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1 0%, #1d4ed8 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(37, 99, 235, 0.6);
}

.pulse-btn {
  animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7); }
  70% { box-shadow: 0 0 0 15px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

.btn-secondary {
  background: rgba(51, 65, 85, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-family: 'Rajdhani', sans-serif;
  font-size: 16px;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-secondary:hover {
  background: rgba(71, 85, 105, 1);
  transform: translateY(-1px);
}

.controls-guide {
  margin-top: 15px;
  font-size: 13px;
  color: #94a3b8;
}

/* Busted Screen */
.busted-stamp {
  display: inline-block;
  font-family: 'Press Start 2P', cursive;
  font-size: 26px;
  color: #ef4444;
  border: 4px solid #ef4444;
  padding: 8px 18px;
  border-radius: 8px;
  transform: rotate(-6deg);
  margin-bottom: 18px;
  text-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
}

#busted-screen h2 {
  font-size: 22px;
  font-weight: 800;
  color: #f87171;
  margin-bottom: 10px;
}

#busted-quote {
  font-style: italic;
  color: #cbd5e1;
  font-size: 17px;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.35);
  padding: 12px;
  border-radius: 8px;
  border-left: 4px solid #ef4444;
}

.busted-icon {
  font-size: 45px;
  margin-bottom: 20px;
}

/* Victory Screen */
.victory-header {
  margin-bottom: 18px;
}
.cake-emoji {
  font-size: 38px;
  margin-bottom: 5px;
  animation: bounce 1.5s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.bday-title {
  font-family: 'Rubik', sans-serif;
  font-size: 24px;
  font-weight: 900;
  background: linear-gradient(135deg, #f43f5e, #fbbf24, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.bday-sub {
  font-size: 15px;
  color: #94a3b8;
}

.victory-card {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
}
.card-row .lbl {
  color: #cbd5e1;
  font-weight: 600;
}
.card-row .val {
  font-weight: 800;
  color: #fff;
}
.card-row .val.green {
  color: #4ade80;
}
.card-row .val.gold {
  color: #facc15;
  font-size: 18px;
}
.card-row .val.rank {
  color: #38bdf8;
  font-weight: 800;
}

.doctor-comment {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.15);
  display: flex;
  gap: 10px;
  align-items: center;
}
.dr-avatar {
  font-size: 28px;
}
.dr-bubble {
  font-size: 13px;
  line-height: 1.35;
  color: #e2e8f0;
}
.dr-name {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
  font-weight: 700;
}

.victory-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Touch controls for mobile */
#mobile-controls {
  position: absolute;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  display: none;
}

@media (pointer: coarse), (max-width: 850px) {
  #mobile-controls {
    display: block;
  }
  .controls-guide {
    display: none;
  }
}

#joystick-zone {
  position: absolute;
  bottom: 25px;
  left: 25px;
  width: 140px;
  height: 140px;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#joystick-base {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.25);
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}

#joystick-thumb {
  width: 55px;
  height: 55px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #38bdf8, #0284c7);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
  position: relative;
  transition: transform 0.05s linear;
}

.joy-label {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 1px;
}

#action-zone {
  position: absolute;
  bottom: 30px;
  right: 25px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  pointer-events: auto;
}

.touch-action-btn {
  width: 85px;
  height: 85px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  font-weight: 800;
  color: white;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 15px rgba(34, 197, 94, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.1;
  padding: 6px;
  background: radial-gradient(circle at 35% 35%, #22c55e, #15803d);
  transition: all 0.1s;
}
.touch-action-btn:active {
  transform: scale(0.92);
  background: #166534;
}

.touch-sneak-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 35% 35%, #64748b, #334155);
}
.touch-sneak-btn.active {
  background: radial-gradient(circle at 35% 35%, #eab308, #ca8a04);
  border-color: #fef08a;
}
