/* Echter Pixel-Font "Press Start 2P" (self-hosted), konsistent mit der Lobby */
@font-face {
  font-family: "Press Start 2P";
  src: url("/assets/fonts/PressStart2P-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #1e2533;
  --surface: #2a3245;      /* Panels, Buttons */
  --surface-deep: #242c3d; /* Slider-Tracks, Pads */
  --border: #3a4255;
  --accent: #E8E8E8;
  --muted: #8a93a6;        /* Hinweistexte */
  --highlight: #00D9FF;
  --p1: #FF4444;
  --p2: #4477FF;
  --p3: #44FF77;
  --p4: #FFDD44;
  --player-color: var(--highlight);
  --radius: 14px;          /* Buttons, Inputs */
  --radius-lg: 18px;       /* Cards, große Flächen */
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--accent);
  font-family: 'Roboto', system-ui, sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  gap: 16px;
}
.screen.active { display: flex; }

.title {
  font-size: 42px;
  font-weight: 900;
  color: var(--highlight);
  letter-spacing: 2px;
  text-align: center;
}

.join-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}
.join-form label { font-size: 18px; color: var(--muted); }

input {
  width: 100%;
  padding: 16px;
  font-size: 24px;
  font-weight: bold;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 6px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  outline: none;
}
input:focus { border-color: var(--highlight); }
input#name-input { letter-spacing: 1px; text-transform: none; font-size: 18px; }

.btn-primary {
  padding: 18px;
  font-size: 22px;
  font-weight: bold;
  background: var(--highlight);
  color: #1e2533;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  width: 100%;
  max-width: 360px;
}
.btn-primary:active { transform: scale(0.97); opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.error-text { color: #ff4444; font-size: 16px; text-align: center; min-height: 22px; }
.host-hint { color: #00D9FF; font-size: 14px; text-align: center; max-width: 320px; }

/* ─── 2s-Dreh-Hinweis zum Spielstart "Handy drehen" ───────────────────────
   NICHT-blockierend und rein informativ: JS blendet ihn zum Spielstart für
   2s ÜBER dem laufenden Spiel ein (ROTATE_HINT vom Display) und automatisch
   wieder aus. pointer-events: none — Eingaben darunter funktionieren IMMER.
   VERTIKAL ZENTRIERT statt am oberen Rand: Die mobile Browser-URL-/Such-
   leiste (ein-/ausklappend) kann einen top-fixierten Banner verdecken —
   die Bildschirmmitte ist in beiden Zuständen garantiert sichtbar. Safe-
   Area-Insets polstern Notch/Rundungen im Querformat ab.
   Pixel-Stil wie die Lobby: Pastell-Orange, Press Start 2P, harte Kanten. */
#rotate-hint {
  display: flex;
  position: fixed;
  top: 50%; left: 0; right: 0;
  z-index: 900;
  background: #f9d8b2;
  border-top: 4px solid #5f3410;
  border-bottom: 4px solid #5f3410;
  box-shadow: inset 0 -4px 0 #de9040, inset 0 4px 0 #f4c288;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left));
  pointer-events: none;
  opacity: 0;
  transform: translateY(calc(-50% + 14px));
  transition: transform 0.25s ease-out, opacity 0.25s ease-out;
}
#rotate-hint.show { opacity: 1; transform: translateY(-50%); }
#rotate-hint .rotate-phone {
  width: 18px;
  height: 30px;
  border: 3px solid #5f3410;
  image-rendering: pixelated;
  animation: rotate-phone-hint 1.8s ease-in-out infinite;
}
#rotate-hint.want-portrait .rotate-phone { animation-name: rotate-phone-hint-back; }
#rotate-hint .rotate-hint-text p {
  font-family: "Press Start 2P", monospace;
  -webkit-font-smoothing: none;
  text-align: left;
  color: #4a2a0c;
}
#rotate-hint .rotate-hint-title { font-size: 8px; color: #a8551c; margin-bottom: 6px; }
#rotate-hint #rotate-hint-msg { font-size: 12px; }
@keyframes rotate-phone-hint {
  0%, 25%   { transform: rotate(0deg); }
  65%, 100% { transform: rotate(90deg); }
}
@keyframes rotate-phone-hint-back {
  0%, 25%   { transform: rotate(90deg); }
  65%, 100% { transform: rotate(0deg); }
}

/* Lobby-Screen ergonomisch im Querformat: kompakter Kopf, D-Pad links /
   OK+ZURÜCK rechts an den Daumen-Positionen */
