:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --border: #d9dce5;
  --text: #171a21;
  --muted: #5d6475;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --ok: #2b8a3e;
  --ok-bg: #e3f6e8;
  --bad: #c92a2a;
  --bad-bg: #fde8e8;
  --warn: #b35c00;
  --warn-bg: #fff1dc;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1a1d24;
    --surface-2: #232731;
    --border: #2f3441;
    --text: #e9ebf0;
    --muted: #9aa1b2;
    --accent: #6d8bff;
    --accent-text: #0d1020;
    --ok: #51cf66;
    --ok-bg: #16301d;
    --bad: #ff6b6b;
    --bad-bg: #3a1a1a;
    --warn: #ffa94d;
    --warn-bg: #3a2810;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.6em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 0.8em; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Bausteine ---------- */

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

button, .btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
}
button:hover:not(:disabled) { filter: brightness(0.97); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
button.bad { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
button.ghost { background: transparent; }
button.sm { min-height: 34px; padding: 4px 10px; font-size: 0.875rem; }
button.on { outline: 2px solid var(--accent); outline-offset: 1px; }
button.wide { width: 100%; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input.sm { min-height: 34px; padding: 4px 8px; font-size: 0.875rem; }
label { display: block; font-weight: 600; margin-bottom: 6px; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 160px; min-width: 0; }
.stack > * + * { margin-top: 12px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.accent { background: var(--accent); color: var(--accent-text); }

.notice {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn);
  margin-bottom: 12px;
}
.notice.error { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--border); flex: none; }
.dot.on { background: var(--ok); }

.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 100%; transition: width 0.2s linear; }
.bar.urgent > i { background: var(--bad); }

.conn {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bad);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.875rem;
  z-index: 10;
}

/* ---------- Gruppen-Seite ---------- */

.group-page { max-width: 520px; margin: 0 auto; padding: 16px; min-height: 100svh; display: flex; flex-direction: column; }
.group-page header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 16px; }
.group-page header .title { font-weight: 700; font-size: 1.05rem; }
.group-page main { flex: 1; }
.center { text-align: center; padding: 32px 8px; }
.big-icon { font-size: 3rem; line-height: 1; margin-bottom: 12px; }

.countdown { font-size: 3.2rem; font-weight: 800; text-align: center; line-height: 1; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.countdown.urgent { color: var(--bad); }

.mc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.mc-grid button { min-height: 96px; font-size: 2.2rem; font-weight: 800; border-width: 2px; }
.mc-grid button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); outline: none; }

.answer-input { font-size: 1.25rem; min-height: 56px; }
.preview { min-height: 1.5em; margin-top: 6px; font-size: 0.95rem; }
.saved { margin-top: 12px; }

/* ---------- Admin ---------- */

.admin-page { max-width: 1400px; margin: 0 auto; padding: 16px; }
.admin-page > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .cols { grid-template-columns: minmax(0, 1fr); } }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; border-radius: 0; background: var(--surface); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent); color: var(--accent-text); outline: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 34px; padding: 4px 10px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.list li:first-child { border-top: 0; }
.list li .name { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }

.mult-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 12px; }
.mult-list .item { display: flex; align-items: center; gap: 8px; }
.mult-list .item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mult-list input { width: 72px; flex: none; }
.mult-list .item.boost span { color: var(--accent); font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.925rem; }
th, td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--border); vertical-align: middle; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; border-top: 0; }
td.answer { overflow-wrap: anywhere; min-width: 120px; font-weight: 600; }
td.pts { font-weight: 700; text-align: right; }
tr.row-ok td.answer { color: var(--ok); }
tr.row-bad td.answer { color: var(--bad); }
td input.sm { width: 76px; }
td .verdict { display: flex; gap: 4px; }

details.round { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; background: var(--surface); }
details.round > summary { cursor: pointer; padding: 10px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; list-style: none; }
details.round > summary::-webkit-details-marker { display: none; }
details.round > summary::before { content: "▸"; color: var(--muted); }
details.round[open] > summary::before { content: "▾"; }
details.round > .body { padding: 0 12px 12px; }
details.round.active { border-color: var(--accent); }

.live-countdown { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.live-countdown.urgent { color: var(--bad); }

.tiers { display: grid; grid-template-columns: auto 80px auto 80px auto auto; gap: 6px; align-items: center; justify-content: start; }
.tiers input { min-height: 34px; padding: 4px 8px; }

.board { counter-reset: none; }
.board li .rank { width: 2.2em; font-weight: 800; text-align: right; flex: none; }
.board li .total { font-weight: 800; font-variant-numeric: tabular-nums; }

.login { max-width: 380px; margin: 12vh auto 0; }
