:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #1b1f24;
  --muted: #6b7280;
  --accent: #2f5fd0;
  --accent-soft: #e8effc;
  --ok: #1f9254;
  --ok-soft: #e4f5ec;
  --bad: #c23b3b;
  --bad-soft: #fbeaea;
  --warn: #b4720d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.05);
}

* { box-sizing: border-box; }

/* Muss vor den Komponenten stehen: display-Regeln wie .btn{display:inline-block}
   sind spezifischer als das [hidden] des Browsers und wuerden es sonst
   aushebeln. Betrifft u.a. den Abgeben-Button, der in der Lobby weg muss. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); }

.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
.wrap-wide { max-width: 1200px; }

header.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
header.top .inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 16px;
}
header.top .brand { font-weight: 700; font-size: 18px; text-decoration: none; color: var(--text); }
header.top nav { margin-left: auto; display: flex; gap: 16px; align-items: center; }
header.top nav a { text-decoration: none; font-size: 15px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }

label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; margin: 6px 0; }

input[type=text], input[type=email], input[type=password], input[type=number],
textarea, select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; background: #fff; color: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}

.btn {
  display: inline-block; padding: 10px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: #eccccc; }
.btn.big { padding: 14px 24px; font-size: 18px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 15px; }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.flash.ok { background: var(--ok-soft); color: var(--ok); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700;
}

/* ---------- Beitrittscode ---------- */
.code-big {
  font: 700 clamp(40px, 9vw, 88px)/1 ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: .12em;
}
input.code-input {
  font: 700 32px/1 ui-monospace, Menlo, monospace;
  letter-spacing: .18em; text-align: center; text-transform: uppercase;
}

/* ---------- Fragedarstellung ---------- */
.prompt { font-size: clamp(20px, 3.2vw, 34px); font-weight: 650; line-height: 1.3; margin: 0 0 20px; }
.q-image { max-height: 42vh; border-radius: var(--radius); display: block; margin: 0 auto 20px; }

.options { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .options { grid-template-columns: 1fr; } }

.option {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border: 2px solid var(--border); border-radius: var(--radius);
  background: #fff; font-size: 17px; text-align: left; cursor: pointer;
  font-family: inherit; color: inherit; width: 100%;
}
/* Nur die interaktive Variante (Schueleransicht) reagiert auf Hover - am
   Beamer und in der Aufloesung sind die Optionen divs und sollen nicht
   anklickbar aussehen. */