@media (orientation: landscape) {
  #lobby-screen { gap: 8px; }
  #lobby-screen .player-badge {
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
    padding: 6px 16px;
  }
  #lobby-screen .player-badge span:first-child { font-size: 22px; }
  #lobby-screen .player-badge span:last-child { font-size: 14px; }
  #lobby-screen .lobby-info { font-size: 13px; line-height: 1.5; }
  #lobby-screen .lobby-info p { display: inline; margin-right: 14px; }
  #player-list { gap: 6px; }
  #player-list .player-chip { padding: 4px 12px; font-size: 12px; }
  #menu-controls {
    flex: 1;
    max-width: none;
    padding: 0 4vw;
    align-items: center;
  }
  #menu-dpad {
    grid-template-columns: repeat(3, minmax(46px, 58px));
    grid-template-rows: repeat(3, minmax(46px, 58px));
  }
  #menu-actions { max-width: 200px; }
  #menu-actions .menu-action-btn.ok { min-height: 84px; }
  #lobby-screen .host-hint { font-size: 11px; }
}

/* ─── Startseite (Join-Screen): Pastell-Pixel-Design, konsistent mit Lobby ──
   Nur der Join-Screen; nach dem Join übernimmt body.pastel das
   Spielerfarben-Theming. Farben/Relief 1:1 aus LobbyScene.js. */
#join-screen {
  background: #f9d8b2;                 /* Pastell-Orange (BG) */
  image-rendering: pixelated;
  -webkit-font-smoothing: none;        /* keine Kantenglättung → scharfe Pixel */
  font-smooth: never;
  gap: 20px;
}
#join-screen .title,
#join-screen .join-form label,
#join-screen input,
#join-screen .btn-primary,
#join-screen .error-text {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-weight: 400;
  -webkit-font-smoothing: none;
  font-smooth: never;
}

#join-screen .title {
  color: #a8551c;                      /* Titel: dunkles Orange, flach */
  font-size: clamp(20px, 8vw, 30px);
  line-height: 1.5;
  letter-spacing: 0;
}

#join-screen .join-form { gap: 18px; }
#join-screen .join-form label {
  font-size: 10px;
  line-height: 1.7;
  color: #4a2a0c;                      /* dunkelbraun */
  text-transform: uppercase;
}

#join-screen input {
  background: #fff4e4;                 /* Creme-Feld */
  color: #4a2a0c;
  border: 3px solid #5f3410;           /* kräftige Pixel-Outline */
  border-radius: 0;                    /* keine Rundung */
  box-shadow: inset 3px 3px 0 rgba(255,255,255,0.55);
  font-size: 20px;
  letter-spacing: 4px;
  padding: 15px 12px;
}
#join-screen input#name-input { font-size: 11px; letter-spacing: 0; }
#join-screen input::placeholder { color: #c2a684; }
#join-screen input:focus {
  border-color: #a8551c;
  box-shadow: inset 3px 3px 0 rgba(255,255,255,0.7);
}

/* Dunkel-orange Pixel-Button mit 2D-Relief (helle Ober-/Linkskante,
   dunkle Unter-/Rechtskante, Outline, keine Rundung) */
#join-screen .btn-primary {
  color: #4a2a0c;
  background: #de9040;                 /* Button-Fläche */
  border: 3px solid #5f3410;           /* Outline */
  border-radius: 0;
  box-shadow: inset 5px 5px 0 #f4c288, inset -5px -5px 0 #a25a1e;
  font-size: 15px;
  letter-spacing: 1px;
  padding: 18px 14px;
  transition: none;
}
#join-screen .btn-primary:active {   /* eingedrückt: Bevel invertiert, dunkler, Creme-Text */
  background: #b06018;
  color: #fff4e4;
  box-shadow: inset -5px -5px 0 #f4c288, inset 5px 5px 0 #a25a1e;
  transform: none;
  opacity: 1;
}
#join-screen .btn-primary:disabled { opacity: 0.55; }

#join-screen .error-text {
  color: #b0340f;                      /* rot-orange, lesbar auf Pastell */
  font-size: 9px;
  line-height: 1.7;
}

.player-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--player-color);
  color: #1e2533;
  padding: 16px 30px;
  border-radius: var(--radius-lg);
  font-weight: 900;
}
.player-badge span:first-child { font-size: 48px; line-height: 1; }
.player-badge span:last-child { font-size: 18px; }
.player-badge.small { padding: 8px 20px; }
.player-badge.small span:first-child { font-size: 24px; }

.lobby-info { text-align: center; font-size: 18px; color: var(--muted); line-height: 1.8; }
.lobby-info strong { color: var(--accent); }

