/* Krawallstadt – Grundstil der Client-Shell (Cartoon + Retro). Klassen der Shell sind ungepräfixt bzw.
   je Szene präfixt (.login-, .menu-, .lobby-, .settings-, .lb-, .device-). */

:root {
  --c-bg: #2b2d6e;
  --c-bg-2: #1f1f4d;
  --c-panel: #fff7e6;
  --c-panel-2: #ffe9c2;
  --c-ink: #1b1b2f;
  --c-outline: #1b1b2f;
  --c-accent: #3a86ff;
  --c-accent-2: #8338ec;
  --c-good: #0ead69;
  --c-bad: #ff4d4d;
  --c-gold: #ffd23f;
  --c-orange: #ff9f1c;
  --c-pink: #ff5ca8;
  --c-muted: #6b6b8a;
  --c-light: #ffffff;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --btn-min: 48px;
  --outline-w: 3px;
  --shadow: 4px 4px 0 var(--c-outline);
  --shadow-sm: 2px 2px 0 var(--c-outline);
  --radius: 14px;
  --radius-sm: 10px;
  --gap: 10px;
  --pad: 12px;
  --fs: 15px;
  --fs-small: 12px;
  --fs-title: 18px;
  --fs-logo: 36px;

  --font-title: "Press Start 2P", "Courier New", ui-monospace, monospace;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Color Emoji", "Apple Color Emoji", sans-serif;
}

body.layout-tablet {
  --outline-w: 4px;
  --shadow: 6px 6px 0 var(--c-outline);
  --shadow-sm: 3px 3px 0 var(--c-outline);
  --radius: 18px;
  --gap: 16px;
  --pad: 20px;
  --fs: 19px;
  --fs-small: 15px;
  --fs-title: 24px;
  --fs-logo: 52px;
  --btn-min: 60px;
}

/* ---------- Grundgerüst: Vollbild, kein Scrollen, kein Zoom ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html { background: var(--c-bg-2); }

body {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% 35%, rgba(131, 56, 236, .55), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .035) 0 14px, transparent 14px 28px),
    var(--c-bg);
  color: var(--c-light);
  font-family: var(--font-ui);
  font-size: var(--fs);
  line-height: 1.3;
}

.app-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

.scene {
  position: absolute;
  inset: 0;
  padding: calc(var(--safe-top) + 8px) calc(var(--safe-right) + 10px) calc(var(--safe-bottom) + 8px) calc(var(--safe-left) + 10px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scene-in .22s ease-out;
}
body.layout-tablet .scene {
  padding: calc(var(--safe-top) + 18px) calc(var(--safe-right) + 24px) calc(var(--safe-bottom) + 18px) calc(var(--safe-left) + 24px);
}
@keyframes scene-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

img, svg { -webkit-user-drag: none; user-select: none; }

/* Scrollbare Bereiche (Ausnahme vom touch-action:none) */
.scroll {
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
}
.scroll-x {
  overflow: auto;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
}

/* Eingabefelder dürfen markieren/tippen */
input, textarea, select, .allow-select {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  touch-action: manipulation;
}
input, select, textarea {
  font-family: var(--font-ui);
  font-size: max(16px, var(--fs)); /* ≥16px: kein Auto-Zoom auf iOS */
}

/* ---------- Typografie ---------- */
.title, h1, h2, h3 {
  font-family: var(--font-title);
  font-weight: 900;
  letter-spacing: .02em;
  margin: 0 0 .5em;
  line-height: 1.2;
}
.title { font-size: var(--fs-title); }
h1 { font-size: calc(var(--fs-title) * 1.3); }
h2 { font-size: var(--fs-title); }
h3 { font-size: calc(var(--fs-title) * .8); }
.title-outline {
  color: var(--c-gold);
  text-shadow:
    -2px -2px 0 var(--c-outline), 2px -2px 0 var(--c-outline), -2px 2px 0 var(--c-outline), 2px 2px 0 var(--c-outline),
    4px 4px 0 var(--c-outline);
}
.muted { color: var(--c-muted); }
.small { font-size: var(--fs-small); }
.center { text-align: center; }
p { margin: 0 0 .6em; }

