/* ============================================================
   Top 10 – Styles
   Mobile-first, glassmorphism, lebendige Gradients, 60fps-Effekte.
   Animationen laufen über transform/opacity (GPU), nicht über Layout.
   ============================================================ */

:root {
  --bg-0: #120024;
  --violet: #7b2ff7;
  --pink: #f72585;
  --orange: #ff9e00;
  --cyan: #21d4fd;
  --blue: #2b6bff;
  --magenta: #b5179e;

  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-brd: rgba(255, 255, 255, 0.18);
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.65);
  --radius: 24px;
  --shadow-glow: 0 10px 40px -8px rgba(123, 47, 247, 0.55);

  /* Safe-area-Insets für iPhones */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ---------- Hintergrund (statisch -> sehr günstig) ---------- */
/* Bewusst KEINE Animation und KEINE backdrop-filter dahinter:
   ein bewegter, unscharfer Hintergrund zwingt mobile Browser (v. a. Firefox)
   zu teuren Neuberechnungen pro Frame. Statisch = flüssig. */
.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: -3;
  background: linear-gradient(
    135deg,
    #2a0a4a, #7b2ff7 28%, #f72585 52%, #ff9e00 70%, #21d4fd 88%, #2b6bff
  );
}

/* dunkler Schleier, damit die Panels knallen */
.bg-gradient::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, transparent, rgba(8, 0, 20, 0.72));
}

/* statische Farb-Orbs (kein Blur-Filter, kein Animieren -> keine Repaints) */
.bg-orbs { position: fixed; inset: 0; z-index: -2; overflow: hidden; }
.orb {
  position: absolute;
  border-radius: 50%;
  opacity: 0.45;
}
.orb-1 { width: 340px; height: 340px; background: radial-gradient(circle, var(--pink), transparent 70%); top: -90px; left: -90px; }
.orb-2 { width: 300px; height: 300px; background: radial-gradient(circle, var(--cyan), transparent 70%); bottom: -80px; right: -80px; }
.orb-3 { width: 260px; height: 260px; background: radial-gradient(circle, var(--orange), transparent 70%); bottom: 28%; left: 36%; }

/* ---------- App-Layout & Screens ---------- */
#app {
  position: relative;
  height: 100%;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: calc(20px + var(--sat)) calc(20px + var(--sar)) calc(20px + var(--sab)) calc(20px + var(--sal));
  overflow-y: auto;
  opacity: 0;
  transform: translateY(24px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.screen.is-active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ---------- Panels (ohne backdrop-filter -> deutlich performanter) ---------- */
/* Statt teurem backdrop-blur ein etwas kräftigerer, halbtransparenter Fond.
   Sieht weiterhin nach "Glas" aus, kostet den Browser aber fast nichts. */
.glass {
  background: rgba(28, 8, 54, 0.55);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* ---------- Branding / Start ---------- */
.brand { text-align: center; margin-top: 6vh; }
.logo {
  font-size: clamp(56px, 18vw, 96px);
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 1;
  background: linear-gradient(135deg, #fff, var(--cyan) 40%, var(--pink) 75%, var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 24px rgba(247, 37, 133, 0.5));
}
.tagline { color: var(--text-dim); font-weight: 500; margin-top: 6px; }
@keyframes floatSlow { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }

.card-stack { padding: 24px; display: flex; flex-direction: column; gap: 16px; margin-top: auto; }

/* ---------- Spielanleitung (aufklappbar) ---------- */
.howto { padding: 0; overflow: hidden; margin-bottom: auto; }
.howto summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
}
.howto summary::-webkit-details-marker { display: none; }
.howto-title { font-size: 16px; }
.howto-chevron {
  font-size: 20px;
  line-height: 1;
  color: var(--text-dim);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.howto[open] .howto-chevron { transform: rotate(180deg); }

.howto-body {
  padding: 0 22px 20px;
  animation: howtoIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes howtoIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.howto-steps { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.howto-steps li { display: flex; align-items: flex-start; gap: 14px; }
.howto-steps p { font-size: 14.5px; line-height: 1.45; color: var(--text-dim); }
.howto-steps p b { color: #fff; font-weight: 700; }
.howto-step-no {
  flex: 0 0 auto;
  width: 28px; height: 28px; line-height: 28px;
  text-align: center;
  border-radius: 50%;
  font-weight: 900; font-size: 14px;
  color: #fff;
  background: linear-gradient(120deg, var(--violet), var(--pink) 55%, var(--orange));
  box-shadow: 0 4px 14px -3px rgba(247, 37, 133, 0.7);
}
.howto-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--glass-brd);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}
.howto-foot b { color: #fff; font-weight: 700; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-weight: 600; font-size: 14px; color: var(--text-dim); padding-left: 4px; }

input {
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  background: rgba(0, 0, 0, 0.28);
  border: 1.5px solid var(--glass-brd);
  border-radius: 16px;
  padding: 16px 18px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input::placeholder { color: rgba(255, 255, 255, 0.4); }
input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(33, 212, 253, 0.18); }

.code-field { text-align: center; letter-spacing: 10px; font-size: 26px; font-weight: 800; }

.join-row { display: flex; gap: 10px; }
.join-row .code-field { flex: 1; }
.join-row .btn { flex: 0 0 auto; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--text-dim); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--glass-brd); }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 16px 22px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.25s ease, filter 0.2s;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: scale(0.95); }
.btn-big { font-size: 19px; padding: 18px 24px; }

.btn-primary {
  background: linear-gradient(120deg, var(--violet), var(--pink) 55%, var(--orange));
  box-shadow: 0 10px 30px -6px rgba(247, 37, 133, 0.6);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 14px 38px -6px rgba(247, 37, 133, 0.8); }

.btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid var(--glass-brd);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.2); }

