/* =============================================================
   Quizfunke – Gestaltung
   ============================================================= */
:root {
  --night: #14213d;
  --night-2: #1f3a5f;
  --spark: #ff7a1a;
  --spark-dark: #e0620a;
  --ink: #1c1f2a;
  --muted: #6b7280;
  --line: #e3e6ee;
  --paper: #f4f5f9;
  --ok: #22a86a;
  --bad: #e5484d;
  --c0: #ef5b5b;  /* Antwort A */
  --c1: #1e9e98;  /* Antwort B */
  --c2: #e9a21b;  /* Antwort C */
  --c3: #7a5cc0;  /* Antwort D */
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 33, 61, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #fff;
  background: linear-gradient(160deg, var(--night), var(--night-2));
  min-height: 100vh;
  min-height: 100dvh;
}
body.light { background: var(--paper); color: var(--ink); }

a { color: inherit; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }

/* ---------- Knöpfe & Formulare ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: .65em 1.1em; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: transform .05s, background .15s;
}
.btn:hover { background: #f0f2f7; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--spark); border-color: var(--spark); color: #fff; }
.btn.primary:hover { background: var(--spark-dark); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost-danger { color: var(--bad); }
.btn.big { font-size: 1.25rem; padding: .8em 1.6em; }
.btn.small { padding: .35em .7em; font-size: .9rem; }

label { display: block; font-weight: 600; margin-bottom: 1rem; }
input[type=text], input[type=email], input[type=password], textarea, select {
  display: block; width: 100%; margin-top: .35rem; font: inherit; font-weight: 400;
  padding: .7em .8em; border: 1px solid #cfd4e0; border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 4.5em; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--spark); outline-offset: 1px; border-color: transparent; }

.error { color: var(--bad); font-weight: 600; min-height: 1.2em; }
.muted { color: var(--muted); }
.hint { font-size: .9rem; color: var(--muted); font-weight: 400; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.2rem; background: var(--night); color: #fff;
}
.logo { font-weight: 800; font-size: 1.3rem; text-decoration: none; letter-spacing: .3px; }
.logo span { color: var(--spark); }
.topbar nav { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.topbar nav a, .topbar nav button { color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.25); }
.topbar nav a:hover, .topbar nav button:hover { background: rgba(255,255,255,.1); }

.container { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

.card {
  background: #fff; color: var(--ink); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head h1 { margin: 0; }

/* ---------- Startseite (Beitreten) ---------- */
.join-page { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 1rem; }
.join-box { width: 100%; max-width: 380px; text-align: center; }
.join-box .logo { font-size: 2.4rem; display: block; margin-bottom: 1.2rem; }
.join-box .card { text-align: left; }
.join-box input { font-size: 1.3rem; text-align: center; font-weight: 700; }
.join-box .btn { width: 100%; }
.privacy-note { font-size: .85rem; opacity: .8; margin-top: 1.2rem; line-height: 1.4; }
.footer-links { margin-top: 1rem; font-size: .9rem; opacity: .8; }
.footer-links a { margin: 0 .5rem; }