/* ---------- Logo ---------- */
.logo {
  font-family: var(--font-title);
  font-weight: 900;
  font-size: var(--fs-logo);
  color: var(--c-gold);
  letter-spacing: .04em;
  line-height: 1;
  white-space: nowrap;
  text-shadow:
    -3px -3px 0 var(--c-outline), 3px -3px 0 var(--c-outline), -3px 3px 0 var(--c-outline), 3px 3px 0 var(--c-outline),
    6px 6px 0 var(--c-bad), 9px 9px 0 var(--c-outline);
}
.logo-small { font-size: calc(var(--fs-logo) * .7); }
.logo-anim span {
  display: inline-block;
  animation: logo-bounce 1.6s ease-in-out infinite;
}
@keyframes logo-bounce {
  0%, 100% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(-8px) rotate(-4deg); }
  40% { transform: translateY(0) rotate(3deg); }
}
.logo-sub {
  font-family: var(--font-title);
  font-size: var(--fs-small);
  color: var(--c-light);
  margin-top: 14px;
  text-shadow: 2px 2px 0 var(--c-outline);
}

/* ---------- Panels ---------- */
.panel {
  background: var(--c-panel);
  color: var(--c-ink);
  border: var(--outline-w) solid var(--c-outline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--pad);
}
.panel-dark {
  background: rgba(27, 27, 47, .82);
  color: var(--c-light);
}
.panel .muted { color: var(--c-muted); }
.panel-dark .muted { color: #b9b9d6; }

/* ---------- Buttons ---------- */
.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45em;
  min-width: var(--btn-min);
  min-height: var(--btn-min);
  padding: .5em 1em;
  border: var(--outline-w) solid var(--c-outline);
  border-radius: var(--radius-sm);
  background: var(--c-light);
  color: var(--c-ink);
  font-family: var(--font-ui);
  font-size: var(--fs);
  font-weight: 800;
  line-height: 1.1;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition: transform .06s, box-shadow .06s, filter .1s;
  text-align: center;
}
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--c-outline); }
.btn:disabled { opacity: .45; filter: grayscale(.6); cursor: default; }
.btn.is-busy { opacity: .7; pointer-events: none; }
.btn:focus-visible { outline: 3px dashed var(--c-gold); outline-offset: 2px; }
.btn-primary { background: var(--c-accent); color: #fff; }
.btn-good { background: var(--c-good); color: #fff; }
.btn-bad { background: var(--c-bad); color: #fff; }
.btn-gold { background: var(--c-gold); color: var(--c-ink); }
.btn-purple { background: var(--c-accent-2); color: #fff; }
.btn-orange { background: var(--c-orange); color: var(--c-ink); }
.btn-ghost { background: transparent; color: inherit; box-shadow: none; border-color: currentColor; }
.btn-big { font-size: calc(var(--fs) * 1.15); min-height: calc(var(--btn-min) * 1.2); padding: .6em 1.2em; }
.btn-small { min-height: 48px; min-width: 48px; padding: .3em .6em; font-size: var(--fs-small); }
.btn-icon { font-size: 1.25em; line-height: 1; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; }
.btn-row.end { justify-content: flex-end; }
.btn-col { display: flex; flex-direction: column; gap: var(--gap); }
.btn-block { width: 100%; }

/* Zurück-Leiste oben */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  margin-bottom: var(--gap);
  flex: 0 0 auto;
}
.topbar .title { margin: 0; flex: 1 1 auto; color: var(--c-light); text-shadow: 3px 3px 0 var(--c-outline); }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--gap); }
.field label { font-weight: 800; font-size: var(--fs-small); }
.input {
  width: 100%;
  min-height: var(--btn-min);
  padding: .4em .7em;
  border: var(--outline-w) solid var(--c-outline);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--c-ink);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, .12);
  outline: none;
}
.input:focus { border-color: var(--c-accent); box-shadow: 0 0 0 3px rgba(58, 134, 255, .35); }
.form-error {
  background: var(--c-bad);
  color: #fff;
  border: 2px solid var(--c-outline);
  border-radius: var(--radius-sm);
  padding: .4em .7em;
  font-weight: 700;
  margin-bottom: var(--gap);
}
select.input { -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--c-ink) 50%), linear-gradient(135deg, var(--c-ink) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 2em; }
select.input:disabled { opacity: .7; }

