/* touch-action: none + user-select: none auf JEDEM Element blockiert
   Doppeltipp-Zoom, Pinch-Zoom und Text-Auswahl zuverlässig auf iOS/Android.
   Einzelne Elemente (canvas, Buttons) setzen es zur Klarheit nochmals explizit. */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

:root {
  --banner-height: 52px;
  --controls-height: 188px; /* max(baseSize=140, jumpSize=96) + margin*2=48 */
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #111;
  font-family: sans-serif;
  -webkit-touch-callout: none;
}

/* Banner mit Restaurant-Name */
#game-banner {
  position: fixed;
  top: 0;
  left: -3%;
  width: 106%;
  height: var(--banner-height);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 17px;
  font-weight: bold;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 16px;
  z-index: 20;
  border-radius: 0 0 50% 50% / 0 0 26px 26px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Spielfeld: zwischen Banner (oben) und Steuerleiste (unten).
   Phaser EXPAND füllt diesen Bereich automatisch aus. */
#game-container {
  position: fixed;
  top: var(--banner-height);
  left: 0;
  right: 0;
  bottom: calc(var(--controls-height) + env(safe-area-inset-bottom, 0px));
}

/* Auf dem Desktop (Steuerleiste ausgeblendet) füllt das Spielfeld die volle Höhe */
body:has(#touch-controls.hidden) #game-container {
  bottom: env(safe-area-inset-bottom, 0px);
}

#game-container canvas {
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
  display: block;
}

/* ── Steuerleiste ────────────────────────────────────────────────────────────
   Eigener Bereich unterhalb des Spielfelds – Buttons liegen NICHT mehr über
   dem Spielgeschehen. Der Hintergrund trennt Spiel und Steuerung sauber. */
#touch-controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 0px);
  height: var(--controls-height);
  pointer-events: none;
  z-index: 10;
  touch-action: none;
  background: rgba(0, 0, 0, 0.55);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#touch-controls.hidden {
  display: none;
}

/* Basis-Button: vertikal zentriert in der Steuerleiste.
   Größe/Rand werden von touch-input.js per Inline-Style aus config.json gesetzt. */
.touch-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
}

/* ── Virtueller Joystick ─────────────────────────────────────────────────── */
#joystick-base {
  position: absolute;
  left: 24px; /* Fallback; joystick.js setzt margin als Inline-Style */
  top: 50%;
  transform: translateY(-50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.35);
  pointer-events: auto;
  touch-action: none;
}

#joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.8);
  pointer-events: none;
}

/* Sprung-Button rechts; touch-input.js setzt margin als Inline-Style */
#btn-jump  { right: 24px; }

/* Auto-Run-Modus: nur der Sprung-Button, mittig */
#btn-jump.jump-center {
  right: auto;
  left: 50%;
  transform: translate(-50%, -50%);
}

.touch-btn.hidden {
  display: none;
}

/* Hinweis für Querformat auf kleinen Bildschirmen */
#orientation-hint {
  display: none;
  position: fixed;
  inset: 0;
  background: #111;
  color: #fff;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 20px;
  padding: 24px;
  z-index: 100;
}

@media (orientation: landscape) and (max-height: 500px) {
  #orientation-hint {
    display: flex;
  }

  #game-container,
  #touch-controls {
    display: none;
  }
}