/* ---------- Lehrerbereich ---------- */
.auth-box { max-width: 420px; margin: 2rem auto; }
.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; }
.tabs button { flex: 1; border: none; background: #eef0f5; padding: .7em; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); }
.tabs button.active { background: var(--night); color: #fff; }

.quiz-list { display: grid; gap: .8rem; }
.quiz-card { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.quiz-card h3 { margin-bottom: .2em; }
.quiz-card p { margin: 0 0 .3em; color: var(--muted); }
.quiz-card .meta { font-size: .85rem; color: var(--muted); }
.quiz-card .actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* Editor */
.question .q-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; flex-wrap: wrap; }
.question .q-head strong { font-size: 1.1rem; }
.tag { background: #eef0f5; border-radius: 99px; padding: .15em .7em; font-size: .8rem; font-weight: 600; }
.q-tools { margin-left: auto; display: flex; gap: .3rem; }
.q-settings { display: flex; gap: 1rem; flex-wrap: wrap; }
.q-settings label { flex: 1; min-width: 150px; }
.answers-edit { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.answer-edit {
  display: flex; align-items: center; gap: .5rem; padding: .45rem; border-radius: 10px;
  border: 2px solid transparent; background: #f6f7fa; margin: 0; font-weight: 400;
}
.answer-edit input[type=text] { margin: 0; flex: 1; }
.answer-edit .letter { width: 2rem; height: 2rem; flex: none; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 800; }
.answer-edit .correct-toggle { display: flex; align-items: center; gap: .3rem; margin: 0; font-size: .85rem; white-space: nowrap; cursor: pointer; }
.answer-edit.is-correct { border-color: var(--ok); background: #eaf8f0; }
.add-row { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.save-bar {
  position: sticky; bottom: 0; background: rgba(244,245,249,.95); backdrop-filter: blur(6px);
  padding: .8rem 0; display: flex; gap: .6rem; justify-content: flex-end; align-items: center; border-top: 1px solid var(--line);
}
.save-bar .error { margin-right: auto; }

.bg-c0 { background: var(--c0); } .bg-c1 { background: var(--c1); }
.bg-c2 { background: var(--c2); } .bg-c3 { background: var(--c3); }

/* ---------- Beamer-Ansicht (Lehrkraft) ---------- */
.host { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.host-bar { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1.2rem; gap: 1rem; }
.host-bar .title { font-weight: 700; opacity: .85; }
.host-main { flex: 1; display: flex; flex-direction: column; padding: 1rem 1.5rem 1.5rem; gap: 1.2rem; }
.host-footer { display: flex; justify-content: flex-end; gap: .8rem; padding: 0 1.5rem 1.5rem; }

.lobby-head { text-align: center; }
.lobby-head .join-url { font-size: 1.4rem; opacity: .9; }
.lobby-head .join-url b { color: var(--spark); }
.pin-big { font-size: clamp(3rem, 10vw, 7rem); font-weight: 900; letter-spacing: .08em; line-height: 1.1; }
.lobby-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.lobby-row .count { font-size: 1.5rem; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; align-content: flex-start; }
.chip {
  background: rgba(255,255,255,.14); border: none; color: #fff; font: inherit; font-size: 1.2rem; font-weight: 700;
  padding: .45em 1em; border-radius: 99px; cursor: pointer; animation: pop .25s ease-out;
}
.chip:hover { background: var(--bad); text-decoration: line-through; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.q-meta { display: flex; justify-content: space-between; align-items: center; gap: 1rem; font-weight: 700; opacity: .9; }
.q-text {
  background: #fff; color: var(--ink); border-radius: var(--radius); padding: 1.4rem;
  font-size: clamp(1.5rem, 3.5vw, 2.6rem); font-weight: 800; text-align: center;
}
.timer {
  width: 5.5rem; height: 5.5rem; border-radius: 50%; background: var(--spark); color: #fff;
  display: grid; place-items: center; font-size: 2.2rem; font-weight: 900; flex: none;
}
.timer.low { background: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.q-center { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.answered-box { text-align: center; font-weight: 700; }
.answered-box .n { font-size: 2.5rem; font-weight: 900; display: block; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; flex: 1; }
.tile {
  display: flex; align-items: center; gap: 1rem; border-radius: var(--radius); padding: 1rem 1.2rem;
  font-size: clamp(1.1rem, 2.4vw, 1.8rem); font-weight: 700; color: #fff; min-height: 5rem; position: relative;
  transition: opacity .3s, transform .3s;
}
.tile .letter { background: rgba(255,255,255,.25); border-radius: 10px; width: 2.6rem; height: 2.6rem; flex: none; display: grid; place-items: center; font-weight: 900; }
.tile .text { flex: 1; }
.tile .count { font-size: 1.6rem; font-weight: 900; }
.tile.dim { opacity: .3; }
.tile.right { transform: scale(1.02); box-shadow: 0 0 0 4px #fff; }
.tile.right .text::after { content: '  ✓'; }

.scoreboard { max-width: 760px; width: 100%; margin: 0 auto; display: grid; gap: .6rem; }
.score-row {
  display: flex; align-items: center; gap: 1rem; background: #fff; color: var(--ink);
  border-radius: 12px; padding: .8rem 1.2rem; font-size: 1.4rem; font-weight: 700; animation: slide .35s ease-out both;
}
.score-row .rank { width: 2.2rem; color: var(--muted); }
.score-row .name { flex: 1; }
@keyframes slide { from { transform: translateX(-30px); opacity: 0; } }
.score-row:nth-child(2) { animation-delay: .07s; } .score-row:nth-child(3) { animation-delay: .14s; }
.score-row:nth-child(4) { animation-delay: .21s; } .score-row:nth-child(5) { animation-delay: .28s; }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 1rem; margin-top: 1rem; }
.podium .place { width: min(30%, 220px); text-align: center; }
.podium .name { font-size: 1.5rem; font-weight: 800; margin-bottom: .2rem; word-break: break-word; }
.podium .pts { opacity: .85; margin-bottom: .5rem; }
.podium .block {
  border-radius: 12px 12px 0 0; display: grid; place-items: center; font-size: 3rem; font-weight: 900;
  animation: rise .7s ease-out both;
}
.podium .p1 .block { height: 220px; background: #f4c430; color: #6b4e00; animation-delay: .9s; }
.podium .p2 .block { height: 160px; background: #cfd6e3; color: #44506a; animation-delay: .5s; }
.podium .p3 .block { height: 120px; background: #d99058; color: #5b3112; animation-delay: .1s; }
@keyframes rise { from { transform: scaleY(0); transform-origin: bottom; } to { transform: scaleY(1); transform-origin: bottom; } }
.center-msg { text-align: center; margin: auto; max-width: 600px; }

/* ---------- Handy-Ansicht (Schüler*innen) ---------- */
.play { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.play-main { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 1rem; gap: 1rem; text-align: center; }
.play-bar { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1rem; background: rgba(0,0,0,.2); font-weight: 700; gap: .5rem; }
.play-bar .score { background: rgba(255,255,255,.15); padding: .2em .8em; border-radius: 99px; }
.play-bar button { background: transparent; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 8px; padding: .3em .7em; font: inherit; font-size: .85rem; cursor: pointer; }
.play .big-emoji { font-size: 4rem; }
.play h2 { font-size: 1.8rem; }
.play .q-small { font-size: 1.15rem; font-weight: 700; background: rgba(255,255,255,.1); padding: .8rem; border-radius: 12px; }
.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; flex: 1; max-height: 60vh; }
.answer-grid.two { grid-template-columns: 1fr; }
.answer-btn {
  border: none; border-radius: var(--radius); color: #fff; font: inherit; font-size: 1.2rem; font-weight: 800;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; padding: .8rem;
  cursor: pointer; min-height: 6rem; box-shadow: 0 4px 0 rgba(0,0,0,.25); word-break: break-word;
}
.answer-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.answer-btn .letter { font-size: 2rem; font-weight: 900; }
.play.result-good { background: linear-gradient(160deg, #1a8a57, #22a86a); }
.play.result-bad { background: linear-gradient(160deg, #b8323a, #e5484d); }
.mini-timer { font-weight: 800; }
.spinner { width: 2.5rem; height: 2.5rem; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Meldungen ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: #fff; padding: .8em 1.2em; border-radius: 10px; font-weight: 600;
  transition: all .25s; z-index: 100; max-width: calc(100% - 2rem);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--bad); }
.toast-ok { background: var(--ok); }

/* ---------- Textseiten (Datenschutz) ---------- */
.prose { max-width: 760px; line-height: 1.6; }
.prose h2 { margin-top: 1.6em; }
.prose .todo { background: #fff4d6; border-left: 4px solid var(--c2); padding: .2em .5em; }

@media (max-width: 640px) {
  .answers-edit, .tiles { grid-template-columns: 1fr; }
  .host-main { padding: 1rem; }
  .q-center { flex-direction: column; }
}


/* Kontomenü oben rechts */
.account-menu { position: relative; display: inline-block; }
.account-btn { white-space: nowrap; }
.account-drop {
  position: absolute; right: 0; top: calc(100% + .4rem); z-index: 60; min-width: 220px; background: #fff; color: var(--ink);
  border-radius: 16px; box-shadow: 0 12px 32px rgba(40,30,10,.2); border: 1px solid #f0e8d6; padding: .4rem; display: grid;
}
.account-drop[hidden] { display: none; }
.account-drop a, .account-drop button {
  display: block; text-align: left; padding: .6rem .8rem; border-radius: 10px; text-decoration: none; color: var(--ink);
  font: inherit; font-weight: 600; background: none; border: none; cursor: pointer;
}
.account-drop a:hover, .account-drop button:hover { background: var(--spark-soft, #fff4d1); }
.account-who { font-size: .8rem; color: var(--muted); padding: .4rem .8rem .5rem; border-bottom: 1px solid #f0e8d6; margin-bottom: .3rem; word-break: break-all; }
.land-account { position: absolute; top: 1.6rem; right: 9.5rem; }
@media (max-width: 720px) { .land-account { top: 1rem; right: 6rem; } }
