/* assets/css/app.css – qBingo
   Fachbereichsfarben kommen aus pool_areas (layout.php setzt --area-*).
   Die Werte hier sind nur der Rückfall, solange das Pool-Schema fehlt. */

@font-face {
  font-family: 'Nunito';
  src: local('Nunito'), url('/assets/fonts/nunito.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --area-mathe: #2563eb;
  --area-nawi: #059669;
  --area-gewi: #d97706;
  --area-sprachen: #7c3aed;
  --area-allgemein: #64748b;

  --ink: #14213d;
  --bg: #f4f6fb;
  --card: #fff;
  --line: #dde2ec;
  --muted: #667085;
  --accent: #f59e0b;
  --ok: #059669;
  --err: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

a { color: inherit; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px; background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-name { font-weight: 900; font-size: 20px; letter-spacing: .3px; }
.brand-mark {
  display: grid; grid-template-columns: repeat(2, 10px); gap: 2px;
}
.brand-mark i { width: 10px; height: 10px; border-radius: 3px; display: block; }
.brand-mark i:nth-child(1) { background: var(--area-mathe); }
.brand-mark i:nth-child(2) { background: var(--area-nawi); }
.brand-mark i:nth-child(3) { background: var(--area-gewi); }
.brand-mark i:nth-child(4) { background: var(--area-sprachen); }
.topbar-right { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.tb-role { background: rgba(255,255,255,.15); padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.tb-link { color: #fff; opacity: .8; }
.tb-link:hover { opacity: 1; }

/* ---------- Grundgerüst ---------- */
.wrap { max-width: 1040px; margin: 0 auto; padding: 32px 16px 64px; }
h1 { font-size: 34px; line-height: 1.15; margin: 0 0 12px; }
h2 { font-size: 20px; margin: 0 0 8px; }
.lead { font-size: 19px; color: #3a4660; max-width: 34em; }
.hint { color: var(--muted); font-size: 15px; margin-top: 0; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; margin-top: 28px;
}
.flash { padding: 12px 16px; border-radius: 10px; margin-top: 20px; border: 1px solid var(--line); }
.flash.error { border-color: var(--err); background: #fef2f2; }

/* ---------- Knöpfe ---------- */
.btn {
  display: inline-block; padding: 11px 18px; border-radius: 10px;
  text-decoration: none; font-weight: 700; border: 2px solid var(--ink);
  margin: 0 8px 8px 0;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { filter: brightness(1.25); }
.btn.disabled { border-color: var(--line); color: var(--muted); cursor: not-allowed; }

/* ---------- Startseite ---------- */
.hero {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: center;
}
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  h1 { font-size: 28px; }
}

.areas {
  list-style: none; padding: 0; margin: 12px 0 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px;
}
.areas li {
  border-radius: 12px; padding: 14px 16px; color: #fff;
  background: var(--c); display: flex; flex-direction: column;
}
.areas strong { font-size: 28px; line-height: 1; }
/* "Gesellschaftswissenschaften" muss in die Kachel passen */
.areas span {
  font-size: 13px; opacity: .92; margin-top: 4px;
  overflow-wrap: anywhere; hyphens: auto;
}

/* ---------- Spielbrett ---------- */
.area-mathe     { --c: var(--area-mathe); }
.area-nawi      { --c: var(--area-nawi); }
.area-gewi      { --c: var(--area-gewi); }
.area-sprachen  { --c: var(--area-sprachen); }
.area-allgemein { --c: var(--area-allgemein); }

.board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  gap: 8px;
  aspect-ratio: 1;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}
.cell {
  border-radius: 12px;
  background: var(--c, #999);
  position: relative;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.18);
}
.cell.done::after {
  content: ''; position: absolute; inset: 22%;
  border-radius: 50%; background: rgba(255,255,255,.92);
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.cell.locked {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.35) 0 6px, transparent 6px 12px),
    var(--c, #999);
  opacity: .55;
}
/* ---------- Spielansicht ---------- */
.play { display: grid; grid-template-columns: 230px 1fr; gap: 28px; align-items: start; }
@media (max-width: 800px) { .play { grid-template-columns: 1fr; } }

.play-side { position: sticky; top: 16px; }
.game-title { font-size: 22px; margin: 0 0 12px; }
.stats { list-style: none; padding: 0; margin: 0 0 16px; }
.stats li { font-size: 15px; color: var(--muted); }
.stats strong { font-size: 20px; color: var(--ink); margin-right: 4px; }
.stats.big { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 8px; }
.stats.big strong { font-size: 30px; display: block; }

.rule { font-size: 14px; color: var(--muted); }
.clock {
  font-size: 34px; font-weight: 900; font-variant-numeric: tabular-nums;
  margin: 8px 0 16px;
}
.clock.soon { color: var(--err); }

.legend { list-style: none; padding: 0; margin: 0 0 20px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: var(--muted); }
.legend .dot, .weight .dot {
  width: 14px; height: 14px; border-radius: 4px; background: var(--c, #999); flex: none;
}

.play-board, .review-board { max-width: 620px; margin: 0 0 16px; }
.play-board .cell, .review-board .cell {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; border: 0; font: inherit; color: #fff; padding: 0;
}
.play-board button.cell { cursor: pointer; }
.play-board button.cell:hover { filter: brightness(1.15); transform: translateY(-2px); }
.play-board button.cell:focus-visible { outline: 4px solid var(--ink); outline-offset: 3px; }
.cell-label { font-weight: 900; font-size: 20px; opacity: .85; }
.cell.done .cell-label, .cell.locked .cell-label { opacity: .5; }
.cell .wait { font-size: 12px; background: rgba(0, 0, 0, .28); padding: 1px 7px; border-radius: 999px; }
.cell.current { outline: 4px solid var(--ink); outline-offset: 3px; }

.pick-hint { color: var(--muted); font-size: 18px; }

.question {
  background: var(--card); border: 1px solid var(--line);
  border-left: 10px solid var(--c, var(--line));
  border-radius: var(--radius); padding: 20px 24px; margin-bottom: 20px;
}
.qmeta { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.qmeta .chip {
  background: var(--c, #999); color: #fff; padding: 2px 10px;
  border-radius: 999px; margin-right: 8px; font-size: 13px;
}
.qtext { font-size: 26px; line-height: 1.35; margin: 0 0 18px; }
.qimg { max-width: 100%; max-height: 260px; border-radius: 10px; }

.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; text-align: left;
  font: inherit; font-size: 19px; padding: 14px 16px; cursor: pointer;
  background: #fff; border: 2px solid var(--line); border-radius: 12px; color: inherit;
}
.option:hover { border-color: var(--ink); }
.option .key {
  width: 30px; height: 30px; flex: none; border-radius: 8px; background: var(--ink);
  color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 15px;
}
.free { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.free input {
  font: inherit; font-size: 22px; padding: 10px 14px; border: 2px solid var(--line);
  border-radius: 10px; min-width: 260px;
}
.free input:focus { outline: none; border-color: var(--ink); }
.free .unit { font-size: 20px; color: var(--muted); }

.result {
  border-radius: 12px; padding: 14px 18px; margin-bottom: 18px; font-size: 18px;
  border: 2px solid var(--line); background: var(--card);
}
.result.ok { border-color: var(--ok); background: #ecfdf5; }
.result.no { border-color: var(--err); background: #fef2f2; }
.result .sol { font-weight: 800; }
.result em { display: block; font-size: 15px; color: var(--muted); font-style: normal; margin-top: 4px; }

.end-form { margin-top: 12px; }
.btn.small { padding: 6px 12px; font-size: 14px; border-width: 1px; }

/* ---------- Einrichten ---------- */
.setup .row { display: flex; gap: 18px; flex-wrap: wrap; }
.setup .field { flex: 1 1 180px; display: block; margin-bottom: 8px; }
.setup .field > span { display: block; font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.setup select, .setup input[type="number"], .setup input[type="text"] {
  width: 100%; font: inherit; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.weights { display: flex; flex-wrap: wrap; gap: 10px; }
.weight {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px 6px 10px; background: #fff;
}
.weight input { width: 72px; font: inherit; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; }
.weight .wname { font-size: 14px; }
.areas.preview li { min-height: 78px; }
.card.warn { border-color: var(--accent); background: #fffbeb; }
.ok-text { color: var(--ok); font-weight: 700; }
.errors { margin: 8px 0 0; padding-left: 20px; }

/* ---------- Spielart wählen ---------- */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.mode {
  display: block; border: 2px solid var(--line); border-radius: 12px;
  padding: 14px 16px; cursor: pointer; background: #fff;
}
.mode.on, .mode:has(input:checked) { border-color: var(--ink); background: #f8fafc; }
.mode strong { display: block; font-size: 17px; margin: 4px 0; }
.mode span { font-size: 14px; color: var(--muted); }

/* ---------- Lobby ---------- */
.lobby { display: grid; grid-template-columns: 1fr 320px; gap: 40px; align-items: start; }
@media (max-width: 800px) { .lobby { grid-template-columns: 1fr; } }
.lobby-code { text-align: center; }
.lobby-hint { color: var(--muted); margin: 0; font-size: 16px; }
.lobby-url { font-size: 26px; font-weight: 800; margin: 4px 0 14px; }
.code {
  font-size: clamp(48px, 9vw, 96px); font-weight: 900; letter-spacing: .06em;
  margin: 0 0 18px; font-variant-numeric: tabular-nums; line-height: 1;
}
.qr { max-width: 240px; margin: 0 auto; }
.qr svg { width: 100%; height: auto; border-radius: 8px; }
.count-big { font-size: 46px; font-weight: 900; margin: 0 0 8px; line-height: 1; }
.count-big .unit { font-size: 16px; font-weight: 600; color: var(--muted); }
.teamlist { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.teamlist li {
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 14px; font-size: 15px;
}

/* ---------- Pult ---------- */
.pult-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.pult-head h1 { margin: 0; }
.pult-meta { display: flex; align-items: center; gap: 16px; }
.code-small { font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: .08em; }
.inline-form { display: inline; }

table.standings {
  width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
table.standings th, table.standings td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line);
}
table.standings thead th { background: #eef1f6; font-size: 13px; color: var(--muted); }
table.standings tr:last-child td { border-bottom: 0; }
table.standings tr.has-bingo { background: #ecfdf5; font-weight: 700; }
table.standings tr.mine td { box-shadow: inset 3px 0 0 var(--ink); }
.bar { background: #e5e9f0; border-radius: 999px; height: 12px; min-width: 120px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--ink); border-radius: 999px; }

/* ---------- Beitritt und Warten ---------- */
.joinbox, .waiting { max-width: 460px; margin: 40px auto; text-align: center; }
.join-form { text-align: left; margin-top: 20px; }
.join-form .field { display: block; margin-bottom: 16px; }
.join-form .field > span { display: block; font-weight: 700; margin-bottom: 4px; }
.join-form input {
  width: 100%; font: inherit; font-size: 20px; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 10px;
}
.join-form input:focus { outline: none; border-color: var(--ink); }
.code-input { font-size: 30px !important; letter-spacing: .25em; text-align: center; }
.join-form .btn { width: 100%; text-align: center; }
.bingo-badge {
  background: #ecfdf5; border: 2px solid var(--ok); color: #065f46;
  border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 700;
}

/* ---------- DuoBingo ---------- */
.rolle {
  border: 2px solid var(--ink); border-radius: 12px;
  padding: 12px 14px; margin: 16px 0; background: #fff;
}
.rolle-name { margin: 0; font-weight: 900; font-size: 18px; }
.rolle-text { margin: 2px 0 8px; font-size: 14px; color: var(--muted); }
.warte-partner {
  font-size: 18px; color: var(--muted); margin: 0;
  padding: 14px 0 4px; border-top: 1px dashed var(--line);
}
.warten {
  background: var(--card); border: 2px dashed var(--line);
  border-radius: var(--radius); padding: 28px 24px; text-align: center; margin-bottom: 20px;
}
.warten h2 { margin: 0 0 6px; }
.duo-teams { text-align: left; margin-bottom: 26px; }
.duo-teams h2 { font-size: 18px; }
.teamlist.choose { flex-direction: column; align-items: stretch; }
.teamlist.choose li { background: none; border: 0; padding: 0; }
.teamlist.choose .btn { width: 100%; text-align: left; margin: 0 0 8px; font-weight: 500; }
.paar-offen, .paar-voll { font-size: 12px; border-radius: 999px; padding: 1px 8px; margin-left: 6px; }
.paar-offen { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }
.paar-voll  { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }

/* ---------- Auswertung ---------- */
.cell .wait.ok { background: rgba(255, 255, 255, .35); }
.hakt { border-top: 1px solid var(--line); padding: 14px 0; }
.hakt:first-of-type { border-top: 0; }
.hakt-kopf { margin: 0 0 6px; font-size: 17px; }
.hakt-kopf .chip {
  background: var(--c, #999); color: #fff; padding: 2px 10px; border-radius: 999px;
  font-size: 13px; margin-right: 8px; font-weight: 800;
}
.hakt-loesung { margin: 0 0 6px; color: var(--ok); font-size: 15px; }
.hakt-antworten { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.hakt-antworten li {
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 999px;
  padding: 3px 12px; font-size: 14px;
}
.hakt-antworten em { font-style: normal; color: var(--muted); margin-left: 4px; }
.result-card.won { border-color: var(--ok); }
table.review { width: 100%; border-collapse: collapse; font-size: 15px; }
table.review th, table.review td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top;
}
table.review thead th { font-size: 13px; color: var(--muted); }
.wrong-answer { color: var(--err); }
.nowrap { white-space: nowrap; }
.prompt { max-width: 420px; }

.board.demo .cell { animation: pop .5s ease-out backwards; }
.board.demo .cell:nth-child(4n+1) { animation-delay: .05s; }
.board.demo .cell:nth-child(4n+2) { animation-delay: .12s; }
.board.demo .cell:nth-child(4n+3) { animation-delay: .19s; }
.board.demo .cell:nth-child(4n)   { animation-delay: .26s; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .board.demo .cell { animation: none; } }
