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

html, body {
  overscroll-behavior: none;
}

body {
  background: #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: sans-serif;
  color: #eee;
  touch-action: none;
  padding: 8px;
  -webkit-user-select: none;
  user-select: none;
}

#hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  row-gap: 6px;
  margin-bottom: 8px;
  font-size: 14px;
  width: 100%;
  max-width: 800px;
}

#quit {
  margin-left: auto;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  touch-action: manipulation;
}

#canvasWrap {
  position: relative;
  width: 100%;
  max-width: 800px;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #1a1a2e;
  border: 2px solid #444;
  touch-action: none;
}

#joystick {
  display: none;
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.25);
  touch-action: none;
}

#joystickThumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

@media (hover: none) and (pointer: coarse) {
  #joystick {
    display: block;
  }
}

#gameover {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  gap: 12px;
}

#gameover.hidden {
  display: none;
}

#restart {
  padding: 8px 20px;
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
}

.save-row {
  display: flex;
  gap: 8px;
}

.save-row input {
  padding: 6px 10px;
  font-size: 14px;
}

.save-row button {
  padding: 6px 14px;
  cursor: pointer;
  touch-action: manipulation;
}

#leaderboard {
  width: 280px;
  max-height: 220px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.06);
  padding: 8px 16px;
  border-radius: 6px;
}

#leaderboard h2 {
  font-size: 14px;
  margin-bottom: 6px;
}

#leaderboardList {
  padding-left: 20px;
  font-size: 13px;
}