#player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 360px;
}
.player-chip {
  padding: 8px 18px;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: bold;
  border: 2px solid currentColor;
  opacity: 0.5;
}
.player-chip.connected { opacity: 1; }

.game-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  flex: 1;
  padding-top: 10px;
  padding-bottom: 10px;
}

#signal-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
#signal-dot {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #333;
  border: 4px solid #555;
  transition: background 0.1s, border-color 0.1s;
}
#signal-dot.on {
  background: #00ff88;
  border-color: #00ff88;
  box-shadow: 0 0 32px #00ff88;
}
#signal-label { font-size: 20px; color: var(--muted); font-weight: bold; }

.tap-button {
  width: min(220px, 55vw);
  height: min(220px, 55vw);
  border-radius: 50%;
  background: var(--player-color);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  font-weight: 900;
  color: #1e2533;
  transition: transform 0.08s, opacity 0.08s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.tap-button:active { transform: scale(0.93); opacity: 0.85; }

/* ─── Game Screen Header & Pause Menu ──────────────────────────────── */
#game-screen {
  position: relative; /* needed for absolute pause-menu overlay */
  gap: 8px;
}

#game-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex-shrink: 0;
}

#pause-menu-btn {
  width: 52px;
  height: 52px;
  background: rgba(42, 50, 69, 0.9);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: #E8E8E8;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
#pause-menu-btn:active { background: var(--border); transform: scale(0.94); }

#pause-menu {
  position: absolute;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}

.pause-menu-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-width: 260px;
  max-width: 320px;
  width: 80vw;
}

.pause-menu-title {
  font-size: 28px;
  font-weight: 900;
  color: #E8E8E8;
  letter-spacing: 6px;
  margin: 0;
}

.pause-menu-opt {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  font-weight: bold;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}
.pause-menu-opt:active { transform: scale(0.96); }
.pause-menu-opt:not(.end) { background: #00D9FF; color: #1e2533; }
.pause-menu-opt.end {
  background: transparent;
  color: #E8E8E8;
  border: 2px solid var(--border);
}
.pause-menu-opt.end:active { border-color: #ff4444; color: #ff4444; }

/* ─── Menü-Navigation (Lobby): D-Pad links, OK/ZURÜCK rechts ─────────────
   Steuert das Pixel-Menü auf dem Display — sendet nur Menü-Events
   (button: UP/DOWN/LEFT/RIGHT/CONFIRM/BACK). Kein In-Game-Layout. */
#menu-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 420px;
  gap: 20px;
}
#menu-dpad {
  display: grid;
  grid-template-columns: repeat(3, minmax(52px, 68px));
  grid-template-rows: repeat(3, minmax(52px, 68px));
  gap: 8px;
}
.menu-dpad-btn {
  font-size: 24px;
  font-weight: bold;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--player-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
  transition: transform 0.06s, background 0.06s;
}
.menu-dpad-btn.up    { grid-column: 2; grid-row: 1; }
.menu-dpad-btn.left  { grid-column: 1; grid-row: 2; }
.menu-dpad-btn.right { grid-column: 3; grid-row: 2; }
.menu-dpad-btn.down  { grid-column: 2; grid-row: 3; }
.menu-dpad-btn.active, .menu-dpad-btn:active {
  background: var(--player-color);
  color: #1e2533;
  transform: scale(0.93);
}
#menu-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  max-width: 160px;
}
.menu-action-btn {
  font-family: "Press Start 2P", "Courier New", monospace;
  -webkit-font-smoothing: none;
  font-smooth: never;
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
  transition: transform 0.06s, background 0.06s;
}
.menu-action-btn.ok {
  min-height: 96px;
  font-size: 20px;
  background: var(--player-color);
  color: #1e2533;
  border: none;
}
.menu-action-btn.back {
  min-height: 56px;
  font-size: 11px;
  background: var(--surface);
  color: var(--accent);
  border: 2px solid var(--border);
}
.menu-action-btn.active, .menu-action-btn:active {
  transform: scale(0.94);
  filter: brightness(0.88);
}

/* Chibi-Wackeln (Lobby, alle Spieler): eigener Chibi winkt auf dem Display */
#wiggle-btn {
  min-height: 56px;
  padding: 0 22px;
  font-size: 12px;
  background: var(--player-color, #de9040);
  color: #1e2533;
  border: none;
  align-self: center;
}