/* Tabs */
.tabs { display: flex; gap: 0; margin-bottom: var(--gap); }
.tab {
  flex: 1 1 0;
  min-height: var(--btn-min);
  border: var(--outline-w) solid var(--c-outline);
  background: var(--c-panel-2);
  color: var(--c-ink);
  font-weight: 800;
  font-size: var(--fs);
  font-family: var(--font-ui);
  touch-action: manipulation;
}
.tab:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.tab:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; }
.tab.is-active { background: var(--c-accent); color: #fff; }

/* Stepper */
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper-label { font-weight: 800; margin-right: 4px; }
.btn-step { min-width: var(--btn-min); padding: 0; font-size: calc(var(--fs) * 1.4); }
.stepper-value {
  min-width: 4.2em;
  text-align: center;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  background: #fff;
  border: 2px solid var(--c-outline);
  border-radius: 8px;
  padding: .35em .4em;
}

/* Schalter */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: .6em;
  min-height: var(--btn-min);
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 700;
  touch-action: manipulation;
  text-align: left;
}
.toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 58px;
  height: 32px;
  border-radius: 20px;
  background: #b9b9c9;
  border: var(--outline-w) solid var(--c-outline);
  transition: background .15s;
}
.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--c-outline);
  transition: transform .15s;
}
.toggle.is-on .toggle-track { background: var(--c-good); }
.toggle.is-on .toggle-knob { transform: translateX(26px); }
.toggle:disabled { opacity: .55; }

/* Segment-Auswahl */
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.seg {
  flex: 1 1 auto;
  min-height: var(--btn-min);
  padding: .3em .8em;
  border: var(--outline-w) solid var(--c-outline);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--c-ink);
  font: inherit;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35em;
}
.seg.is-active { background: var(--c-gold); }
.seg:disabled { opacity: .75; }
.seg:disabled.is-active { opacity: 1; }
.segmented.is-disabled .seg { box-shadow: none; }

