:root {
  --lila: #7e57c2;
  --gruen: #43a047;
  --bg: #f4f2f8;
  --text: #222;
  --muted: #777;
  --card: #fff;
  --radius: 16px;
}
body.lila { --accent: var(--lila); }
body.gruen { --accent: var(--gruen); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}

body.start-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(160deg, var(--lila), var(--gruen));
}
.start-card { width: 100%; max-width: 420px; }

main { max-width: 560px; margin: 0 auto; padding: 12px; }
h1 { margin: 0 0 8px; font-size: 1.6rem; }
h2 { margin: 0 0 12px; font-size: 1.2rem; }
h3 { margin: 16px 0 8px; font-size: 1rem; }
.muted { color: var(--muted); }
.error { color: #c62828; min-height: 1.2em; }
.info { text-align: center; color: var(--muted); margin: 8px 0 4px; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.row > button { flex: 1; }
.full { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-weight: 600; }
input {
  font: inherit;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 10px;
  width: 100%;
}

button {
  font: inherit;
  font-weight: 600;
  min-height: 46px;
  padding: 10px 14px;
  border: none;
  border-radius: 12px;
  background: #e6e3ee;
  color: var(--text);
  cursor: pointer;
}
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent, #555); color: #fff; }
button.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
button.danger { background: #fdecea; }
button.selected {
  background: var(--accent, #555);
  color: #fff;
}

/* Startseite */
.color-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.color-btn { min-height: 90px; font-size: 1.2rem; color: #fff; }
.color-btn.lila { background: var(--lila); }
.color-btn.gruen { background: var(--gruen); }

/* Kopfzeile */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--accent, #555);
  color: #fff;
  font-weight: 700;
}
.topbar button.small { background: rgba(255, 255, 255, .2); color: #fff; }

/* Hinweis */
.notice {
  background: #fff4d6;
  color: #6b4e00;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 12px 0;
  font-size: .9rem;
}

/* Aktuelle Frage */
.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent, #555);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .15);
}
.banner-main { flex: 1; min-width: 0; }
.skip-btn {
  flex-shrink: 0;
  min-height: 44px;
  background: rgba(255, 255, 255, .22);
  color: #fff;
  font-size: .9rem;
}
.banner-owner { font-size: .85rem; opacity: .85; text-transform: uppercase; letter-spacing: .05em; }
.banner-text { font-size: 1.35rem; font-weight: 700; margin-top: 6px; word-break: break-word; }
.banner.flash { animation: flash 1s ease-in-out 3; }
@keyframes flash {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 8px #ffd54f; }
}

/* Fragenliste */
.add-form { display: flex; gap: 8px; }
.add-form button { min-width: 52px; font-size: 1.2rem; }
.questions { list-style: none; padding: 0; margin: 8px 0; counter-reset: q; }
.questions li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  counter-increment: q;
  transition: transform .15s;
}
.questions.no-anim li { transition: none !important; }
.q-text { flex: 1; word-break: break-word; }
.q-text::before { content: counter(q) ". "; }
.questions li button.danger { min-height: 36px; min-width: 36px; padding: 4px 8px; }

.handle {
  touch-action: none;   /* wichtig, damit das Ziehen nicht die Seite scrollt */
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  font-size: 1.5rem;
  line-height: 1;
  padding: 8px 10px;
  color: #888;
}
.questions li.dragging {
  position: relative;
  z-index: 5;
  transition: none;
  background: #f0ebfa;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #eee; }
#scoreboard tr.lila td:first-child { border-left: 6px solid var(--lila); }
#scoreboard tr.gruen td:first-child { border-left: 6px solid var(--gruen); }

/* Auswertung: Ja grün, Nein rot */
td.ans-ja { background: #e3f4e5; color: #1b6e24; font-weight: 700; }
td.ans-nein { background: #fdecea; color: #b71c1c; font-weight: 700; }

/* Overlay für neue Frage */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
}
.overlay.show { display: flex; animation: fade .25s ease-out; }
.overlay-box {
  background: #fff;
  color: var(--accent, #555);
  font-size: 1.6rem;
  font-weight: 800;
  padding: 28px 32px;
  border-radius: 22px;
  text-align: center;
  white-space: pre-line;
  animation: pop .35s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.6); } to { transform: scale(1); } }

/* Toast für Fehlermeldungen */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  display: none;
  z-index: 20;
  max-width: 90%;
}
.toast.show { display: block; }

/* Spielcode */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--muted);
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: #ddd; }
.code-input { text-transform: uppercase; letter-spacing: .25em; text-align: center; font-weight: 700; }
.code-box {
  background: #f0ebfa;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  text-align: center;
}
.code-show { font-size: 2.2rem; font-weight: 800; letter-spacing: .25em; margin-top: 4px; }

/* Mehrspieler */
body.start-page { --accent: var(--lila); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1eef7;
  font-size: .9rem;
}
.chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--c, #888); }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
}
tr.me-row td { font-weight: 700; }

.guess-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
}
.guess-grid button { min-width: 0; }

/* Status in der Punkteliste */
.st-on { color: #2e7d32; font-weight: 600; }
.st-off { color: #b26a00; font-weight: 600; }
.kick-btn {
  margin-left: 6px;
  min-height: 26px;
  min-width: 26px;
  padding: 0 6px;
  font-size: .75rem;
  line-height: 1;
  border-radius: 8px;
  color: #b71c1c;
  vertical-align: middle;
}
button.ghost { background: transparent; color: var(--muted); border: 1px solid #ddd; font-weight: 500; }

/* Besucherzähler (rechts unten) */
.visitor-counter {
  position: fixed;
  right: calc(10px + env(safe-area-inset-right));
  bottom: calc(8px + env(safe-area-inset-bottom));
  font-size: .75rem;
  color: var(--muted);
  background: rgba(255, 255, 255, .75);
  padding: 2px 8px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 1;
}