/* ─── Duell-Reflex ────────────────────────────────────────────────────
   Ein großer DRAW-Button, KEINE Zeitanzeige/Timer (Signal-Timing darf
   nicht ablesbar sein). Button bleibt immer drückbar (Fehlstart ist eine
   gültige Aktion, die das Display wertet). */
#dr-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  gap: 16px;
  padding: 16px;
  align-items: center;
  justify-content: center;
}
#dr-status {
  font-family: "Press Start 2P", "Courier New", monospace;
  -webkit-font-smoothing: none;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  min-height: 16px;
}
#dr-shoot {
  font-family: "Press Start 2P", "Courier New", monospace;
  -webkit-font-smoothing: none;
  font-size: 30px;
  color: #fff4e4;
  background: #a8551c;
  border: none;
  border-radius: 50%;
  width: min(72vw, 56vh);
  aspect-ratio: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
  box-shadow: inset 0 -10px 0 rgba(0,0,0,0.2);
}
#dr-shoot.active { transform: scale(0.95); filter: brightness(0.85); }
#dr-shoot.disabled { background: #8a8a8a; box-shadow: none; }

/* ─── Zeitgefühl ──────────────────────────────────────────────────────
   Ein großer STOP-Button, KEINE Zeitanzeige, keine Loop-Animationen
   (Blindphase-Regel: nichts darf die verstrichene Zeit verraten). */
#zg-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  gap: 16px;
  padding: 16px;
  align-items: center;
  justify-content: center;
}
#zg-status {
  font-family: "Press Start 2P", "Courier New", monospace;
  -webkit-font-smoothing: none;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  min-height: 16px;
}
#zg-stop {
  font-family: "Press Start 2P", "Courier New", monospace;
  -webkit-font-smoothing: none;
  font-size: 28px;
  color: #fff4e4;
  background: #c2402a;
  border: none;
  border-radius: 50%;
  width: min(70vw, 55vh);
  aspect-ratio: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
  box-shadow: inset 0 -10px 0 rgba(0,0,0,0.18);
}
#zg-stop:active { transform: scale(0.95); filter: brightness(0.85); }
#zg-stop.stopped { background: #8a8a8a; box-shadow: none; }

/* ─── Boxen-Ring ──────────────────────────────────────────────────────
   LINKS zwei Richtungstasten (VOR/ZURÜCK — eine Achse), RECHTS genau drei
   Aktionen (SCHLAG/BLOCK/KONTER). Querformat empfohlen (GAME_ORIENTATION).
   Der KONTER-Cooldown ist reine ANZEIGE; autoritativ ist das Display. */
#box-layout {
  display: flex;
  flex: 1;
  width: 100%;
  gap: 14px;
  padding: 10px;
  align-items: stretch;
}
.box-move,
.box-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.box-move { flex: 1; }
.box-actions { flex: 1.15; }
.box-btn {
  font-family: "Press Start 2P", "Courier New", monospace;
  -webkit-font-smoothing: none;
  font-size: 12px;
  line-height: 1.6;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
  transition: transform 0.06s, filter 0.06s;
  color: #1e2533;
  flex: 1;
}
.box-move-btn { background: #cfd8e3; }
.box-punch { background: var(--player-color, #ff6b6b); }
.box-block { background: #bcd3c4; }
.box-counter { background: #ffd75e; }
.box-cd {
  display: block;
  font-size: 10px;
  line-height: 1.4;
  min-height: 14px;
  opacity: 0.85;
}
.box-btn.active, .box-btn:active { transform: scale(0.94); filter: brightness(0.85); }
.box-btn.disabled { filter: grayscale(0.7) brightness(0.9); }
/* Konter gesperrt: gedimmt + ausgegraut, Restzeit steht im .box-cd-Label */
.box-counter.cooldown {
  background: #9aa3ad;
  color: #3d444d;
  filter: brightness(0.95);
}
.box-hint {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  min-height: 16px;
  padding-top: 6px;
}

/* ─── Pong Slider ─────────────────────────────────────────────────── */
.slider-hint {
  font-size: 18px;
  color: var(--muted);
  text-align: center;
  margin-top: 10px;
}

#paddle-slider {
  position: relative;
  width: min(180px, 50vw);
  height: min(420px, 60vh);
  background: var(--surface);
  border: 3px solid var(--border);
  border-radius: var(--radius-lg);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  margin-top: 20px;
  overflow: hidden;
}

#paddle-track {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--border);
  transform: translateX(-50%);
  border-radius: 3px;
}

#paddle-thumb {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 60px;
  background: var(--player-color);
  border-radius: var(--radius);
  transform: translateY(-50%);
  transition: top 0.05s linear;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* ─── Tetris Race Controls ─────────────────────────────────────────── */
#tetris-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 360px;
  align-items: center;
  margin-top: 20px;
}
.tetris-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  width: 100%;
}
.tetris-btn {
  flex: 1;
  min-width: 80px;
  height: 80px;
  font-size: 32px;
  font-weight: bold;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--player-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s, background 0.08s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tetris-btn.active, .tetris-btn:active {
  background: var(--player-color);
  color: #1e2533;
  transform: scale(0.94);
}
.tetris-btn.wide {
  flex: 1;
  min-width: 100%;
  font-size: 22px;
  height: 64px;
}
#tetris-controls .tetris-row:last-child {
  margin-top: 20px;
}

/* ─── Kart Race Controls (Landscape) ───────────────────────────────── */
.kart-rotate-hint {
  font-size: 16px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 8px;
}

#kart-landscape {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
}

