* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  background: #05050f;
  color: #e8f0ff;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  overflow: hidden;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

#title-bar {
  text-align: center;
  padding: 4px 0 2px;
}

#title-logo {
  display: block;
  margin: 0 auto;
  width: min(600px, 94vw);
  height: auto;
}

.title-logo-small {
  display: block;
  margin: 0 auto 4px;
  width: min(480px, 90vw);
  height: auto;
}

/* Wrapper übernimmt die Größenberechnung von Canvas/Aspect-Ratio, damit HUD-Elemente
   absolut relativ zur tatsächlichen Spielfeldgröße positioniert werden können statt
   relativ zum vollen Browserfenster (#game-container). Die Höhe basiert auf dvh statt
   vh, damit mobile Browserleisten (Adress-/Navigationsleiste) nicht Teile des
   Spielfelds (z. B. Rakete, Leben-Anzeige) am unteren Rand verdecken. */
#game-viewport {
  position: relative;
  max-width: 100%;
  max-height: 64dvh;
  width: auto;
  height: 64dvh;
  aspect-ratio: 2 / 3;
}

@media (max-height: 700px) {
  #title-bar {
    padding: 2px 0 0;
  }

  #title-logo {
    width: min(440px, 82vw);
  }

  #game-viewport {
    max-height: 56dvh;
    height: 56dvh;
  }
}

#game-canvas {
  display: block;
  background: #05050f;
  width: 100%;
  height: 100%;
  border: 1px solid #1c2038;
  touch-action: none;
}

#hud {
  position: absolute;
  top: 6px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 6px 14px;
  font-size: 0.85rem;
  color: #cfe8ff;
  pointer-events: none;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

#hud-score, #hud-level {
  font-size: 1.4rem;
  font-weight: 700;
}

#hud-lives {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: flex;
  gap: 4px;
  align-items: center;
  pointer-events: none;
}

.life-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #35ff6b;
  box-shadow: 0 0 6px rgba(53, 255, 107, 0.8);
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(3, 3, 12, 0.92);
  text-align: center;
  padding: 16px;
}

.screen.hidden {
  display: none;
}

.screen h2 {
  color: #7fffd4;
  margin: 0 0 4px;
}

.screen button {
  background: #1c2b4a;
  color: #e8f0ff;
  border: 1px solid #3d5a8f;
  border-radius: 6px;
  padding: 10px 22px;
  font-size: 1rem;
  cursor: pointer;
}

.screen button:hover {
  background: #2a3f6a;
}

.name-hint {
  font-size: 0.75rem;
  color: #8fa8d6;
  max-width: 260px;
}

#name-entry input {
  padding: 8px;
  font-size: 1rem;
  border-radius: 4px;
  border: 1px solid #3d5a8f;
  background: #0e1526;
  color: #e8f0ff;
  margin-right: 6px;
}

#leaderboard-list, #leaderboard-list-gameover {
  text-align: left;
  min-width: 220px;
  padding-left: 26px;
  font-size: 0.9rem;
}

#leaderboard-list li, #leaderboard-list-gameover li {
  margin: 2px 0;
}

#legal-footer {
  display: flex;
  gap: 14px;
  margin-top: 4px;
}

#legal-footer a {
  color: #6a8ac2;
  font-size: 0.75rem;
  text-decoration: none;
}

#legal-footer a:hover {
  color: #cfe8ff;
  text-decoration: underline;
}

#touch-controls {
  position: absolute;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  left: 0;
  width: 100%;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  pointer-events: none;
}

/* Beide Bewegungstasten links gruppiert, damit sie mit dem linken Daumen
   erreichbar sind; der Feuerknopf bleibt allein auf der rechten Seite. */
#touch-controls-move {
  display: flex;
  gap: 14px;
  pointer-events: none;
}

.touch-btn {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(28, 43, 74, 0.75);
  border: 1px solid #3d5a8f;
  color: #e8f0ff;
  font-size: 1.4rem;
  user-select: none;
}

.touch-btn-shoot {
  width: 72px;
  height: 72px;
  font-size: 1.6rem;
}

@media (pointer: coarse) {
  #touch-controls {
    display: flex;
  }
}
