html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0a0a0a;
  color: #ddd;
  font-family: "Courier New", monospace;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  background: #0a0a14;
  display: block;
  width: 100vw;
  height: 100vh;
  position: absolute;
  inset: 0;
}

.world-popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 22px;
  letter-spacing: 1px;
  text-shadow: 0 0 6px #000, 2px 2px 0 #000;
  pointer-events: none;
  z-index: 6;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s linear;
}

.overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(20,0,0,0.85), rgba(0,0,0,0.97));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  text-align: center;
}

.overlay.hidden,
.hidden { display: none !important; }

.title {
  font-size: 88px;
  margin: 0;
  letter-spacing: 8px;
  color: #ff2222;
  text-shadow:
    0 0 18px #ff0000,
    3px 3px 0 #500,
    6px 6px 16px #000;
  animation: bloodPulse 2.4s ease-in-out infinite;
}

.bloody {
  font-size: 96px;
  margin: 0 0 12px 0;
  letter-spacing: 10px;
  color: #ff0000;
  text-shadow:
    0 0 40px #ff0000,
    0 0 8px #ff8080,
    4px 4px 0 #300;
}

.winner {
  font-size: 72px;
  margin: 0 0 12px 0;
  letter-spacing: 6px;
  color: #ffd700;
  text-shadow: 0 0 24px #ffaa00, 3px 3px 0 #4a3000;
}

@keyframes bloodPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); filter: brightness(1.2); }
}

.subtitle {
  margin-top: 4px;
  letter-spacing: 6px;
  color: #999;
  font-size: 14px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 32px;
}

button {
  background: transparent;
  color: #ff4444;
  border: 2px solid #ff2222;
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 4px;
  padding: 12px 36px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-transform: uppercase;
}

button:hover {
  background: #ff2222;
  color: #fff;
  box-shadow: 0 0 24px #ff0000;
  transform: translateY(-1px);
}

.hi-block {
  margin-top: 28px;
  font-size: 16px;
  color: #ffaa00;
  letter-spacing: 2px;
}

.controls {
  margin-top: 32px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 32px;
  font-size: 13px;
  color: #888;
  letter-spacing: 1px;
}

.controls b { color: #ddd; }

.back-link {
  margin-top: 28px;
  color: #555;
  text-decoration: none;
  letter-spacing: 4px;
  font-size: 12px;
  border: 1px solid #333;
  padding: 8px 16px;
}

.back-link:hover { color: #aaa; border-color: #777; }

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  color: #fff;
  text-shadow: 0 0 6px #000, 1px 1px 0 #000;
}

#hud-top {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 28px;
  background: rgba(0,0,0,0.5);
  padding: 8px 24px;
  border: 1px solid rgba(255,40,40,0.4);
  border-radius: 4px;
}

.hud-block {
  text-align: center;
  min-width: 70px;
}

.hud-label {
  font-size: 10px;
  letter-spacing: 3px;
  color: #ff6666;
}

.hud-value.big {
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 2px;
}

#hud-bottom-left {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 220px;
  background: rgba(0,0,0,0.5);
  padding: 12px;
  border: 1px solid rgba(255,40,40,0.4);
  border-radius: 4px;
}

#hp-bar, #nitro-bar {
  width: 100%;
  height: 14px;
  background: #200;
  border: 1px solid #500;
  margin-top: 4px;
  overflow: hidden;
}

#hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff0000, #ff8800);
  transition: width 0.2s ease;
}

#nitro-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00aaff, #00ffee);
  transition: width 0.1s linear;
}

#powerup-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.powerup-active {
  font-size: 12px;
  letter-spacing: 2px;
  color: #ffd700;
  padding: 2px 6px;
  background: rgba(255,200,0,0.15);
  border-left: 3px solid #ffd700;
}

#hud-bottom-right {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#speedo {
  position: relative;
  width: 200px;
  background: rgba(0,0,0,0.6);
  padding: 6px 8px;
  border: 1px solid rgba(255,40,40,0.4);
  border-radius: 4px;
}

#speedo svg { display: block; width: 100%; height: auto; }
#speedo-text {
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 2px;
  margin-top: -8px;
}

#minimap {
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,40,40,0.5);
  display: block;
}

#combo-popup {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 64px;
  color: #ff2222;
  text-shadow: 0 0 24px #ff0000, 4px 4px 0 #000;
  letter-spacing: 4px;
  opacity: 0;
  pointer-events: none;
  font-weight: bold;
}