#kart-joystick {
  position: relative;
  width: min(200px, 40vw);
  height: min(200px, 40vw);
  flex-shrink: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#kart-joystick-base {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 3px solid var(--border);
  border-radius: 50%;
}

#kart-joystick-thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30%;
  height: 30%;
  background: var(--player-color);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  pointer-events: none;
  transition: transform 0.05s linear;
}

#kart-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  flex: 1;
  max-width: 280px;
}

.kart-btn {
  font-size: 28px;
  font-weight: bold;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--player-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.08s, background 0.08s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  min-height: 80px;
}
.kart-btn.active, .kart-btn:active {
  transform: scale(0.93);
  background: var(--player-color);
  color: #1e2533;
}
.kart-btn.gas {
  grid-column: 2;
  grid-row: 1 / span 2;
  background: #44ff77;
  color: #1e2533;
  font-size: 48px;
  border-color: #44ff77;
}
.kart-btn.gas.active, .kart-btn.gas:active {
  background: #2acc5a;
}
.kart-btn.brake {
  background: #ff4444;
  color: #1e2533;
  font-size: 36px;
  border-color: #ff4444;
}
.kart-btn.drift {
  font-size: 18px;
  background: #FFDD44;
  color: #1e2533;
  border-color: #FFDD44;
}

/* Force landscape orientation hint */
@media (orientation: portrait) {
  #kart-race-ui .kart-rotate-hint {
    color: #ff8800;
    font-size: 20px;
    font-weight: bold;
  }
}

/* ─── Tank Battle Controls (Dual-Joystick Landscape) ──────────────────── */
#tank-battle-ui {
  flex-direction: column;
  padding: 0;
}

#tank-layout {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 8px 6px;
}

.tank-joystick-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.tank-joystick-label {
  font-size: 14px;
  font-weight: bold;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.tank-joystick {
  position: relative;
  width: min(195px, 42vw);
  height: min(195px, 42vw);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  flex-shrink: 0;
}

.tank-joystick-base {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(255,255,255,0.06);
  border: 3px solid var(--border);
  border-radius: 50%;
}

.tank-joystick-thumb {
  position: absolute;
  top: 50%; left: 50%;
  width: 32%; height: 32%;
  background: var(--player-color);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  transition: transform 0.04s linear;
}

/* Aim joystick gets a different accent so players can distinguish */
#tank-aim-joystick .tank-joystick-base {
  border-color: #ff8844;
  background: rgba(255, 136, 68, 0.06);
}
#tank-aim-joystick .tank-joystick-thumb {
  background: #ff8844;
}

@media (orientation: portrait) {
  #tank-battle-ui .tank-joystick-label:first-of-type::before {
    content: "📱 Quer halten! ";
    color: #ff8800;
  }
}

/* ─── Fußball / Hot Potato / Meteor Dodge / Minesweeper / Paint Duel: Landscape (Movement links, Aktion rechts) ── */
#fussball-layout,
#hotpotato-layout,
#minesweeper-layout,
#paint-layout,
#asteroids-layout,
#meteor-layout {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 12px 10px;
  gap: 12px;
}

/* Querformat erzwingen: Hinweis, wenn das Handy im Hochformat gehalten wird */
@media (orientation: portrait) {
  #hot-potato-ui .tank-joystick-label::before,
  #minesweeper-versus-ui .tank-joystick-label::before,
  #meteor-dodge-ui .tank-joystick-label::before {
    content: "📱 Quer halten! ";
    color: #ff8800;
  }
}