.btn-text {
  background: transparent;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 15px;
  padding: 12px;
}
.btn-text:hover { color: #fff; }

/* ---------- Lobby ---------- */
.lobby-head { text-align: center; padding: 22px; }
.lobby-label { color: var(--text-dim); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 2px; }
.room-code {
  font-size: clamp(48px, 16vw, 72px);
  font-weight: 900;
  letter-spacing: 12px;
  margin: 6px 0 16px;
  text-indent: 12px;
  background: linear-gradient(135deg, #fff, var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.qr-box {
  display: inline-block;
  width: 192px;
  height: 192px;
  padding: 12px;
  background: #fff;
  border-radius: 18px;
  line-height: 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.qr-box svg { display: block; width: 100%; height: 100%; }
.qr-hint { color: var(--text-dim); font-size: 13px; margin-top: 12px; }
.join-url { color: var(--text-dim); font-size: 12px; margin-top: 6px; word-break: break-all; opacity: 0.8; }

.players-panel { padding: 20px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel-title { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.pill {
  font-size: 14px; font-weight: 800;
  background: linear-gradient(120deg, var(--violet), var(--pink));
  padding: 3px 12px; border-radius: 999px;
}
.player-list { list-style: none; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.player-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--glass-brd);
  border-radius: 14px;
  font-weight: 600;
  animation: slideIn 0.4s cubic-bezier(0.22,1,0.36,1);
}
@keyframes slideIn { from{opacity:0; transform:translateX(-16px)} to{opacity:1; transform:none} }
.player-list li .dot { width: 10px; height: 10px; border-radius: 50%; background: #3ce06f; box-shadow: 0 0 10px #3ce06f; flex: 0 0 auto; }
.player-list li.offline { opacity: 0.45; }
.player-list li.offline .dot { background: #888; box-shadow: none; }
.player-list li .tags { margin-left: auto; display: flex; gap: 6px; }
.tag { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; letter-spacing: 0.5px; }
.tag-host { background: rgba(255,158,0,0.25); color: var(--orange); border: 1px solid rgba(255,158,0,0.5); }
.tag-you { background: rgba(33,212,253,0.22); color: var(--cyan); border: 1px solid rgba(33,212,253,0.5); }
.tag-cap { background: rgba(247,37,133,0.25); color: #ff7eb6; border: 1px solid rgba(247,37,133,0.5); }

.lobby-actions { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.lobby-actions .btn-big { width: 100%; }
.waiting-text { font-weight: 700; font-size: 17px; color: var(--text-dim); padding: 14px; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:0.55} 50%{opacity:1} }

/* ---------- Game ---------- */
.game-toolbar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.toolbar-spacer { flex: 1; }
.chip {
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  border: 1px solid var(--glass-brd);
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.chip:active { transform: scale(0.94); }
.chip b { letter-spacing: 2px; }
.chip-code { background: rgba(33,212,253,0.18); border-color: rgba(33,212,253,0.5); }
.chip-code:hover { background: rgba(33,212,253,0.3); }
.chip-danger { background: rgba(247,37,133,0.16); border-color: rgba(247,37,133,0.45); color: #ff9ec0; }
.chip-danger:hover { background: rgba(247,37,133,0.28); }

.game-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; flex: 0 0 auto; }
.round-badge { font-weight: 700; color: var(--text-dim); font-size: 15px; }
.round-badge span { color: #fff; font-weight: 900; }
.captain-badge {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(120deg, rgba(247,37,133,0.3), rgba(255,158,0,0.3));
  border: 1px solid rgba(255,158,0,0.5);
  padding: 8px 16px; border-radius: 999px;
  font-weight: 800;
  box-shadow: 0 0 20px -4px rgba(255,158,0,0.5);
}
.captain-badge .crown { font-size: 20px; display: inline-block; }
.captain-badge.crowning .crown { animation: crownPop 0.7s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes crownPop {
  0% { transform: translateY(-28px) rotate(-30deg) scale(0); opacity: 0; }
  60% { transform: translateY(4px) rotate(8deg) scale(1.3); opacity: 1; }
  100% { transform: none; }
}

.card-area { flex: 1; display: flex; align-items: center; min-height: 0; }
.theme-card {
  width: 100%;
  padding: 30px 26px;
  text-align: center;
  animation: cardIn 0.5s cubic-bezier(0.22,1,0.36,1);
}
.theme-card.swap { animation: cardSwap 0.5s cubic-bezier(0.22,1,0.36,1); }
@keyframes cardIn { from{opacity:0; transform:translateY(24px) scale(0.96)} to{opacity:1; transform:none} }
@keyframes cardSwap {
  0% { opacity: 0; transform: translateY(30px) rotateX(12deg) scale(0.94); }
  100% { opacity: 1; transform: none; }
}

.perf-tag {
  display: inline-block;
  font-weight: 800; font-size: 13px;
  background: linear-gradient(120deg, var(--magenta), var(--violet));
  padding: 6px 14px; border-radius: 999px; margin-bottom: 16px;
  box-shadow: 0 4px 16px -2px rgba(181,23,158,0.6);
}
.theme-text {
  font-size: clamp(24px, 6.5vw, 34px);
  font-weight: 800; line-height: 1.18;
  margin-bottom: 28px;
  text-shadow: 0 4px 24px rgba(0,0,0,0.35);
}

/* Skala-Balken: Verlauf kühl (1) -> warm (10) */
.scale { display: flex; flex-direction: column; gap: 12px; }
.scale-bar {
  position: relative;
  height: 14px; border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--blue) 30%, var(--violet) 55%, var(--pink) 80%, var(--orange));
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3), 0 0 18px -2px rgba(247,37,133,0.5);
}
.scale-knob { display: none; }
.scale-ends { display: flex; justify-content: space-between; gap: 16px; }
.scale-end { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.scale-end.low { text-align: left; }
.scale-end.high { text-align: right; }
.scale-end .num {
  font-weight: 900; font-size: 22px;
  width: 34px; height: 34px; line-height: 34px;
  border-radius: 50%; text-align: center;
}
.scale-end.low .num { background: rgba(33,212,253,0.25); color: var(--cyan); border: 1px solid rgba(33,212,253,0.5); }
.scale-end.high .num { background: rgba(255,158,0,0.25); color: var(--orange); border: 1px solid rgba(255,158,0,0.5); align-self: flex-end; }
.scale-end .lbl { font-weight: 600; font-size: 14px; color: var(--text-dim); }

/* ---------- Bottom-Zone & Geheimzahl ---------- */
.bottom-zone { flex: 0 0 auto; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.bottom-zone .btn-big { width: 100%; }
.progress-text { color: var(--text-dim); font-size: 12px; font-weight: 600; }

.reveal-zone {
  position: relative;
  width: 100%;
  height: 150px;
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-brd);
}

.secret-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 100px;
  font-weight: 900;
  color: #fff;
  /* Glow per text-shadow statt teurem drop-shadow-Filter; nur opacity+transform
     werden während des Ziehens animiert -> GPU-günstig, flüssig. */
  text-shadow: 0 0 24px rgba(247, 37, 133, 0.65), 0 0 8px rgba(33, 212, 253, 0.5);
  opacity: 0;
  transform: scale(0.7);
  will-change: opacity, transform;
}
.secret-number.glow { animation: numGlow 0.45s ease; }
@keyframes numGlow {
  0% { text-shadow: 0 0 6px rgba(247,37,133,0.3); }
  50% { text-shadow: 0 0 44px rgba(247,37,133,1), 0 0 16px rgba(33,212,253,0.8); }
  100% { text-shadow: 0 0 24px rgba(247,37,133,0.65), 0 0 8px rgba(33,212,253,0.5); }
}

.reveal-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: linear-gradient(150deg, rgba(123,47,247,0.9), rgba(247,37,133,0.85) 60%, rgba(255,158,0,0.85));
  border-radius: var(--radius);
  touch-action: none;            /* Seiten-Scroll während des Ziehens unterbinden */
  cursor: grab;
  will-change: transform;
  box-shadow: 0 -6px 24px -4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.25);
}
.reveal-card:active { cursor: grabbing; }
.reveal-grip { width: 48px; height: 5px; border-radius: 999px; background: rgba(255,255,255,0.7); }
.reveal-hint { font-weight: 700; font-size: 15px; color: #fff; display: flex; align-items: center; gap: 8px; text-shadow: 0 1px 6px rgba(0,0,0,0.3); }
.reveal-arrow { display: inline-block; animation: bobUp 1.6s ease-in-out infinite; }
@keyframes bobUp { 0%,100%{transform:translateY(0); opacity:0.6} 50%{transform:translateY(-5px); opacity:1} }

/* ---------- Beitritts-Overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 0, 20, 0.7);
  animation: fadeIn 0.25s ease;
}
.overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.overlay-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 28px 24px;
  text-align: center;
  animation: cardIn 0.35s cubic-bezier(0.22,1,0.36,1);
}
.overlay-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--glass-brd);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.12s, background 0.2s;
}
.overlay-close:active { transform: scale(0.9); }
.overlay-close:hover { background: rgba(255,255,255,0.2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--sab));
  transform: translate(-50%, 30px);
  background: rgba(20,4,40,0.95);
  border: 1px solid var(--glass-brd);
  padding: 13px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s cubic-bezier(0.22,1,0.36,1);
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Hilfstexte ---------- */
.error-text { color: #ff9aa9; font-weight: 600; font-size: 14px; text-align: center; min-height: 1em; }
.hint { color: var(--text-dim); font-size: 13px; text-align: center; }

/* ---------- Reduced Motion: ruhigere Variante ---------- */
@media (prefers-reduced-motion: reduce) {
  .bg-gradient { animation: none; background-position: 0 50%; }
  .orb { animation: none; }
  .brand, .reveal-arrow, .waiting-text, .btn-primary { animation: none; }
  .screen { transition: opacity 0.2s ease; transform: none; }
  .theme-card, .theme-card.swap, .player-list li, .captain-badge.crowning .crown { animation: none; }
  .secret-number.glow { animation: none; }
  .howto-body { animation: none; }
  .howto-chevron { transition: none; }
  * { scroll-behavior: auto; }
}
