:root {
  --orange: #ec6608;
  --orange-dark: #c45200;
  --orange-soft: #fdf0e6;
  --amber: #f7a600;
  --lime: #cbd10f;
  --teal: #88cdd3;
  --blue: #8badDC;
  --lblue: #a1daf8;
  --ink: #1d1d1b;
  --muted: #6b6b6b;
  --line: #e4e4e4;
  --bg: #ffffff;
  --bg-soft: #f6f6f4;
  --ok: #3f9b3a;
  --ok-soft: #e8f4e6;
  --bad: #c0392b;
  --radius: 14px;
  --font: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* =========================================================
   Teilnahme (Smartphone)
   ========================================================= */
.p-app { min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg-soft); }
.p-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: var(--bg); border-bottom: 3px solid var(--orange);
}
.p-brand { font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.p-brand span { color: var(--orange); }
.p-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.p-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.p-status.open::before { background: var(--ok); }
.p-status.closed::before, .p-status.connecting::before { background: var(--amber); }
.p-main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 20px 16px 40px; }
.p-card { background: var(--bg); border-radius: var(--radius); padding: 20px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.p-kicker { font-size: 13px; font-weight: 700; color: var(--orange); text-transform: none; margin: 0 0 6px; }
.p-title { font-size: 21px; line-height: 1.3; margin: 0 0 18px; font-weight: 700; }
.p-hint { font-size: 14px; color: var(--muted); margin: 0 0 14px; }
.p-center { text-align: center; padding: 40px 12px; }
.p-center h2 { margin: 12px 0 6px; font-size: 22px; }
.p-center p { color: var(--muted); margin: 0; }
.p-big-icon { font-size: 44px; line-height: 1; }

.code-form { display: flex; flex-direction: column; gap: 12px; }
.code-input {
  font-size: 34px; letter-spacing: .3em; text-align: center; padding: 14px 10px;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--bg); width: 100%;
}
.code-input:focus { outline: none; border-color: var(--orange); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 14px 22px; font-weight: 700; font-size: 16px;
  background: var(--orange); color: #fff; min-height: 50px;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn:not(:disabled):active { background: var(--orange-dark); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--orange); border: 2px solid var(--orange); }
.btn.small { padding: 8px 14px; min-height: 0; font-size: 14px; }
.link-btn { background: none; border: 0; color: var(--orange); font-weight: 700; padding: 8px 0; text-decoration: underline; }

.opt-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg);
  font-size: 16px; line-height: 1.35; min-height: 54px;
}
.opt .mark {
  flex: 0 0 22px; height: 22px; border-radius: 50%; border: 2px solid #b9b9b9; display: grid; place-items: center;
  font-size: 13px; color: #fff;
}
.opt.multi .mark { border-radius: 6px; }
.opt.sel { border-color: var(--orange); background: var(--orange-soft); }
.opt.sel .mark { background: var(--orange); border-color: var(--orange); }
.opt.sel .mark::after { content: "✓"; }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); }
.opt:disabled { cursor: default; color: inherit; }

