* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0f1a;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}

#app { position: relative; width: 100%; height: 100%; }
canvas { display: block; }

#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 5;
}

#music-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  pointer-events: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(30,40,60,.55);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  transition: transform .12s ease, background .2s ease;
}
#music-btn:hover { transform: scale(1.1); }
#music-btn.muted { opacity: .45; }

/* Virtual joystick for touch */
#joy {
  position: absolute;
  left: 26px;
  bottom: 30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 2px solid rgba(255,255,255,.15);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 8;
  touch-action: none;
}
#joy.show { display: flex; }
#joy-knob {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.5), rgba(120,170,255,.55));
  box-shadow: 0 4px 18px rgba(0,0,0,.5);
  pointer-events: none;
  transition: transform .03s linear;
}

#score {
  font-size: 26px;
  font-weight: 800;
  text-shadow: 0 2px 10px rgba(0,0,0,.6);
}

#threat-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

#cop-count {
  font-size: 15px;
  font-weight: 700;
  color: #9ecbff;
  background: rgba(30,40,60,.5);
  padding: 4px 10px;
  border-radius: 8px;
}

#distance-bar {
  width: 160px;
  height: 6px;
  background: rgba(255,255,255,.15);
  border-radius: 3px;
  overflow: hidden;
}

#distance-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #4af, #ff5a5a);
  transform-origin: left;
}

#overlay, #gameover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  z-index: 10;
}

#overlay {
  background:
    radial-gradient(120% 90% at 50% 30%, transparent 30%, rgba(6, 8, 16, 0) 55%, rgba(6, 8, 16, .72) 100%),
    linear-gradient(to bottom, rgba(6, 8, 16, 0) 0%, rgba(6, 8, 16, .35) 60%, rgba(6, 8, 16, .85) 100%);
  pointer-events: none;
}

.title-wrap {
  pointer-events: auto;
  padding-bottom: 7vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#overlay h1 {
  font-size: 72px;
  font-weight: 900;
  letter-spacing: 6px;
  text-transform: uppercase;
  line-height: .95;
  text-shadow: 0 0 30px rgba(30, 200, 255, .5), 0 6px 30px rgba(0,0,0,.8);
  color: #eaf6ff;
}
#overlay h1 span {
  display: block;
  font-size: 46px;
  letter-spacing: 14px;
  background: linear-gradient(90deg, #00d0ff, #ff2255, #00d0ff);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 4s linear infinite;
  text-shadow: none;
}
@keyframes shimmer {
  to { background-position: 200% center; }
}

.police-lights {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.police-lights i {
  width: 22px;
  height: 12px;
  border-radius: 4px;
}
.police-lights i:nth-child(1), .police-lights i:nth-child(3) {
  background: #ff2255;
  box-shadow: 0 0 18px #ff2255;
  animation: blinkred 1s step-end infinite;
}
.police-lights i:nth-child(2) {
  background: #2a6bff;
  box-shadow: 0 0 18px #2a6bff;
  animation: blinkblue 1s step-end infinite;
}
@keyframes blinkred { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .15; } }
@keyframes blinkblue { 0%, 49% { opacity: .15; } 50%, 100% { opacity: 1; } }

#overlay p {
  font-size: 15px;
  color: #cfd6e6;
  max-width: 340px;
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
}

.keys {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: #9aa6c0;
}
.keys span {
  background: rgba(255,255,255,.08);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.12);
}

button {
  margin-top: 10px;
  padding: 16px 52px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(90deg, #00b8ff, #ff2255);
  background-size: 200% auto;
  border: none;
  border-radius: 40px;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(255, 60, 120, .45);
  transition: transform .12s ease, box-shadow .2s ease;
  animation: btnshift 3s linear infinite;
}
@keyframes btnshift {
  to { background-position: 200% center; }
}
button:hover { transform: scale(1.06); box-shadow: 0 10px 40px rgba(0, 184, 255, .55); }
button:active { transform: scale(.96); }

#gameover {
  background: rgba(6, 8, 16, .72);
  backdrop-filter: blur(4px);
  justify-content: center;
}
#gameover h1 { color: #ff5a5a; font-size: 46px; letter-spacing: 2px; }
#final-score { font-size: 30px; font-weight: 800; }

.hidden { display: none !important; }
