/* === Reset === */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: 'Comic Sans MS', 'Trebuchet MS', sans-serif; user-select: none; -webkit-user-select: none; }
body { background: #87CEEB; }

/* === Game container === */
#game-container { position: relative; width: 100vw; height: 100vh; overflow: hidden; }
/* touch-action: none NUR auf dem Canvas — sonst kann man in Overlays nicht scrollen */
#game-canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* === HUD === */
#hud { position: absolute; inset: 0; pointer-events: none; padding: 14px; display: flex; justify-content: space-between; align-items: flex-start; }
#hud-top-left, #hud-top-right { display: flex; flex-direction: column; gap: 6px; }
#hud-top-right { margin-right: 110px; } /* Platz für Mute + Pause buttons */

#powerup-bar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: none;
  max-width: 60vw;
  flex-wrap: wrap;
  justify-content: center;
}

.hud-pill {
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid #333;
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: bold;
  font-size: 16px;
  color: #222;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 80px;
  justify-content: center;
}
#coin-counter { color: #b8860b; background: rgba(255, 250, 200, 0.95); }
#coin-counter .hud-icon { color: #FFD700; }
/* === Größen-Score: prominent, immer gut sichtbar === */
#size-counter {
  background: linear-gradient(135deg, rgba(220, 255, 220, 0.97), rgba(180, 240, 180, 0.97));
  color: #1f5e1f;
  font-size: 30px;
  padding: 12px 22px;
  border: 4px solid #1f5e1f;
  border-radius: 18px;
  min-width: 130px;
  letter-spacing: 0.5px;
  text-shadow: 1px 1px 0 rgba(255,255,255,0.6);
  box-shadow: 0 5px 0 rgba(0,0,0,0.3), inset 0 -3px 0 rgba(0,0,0,0.1);
  transition: box-shadow 0.3s, background 0.3s;
}
#size-counter .hud-icon { font-size: 24px; }
#size-counter.at-cap {
  background: linear-gradient(135deg, rgba(255, 235, 100, 0.98), rgba(255, 190, 30, 0.98));
  color: #6b3a0a;
  border-color: #b8860b;
  box-shadow: 0 5px 0 rgba(0,0,0,0.3), 0 0 24px rgba(255, 215, 0, 0.95), inset 0 -3px 0 rgba(0,0,0,0.15);
  animation: pulse 1.4s ease-in-out infinite;
}
#combo-counter { background: rgba(255, 235, 200, 0.95); color: #a4530a; min-width: 60px; }
#combo-counter.active { background: rgba(255, 200, 100, 0.95); animation: pulse 0.5s ease-in-out infinite; }
#distance-pill { background: rgba(240, 230, 255, 0.95); color: #5a3a8c; }
#timer-pill { background: rgba(220, 235, 255, 0.95); color: #1a4a8c; }
#lives-pill { font-size: 20px; letter-spacing: 2px; background: rgba(255, 220, 220, 0.95); }

.powerup-badge {
  border: 3px solid #333;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: bold;
  font-size: 14px;
  color: #222;
  box-shadow: 0 3px 0 rgba(0,0,0,0.25);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  animation: pulse 1.2s ease-in-out infinite;
  white-space: nowrap;
}
.powerup-badge.expiring { animation: pulse 0.3s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

/* === Top-Right Action-Buttons (Mute + Pause) === */
#top-right-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 60;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #333;
  background: rgba(255,255,255,0.85);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.25);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
#pause-btn { display: none; }
#pause-btn.visible { display: flex; }
.icon-btn:active { transform: translateY(2px); }

/* === Touch controls === */
#touch-controls {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: none;
  justify-content: space-between;
  padding: 0 16px;
  pointer-events: none;
  gap: 8px;
}
.touch-btn {
  pointer-events: auto;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #333;
  background: rgba(255, 255, 255, 0.7);
  font-size: 32px;
  font-weight: bold;
  color: #333;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.05s;
}
.touch-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,0.3); background: rgba(255,255,150,0.9); }
.touch-btn-jump { background: rgba(255, 230, 100, 0.85); }
.touch-btn-slide { background: rgba(180, 220, 255, 0.85); }

@media (pointer: coarse), (max-width: 1024px) {
  #touch-controls { display: flex; }
}

/* === Overlays === */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
  padding: 24px 16px;
  /* Scrollbar verhält sich verlässlich, wenn der Container BLOCK ist (kein Flex-Center-Bug auf Mobile) */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.overlay.hidden { display: none; }

.panel {
  background: linear-gradient(135deg, #FFF8B0, #FFE066);
  border: 5px solid #333;
  border-radius: 24px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.35);
  color: #222;
  /* Einfache horizontale Zentrierung — Overlay scrollt vertikal */
  margin: 0 auto;
}

/* Einklappbare Anleitung */
.help-details {
  margin-top: 16px;
  text-align: left;
}
.help-details summary {
  cursor: pointer;
  background: rgba(255,255,255,0.7);
  border: 3px solid #333;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: bold;
  font-size: 16px;
  color: #333;
  text-align: center;
  list-style: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 3px 0 rgba(0,0,0,0.2);
  transition: transform 0.05s;
}
.help-details summary::-webkit-details-marker { display: none; }
.help-details summary:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.2); }
.help-details[open] summary { background: #fff; margin-bottom: 8px; }
.panel h1 { font-size: 28px; margin-bottom: 6px; color: #1a4a8c; text-shadow: 2px 2px 0 #fff; }
.panel h2 { font-size: 16px; margin: 12px 0 6px; color: #444; }
.panel h3 { font-size: 14px; margin: 4px 0 6px; color: #444; }
.panel .subtitle { font-size: 14px; margin-bottom: 14px; color: #555; }

.instructions, .powerup-legend, .obstacle-legend {
  text-align: left;
  margin: 10px 0;
  background: rgba(255,255,255,0.6