* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #1a1a2e;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  height: 100dvh; 
  font-family: 'Segoe UI', sans-serif;
  overflow: hidden;
  overscroll-behavior: none; 
}

/* --- Spiel-Container --- */
#game-wrapper {
  position: relative;
  width: 100%;
  max-width: min(960px, 100vw, calc(85dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  border: 3px solid #e94560;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(233, 69, 96, 0.4);
  touch-action: none; 
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* --- Heads-Up Display (HUD) --- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 40px;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10;
  pointer-events: none;
}

#hud-left, #hud-center, #hud-right {
  font-size: 18px;
  color: #fff;
  text-shadow: 1px 1px 3px #000;
}

#hud-center {
  font-weight: bold;
  font-size: 20px;
  color: #ffd700;
}

/* --- Start- / Game Over - Overlay --- */
#overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
}

#overlay.hidden {
  display: none;
}

#overlay-box {
  background: #16213e;
  border: 2px solid #e94560;
  border-radius: 12px;
  padding: 30px 40px;
  text-align: center;
  color: #fff;
  box-shadow: 0 0 30px rgba(233, 69, 96, 0.5);
  max-width: 90%;
  width: 450px;
  max-height: 90%;
  overflow-y: auto;
}

#overlay-title {
  font-size: 38px;
  margin-bottom: 12px;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

#overlay-msg {
  font-size: 16px;
  margin-bottom: 20px;
  color: #ccc;
  line-height: 1.5;
}

#overlay-btn {
  background: #e94560;
  color: #fff;
  border: none;
  padding: 14px 40px;
  font-size: 20px;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s, transform 0.1s;
}

#overlay-btn:hover {
  background: #c73652;
  transform: scale(1.02);
}

/* --- Highscore Styles --- */
.hs-input {
  background: rgba(255,255,255,0.1);
  border: 1px solid #ffd700;
  color: #fff;
  padding: 10px;
  width: 60%;
  font-size: 16px;
  border-radius: 4px;
  outline: none;
  text-align: center;
  margin-bottom: 10px;
}

.hs-btn {
  background: #ffd700;
  color: #16213e;
  border: none;
  padding: 10px 15px;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  transition: 0.2s;
}

.hs-btn:hover { background: #e6c200; }

.highscore-list {
  background: rgba(0, 0, 0, 0.3);
  padding: 15px;
  border-radius: 8px;
  margin-top: 15px;
  max-height: 180px;
  overflow-y: auto;
  text-align: left;
}

.hs-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.hs-rank { color: #e94560; font-weight: bold; width: 25px; }
.hs-name { flex: 1; color: #fff; }
.hs-time { color: #ffd700; font-weight: bold; }

/* --- Mobile Steuerung (Touch-Buttons) --- */
#mobile-controls {
  display: none; 
  position: absolute;
  bottom: 15px;
  left: 15px;
  right: 15px;
  justify-content: space-between;
  z-index: 1000;
  user-select: none;
}

.control-group {
  display: flex;
  gap: 15px;
}

.touch-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  color: white;
  font-size: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: manipulation;
}

.touch-btn:active {
  background: rgba(255, 255, 255, 0.6);
  border-color: #fff;
}

@media (max-width: 1024px), (pointer: coarse) {
  #mobile-controls {
    display: flex;
  }
}