.quiz-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.quiz-opt {
  border: 0; border-radius: 12px; padding: 16px 12px; min-height: 96px; color: #fff; font-weight: 700;
  font-size: 16px; line-height: 1.3; display: flex; align-items: center; justify-content: center; text-align: center;
}
.quiz-opt:nth-child(1) { background: #d4560a; }
.quiz-opt:nth-child(2) { background: #2f7f8a; }
.quiz-opt:nth-child(3) { background: #5e6f1a; }
.quiz-opt:nth-child(4) { background: #3f5f9a; }
.quiz-opt:disabled { opacity: .35; }
.quiz-opt.sel { opacity: 1; outline: 4px solid var(--ink); outline-offset: 2px; }

.timer { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 0 0 16px; }
.timer > div { height: 100%; background: var(--orange); transition: width .25s linear; }
.timer-num { font-weight: 700; font-size: 14px; color: var(--muted); margin-bottom: 6px; }

.field { width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 16px; background: var(--bg); }
.field:focus { outline: none; border-color: var(--orange); }
textarea.field { min-height: 110px; resize: vertical; }
.fields { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.counter { font-size: 12px; color: var(--muted); text-align: right; margin: -6px 0 12px; }

.slider-item { padding: 14px 0; border-top: 1px solid var(--line); }
.slider-item:first-of-type { border-top: 0; padding-top: 0; }
.slider-item h3 { margin: 0 0 10px; font-size: 16px; }
.slider-row { display: grid; grid-template-columns: 1fr; gap: 4px; margin-bottom: 10px; }
.slider-row .ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
input[type=range] { width: 100%; accent-color: var(--orange); height: 28px; }

.done { text-align: center; padding: 18px 8px 4px; }
.done .p-big-icon { color: var(--ok); }
.done h2 { margin: 10px 0 4px; font-size: 20px; }
.done p { margin: 0 0 12px; color: var(--muted); }
.result-badge { display: inline-block; margin-top: 8px; padding: 8px 14px; border-radius: 999px; font-weight: 700; }
.result-badge.ok { background: var(--ok-soft); color: var(--ok); }
.result-badge.bad { background: #fbeaea; color: var(--bad); }
.score-line { margin-top: 12px; font-size: 15px; color: var(--muted); }
.score-line b { color: var(--ink); }

.p-foot { text-align: center; font-size: 12px; color: var(--muted); padding: 0 16px 20px; }
.p-foot a { color: var(--muted); }

/* =========================================================
   Präsentation / Add-in (16:9-Bühne)
   ========================================================= */
.stage-wrap {
  position: fixed; inset: 0; display: grid; place-items: center; background: #fff; overflow: hidden;
}
.stage {
  /* Basis-Einheit: 1u = 1/100 der Bühnenbreite */
  --u: min(1vw, calc(100vh * 16 / 9 / 100));
  width: calc(var(--u) * 100); height: calc(var(--u) * 56.25);
  position: relative; display: flex; flex-direction: column;
  padding: calc(var(--u) * 3.2) calc(var(--u) * 4) calc(var(--u) * 2);
  font-size: calc(var(--u) * 1.6);
  background: #fff;
}
.stage::before {
  content: ""; position: absolute; left: calc(var(--u) * 4); right: calc(var(--u) * 4); top: 0;
  height: calc(var(--u) * .45); background: var(--orange);
}
.s-head { margin-bottom: calc(var(--u) * 1.8); }
.s-kicker { color: var(--orange); font-weight: 700; font-size: calc(var(--u) * 1.5); margin-bottom: calc(var(--u) * .5); }
.s-title { font-size: calc(var(--u) * 2.9); line-height: 1.22; font-weight: 700; margin: 0; max-width: 92%; }
.s-title.long { font-size: calc(var(--u) * 2.3); }
.s-viz { flex: 1; min-height: 0; position: relative; display: flex; }
.s-foot {
  display: flex; align-items: flex-end; justify-content: space-between; gap: calc(var(--u) * 2);
  margin-top: calc(var(--u) * 1.2); font-size: calc(var(--u) * 1.35); color: var(--muted);
}
.s-join { display: flex; align-items: center; gap: calc(var(--u) * 1.2); }
.s-join .qr { width: calc(var(--u) * 6.5); height: calc(var(--u) * 6.5); }
.s-join .qr svg { width: 100%; height: 100%; display: block; }
.s-join b { color: var(--ink); }
.s-join .code { color: var(--orange); font-size: calc(var(--u) * 2.2); font-weight: 800; letter-spacing: .08em; }
.s-meta { display: flex; gap: calc(var(--u) * 1.6); align-items: center; }
.s-meta .pill { background: var(--bg-soft); padding: calc(var(--u) * .4) calc(var(--u) * 1); border-radius: 999px; }
.s-meta .pill b { color: var(--ink); }

/* Balken (Multiple Choice / Quiz) */
.bars { width: 100%; display: flex; flex-direction: column; justify-content: center; gap: calc(var(--u) * 1.1); }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: calc(var(--u) * .35); }
.bar-label { display: flex; justify-content: space-between; gap: calc(var(--u) * 1); font-size: calc(var(--u) * 1.75); font-weight: 600; }
.bar-label .pct { font-weight: 800; white-space: nowrap; }
.bar-track { height: calc(var(--u) * 2.4); background: var(--bg-soft); border-radius: calc(var(--u) * .5); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--orange); border-radius: calc(var(--u) * .5); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.bar-row:nth-child(2) .bar-fill { background: var(--amber); }
.bar-row:nth-child(3) .bar-fill { background: var(--teal); }
.bar-row:nth-child(4) .bar-fill { background: var(--blue); }
.bar-row:nth-child(5) .bar-fill { background: var(--lime); }
.bars.revealed .bar-row .bar-fill { background: #cfcfcf; }
.bars.revealed .bar-row.correct .bar-fill { background: var(--ok); }
.bars.revealed .bar-row.correct .bar-label span:first-child::before { content: "✓ "; color: var(--ok); }
.bars.revealed .bar-row:not(.correct) .bar-label { color: var(--muted); }
.bars.compact { gap: calc(var(--u) * .7); }
.bars.compact .bar-label { font-size: calc(var(--u) * 1.5); }
.bars.compact .bar-track { height: calc(var(--u) * 1.8); }

.hidden-note {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted);
  font-size: calc(var(--u) * 1.8);
}
.hidden-note .big { font-size: calc(var(--u) * 6); font-weight: 800; color: var(--ink); display: block; line-height: 1; }

/* Quiz */
.quiz-stage { width: 100%; display: grid; grid-template-columns: calc(var(--u) * 14) 1fr; gap: calc(var(--u) * 3); align-items: center; }
.countdown { width: calc(var(--u) * 13); height: calc(var(--u) * 13); position: relative; }
.countdown svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.countdown .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--u) * 4.6); font-weight: 800; }
.q-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--u) * 1.2); }
.q-tile { color: #fff; font-weight: 700; border-radius: calc(var(--u) * .8); padding: calc(var(--u) * 1.6); font-size: calc(var(--u) * 1.9); min-height: calc(var(--u) * 8); display: flex; align-items: center; }
.q-tile:nth-child(1) { background: #d4560a; }
.q-tile:nth-child(2) { background: #2f7f8a; }
.q-tile:nth-child(3) { background: #5e6f1a; }
.q-tile:nth-child(4) { background: #3f5f9a; }
.answered { font-size: calc(var(--u) * 1.6); color: var(--muted); text-align: center; margin-top: calc(var(--u) * 1); }

/* Wortwolke */
.cloud {
  width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; align-content: center;
  gap: calc(var(--u) * .6) calc(var(--u) * 1.8); padding: 0 calc(var(--u) * 2); overflow: hidden;
}
.cloud span { font-weight: 800; line-height: 1.05; white-space: nowrap; transition: font-size .5s; }
.cloud span:nth-child(5n+1) { color: var(--orange); }
.cloud span:nth-child(5n+2) { color: #2f7f8a; }
.cloud span:nth-child(5n+3) { color: #3f5f9a; }
.cloud span:nth-child(5n+4) { color: #8a8f10; }
.cloud span:nth-child(5n+5) { color: #b07700; }

/* Antwortwand */
.wall {
  width: 100%; columns: 3; column-gap: calc(var(--u) * 1.4); overflow: hidden; align-self: flex-start;
}
.wall.few { columns: 2; }
.card {
  break-inside: avoid; background: var(--bg-soft); border-left: calc(var(--u) * .35) solid var(--orange);
  border-radius: calc(var(--u) * .6); padding: calc(var(--u) * 1) calc(var(--u) * 1.2);
  margin-bottom: calc(var(--u) * 1.2); font-size: calc(var(--u) * 1.5); line-height: 1.35; position: relative;
  animation: pop .35s ease-out;
}
.card:nth-child(4n+2) { border-left-color: var(--teal); }
.card:nth-child(4n+3) { border-left-color: var(--amber); }
.card:nth-child(4n+4) { border-left-color: var(--blue); }
.card .x {
  position: absolute; top: calc(var(--u) * .3); right: calc(var(--u) * .4); border: 0; background: none;
  color: var(--muted); font-size: calc(var(--u) * 1.4); opacity: 0; padding: 0 calc(var(--u) * .3);
}
.can-moderate .card:hover .x { opacity: 1; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

/* 2×2-Raster */
.grid-viz { width: 100%; height: 100%; position: relative; }
.grid-viz svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Bestenliste */
.lb { width: 100%; display: flex; flex-direction: column; justify-content: center; gap: calc(var(--u) * .45); max-width: calc(var(--u) * 60); margin: 0 auto; }
.lb-row {
  display: grid; grid-template-columns: calc(var(--u) * 4) 1fr auto; align-items: center;
  background: var(--bg-soft); border-radius: calc(var(--u) * .6); padding: calc(var(--u) * .45) calc(var(--u) * 1.4);
  font-size: calc(var(--u) * 1.5);
}
.lb-row .rk { font-weight: 800; color: var(--muted); }
.lb-row .pts { font-weight: 800; }
.lb-row:nth-child(1) { background: var(--orange); color: #fff; font-size: calc(var(--u) * 1.9); }
.lb-row:nth-child(1) .rk { color: #fff; }
.lb-row:nth-child(2) { background: #f9c49c; }
.lb-row:nth-child(3) { background: var(--orange-soft); }

.empty { margin: auto; color: var(--muted); font-size: calc(var(--u) * 1.8); text-align: center; }
.empty .big { display: block; font-size: calc(var(--u) * 5); margin-bottom: calc(var(--u) * 1); }

/* großer QR-Code */
.qr-overlay {
  position: absolute; inset: 0; background: rgba(255,255,255,.97); z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: calc(var(--u) * 6);
}
.qr-overlay .qr { width: calc(var(--u) * 30); height: calc(var(--u) * 30); }
.qr-overlay .qr svg { width: 100%; height: 100%; }
.qr-overlay .txt { font-size: calc(var(--u) * 2.4); line-height: 1.5; }
.qr-overlay .txt b { display: block; font-size: calc(var(--u) * 3.2); }
.qr-overlay .txt .code { color: var(--orange); font-size: calc(var(--u) * 7); font-weight: 800; letter-spacing: .08em; line-height: 1.1; }

/* Steuerleiste (Präsentation) */
.controls {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 10;
  display: flex; align-items: center; gap: 6px; padding: 8px; border-radius: 999px;
  background: rgba(29,29,27,.92); color: #fff; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25);
  transition: opacity .25s; max-width: calc(100vw - 24px); flex-wrap: wrap; justify-content: center;
}
.controls.faded { opacity: 0; }
.controls:hover { opacity: 1; }
.controls button {
  border: 0; background: transparent; color: #fff; padding: 8px 12px; border-radius: 999px; font-weight: 600; white-space: nowrap;
}
.controls button:hover { background: rgba(255,255,255,.12); }
.controls button.on { background: var(--orange); }
.controls .sep { width: 1px; height: 22px; background: rgba(255,255,255,.2); margin: 0 4px; }
.controls .pos { padding: 0 8px; font-variant-numeric: tabular-nums; opacity: .8; }
.controls .live { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; }
.controls .live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.controls .live.open::before { background: #5cc35a; }
.controls .live.closed::before { background: #e05a4a; }
.controls .warn { color: var(--amber); padding: 0 8px; }

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 20; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* Einrichtungsseiten */
.setup { max-width: 760px; margin: 0 auto; padding: 32px 20px 60px; }
.setup h1 { font-size: 26px; margin: 0 0 6px; }
.setup h1 span { color: var(--orange); }
.setup .lead { color: var(--muted); margin: 0 0 24px; }
.deck-list { display: grid; gap: 10px; }
.deck {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; text-decoration: none; color: inherit;
  padding: 16px 18px; border: 2px solid var(--line); border-radius: var(--radius); background: #fff;
}
.deck:hover { border-color: var(--orange); }
.deck .t { font-weight: 700; }
.deck .s { color: var(--muted); font-size: 14px; }
.deck .c { font-weight: 800; color: var(--orange); font-size: 20px; letter-spacing: .08em; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.label { display: block; font-weight: 700; font-size: 14px; margin: 14px 0 6px; }
.note { font-size: 13px; color: var(--muted); }
.error { color: var(--bad); font-size: 14px; margin-top: 8px; }

/* Add-in */
.addin-config { padding: 18px 20px; font-size: 14px; max-width: 640px; }
.addin-config h2 { margin: 0 0 4px; font-size: 18px; }
.addin-config select, .addin-config input { width: 100%; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; }
.addin-config .check { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.addin-config .check input { width: auto; }
.addin-bar {
  position: fixed; right: 8px; top: 8px; z-index: 10; display: flex; gap: 4px; opacity: 0; transition: opacity .2s;
  background: rgba(29,29,27,.85); padding: 4px; border-radius: 999px;
}
body:hover .addin-bar { opacity: 1; }
.addin-bar button { border: 0; background: transparent; color: #fff; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 600; }
.addin-bar button:hover, .addin-bar button.on { background: var(--orange); }
