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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  font-family: 'Press Start 2P', monospace;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* HUD */
#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  pointer-events: none;
}

#hud .name {
  color: #fff;
  font-size: 10px;
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 4px;
}

#hud .bar-bg {
  width: 140px;
  height: 12px;
  background: #333;
  border: 2px solid #555;
  border-radius: 2px;
}

#hud .bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(#4f4, #0a0);
  border-radius: 1px;
}

/* HUD right side (score & stage) */
#hud-right {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10;
  pointer-events: none;
  text-align: right;
}

#stage-display, #score-display {
  color: #fff;
  font-size: 10px;
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 4px;
}

#stage-display {
  color: #ffcc44;
}

#enemy-display {
  color: #aaa;
  font-size: 8px;
  text-shadow: 2px 2px 0 #000;
  margin-top: 4px;
}

/* Desktop controls hint */
#controls-hint {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.4);
  font-size: 7px;
  text-shadow: 1px 1px 0 #000;
  z-index: 10;
  pointer-events: none;
  text-align: center;
  line-height: 2.2;
}

/* Mobile controls */
#mobile-controls {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  z-index: 20;
  justify-content: space-between;
  padding: 0 16px;
  pointer-events: none;
  align-items: flex-end;
}

#joystick-zone {
  pointer-events: auto;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#joystick-base {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

#joystick-thumb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.5);
  position: absolute;
  transition: none;
}

.action-btns {
  pointer-events: auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.act-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid rgba(255, 70, 70, 0.6);
  background: rgba(180, 30, 30, 0.4);
  color: #faa;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.act-btn:active, .act-btn.pressed {
  background: rgba(255, 70, 70, 0.4);
  border-color: #f66;
}

.act-btn.jump-btn {
  border-color: rgba(70, 150, 255, 0.6);
  background: rgba(30, 60, 180, 0.4);
  color: #adf;
}

.act-btn.jump-btn:active, .act-btn.jump-btn.pressed {
  background: rgba(70, 150, 255, 0.4);
  border-color: #6af;
}

@media (pointer: coarse) {
  #mobile-controls { display: flex; }
  #controls-hint { display: none; }

  /* Larger, more readable HUD text on mobile */
  #hud .name {
    font-size: 12px;
  }

  #stage-display, #score-display {
    font-size: 11px;
  }

  #enemy-display {
    font-size: 10px;
  }

  /* Larger tap targets on action buttons */
  .act-btn {
    width: 78px;
    height: 78px;
    font-size: 11px;
  }

  /* More separation between buttons, and raise them so their
     bottom aligns with the joystick base bottom.
     joystick-zone is 160px; joystick-base (140px) is centred inside it,
     so the base bottom sits 10px above the zone bottom — match that offset. */
  .action-btns {
    gap: 22px;
    margin-bottom: 10px;
  }
}