/* Minesweeper Versus: D-Pad links (diskrete Cursor-Schritte, Auto-Repeat) */
#ms-dpad {
  display: grid;
  grid-template-columns: repeat(3, minmax(52px, 78px));
  grid-template-rows: repeat(3, minmax(52px, 78px));
  gap: 10px;
  flex-shrink: 0;
}
.ms-dpad-btn {
  font-size: 28px;
  font-weight: bold;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--player-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
  transition: transform 0.05s, background 0.05s;
}
.ms-dpad-btn.up    { grid-column: 2; grid-row: 1; }
.ms-dpad-btn.left  { grid-column: 1; grid-row: 2; }
.ms-dpad-btn.right { grid-column: 3; grid-row: 2; }
.ms-dpad-btn.down  { grid-column: 2; grid-row: 3; }
.ms-dpad-btn.active, .ms-dpad-btn:active {
  background: var(--player-color);
  color: #1e2533;
  transform: scale(0.93);
}

/* Paint Duel: Held-D-Pad links (wie ms-dpad) + SPRINT-Button mit
   Cooldown-Füllung (steigt von unten, nur Anzeige — autoritativ ist das Display) */
#paint-dpad {
  display: grid;
  grid-template-columns: repeat(3, minmax(52px, 78px));
  grid-template-rows: repeat(3, minmax(52px, 78px));
  gap: 10px;
  flex-shrink: 0;
}
.paint-dpad-btn {
  font-size: 28px;
  font-weight: bold;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--player-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
  transition: transform 0.05s, background 0.05s;
}
.paint-dpad-btn.up    { grid-column: 2; grid-row: 1; }
.paint-dpad-btn.left  { grid-column: 1; grid-row: 2; }
.paint-dpad-btn.right { grid-column: 3; grid-row: 2; }
.paint-dpad-btn.down  { grid-column: 2; grid-row: 3; }
.paint-dpad-btn.active, .paint-dpad-btn:active {
  background: var(--player-color);
  color: #1e2533;
  transform: scale(0.93);
}
.paint-sprint-btn {
  position: relative;
  overflow: hidden;
  width: min(170px, 40vw);
  height: min(170px, 40vw);
  border-radius: 50%;
  border: 4px solid var(--player-color);
  background: var(--player-color);
  color: #fff;
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 1px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  flex-shrink: 0;
}
.paint-sprint-btn.active { transform: scale(0.93); }
.paint-sprint-btn.cooldown { filter: saturate(0.35) brightness(1.05); }
.paint-sprint-label { position: relative; z-index: 2; }
#paint-sprint-cd {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0%;
  background: rgba(255, 255, 255, 0.55);
  z-index: 1;
  pointer-events: none;
}

/* Minesweeper Versus: zwei Aktions-Buttons rechts (AUFDECKEN groß, FLAGGE sekundär) */
#ms-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  max-width: min(300px, 42vw);
  height: 100%;
  max-height: min(320px, 78vh);
  justify-content: center;
}
.ms-btn {
  border-radius: var(--radius-lg);
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
  transition: transform 0.06s, filter 0.06s;
}
.ms-btn.reveal {
  flex: 2;
  min-height: 96px;
  font-size: 22px;
  background: var(--player-color);
  color: #1e2533;
  border: none;
}
.ms-btn.flag {
  flex: 1;
  min-height: 60px;
  font-size: 17px;
  background: var(--surface);
  color: var(--accent);
  border: 2px solid var(--border);
}
.ms-btn.active, .ms-btn:active {
  transform: scale(0.94);
  filter: brightness(0.88);
}

.fussball-shoot-btn {
  width: min(170px, 40vw);
  height: min(170px, 40vw);
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  border: 4px solid var(--player-color);
  background: var(--player-color);
  color: #fff;
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 1px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  flex-shrink: 0;
}

.fussball-shoot-btn .fussball-btn-sub {
  font-size: 30px;
}

.fussball-shoot-btn.active {
  transform: scale(0.93);
  filter: brightness(0.85);
}

/* ─── Minigolf Controller ─────────────────────────────────────────────────── */
#minigolf-ui {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px 16px;
  height: 100%;
}
.mg-phase {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}
.mg-label {
  font-size: 28px;
  font-weight: bold;
  color: #FFFFFF;
  text-align: center;
}
.mg-sublabel {
  font-size: 18px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}