/* Range-Slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: var(--btn-min);
  background: transparent;
  touch-action: none;
}
input[type="range"]::-webkit-slider-runnable-track { height: 14px; border-radius: 8px; background: #fff; border: 3px solid var(--c-outline); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 34px; height: 34px; margin-top: -13px; border-radius: 50%; background: var(--c-gold); border: 3px solid var(--c-outline); }
input[type="range"]::-moz-range-track { height: 10px; border-radius: 8px; background: #fff; border: 3px solid var(--c-outline); }
input[type="range"]::-moz-range-thumb { width: 30px; height: 30px; border-radius: 50%; background: var(--c-gold); border: 3px solid var(--c-outline); }

/* ---------- Toasts / Banner / Dialoge / Overlays ---------- */
.toasts {
  position: fixed;
  z-index: 900;
  top: calc(var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  width: min(92vw, 560px);
}
.toast {
  pointer-events: auto;
  background: var(--c-panel);
  color: var(--c-ink);
  border: 3px solid var(--c-outline);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: .5em 1em;
  font-weight: 800;
  text-align: center;
  animation: toast-in .2s ease-out;
  transition: opacity .3s, transform .3s;
}
.toast-error { background: var(--c-bad); color: #fff; }
.toast-success { background: var(--c-good); color: #fff; }
.toast-out { opacity: 0; transform: translateY(-10px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(.95); } to { opacity: 1; transform: none; } }

.net-banner {
  position: fixed;
  z-index: 950;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 10px);
  transform: translateX(-50%);
  background: var(--c-gold);
  color: var(--c-ink);
  border: 3px solid var(--c-outline);
  border-radius: 30px;
  box-shadow: var(--shadow-sm);
  padding: .45em 1.1em;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: .6em;
  white-space: nowrap;
  pointer-events: none;
}
.net-banner[hidden] { display: none; }

.hint-bar {
  position: fixed;
  z-index: 800;
  left: calc(var(--safe-left) + 10px);
  right: calc(var(--safe-right) + 10px);
  bottom: calc(var(--safe-bottom) + 10px);
  margin: 0 auto;
  max-width: 640px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--c-panel);
  color: var(--c-ink);
  border: 3px solid var(--c-outline);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 6px 6px 6px 12px;
  font-weight: 700;
  animation: toast-in .25s ease-out;
}
.hint-text { flex: 1 1 auto; }
.hint-icon { font-size: 1.4em; }

.dialogs { position: fixed; inset: 0; z-index: 700; pointer-events: none; }
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 35, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 10px) calc(var(--safe-right) + 10px) calc(var(--safe-bottom) + 10px) calc(var(--safe-left) + 10px);
  pointer-events: auto;
  animation: fade-in .15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.dialog {
  width: min(560px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  animation: pop-in .2s cubic-bezier(.2, 1.4, .5, 1);
}
body.layout-tablet .dialog { width: min(720px, 100%); }
@keyframes pop-in { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.dialog-body { flex: 1 1 auto; margin-bottom: var(--gap); }
.dialog-buttons { justify-content: flex-end; flex: 0 0 auto; }

.rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  touch-action: none;
}
.rotate-overlay[hidden] { display: none; }
.rotate-box .title { color: var(--c-gold); text-shadow: 3px 3px 0 var(--c-outline); font-size: 20px; }
.rotate-phone { font-size: 72px; display: inline-block; animation: rotate-hint 2s ease-in-out infinite; margin-bottom: 16px; }
@keyframes rotate-hint { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

.splash {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.splash[hidden] { display: none; }
.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, .25);
  border-top-color: var(--c-gold);
  animation: spin .8s linear infinite;
}
.spinner-small { width: 18px; height: 18px; border-width: 3px; border-color: rgba(0, 0, 0, .2); border-top-color: var(--c-ink); }
@keyframes spin { to { transform: rotate(360deg); } }

.scene-error { align-items: center; justify-content: center; }
.error-panel { max-width: 520px; text-align: center; }
.error-panel .btn-row { justify-content: center; }
.noscript { color: #fff; padding: 2em; text-align: center; }

/* Figur-Container */
.char { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; line-height: 0; }
.char svg { display: block; width: 100%; height: 100%; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-small);
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
  border: 2px solid var(--c-outline);
  background: var(--c-panel-2);
  color: var(--c-ink);
  white-space: nowrap;
}
.badge-good { background: var(--c-good); color: #fff; }
.badge-bad { background: var(--c-bad); color: #fff; }
.badge-gold { background: var(--c-gold); }
.badge-muted { background: #d8d8e4; color: #555; }

/* ============================================================
   Szene: Login
   ============================================================ */
.scene-login { flex-direction: row; align-items: center; justify-content: center; gap: calc(var(--gap) * 2); }
.login-brand { flex: 1 1 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-width: 0; }
.login-brand .logo { font-size: clamp(20px, 4.6vw, var(--fs-logo)); }
.login-brand .logo-sub { max-width: 30em; line-height: 1.6; }
.login-chars { display: flex; gap: 6px; margin-top: 18px; }
.login-chars .char { width: 48px; height: 48px; animation: logo-bounce 1.8s ease-in-out infinite; }
body.layout-tablet .login-chars .char { width: 80px; height: 80px; }
.login-form { flex: 0 1 380px; max-height: 100%; }
body.layout-tablet .login-form { flex-basis: 460px; }
.login-form form { margin: 0; }
.login-form .btn-primary { width: 100%; margin-top: 4px; }

/* ============================================================
   Szene: Gerätewahl
   ============================================================ */
.scene-device { align-items: center; justify-content: center; text-align: center; gap: var(--gap); }
.device-title { color: var(--c-light); }
.device-choices { display: flex; gap: calc(var(--gap) * 2); justify-content: center; flex-wrap: nowrap; }
.device-choice {
  position: relative;
  width: min(36vw, 340px);
  min-height: min(46vh, 260px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: var(--outline-w) solid var(--c-outline);
  border-radius: var(--radius);
  background: var(--c-panel);
  color: var(--c-ink);
  box-shadow: var(--shadow);
  font: inherit;
  font-weight: 900;
  touch-action: manipulation;
}
.device-choice .device-emoji { font-size: clamp(48px, 12vh, 110px); line-height: 1; }
.device-choice .device-name { font-size: calc(var(--fs) * 1.25); }
.device-choice .device-desc { font-size: var(--fs-small); font-weight: 600; color: var(--c-muted); padding: 0 10px; }
.device-choice.is-selected { background: var(--c-gold); transform: translateY(-4px); }
.device-choice:active { transform: translate(2px, 2px); box-shadow: var(--shadow-sm); }
.device-rec {
  position: absolute;
  top: -14px;
  right: -10px;
  transform: rotate(6deg);
  background: var(--c-good);
  color: #fff;
  border: 3px solid var(--c-outline);
  border-radius: 10px;
  padding: 2px 10px;
  font-size: var(--fs-small);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Szene: Menü
   ============================================================ */
.scene-menu { flex-direction: row; gap: calc(var(--gap) * 1.5); align-items: stretch; }
.menu-hero {
  flex: 0 0 34%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
}
.menu-hero .logo { font-size: clamp(14px, 3vw, calc(var(--fs-logo) * .75)); margin-bottom: 14px; }
.menu-hero .char { width: min(26vh, 150px); height: min(26vh, 150px); animation: logo-bounce 2.4s ease-in-out infinite; }
body.layout-tablet .menu-hero .char { width: min(30vh, 240px); height: min(30vh, 240px); }
.menu-greet { font-weight: 900; font-size: calc(var(--fs) * 1.15); margin-top: 8px; text-shadow: 2px 2px 0 var(--c-outline); }
.menu-main { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; min-width: 0; gap: var(--gap); }
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}
body.layout-tablet .menu-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.menu-grid .btn { min-height: calc(var(--btn-min) * 1.15); justify-content: flex-start; }
body.layout-tablet .menu-grid .btn { min-height: 110px; flex-direction: column; justify-content: center; }
body.layout-tablet .menu-grid .btn .btn-icon { font-size: 2em; }
.menu-grid .menu-primary { grid-column: span 1; }
.menu-hint { font-size: var(--fs-small); color: #dcdcf5; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Raumcode-Eingabe */
.code-entry { display: flex; flex-direction: row; gap: calc(var(--gap) * 1.5); align-items: center; justify-content: center; }
.code-display { display: flex; flex-direction: column; align-items: center; gap: var(--gap); }
.code-input {
  width: 6.2em;
  text-align: center;
  font-family: var(--font-title);
  font-size: 34px !important;
  letter-spacing: .25em;
  padding: .25em 0 .25em .25em;
}
body.layout-tablet .code-input { font-size: 48px !important; }
.keypad { display: grid; grid-template-columns: repeat(3, var(--btn-min)); gap: 6px; }
.keypad .btn { font-size: calc(var(--fs) * 1.3); padding: 0; min-height: calc(var(--btn-min) * .95); }
body.layout-tablet .keypad { grid-template-columns: repeat(3, 76px); gap: 10px; }
body.layout-tablet .keypad .btn { min-height: 70px; }

/* ============================================================
   Szene: Lobby
   ============================================================ */
.scene-lobby { gap: var(--gap); }
.lobby-head { display: flex; align-items: center; gap: var(--gap); flex: 0 0 auto; }
.lobby-code {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--c-gold);
  color: var(--c-ink);
  border: var(--outline-w) solid var(--c-outline);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 4px 14px;
}
.lobby-code-label { font-weight: 800; font-size: var(--fs-small); line-height: 1.1; }
.lobby-code-value { font-family: var(--font-title); font-weight: 900; font-size: 28px; letter-spacing: .18em; }
body.layout-tablet .lobby-code-value { font-size: 44px; }
.lobby-head .spacer { flex: 1 1 auto; }
.lobby-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: var(--gap); }
body.layout-tablet .lobby-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
.lobby-col { min-height: 0; display: flex; flex-direction: column; gap: var(--gap); }
.lobby-col > .panel { min-height: 0; }
.lobby-players { flex: 1 1 auto; display: flex; flex-direction: column; padding: 8px; }
.lobby-players .title { margin: 4px 6px 8px; }
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 2px solid var(--c-outline);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  position: relative;
}
.player-row .char { width: 40px; height: 40px; }
body.layout-tablet .player-row .char { width: 56px; height: 56px; }
.player-row.is-offline { opacity: .5; }
.player-row.is-me { background: #eaf2ff; }
.player-name { flex: 1 1 auto; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.player-device { font-size: 1.3em; }
.player-crown { font-size: 1.2em; }
/* Schmale Fenster (iPad Split View, kleine Handys): Namen nicht auf „t_s…“ kürzen */
@media (max-width: 720px) {
  .lobby-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .player-crown { display: none; } /* „Host“-Badge sagt dasselbe */
  .player-row { gap: 6px; }
  .player-row .badge { font-size: .8em; padding-left: 6px; padding-right: 6px; }
  .player-name {
    white-space: normal; overflow-wrap: anywhere; line-height: 1.15;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  }
}
.emote-bubble {
  position: absolute;
  right: 10px;
  top: -12px;
  background: #fff;
  border: 2px solid var(--c-outline);
  border-radius: 14px;
  padding: 2px 10px;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  animation: pop-in .2s ease-out;
  z-index: 2;
  white-space: nowrap;
}
.lobby-settings { flex: 1 1 auto; display: flex; flex-direction: column; padding: 8px 10px; }
.lobby-settings .title { margin: 4px 0 8px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 0;
  border-bottom: 2px dashed rgba(27, 27, 47, .15);
}
.setting-row:last-child { border-bottom: 0; }
.setting-label { font-weight: 800; }
.setting-row.block { flex-direction: column; align-items: stretch; }
.mg-toggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 10px; }
body.layout-tablet .mg-toggles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
body.layout-tablet .mode-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mode-desc { font-size: var(--fs-small); color: var(--c-muted); margin-top: 4px; }
.readonly-note { font-size: var(--fs-small); color: var(--c-muted); font-weight: 700; }
.save-note { background: var(--c-panel-2); border: 2px solid var(--c-outline); border-radius: var(--radius-sm); padding: 6px 10px; font-weight: 700; font-size: var(--fs-small); }
.lobby-foot { flex: 0 0 auto; display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap; }
.lobby-foot .spacer { flex: 1 1 auto; }
.lobby-status { font-weight: 800; text-shadow: 2px 2px 0 var(--c-outline); }
/* Emote-Leiste (Kit) ist absolut positioniert -> Platzhalter reserviert ihren Platz, damit beim Umbruch
   (z. B. iPad Split View) kein Knopf darunter verschwindet. */
.lobby-emotes { position: relative; flex: 0 0 auto; width: 52px; height: 52px; }
.lobby-emotes[hidden] { display: none; }
.lobby-emotes > .kit-emotebar { left: 0; bottom: 0; }
.save-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.save-item { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--c-outline); border-radius: var(--radius-sm); padding: 6px 10px; }
.save-item .save-info { flex: 1 1 auto; min-width: 0; }
.save-item .save-title { font-weight: 800; }

/* ============================================================
   Szene: Einstellungen
   ============================================================ */
.settings-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--gap); }
.settings-col { min-height: 0; display: flex; flex-direction: column; gap: var(--gap); }
.settings-col > .panel { flex: 0 0 auto; }
.settings-col.scroll { padding-right: 4px; padding-bottom: 8px; }
.settings-col .panel .title { font-size: calc(var(--fs-title) * .8); }
.volume-row { display: flex; align-items: center; gap: 10px; }
.volume-row input { flex: 1 1 auto; }
.volume-value { min-width: 3.2em; text-align: right; font-weight: 900; }
.controls-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px) 0 0 / 20px 20px,
    #2a3b2a;
  border: var(--outline-w) solid var(--c-outline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  touch-action: none;
}
.controls-preview::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  border-left: 2px dashed rgba(255, 255, 255, .25);
}
.controls-preview .preview-label {
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, .75);
  font-size: var(--fs-small);
  font-weight: 700;
  pointer-events: none;
}
.ctl-joy, .ctl-fire {
  position: absolute;
  transform: translate(-50%, 50%);
  border-radius: 50%;
  border: 3px solid var(--c-outline);
  touch-action: none;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: var(--c-ink);
  z-index: 1;
}
.ctl-joy { background: rgba(255, 255, 255, .45); }
.ctl-joy::after { content: ''; width: 42%; height: 42%; border-radius: 50%; background: #fff; border: 3px solid var(--c-outline); }
.ctl-joy.is-floating { border-style: dashed; background: rgba(255, 255, 255, .2); }
.ctl-fire { background: var(--c-bad); color: #fff; }
.ctl-joy.is-dragging, .ctl-fire.is-dragging { cursor: grabbing; box-shadow: 0 0 0 4px var(--c-gold); }
.size-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ============================================================
   Szene: Bestenliste
   ============================================================ */
.lb-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: var(--gap); }
body.layout-tablet .lb-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr); }
.lb-stats { flex: 0 0 auto; }
.lb-stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
body.layout-tablet .lb-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat {
  background: #fff;
  border: 2px solid var(--c-outline);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  text-align: center;
}
.stat-value { font-family: var(--font-title); font-weight: 900; font-size: calc(var(--fs) * 1.2); }
.stat-label { font-size: var(--fs-small); color: var(--c-muted); font-weight: 700; }
.lb-table-wrap { flex: 1 1 auto; min-height: 0; padding: 0; overflow: hidden; display: flex; }
.lb-table-wrap .scroll-x { flex: 1 1 auto; }
.lb-table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
body.layout-tablet .lb-table { font-size: var(--fs); }
.lb-table th, .lb-table td { padding: 6px 8px; text-align: center; white-space: nowrap; border-bottom: 2px solid rgba(27, 27, 47, .12); }
.lb-table th { position: sticky; top: 0; background: var(--c-panel-2); z-index: 1; font-weight: 900; }
.lb-table td.lb-name { text-align: left; font-weight: 800; max-width: 12em; overflow: hidden; text-overflow: ellipsis; }
.lb-table td.lb-rank { font-family: var(--font-title); font-weight: 900; }
.lb-table .char { width: 34px; height: 34px; }
body.layout-tablet .lb-table .char { width: 46px; height: 46px; }
.lb-table tr.is-me td { background: #eaf2ff; }
.lb-table tr.top-1 td.lb-rank { color: #c99700; }
.lb-empty { padding: 20px; text-align: center; }

/* Kleine Handys (sehr niedrige Höhe) */
@media (max-height: 380px) {
  :root { --fs: 14px; --pad: 8px; --gap: 8px; }
  .menu-grid .btn { min-height: var(--btn-min); }
  .code-input { font-size: 26px !important; }
}

/* ---- Host-Menü pro Spieler (Lobby/Brett/Serie) ---- */
.host-menu-btn {
  min-width: 44px; min-height: 44px; padding: 0 .4em;
  font-size: calc(var(--fs, 16px) * 1.4); line-height: 1; font-weight: 900;
  flex: 0 0 auto;
}
.player-presence { font-size: .8em; color: var(--c-bad); white-space: nowrap; }
.player-presence.is-kicked { color: var(--c-ink); opacity: .6; }
.player-row.is-kicked { opacity: .5; }
.host-menu-dialog .dialog-buttons { flex-direction: column; align-items: stretch; }
.host-menu-dialog .dialog-buttons .btn { width: 100%; justify-content: flex-start; }
