/* ================= Zackboing – gemeinsames Design ================= */

:root {
  --bg1: #2e0a5c;
  --bg2: #1a0b3d;
  --card: #ffffff;
  --ink: #1f1235;
  --muted: #6b6480;
  --accent: #8b32ff;
  --accent2: #ff2ea6;
  --ok: #26b563;
  --bad: #e01d3c;
  --gold: #ffd23e;
  --a-red: #e21b3c;
  --a-blue: #1368ce;
  --a-yellow: #d89e00;
  --a-green: #26890c;
  --radius: 16px;
  --shadow: 0 8px 0 rgba(0, 0, 0, 0.22);
}

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

html, body { height: 100%; }

body {
  font-family: 'Segoe UI', 'Trebuchet MS', system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, #55159e 0%, var(--bg1) 45%, var(--bg2) 100%);
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
}

/* animierte Hintergrund-Blasen für den Spiel-Look */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.14;
  z-index: 0;
  pointer-events: none;
}
body::before {
  width: 44vmin; height: 44vmin;
  background: #ff2ea6;
  left: -10vmin; bottom: -10vmin;
  animation: float 11s ease-in-out infinite;
}
body::after {
  width: 34vmin; height: 34vmin;
  background: #2ec9ff;
  right: -8vmin; top: 12vh;
  animation: float 9s ease-in-out infinite reverse;
}
@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5vmin) scale(1.08); }
}

