:root {
  --background: #007bbd;
  --surface: #192e38;
  --surface-2: #213c49;
  --line: #34566a;
  --text: #edf2f4;
  --muted: #b6c4cb;
  --primary: #007bbd;
  --accent: #a3d9ff;
  --danger: #e0625a;
  --green: #3fb96b;
  --yellow: #f2c230;
  --red: #e0564d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { min-height: 100vh; background: var(--background); color: var(--text); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
a { color: inherit; }
.noscript { padding: 24px; text-align: center; }

.wrap { width: min(960px, calc(100% - 32px)); margin-inline: auto; padding-block: 48px 24px; }
.wrap.narrow { width: min(560px, calc(100% - 24px)); padding-top: 20px; }
.intro { text-align: center; color: #fff; margin-bottom: 28px; }
.intro h1 { font-size: clamp(28px, 4vw, 36px); line-height: 1.25; margin: 0 0 8px; }
.intro p { margin: 0 auto; max-width: 640px; }
.intro.compact { margin-bottom: 14px; }
.intro.compact h1 { font-size: 22px; margin: 0; }
.footer { text-align: center; color: #fff; font-size: 12px; padding-top: 24px; }

.panel { background: var(--surface); border-radius: 18px; padding: 24px; margin-bottom: 20px; box-shadow: 0 2px 8px #002d4614; }
.panel h2 { font-size: 20px; margin: 0 0 16px; }

.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.template { text-align: left; font: inherit; color: var(--text); background: var(--surface-2); border: 2px solid transparent; border-radius: 14px; padding: 14px 16px; cursor: pointer; }
.template:hover { border-color: var(--line); }
.template[aria-checked="true"] { border-color: var(--accent); background: #254b60; }
.template strong { display: block; font-size: 16px; margin-bottom: 4px; }
.template span { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; }

.field { display: block; margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input:not([type]), input[type="text"], textarea, select { width: 100%; font: inherit; color: var(--text); background: #0f1f27; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
textarea { resize: vertical; }
select { appearance: auto; }
.check { display: flex; align-items: center; gap: 10px; margin: 8px 0 16px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.option-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.option-list li { display: flex; gap: 8px; align-items: center; }
.option-list .swatch { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.icon-button { font: inherit; width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { color: var(--text); border-color: var(--muted); }

.button { font: inherit; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 24px; padding: 10px 18px; min-height: 44px; cursor: pointer; border: 1px solid #54b1e5; color: #fff; background: var(--primary); text-decoration: none; }
.button:hover { background: #006ba6; }
.button:disabled { opacity: .6; cursor: wait; }
.button.secondary { background: transparent; border-color: var(--line); color: var(--text); }
.button.secondary:hover { background: var(--surface-2); }
.button.danger { background: transparent; border-color: #8a3c38; color: #ffb4ae; }
.button.danger:hover { background: #3a2226; }
.button.small { min-height: 38px; padding: 6px 14px; font-size: 14px; }
.button.large { width: 100%; min-height: 52px; font-size: 17px; }
.error { color: #ffb4ae; font-weight: 600; margin: 0 0 12px; }

/* Tafelansicht */
.board { min-height: 100vh; display: flex; flex-direction: column; padding: 16px; gap: 16px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--surface); border-radius: 14px; padding: 8px 12px; }
.status { margin-right: auto; font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.status.closed::before { background: var(--yellow); }
.status.offline::before { background: var(--red); }
.board-layout { flex: 1; display: grid; grid-template-columns: minmax(260px, 30%) 1fr; gap: 16px; align-items: start; }
.board-layout.no-qr { grid-template-columns: 1fr; }
.join-card { background: #fff; color: #10232c; border-radius: 18px; padding: 20px; text-align: center; position: sticky; top: 16px; }
.join-hint { font-size: clamp(18px, 1.6vw, 26px); font-weight: 700; margin: 0 0 10px; }
.qr svg { display: block; width: 100%; height: auto; }
.join-url { margin: 10px 0 0; font-size: clamp(13px, 1vw, 16px); overflow-wrap: anywhere; color: #3b5360; }
.join-code { margin: 6px 0 0; font-size: clamp(18px, 1.6vw, 24px); }
.join-code strong { font-size: clamp(30px, 3vw, 48px); letter-spacing: .12em; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; display: block; line-height: 1.2; }
.capture { background: var(--surface); border-radius: 18px; padding: clamp(18px, 2vw, 32px); min-height: 60vh; display: flex; flex-direction: column; }
.capture-head { display: flex; gap: 20px; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.capture-head h1 { margin: 0; font-size: clamp(24px, 2.6vw, 42px); line-height: 1.25; overflow-wrap: anywhere; }
.count { margin: 0; text-align: right; white-space: nowrap; color: var(--muted); font-size: clamp(14px, 1.2vw, 18px); }
.count strong { display: block; color: var(--text); font-size: clamp(36px, 4vw, 64px); line-height: 1; }
.cover { flex: 1; display: grid; place-items: center; color: var(--muted); font-size: clamp(20px, 2vw, 30px); border: 2px dashed var(--line); border-radius: 14px; min-height: 200px; }
.results { flex: 1; }
.capture-meta { margin: 20px 0 0; color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); font-size: clamp(18px, 1.6vw, 24px); text-align: center; padding: 48px 0; }
.board-error { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); margin: 0; background: #3a2226; color: #ffd4d0; padding: 10px 16px; border-radius: 12px; }

.bars { display: grid; gap: clamp(14px, 1.6vw, 24px); }
.bar-label { display: flex; justify-content: space-between; gap: 16px; font-size: clamp(17px, 1.6vw, 26px); margin-bottom: 6px; }
.bar-label span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.bar-label b { color: var(--text); }
.bar-track { height: clamp(22px, 2.4vw, 40px); background: #0f1f27; border-radius: 10px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 10px; min-width: 0; transition: width .4s ease; }
.bar-names { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.scale-summary { font-size: clamp(18px, 1.8vw, 28px); margin: 0 0 20px; }
.scale-summary strong { font-size: 1.4em; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 14px; align-items: start; }
.card { position: relative; background: #fdf6c8; color: #1d2a30; border-radius: 12px; padding: 14px 44px 14px 16px; font-size: clamp(16px, 1.3vw, 21px); white-space: pre-wrap; overflow-wrap: anywhere; }
.card small { display: block; margin-top: 8px; font-size: 13px; color: #5d6a70; }
.card .hide-card { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: #5d6a70; font-size: 18px; cursor: pointer; }
.card .hide-card:hover { background: #0000001a; color: #1d2a30; }
.hidden-note { margin: 16px 0 0; color: var(--muted); font-size: 14px; }
.hidden-note button { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }
.columns-321 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.columns-321 h2 { font-size: clamp(17px, 1.5vw, 24px); margin: 0 0 12px; }
.columns-321 .cards { grid-template-columns: 1fr; }
.capturing .hide-card, .capturing .hidden-note { display: none; }

/* Schüleransicht */
.student-question { font-size: 22px; line-height: 1.35; margin: 0 0 20px; overflow-wrap: anywhere; }
.choices { display: grid; gap: 10px; margin-bottom: 20px; border: 0; padding: 0; }
.choice { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 2px solid transparent; cursor: pointer; font-size: 17px; }
.choice:has(input:checked) { border-color: var(--accent); background: #254b60; }
.choice input { width: 22px; height: 22px; accent-color: var(--primary); flex-shrink: 0; }
.choice .swatch { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 8px; border: 0; padding: 0; }
.scale label { cursor: pointer; }
.scale input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scale span { display: grid; place-items: center; height: 56px; border-radius: 14px; background: var(--surface-2); border: 2px solid transparent; font-size: 22px; font-weight: 700; }
.scale input:checked + span { border-color: var(--accent); background: var(--primary); }
.scale input:focus-visible + span { outline: 3px solid #fff; outline-offset: 2px; }
.scale-labels { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.scale-labels span:last-child { text-align: right; }
.counter { display: block; text-align: right; color: var(--muted); font-size: 13px; margin-top: 4px; }
.group-321 { margin-bottom: 18px; border: 0; padding: 0; }
.group-321 legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.group-321 input { margin-bottom: 8px; }
.code-input { font-size: 28px !important; letter-spacing: .15em; text-align: center; text-transform: uppercase; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.done { text-align: center; }
.done-mark { width: 72px; height: 72px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: #fff; font-size: 40px; font-weight: 700; }
.done h2 { font-size: 26px; margin-bottom: 8px; }
.done p { margin: 0 0 20px; color: var(--muted); }
.message { font-weight: 600; }

@media (max-width: 900px) {
  .board-layout { grid-template-columns: 1fr; }
  .join-card { position: static; max-width: 420px; width: 100%; margin-inline: auto; }
  .columns-321 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding-top: 28px; }
  .panel { padding: 18px; }
  .field-row { grid-template-columns: 1fr; }
  .status { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .bar-fill { transition: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