.mg-hint {
  font-size: 15px;
  color: var(--muted);
  text-align: center;
}
.mg-big-btn {
  width: 100%;
  max-width: 320px;
  padding: 24px 28px;
  font-size: 26px;
  font-weight: bold;
  background: var(--player-color);
  color: #1e2533;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: 12px;
  letter-spacing: 0.5px;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s, opacity 0.08s;
}
.mg-big-btn:active { transform: scale(0.96); opacity: 0.88; }
.mg-waiting-icon, .mg-hit-icon {
  font-size: 72px;
  line-height: 1;
}
/* Ziel-Pad: Ziehen stellt die Schlagrichtung ein */
#mg-aim-pad-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#mg-aim-pad {
  border-radius: 50%;
  touch-action: none;
  width: 260px;
  height: 260px;
}
.mg-angle-label {
  font-size: 22px;
  font-weight: bold;
  color: var(--player-color, #00D9FF);
  min-width: 60px;
  text-align: center;
}

/* 2-Schritt-Flow: Richtung → Kraft */
.mg-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}
.mg-power-angle {
  font-size: 20px;
  color: var(--muted);
}
.mg-power-angle span {
  color: var(--player-color);
  font-weight: bold;
}
.mg-secondary-btn {
  padding: 14px 22px;
  min-height: 48px;
  font-size: 17px;
  font-weight: bold;
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s;
}
.mg-secondary-btn:active { transform: scale(0.96); border-color: var(--player-color); color: var(--player-color); }

/* Power-Balken: halten lädt (oszilliert), loslassen schlägt */
#mg-power-wrap {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#mg-power-bar {
  width: 100%;
  height: 26px;
  background: var(--surface-deep);
  border: 2px solid #4a5468;
  border-radius: 13px;
  overflow: hidden;
}
#mg-power-fill {
  height: 100%;
  width: 0%;
  background: #44FF77;
  border-radius: 9px;
}
#mg-power-btn { margin-top: 0; min-height: 88px; touch-action: none; }
.mg-btn-sub {
  display: block;
  font-size: 14px;
  font-weight: normal;
  opacity: 0.65;
  margin-top: 2px;
}

/* Minigolf im Querformat: Ziel-Pad links, Aktionen rechts (Daumen) —
   die Hochformat-Spalte würde vertikal überlaufen */
@media (orientation: landscape) {
  #minigolf-ui { padding: 10px 16px; gap: 6px; }
  .mg-phase { max-width: none; }
  .mg-step {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 26px;
  }
  #mg-aim-pad { width: 220px; height: 220px; }
  .mg-hint { max-width: 170px; }
  #mg-step-aim .mg-big-btn { max-width: 250px; }
  #mg-power-wrap { max-width: 300px; }
  .mg-power-angle { max-width: 150px; text-align: center; }
}

/* ─── Küche im Chaos Controller ─────────────────────────────────────────── */
#kuche-im-chaos-ui {
  flex-direction: column;
  padding: 0;
}

#kitchen-layout {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px;
  gap: 10px;
}

#kitchen-joystick-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#kitchen-joystick {
  position: relative;
  width: min(200px, 44vw);
  height: min(200px, 44vw);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#kitchen-joystick-base {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 3px solid var(--border);
  border-radius: 50%;
}

#kitchen-joystick-thumb {
  position: absolute;
  top: 50%; left: 50%;
  width: 42%; height: 42%;
  background: var(--player-color);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 4px 18px rgba(0,0,0,0.55);
  transition: transform 0.04s linear;
}

#kitchen-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  height: 100%;
  max-height: min(360px, 80vh);
}

.kitchen-btn {
  flex: 1;
  font-size: 18px;
  font-weight: bold;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.3;
  letter-spacing: 0.3px;
  transition: transform 0.07s, opacity 0.07s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.kitchen-btn:active, .kitchen-btn.active {
  transform: scale(0.93);
  opacity: 0.85;
}

.kitchen-btn.pickup {
  background: #44cc66;
  color: #1e2533;
}
.kitchen-btn.action {
  background: #FFDD44;
  color: #1e2533;
}
.kitchen-btn.throw {
  background: #ff4444;
  color: #ffffff;
}

/* ─── Fackelträger Controller (Bewegungs-Joystick links + AKTION rechts) ─── */
#ft-layout {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 12px 10px;
  gap: 12px;
}
.ft-action-btn {
  width: min(170px, 40vw);
  height: min(170px, 40vw);
  border-radius: 50%;
  border: 4px solid var(--player-color);
  background: var(--player-color);
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 1px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  flex-shrink: 0;
}
.ft-action-btn .ft-btn-sub {
  display: block;
  font-size: 11px;
  font-weight: normal;
  opacity: 0.75;
  margin-top: 4px;
}
.ft-action-btn.active {
  transform: scale(0.93);
  filter: brightness(0.85);
}