button.option:hover { border-color: var(--accent); }
.option .key {
  flex: none; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option .bar {
  margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700;
  color: var(--muted);
}

/* ---------- Markieren ---------- */
.marktext { font-size: clamp(17px, 2.4vw, 22px); line-height: 2.1; }
.tok {
  display: inline-block; padding: 2px 4px; border-radius: 6px;
  border: 2px solid transparent; cursor: pointer;
}
.tok.selectable:hover { background: #eef1f5; }
.tok.fixed { cursor: default; color: inherit; }
.tok.marked { background: var(--accent-soft); border-color: var(--accent); }
.tok.correct { background: var(--ok-soft); border-color: var(--ok); }
.tok.wrong { background: var(--bad-soft); border-color: var(--bad); }

/* ---------- Lueckentext ---------- */
.cloze { font-size: clamp(17px, 2.4vw, 22px); line-height: 2.2; }
.cloze input {
  width: 9ch; display: inline-block; padding: 4px 8px; margin: 0 4px;
  border: 0; border-bottom: 2px solid var(--accent); border-radius: 4px 4px 0 0;
  background: var(--accent-soft); font: inherit; text-align: center;
}

/* ---------- Hotspot ---------- */
.hotspot { position: relative; display: inline-block; max-width: 100%; }
.hotspot img { display: block; max-width: 100%; border-radius: var(--radius); cursor: crosshair; }
.hotspot .marker {
  position: absolute; transform: translate(-50%, -50%);
  border: 3px solid var(--accent); background: rgba(47,95,208,.18);
  border-radius: 50%; pointer-events: none;
}
.hotspot .marker.solution { border-color: var(--ok); background: rgba(31,146,84,.18); }
.hotspot .marker.dot {
  width: 18px; height: 18px; background: var(--accent); border-color: #fff;
}

/* ---------- Host / Beamer ---------- */
.host-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 16px; box-shadow: var(--shadow);
}
.timer {
  font: 700 34px/1 ui-monospace, Menlo, monospace;
  font-variant-numeric: tabular-nums; min-width: 3.2ch; text-align: center;
}
.timer.low { color: var(--bad); }
.counter { font-size: 22px; font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 8px 14px; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent); font-weight: 650; font-size: 16px;
  display: inline-flex; align-items: center; gap: 8px;
}
.chip.off { background: #eceef1; color: var(--muted); }
.chip button {
  border: 0; background: none; color: inherit; cursor: pointer;
  font-size: 15px; line-height: 1; opacity: .55; padding: 0;
}

.scoreboard { display: grid; gap: 8px; }
.score-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 18px;
}
.score-row .rank { font-weight: 800; color: var(--muted); min-width: 2.2ch; }
.score-row .pts { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-row.me { border-color: var(--accent); background: var(--accent-soft); }

.result-banner {
  padding: 22px; border-radius: var(--radius); text-align: center;
  font-size: 22px; font-weight: 700; margin-bottom: 18px;
}
.result-banner.ok { background: var(--ok-soft); color: var(--ok); }
.result-banner.bad { background: var(--bad-soft); color: var(--bad); }
.result-banner.part { background: #fdf3e2; color: var(--warn); }

.waiting { text-align: center; padding: 48px 20px; color: var(--muted); font-size: 18px; }

/* Hinweisbanner blenden sich auf dem Schuelergeraet selbst aus - der Platz
   ist knapp und die Meldung ist nach ein paar Sekunden erledigt. */
.flash { transition: opacity .6s ease; }
.flash.fade { opacity: 0; }

/* ---------- Avatare ---------- */
.avatar-svg { display: block; border-radius: 14px; }

.avatar-preview {
  display: flex; justify-content: center;
}
.avatar-preview .avatar-svg {
  border-radius: 22px; box-shadow: var(--shadow);
}

.join-card { max-width: 520px; margin: 24px auto; }

.avatar-code {
  font: 700 17px/1 ui-monospace, Menlo, monospace;
  letter-spacing: .1em; color: var(--text);
  background: var(--accent-soft); padding: 3px 8px; border-radius: 6px;
}

.designer { margin: 18px 0 6px; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cat {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font: 600 13px/1 inherit;
  cursor: pointer;
}
.cat.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.opts {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  max-height: 232px; overflow-y: auto; padding: 2px;
}
.opt {
  border: 2px solid var(--border); border-radius: 12px; background: #fff;
  padding: 2px; cursor: pointer; line-height: 0;
}
.opt:hover { border-color: var(--accent); }
.opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.opt .avatar-svg { width: 100%; height: auto; border-radius: 9px; }

.reload { margin: 16px 0 4px; }
.reload summary { cursor: pointer; font-size: 14px; color: var(--accent); }

/* Avatar neben einem Namen - Chips, Ranglisten, Tabellen */
.with-avatar { display: inline-flex; align-items: center; gap: 8px; }
.with-avatar .avatar-svg { flex: none; border-radius: 8px; }
.chip .avatar-svg { border-radius: 999px; }
.score-row .avatar-svg { border-radius: 10px; }
.host-bar + .card .score-row { padding: 14px 16px; font-size: 20px; }

/* ---------- PDF-Import ---------- */
.sticky-actions {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

.flash.note { background: #fdf3e2; color: var(--warn); }

.import-q { padding: 16px 18px; }
.import-q.flagged { border-color: var(--bad); background: #fffafa; }
.import-q textarea { min-height: 0; }

/* ---------- Fragen übernehmen ---------- */
.pick-q { display: block; cursor: pointer; padding: 14px 16px; }
.pick-q:hover { border-color: var(--accent); }
.pick-q:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.opt-chip {
  display: inline-block; padding: 2px 8px; margin: 2px 4px 2px 0;
  border-radius: 999px; background: #eef0f3;
}
.opt-chip.right { background: var(--ok-soft); color: var(--ok); font-weight: 600; }

/* Kein Innenabstand: der wuerde den Text auseinanderschieben und aus
   "Zellen" ein "Zelle n" machen. Der Schein kommt aus dem Schatten. */
mark {
  background: #ffe9a8; color: inherit; border-radius: 2px;
  box-shadow: 0 0 0 2px #ffe9a8;
}