#big-message {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translate(-50%, 0);
  font-size: 40px;
  color: #ffd700;
  text-shadow: 0 0 20px #ff8800, 3px 3px 0 #000;
  letter-spacing: 4px;
  opacity: 0;
  pointer-events: none;
  font-weight: bold;
}

#gameover-stats, #victory-stats {
  margin-top: 16px;
  font-size: 16px;
  letter-spacing: 2px;
  color: #ddd;
  line-height: 2;
}

#gameover-stats b, #victory-stats b { color: #ff6666; margin-right: 8px; }

/* ----- Touch / mobile controls (hidden by default; revealed on first touch) ----- */
#touch-ui {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: none;
}
#touch-ui.active { display: block; }

#touch-stick {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(20, 0, 0, 0.35);
  border: 2px solid rgba(255, 40, 40, 0.5);
  pointer-events: auto;
  touch-action: none;
}
#touch-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 80px;
  height: 80px;
  margin-left: -40px;
  margin-top: -40px;
  border-radius: 50%;
  background: rgba(255, 40, 40, 0.6);
  border: 3px solid rgba(255, 255, 255, 0.55);
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 18px rgba(255, 0, 0, 0.45);
}
.touch-stick-hint {
  position: absolute;
  left: 50%;
  bottom: -22px;
  transform: translateX(-50%);
  color: #ff8888;
  font-size: 11px;
  letter-spacing: 3px;
  pointer-events: none;
}

.touch-btn {
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 2px solid rgba(255, 40, 40, 0.6);
  background: rgba(20, 0, 0, 0.4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 3px;
  font-weight: bold;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  text-shadow: 0 0 6px #000;
}
.touch-btn.held {
  background: rgba(255, 40, 40, 0.7);
  border-color: #fff;
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.6);
}
.touch-btn.small {
  width: 56px;
  height: 56px;
  font-size: 22px;
  letter-spacing: 0;
}
#touch-nitro     { right: 24px;  bottom: 150px; color: #00ddff; border-color: rgba(0, 200, 255, 0.7); }
#touch-handbrake { right: 150px; bottom: 24px;  color: #ffd700; border-color: rgba(255, 215, 0, 0.7); }
#touch-pause     { right: 16px;  top: 16px; }
#touch-nitro.held     { background: rgba(0, 200, 255, 0.55); border-color: #fff; }
#touch-handbrake.held { background: rgba(255, 215, 0, 0.55); border-color: #fff; }

/* Overlays sit above the touch UI so menus/pause/game-over screens are
   never obscured by the joystick or action buttons. */
.overlay { z-index: 30; }

/* On small/touch screens, relocate the HUD so the bottom corners are
   free for the joystick and action buttons. */
@media (max-width: 820px), (max-height: 520px) {
  #hud-top { gap: 10px; padding: 4px 10px; top: 8px; }
  .hud-value.big { font-size: 14px; }
  .hud-label { font-size: 8px; letter-spacing: 1px; }
  /* HP / nitro / powerup-list moves to the top-left as a thin column. */
  #hud-bottom-left {
    left: 8px; top: 8px; bottom: auto; width: 130px; padding: 6px;
  }
  /* Speedo + minimap move to top-right as a thin column. */
  #hud-bottom-right { right: 8px; top: 8px; bottom: auto; gap: 4px; align-items: flex-end; }
  #speedo { width: 110px; padding: 2px 4px; }
  #speedo-text { font-size: 11px; }
  #minimap { width: 90px !important; height: 90px !important; }

  #touch-stick { width: 150px; height: 150px; left: 14px; bottom: 14px; }
  #touch-stick-knob { width: 64px; height: 64px; margin-left: -32px; margin-top: -32px; }
  .touch-btn { width: 92px; height: 92px; font-size: 14px; }
  #touch-nitro     { right: 14px;  bottom: 120px; }
  #touch-handbrake { right: 120px; bottom: 14px; }
  .touch-btn.small { width: 48px; height: 48px; font-size: 20px; }

  .title { font-size: 48px; letter-spacing: 4px; }
  .bloody { font-size: 56px; }
  .winner { font-size: 40px; }
  .controls { font-size: 11px; gap: 4px 16px; }
  button { font-size: 14px; padding: 10px 20px; letter-spacing: 2px; }
}

/* Coarse-pointer hint: any pointer that's primarily touch (phones, tablets)
   should be allowed to drag the stick even if the screen is large. */
@media (pointer: coarse) {
  body { overscroll-behavior: contain; }
}