/* ─── Snake Royale Controller (D-Pad) ────────────────────────────────────── */
#snake-royale-ui {
  flex-direction: column;
  justify-content: center;
  gap: 28px;
}
#snake-joystick-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
}
#snake-joystick-wrap .tank-joystick {
  width: min(260px, 64vw);
  height: min(260px, 64vw);
}

/* ─── Pastell-Theme: Controller in der Pastellfarbe des Spielers ──────────
   Aktiv ab Join (body.pastel, --player-pastel aus JS). Gleiche Struktur für
   alle Spiele — Flächen weiß, Texte dunkel, Bedienelemente in Spielerfarbe. */
body.pastel {
  --bg: var(--player-pastel);
  --surface: #ffffff;
  --surface-deep: #f4f1ea;
  --border: #d8d2c6;
  --accent: #26303f;
  --muted: #5b6472;
  background: var(--bg);
  color: var(--accent);
}
body.pastel .btn-primary { background: var(--player-color); color: #1e2533; }
body.pastel #pause-menu-btn { background: #ffffff; border-color: var(--border); color: var(--accent); }
body.pastel .pause-menu-card { background: #ffffff; border-color: var(--border); }
body.pastel .pause-menu-title { color: var(--accent); }
body.pastel .pause-menu-opt:not(.end) { background: var(--player-color); color: #1e2533; }
body.pastel .pause-menu-opt.end { color: var(--accent); border-color: var(--border); }
body.pastel #signal-dot { background: #eae5da; border-color: #d8d2c6; }
body.pastel #kart-joystick-base,
body.pastel .tank-joystick-base,
body.pastel #kitchen-joystick-base { background: rgba(0, 0, 0, 0.05); }
body.pastel #mg-power-bar { border-color: var(--border); }
body.pastel input { background: #ffffff; border-color: var(--border); color: var(--accent); }
body.pastel .mg-label { color: var(--accent); }
body.pastel .host-hint { color: var(--muted); }

/* ─── Knockout (links Richtungs-Rad, rechts oszillierender Kraft-Balken) ───── */
#ko-layout {
  position: relative;
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  align-items: stretch;
  padding: 10px;
  gap: 10px;
}
#ko-left, #ko-right {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}
.ko-label {
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.55);
  letter-spacing: 1px;
}
#ko-wheel {
  position: relative;
  width: min(46vw, 60vh, 240px);
  height: min(46vw, 60vh, 240px);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  border: 4px solid rgba(0, 0, 0, 0.25);
  touch-action: none;
}
#ko-arrow {
  position: absolute;
  left: 50%; top: 50%;
  width: 0; height: 0;
  transform: rotate(0deg);
}
.ko-arrow-shaft {
  position: absolute;
  left: 0; top: -6px;
  width: 34%; height: 12px;
  background: #26303f;
}
#ko-wheel .ko-arrow-shaft { width: 62px; }
.ko-arrow-head {
  position: absolute;
  left: 62px; top: -16px;
  width: 0; height: 0;
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
  border-left: 22px solid #26303f;
}
#ko-wheel-dot {
  position: absolute;
  left: 50%; top: 50%;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #26303f;
}
#ko-power {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
  width: 100%;
  height: 100%;
  max-height: min(52vh, 220px);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#ko-power-btns {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}
.ko-step-btn {
  width: 64px;
  flex: 1 1 auto;
  font-family: "Press Start 2P", monospace;
  font-size: 22px;
  color: #26303f;
  background: rgba(255, 255, 255, 0.65);
  border: 4px solid rgba(0, 0, 0, 0.25);
  border-radius: 10px;
}
.ko-step-btn.active { background: rgba(255, 255, 255, 0.95); }
#ko-confirm {
  font-family: "Press Start 2P", monospace;
  font-size: 13px;
  color: #fff4e4;
  background: #b06018;
  border: 4px solid rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 14px 18px;
}
#ko-confirm.active { background: #8a4a10; }
#ko-power-track {
  position: relative;
  width: min(30vw, 120px);
  flex: 1 1 auto;
  min-height: 120px;
  background: rgba(255, 255, 255, 0.55);
  border: 4px solid rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  overflow: hidden;
}
#ko-power-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0%;
  background: linear-gradient(to top, #44dd77 0%, #ffdd44 60%, #ff4444 100%);
}
#ko-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  z-index: 5;
}
#ko-overlay-text {
  font-family: "Press Start 2P", monospace;
  font-size: 18px;
  color: #26303f;
  text-align: center;
  line-height: 1.7;
}