.screen { display: none; position: relative; z-index: 1; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

.center { align-items: center; justify-content: center; text-align: center; padding: 24px; }

h1.logo {
  font-size: clamp(2.4rem, 7vw, 4.2rem);
  letter-spacing: 0.06em;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
  background: linear-gradient(90deg, #ffd23e, #ff2ea6, #2ec9ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,0.35));
}

.tagline { opacity: 0.85; margin-top: 6px; font-size: 1.05rem; }

/* ------------------------------- Karten & Formulare */

.card {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  width: min(430px, 92vw);
  margin-top: 26px;
}

.card h2 { margin-bottom: 14px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: 13px 15px;
  border: 3px solid #d8d2e8;
  border-radius: 10px;
  font-size: 1.05rem;
  font-family: inherit;
  margin-bottom: 12px;
  background: #faf8ff;
  color: var(--ink);
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

input.pin-input {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.35em;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 12px;
  padding: 14px 26px;
  font-size: 1.1rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, var(--accent), #6a1fd0);
  box-shadow: 0 5px 0 #4a1596;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
  text-decoration: none;
  user-select: none;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #4a1596; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.big { width: 100%; font-size: 1.3rem; padding: 16px; }
.btn.pink { background: linear-gradient(180deg, var(--accent2), #c40e77); box-shadow: 0 5px 0 #8f0a57; }
.btn.pink:active { box-shadow: 0 1px 0 #8f0a57; }
.btn.green { background: linear-gradient(180deg, #2fd06f, #1d9b4e); box-shadow: 0 5px 0 #147038; }
.btn.green:active { box-shadow: 0 1px 0 #147038; }
.btn.ghost {
  background: transparent;
  border: 3px solid rgba(255,255,255,0.5);
  box-shadow: none;
  color: #fff;
}
.btn.ghost:active { transform: translateY(2px); }
.btn.small { padding: 8px 14px; font-size: 0.92rem; border-radius: 9px; }
.btn.danger { background: linear-gradient(180deg, #ff5468, #d21830); box-shadow: 0 5px 0 #93101f; }
.btn.danger:active { box-shadow: 0 1px 0 #93101f; }

.error-msg {
  background: #ffe3e8;
  color: #b00020;
  border-radius: 9px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-weight: 600;
  display: none;
}
.error-msg.show { display: block; animation: shake 0.4s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

.link-row { margin-top: 14px; font-size: 0.95rem; color: var(--muted); }
.link-row a, a.plain { color: var(--accent); font-weight: 700; cursor: pointer; text-decoration: none; }

/* ------------------------------- Antwort-Buttons (Spieler + Host) */

.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* alle Zeilen gleich hoch – auch wenn das Raster auf dem Handy einspaltig wird */
  grid-auto-rows: 1fr;
  gap: 12px;
  width: 100%;
  flex: 1;
  padding: 12px;
}

.answer-btn {
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: clamp(1.1rem, 3.4vw, 1.7rem);
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.08s, filter 0.1s, opacity 0.3s;
  text-align: left;
  word-break: break-word;
}
.answer-btn:active { transform: scale(0.97); }
.answer-btn .shape { font-size: 1.4em; flex-shrink: 0; }
.answer-btn.c0 { background: var(--a-red); }
.answer-btn.c1 { background: var(--a-blue); }
.answer-btn.c2 { background: var(--a-yellow); }
.answer-btn.c3 { background: var(--a-green); }
.answer-btn.dimmed { opacity: 0.25; filter: grayscale(0.6); }
.answer-btn.reveal-correct {
  animation: pulse 0.7s ease-in-out infinite;
  outline: 5px solid #fff;
}
.answer-btn .checkmark { margin-left: auto; font-size: 1.3em; }

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

/* ------------------------------- Host: Lobby */

.host-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px;
  flex-wrap: wrap;
}

.pin-banner {
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 30px;
  text-align: center;
}
.pin-banner .label { font-size: 1rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.pin-banner .pin { font-size: clamp(2.6rem, 6vw, 4.6rem); font-weight: 900; letter-spacing: 0.12em; line-height: 1.1; }

.qr-box {
  background: #fff;
  padding: 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  color: var(--ink);
}
.qr-box img { display: block; width: clamp(130px, 18vw, 210px); height: auto; border-radius: 8px; }
.qr-box .url { font-size: 0.85rem; font-weight: 700; margin-top: 6px; color: var(--muted); word-break: break-all; max-width: 220px; }

.player-count-badge {
  font-size: 1.3rem;
  font-weight: 800;
  background: rgba(255,255,255,0.14);
  padding: 10px 20px;
  border-radius: 999px;
}

.lobby-players {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-content: flex-start;
  padding: 20px;
  flex: 1;
}
.lobby-chip {
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  font-weight: 800;
  font-size: 1.15rem;
  border-radius: 999px;
  padding: 9px 20px;
  display: flex;
  align-items: center;
  gap: 9px;
  animation: popIn 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
  cursor: pointer;
}
.lobby-chip:hover { background: #ffd9d9; text-decoration: line-through; }
.lobby-chip .avatar { font-size: 1.5rem; }

@keyframes popIn {
  from { transform: scale(0.2); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.waiting-hint { text-align: center; opacity: 0.75; font-size: 1.1rem; padding-bottom: 8px; }

/* ------------------------------- Host: Frage */

.q-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  gap: 16px;
}
.q-counter { font-weight: 800; font-size: 1.2rem; background: rgba(255,255,255,0.14); border-radius: 999px; padding: 8px 18px; }

.q-text {
  background: #fff;
  color: var(--ink);
  font-size: clamp(1.5rem, 4vw, 2.6rem);
  font-weight: 800;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 34px);
  margin: 0 24px;
  text-align: center;
}

.q-middle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 40px;
}
.timer-circle {
  width: clamp(70px, 10vw, 110px);
  height: clamp(70px, 10vw, 110px);
  border-radius: 50%;
  background: var(--accent2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.7rem, 3.4vw, 2.7rem);
  font-weight: 900;
  box-shadow: 0 6px 0 rgba(0,0,0,0.28);
}
.timer-circle.hurry { animation: pulse 0.5s infinite; background: var(--bad); }
.answer-count { text-align: center; }
.answer-count .num { font-size: clamp(1.8rem, 3.6vw, 3rem); font-weight: 900; }
.answer-count .lbl { opacity: 0.8; font-weight: 700; }

.timer-bar-wrap { height: 10px; background: rgba(255,255,255,0.15); border-radius: 999px; margin: 0 24px 8px; overflow: hidden; }
.timer-bar { height: 100%; background: linear-gradient(90deg, #ffd23e, var(--accent2)); border-radius: 999px; transition: width 0.2s linear; }

/* Vorbereitungs-Countdown */
.prepare-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 24px; }
.prepare-count {
  font-size: clamp(5rem, 16vw, 11rem);
  font-weight: 900;
  animation: popIn 0.5s;
  text-shadow: 0 8px 0 rgba(0,0,0,0.3);
}

/* ------------------------------- Host: Ergebnisse */

.chart {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(14px, 4vw, 44px);
  flex: 1;
  padding: 26px 26px 8px;
  min-height: 200px;
}
.chart .bar-col { display: flex; flex-direction: column; align-items: center; gap: 8px; width: clamp(70px, 12vw, 150px); }
.chart .bar {
  width: 100%;
  border-radius: 10px 10px 0 0;
  min-height: 6px;
  transition: height 0.9s cubic-bezier(0.2, 1.3, 0.4, 1);
  box-shadow: inset 0 -5px 0 rgba(0,0,0,0.22);
}
.chart .bar.c0 { background: var(--a-red); }
.chart .bar.c1 { background: var(--a-blue); }
.chart .bar.c2 { background: var(--a-yellow); }
.chart .bar.c3 { background: var(--a-green); }
.chart .bar-col.wrong .bar { opacity: 0.35; }
.chart .count { font-weight: 900; font-size: 1.5rem; }
.chart .shape-lbl { font-size: 1.7rem; }
.chart .bar-col .tick { font-size: 1.5rem; height: 1.6rem; }

.leaderboard {
  width: min(680px, 92vw);
  margin: 14px auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lb-row {
  background: rgba(255,255,255,0.95);
  color: var(--ink);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  font-weight: 800;
  font-size: 1.2rem;
  box-shadow: 0 4px 0 rgba(0,0,0,0.2);
  animation: slideIn 0.5s backwards;
}
.lb-row:nth-child(1) { animation-delay: 0.4s; background: linear-gradient(90deg, #fff3c4, #ffe27a); }
.lb-row:nth-child(2) { animation-delay: 0.3s; }
.lb-row:nth-child(3) { animation-delay: 0.2s; }
.lb-row:nth-child(4) { animation-delay: 0.1s; }
.lb-row .rank { width: 2em; text-align: center; font-size: 1.3rem; }
.lb-row .score { margin-left: auto; font-variant-numeric: tabular-nums; }
.lb-row .streak-flame { font-size: 1rem; color: #ff7a00; }

@keyframes slideIn {
  from { transform: translateX(-40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.host-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px; }

/* ------------------------------- Podium */

.podium-wrap { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: clamp(10px, 3vw, 30px); padding: 20px 20px 0; }
.podium-col { display: flex; flex-direction: column; align-items: center; gap: 10px; width: clamp(100px, 22vw, 230px); }
.podium-col .avatar { font-size: clamp(2.4rem, 6vw, 4.4rem); animation: bounce 1.6s ease-in-out infinite; }
.podium-col .pname { font-weight: 900; font-size: clamp(1rem, 2.6vw, 1.6rem); text-align: center; word-break: break-word; }
.podium-col .pscore { font-weight: 700; opacity: 0.9; font-variant-numeric: tabular-nums; }
.podium-block {
  width: 100%;
  border-radius: 14px 14px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-size: clamp(2rem, 5vw, 3.6rem);
  padding-top: 12px;
  box-shadow: inset 0 -8px 0 rgba(0,0,0,0.25);
  animation: growUp 1s cubic-bezier(0.2, 1.3, 0.4, 1) backwards;
}
.podium-col.p1 .podium-block { height: clamp(150px, 26vh, 260px); background: linear-gradient(180deg, #ffd23e, #e0a800); animation-delay: 1.1s; }
.podium-col.p2 .podium-block { height: clamp(105px, 18vh, 185px); background: linear-gradient(180deg, #cfd8e6, #97a5bb); animation-delay: 0.6s; }
.podium-col.p3 .podium-block { height: clamp(75px, 13vh, 130px); background: linear-gradient(180deg, #e8a66b, #b9713a); animation-delay: 0.2s; }
.podium-col .avatar, .podium-col .pname, .podium-col .pscore { animation-name: bounce, fadeIn; }

@keyframes growUp { from { transform: scaleY(0); transform-origin: bottom; } to { transform: scaleY(1); transform-origin: bottom; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.final-list { width: min(560px, 92vw); margin: 16px auto 30px; }

/* ------------------------------- Spieler-Screens */

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(0,0,0,0.25);
  font-weight: 800;
  gap: 10px;
}
.player-header .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.player-header .who span.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-header .pts { font-variant-numeric: tabular-nums; background: rgba(255,255,255,0.15); border-radius: 999px; padding: 5px 14px; }

.big-emoji { font-size: clamp(4rem, 18vw, 7rem); animation: bounce 1.8s infinite; }
.result-full { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.result-full.good { background: linear-gradient(180deg, #1f9d55, #167a41); }
.result-full.bad-bg { background: linear-gradient(180deg, #d21830, #9c1023); }
.result-full h2 { font-size: clamp(1.9rem, 7vw, 2.8rem); text-shadow: 0 3px 0 rgba(0,0,0,0.25); }
.points-gained { font-size: clamp(1.4rem, 6vw, 2rem); font-weight: 900; }
.streak-banner {
  background: rgba(0,0,0,0.25);
  border-radius: 999px;
  padding: 8px 22px;
  font-weight: 800;
  font-size: 1.15rem;
}
.rank-info { opacity: 0.92; font-weight: 700; font-size: 1.05rem; }

/* ------------------------------- Lehrer-Dashboard & Editor */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(0,0,0,0.25);
  gap: 12px;
  flex-wrap: wrap;
}
.topbar .brand { font-size: 1.5rem; font-weight: 900; letter-spacing: 0.05em; }
.topbar .brand a { color: #fff; text-decoration: none; }
.topbar .user-info { display: flex; align-items: center; gap: 12px; font-weight: 700; }

.content { width: min(980px, 94vw); margin: 26px auto; position: relative; z-index: 1; flex: 1; }

.quiz-list { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.quiz-item {
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.quiz-item .meta { flex: 1; min-width: 180px; }
.quiz-item h3 { font-size: 1.25rem; }
.quiz-item .sub { color: var(--muted); font-size: 0.92rem; margin-top: 3px; }
.quiz-item .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  opacity: 0.85;
  font-size: 1.15rem;
}
.empty-state .big-emoji { display: block; margin-bottom: 10px; animation: none; }

/* Editor */
.editor-card { background: #fff; color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 18px; }
.editor-card label { font-weight: 700; font-size: 0.92rem; display: block; margin-bottom: 5px; color: var(--muted); }

.question-card { position: relative; }
.question-card .q-num {
  position: absolute;
  top: -12px;
  left: 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.9rem;
}
.answer-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.answer-edit {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 8px 10px;
  color: #fff;
}
.answer-edit.c0 { background: var(--a-red); }
.answer-edit.c1 { background: var(--a-blue); }
.answer-edit.c2 { background: var(--a-yellow); }
.answer-edit.c3 { background: var(--a-green); }
.answer-edit input[type="text"] { margin: 0; border: none; background: rgba(255,255,255,0.94); font-size: 0.98rem; padding: 9px 11px; }
.answer-edit input[type="radio"] { width: 22px; height: 22px; accent-color: #fff; cursor: pointer; flex-shrink: 0; }
.q-settings { display: flex; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.q-settings > div { flex: 1; min-width: 130px; }
.q-toolbar { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; flex-wrap: wrap; }
.editor-footer { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin: 20px 0 40px; }

.muted-note { color: var(--muted); font-size: 0.9rem; }

/* Sound-Schalter */
.sound-toggle {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 50;
  background: rgba(255,255,255,0.92);
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.25);
}

/* Konfetti-Canvas */
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

@media (max-width: 640px) {
  .answers-grid { grid-template-columns: 1fr; }
  .q-middle { padding: 10px 20px; }
  .answer-edit-grid { grid-template-columns: 1fr; }
}

/* ================= Version 2: Medien, Fragetypen, Admin ================= */

/* Medienanzeige (Host + Editor) */
.q-media { display: flex; justify-content: center; padding: 10px 24px 0; }
.q-media img { max-height: 30vh; max-width: min(640px, 90vw); border-radius: 12px; box-shadow: var(--shadow); background: #fff; }
.q-media video { max-height: 32vh; max-width: min(720px, 90vw); border-radius: 12px; box-shadow: var(--shadow); }
.q-media audio { width: min(480px, 88vw); }
.answer-btn img.answer-media { height: 3.2em; border-radius: 8px; background: #fff; padding: 2px; }

.type-badge {
  display: inline-block;
  background: rgba(255,255,255,0.16);
  border-radius: 999px;
  padding: 6px 16px;
  font-weight: 800;
  font-size: 0.95rem;
}

/* ---------- Spieler: Freitext / Wortwolke / Brainstorming */
.input-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 22px; }
.input-stage input[type="text"] {
  font-size: 1.3rem;
  text-align: center;
  border-width: 4px;
}
.input-stage .hint { opacity: 0.8; text-align: center; }
.idea-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 560px; }
.idea-chip {
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  animation: popIn 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}
.idea-chip .avatar { font-size: 1.2em; }

/* ---------- Spieler: Schieberegler */
.slider-stage input[type="range"] {
  width: min(520px, 86vw);
  accent-color: var(--accent2);
  height: 40px;
  cursor: pointer;
}
.slider-value {
  font-size: clamp(2.6rem, 10vw, 4rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 0 rgba(0,0,0,0.3);
}
.slider-minmax { display: flex; justify-content: space-between; width: min(520px, 86vw); font-weight: 700; opacity: 0.8; }

/* ---------- Spieler: Skala */
.scale-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 560px; }
.scale-btn {
  width: 64px; height: 64px;
  border-radius: 14px;
  border: none;
  font-size: 1.5rem;
  font-weight: 900;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, var(--accent), #6a1fd0);
  box-shadow: 0 4px 0 #4a1596;
  transition: transform 0.08s;
}
.scale-btn:active { transform: translateY(3px); }
.scale-labels { display: flex; justify-content: space-between; width: min(540px, 88vw); opacity: 0.85; font-weight: 700; gap: 20px; }

/* ---------- Spieler + Host: Puzzle */
.order-list { display: flex; flex-direction: column; gap: 10px; width: min(560px, 92vw); margin: 0 auto; }
.order-item {
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 800;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.2);
  transition: transform 0.15s;
}
.order-item .pos {
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  min-width: 2em;
  text-align: center;
  padding: 3px 0;
  flex-shrink: 0;
}
.order-item .txt { flex: 1; word-break: break-word; }
.order-item .move { display: flex; gap: 6px; }
.order-item .move button {
  border: none;
  background: #ece7f8;
  color: var(--ink);
  border-radius: 8px;
  width: 42px; height: 42px;
  font-size: 1.2rem;
  cursor: pointer;
  font-weight: 900;
}
.order-item .move button:active { background: var(--accent); color: #fff; }
.order-item.correct-pos { outline: 4px solid var(--ok); }

/* ---------- Host: Wortwolke */
.wordcloud {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  justify-content: center;
  gap: 6px 18px;
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}
.wordcloud span {
  font-weight: 900;
  line-height: 1.15;
  animation: popIn 0.5s backwards;
  text-shadow: 0 3px 0 rgba(0,0,0,0.25);
  word-break: break-word;
}

/* ---------- Host: Skalen-/Umfrage-Ergebnis */
.scale-result { width: min(760px, 92vw); margin: 10px auto; display: flex; flex-direction: column; gap: 8px; }
.scale-row { display: flex; align-items: center; gap: 12px; font-weight: 800; }
.scale-row .val { width: 2.2em; text-align: right; font-size: 1.2rem; }
.scale-row .track { flex: 1; background: rgba(255,255,255,0.12); border-radius: 999px; height: 26px; overflow: hidden; }
.scale-row .fill { height: 100%; background: linear-gradient(90deg, #2ec9ff, var(--accent2)); border-radius: 999px; transition: width 0.8s cubic-bezier(0.2,1.3,0.4,1); min-width: 0; }
.scale-row .cnt { width: 2.2em; }
.big-average { text-align: center; font-size: 1.5rem; font-weight: 900; margin: 8px 0; }
.big-average .num { font-size: 2.2rem; color: #ffd23e; }

/* ---------- Host: Freitext-Ergebnis */
.freetext-results { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 16px 24px; }
.freetext-chip {
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 800;
  font-size: 1.15rem;
  display: flex; align-items: center; gap: 8px;
  animation: popIn 0.4s backwards;
}
.freetext-chip.right { background: #d3f5e0; outline: 3px solid var(--ok); }
.freetext-chip .cnt { background: rgba(0,0,0,0.12); border-radius: 999px; padding: 2px 10px; font-size: 0.9em; }

/* ---------- Host: Schätzfrage-Ergebnis */
.number-line-wrap { width: min(860px, 92vw); margin: 20px auto; }
.number-line { position: relative; height: 90px; }
.number-line .axis { position: absolute; left: 0; right: 0; top: 44px; height: 8px; background: rgba(255,255,255,0.25); border-radius: 999px; }
.number-line .tol {
  position: absolute; top: 40px; height: 16px;
  background: rgba(38, 224, 127, 0.45);
  border-radius: 999px;
}
.number-line .dot {
  position: absolute; top: 30px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #2ec9ff;
  border: 2px solid #fff;
  transform: translateX(-50%);
  animation: dropIn 0.6s backwards;
}
.number-line .marker {
  position: absolute; top: -6px;
  transform: translateX(-50%);
  text-align: center;
  font-weight: 900;
}
.number-line .marker .flag { font-size: 1.6rem; }
.number-line .ends { display: flex; justify-content: space-between; font-weight: 700; opacity: 0.8; margin-top: 4px; }
@keyframes dropIn { from { transform: translate(-50%, -40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ---------- Editor */
.type-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 12px; }
.type-pick-btn {
  border: 3px solid #e4def4;
  background: #faf8ff;
  color: var(--ink);
  border-radius: 12px;
  padding: 14px 10px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.98rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s, transform 0.08s;
}
.type-pick-btn:hover { border-color: var(--accent); transform: translateY(-2px); }
.type-pick-btn .icon { display: block; font-size: 1.8rem; margin-bottom: 4px; }
.type-pick-btn .sub { display: block; font-weight: 600; font-size: 0.78rem; color: var(--muted); margin-top: 3px; }

.q-type-chip {
  position: absolute;
  top: -12px;
  right: 18px;
  background: #3d2b66;
  color: #fff;
  font-weight: 800;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.85rem;
}

.media-slot { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; flex-wrap: wrap; }
.media-slot .preview { position: relative; }
.media-slot img { height: 74px; border-radius: 10px; border: 3px solid #e4def4; background: #fff; }
.media-slot .file-chip { background: #ece7f8; color: var(--ink); border-radius: 10px; padding: 8px 14px; font-weight: 700; font-size: 0.9rem; }
.btn.tiny { padding: 6px 10px; font-size: 0.82rem; border-radius: 8px; }
.answer-edit .btn.tiny { flex-shrink: 0; }
.answer-edit img.ans-media-preview { height: 40px; border-radius: 6px; background: #fff; }

.order-edit-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.order-edit-row .pos { font-weight: 900; color: var(--muted); min-width: 1.6em; }
.order-edit-row input { margin: 0; }

/* Galerie-/Medien-Auswahl (Overlay) */
.overlay {
  position: fixed; inset: 0;
  background: rgba(16, 5, 40, 0.75);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay-card {
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  width: min(860px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.overlay-card h3 { margin-bottom: 12px; }
.overlay-card .close-x { position: absolute; } 
.gallery-search { display: flex; gap: 8px; }
.gallery-search input { margin: 0; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  overflow-y: auto;
  margin-top: 14px;
  padding: 2px;
}
.gallery-grid button {
  border: 3px solid transparent;
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  background: #f2eefc;
  overflow: hidden;
  aspect-ratio: 1;
}
.gallery-grid button:hover { border-color: var(--accent); }
.gallery-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 10px; }
.gallery-status { color: var(--muted); font-weight: 600; }

/* ---------- Admin */
.admin-table { width: 100%; border-collapse: collapse; background: #fff; color: var(--ink); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.admin-table th, .admin-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid #eee7fb; }
.admin-table th { background: #f4f0fd; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.admin-table td .btn { margin-right: 6px; }
.role-pill { border-radius: 999px; padding: 3px 12px; font-weight: 800; font-size: 0.82rem; }
.role-pill.admin { background: #ffe3f1; color: #c40e77; }
.role-pill.teacher { background: #e5f0ff; color: #1368ce; }
.settings-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.settings-row label.inline { font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 8px; margin: 0; }
.settings-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.settings-row input[type="text"] { margin: 0; max-width: 420px; }

@media (max-width: 700px) {
  .admin-table { display: block; overflow-x: auto; }
}

/* ================= Version 3: Fächer, Freigabe, Bibliothek ================= */

.tab-bar { display: flex; gap: 8px; }
.tab-btn {
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 11px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}
.tab-btn:hover { background: rgba(255,255,255,0.22); }
.tab-btn.active { background: #fff; color: var(--ink); }

.subject-badge {
  display: inline-block;
  background: #e5f0ff;
  color: #1368ce;
  border-radius: 999px;
  padding: 3px 12px;
  font-weight: 800;
  font-size: 0.8rem;
  margin-right: 6px;
}
.shared-badge {
  display: inline-block;
  background: #d3f5e0;
  color: #147038;
  border-radius: 999px;
  padding: 3px 12px;
  font-weight: 800;
  font-size: 0.8rem;
}

.lib-filter { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.lib-filter select { max-width: 260px; margin: 0; }
.lib-filter input { flex: 1; min-width: 200px; margin: 0; }

.lib-subject-header {
  font-size: 1.15rem;
  font-weight: 900;
  margin: 22px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.lib-subject-header .line { flex: 1; height: 2px; background: rgba(255,255,255,0.18); border-radius: 999px; }

label.inline-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  margin: 0;
  font-size: 1rem;
}
label.inline-check input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }

/* ============================================================
   V4: Verbindungsstabilität (Reconnect)
   ============================================================ */

/* Host-Banner bei kurzem Verbindungsabbruch */
#offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 400;
  padding: 12px 20px;
  text-align: center;
  font-weight: 700;
  background: #ffb020;
  color: #201500;
  animation: pulse 1.4s ease-in-out infinite;
}

/* Lobby: kurz getrennte Spieler bleiben sichtbar, aber ausgegraut */
.lobby-chip.offline {
  opacity: 0.4;
  filter: grayscale(0.8);
}

/* Import/Export im Dashboard */
.import-bar { margin-top: 10px; }
.import-bar a { color: var(--accent); font-weight: 700; }
.import-result {
  margin-top: 12px;
  background: #d3f5e0;
  color: #147038;
  border-radius: 9px;
  padding: 10px 14px;
  font-weight: 600;
}
.import-result.warn { background: #fff3cd; color: #7a5200; }
.import-result.error { background: #ffe3e8; color: #b00020; }
.import-result ul { margin: 6px 0 0 18px; font-weight: 500; }

/* Lobby: Avatar antippen → neuer Avatar */
.avatar-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
  padding: 6px 14px;
  border-radius: 20px;
  -webkit-tap-highlight-color: transparent;
}
.avatar-btn:active { transform: scale(0.9); animation: none; }
.avatar-btn.spin { animation: avatarSpin 0.4s ease-out; }
@keyframes avatarSpin {
  0% { transform: rotate(0) scale(1); }
  50% { transform: rotate(180deg) scale(1.25); }
  100% { transform: rotate(360deg) scale(1); }
}
