:root {
  --bg: #101018;
  --panel: #191924;
  --panel-2: #21212f;
  --line: #2e2e40;
  --ink: #f2f2f7;
  --muted: #9a9ab0;
  --accent: #ffcf4a;
  --accent-ink: #241d00;
  --danger: #ff6b6b;
  --radius: 14px;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* Muss über allem stehen: Regeln wie .settings{display:grid} oder .row{display:flex}
   schlagen sonst die Browser-Regel für [hidden] — und Gäste sehen dann Knöpfe,
   die nur dem Gastgeber gehören. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  overscroll-behavior: none;   /* kein Ziehen-zum-Neuladen mitten im Strich */
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ─────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--font);
  font-size: 22px;
  letter-spacing: .01em;
  color: var(--ink);
  text-decoration: none;
}
.brand span { color: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px;
  letter-spacing: .18em;
  color: var(--accent);
  padding-left: .18em;
}

/* ── Layout ─────────────────────────────────────────────── */

main {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.screen.wide { max-width: none; }
main:has(.screen.wide:not([hidden])) { max-width: 900px; }

h2 {
  font-family: var(--font);
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 500;
  margin: 0 0 10px;
}

h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; font-weight: 600; }

.lead { color: var(--muted); line-height: 1.6; margin: 0 0 22px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ── Karten & Formulare ─────────────────────────────────── */

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label { font-size: 13px; color: var(--muted); }

input, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  padding: 12px 14px;
}

input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

#codeInput {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 24px;
  letter-spacing: .3em;
  text-transform: uppercase;
}

textarea { resize: vertical; line-height: 1.5; }

button {
  font: inherit;
  touch-action: manipulation;  /* kein Doppeltipp-Zoom auf Knöpfen */
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease;
}
button:hover { background: #2a2a3c; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }

button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.primary:hover { background: #ffd868; }
button.ghost { background: transparent; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.row.center { justify-content: center; }

/* Große Ziele für kleine Finger: Startseite und Hauptknöpfe. */
.name-card { margin-bottom: 14px; }
#screen-home > .card:first-child { margin-top: 6px; }

.card-title { font-size: 17px; font-family: var(--font); text-transform: none;
  letter-spacing: 0; color: var(--ink); font-weight: 500; margin: 0; }
.card-text { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0; }

button.big { padding: 16px 22px; font-size: 17px; }

select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  padding: 12px 14px;
}
.join-card #codeInput { text-align: center; }
#joinHint { min-height: 1.4em; margin: 0; }

.big-code { font-size: 30px; letter-spacing: .22em; color: var(--accent); }

.steps { counter-reset: step; list-style: none; margin: 30px 0 14px; padding: 0;
  display: grid; gap: 12px; }
.steps li { position: relative; padding-left: 44px; color: var(--muted); line-height: 1.5; }
.steps li strong { color: var(--ink); font-weight: 600; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--sans); font-weight: 700; font-size: 15px;
}

/* ── Spielerliste ───────────────────────────────────────── */

.players { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 8px; }

.players li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
}

.players li .tag { margin-left: auto; font-size: 12px; color: var(--muted); }
.players li.done { border-color: #3d5a3d; }
.players li.done .tag { color: #7fd17f; }
.players li.off { opacity: .45; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: #4caf7d; flex: none; }
.dot.off { background: var(--muted); }

/* ── Einstellungen in der Lobby ─────────────────────────── */

.settings {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 16px;
}

.setting-row { display: grid; gap: 8px; }
.setting-row label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.setting-row output { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }

.settings input[type="range"] { width: 100%; accent-color: var(--accent); padding: 0; background: none; border: none; }
.settings .hint { margin: 0; }

/* ── Runde ──────────────────────────────────────────────── */

.round-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

.pill {
  font-size: 12px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
}

.timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}
.timer.urgent { color: var(--danger); }

.prompt {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 18px;
  font-family: var(--font);
  font-size: 20px;
  line-height: 1.45;
}
.prompt img { width: 100%; border-radius: 8px; display: block; background: #fff; }
.prompt .who { display: block; font-family: var(--sans); font-size: 12px; color: var(--muted); margin-bottom: 8px; }

/* ── Zeichnen ───────────────────────────────────────────── */

.canvas-wrap {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  touch-action: none;
}

#canvas {
  display: block; width: 100%; height: 100%;
  touch-action: none; cursor: crosshair;
  /* Kein Auswählen, kein Lupen-Popup, kein blauer Blitz beim Antippen */
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.swatches { display: flex; flex-wrap: wrap; gap: 11px; padding: 3px 0; }
.sizes { display: flex; gap: 6px; }

/* Die Farbfelder liegen auf dunklem Grund — ohne hellen Ring wäre gerade
   Schwarz eine unsichtbare Fläche. Der Ring gilt für alle, damit die Reihe
   gleichmäßig aussieht. */
.swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .55);
}
.swatch:hover { box-shadow: 0 0 0 2px rgba(255, 255, 255, .9); }

/* Die gewählte Farbe bekommt einen abgesetzten Ring statt eines Rahmens —
   der funktioniert über jeder Farbe, auch über Weiß und Gelb. */
.swatch.active {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px var(--accent);
  transform: scale(1.06);
}

.size {
  width: 34px; height: 30px;
  display: grid; place-items: center;
  padding: 0;
}
.size i { display: block; background: var(--ink); border-radius: 50%; }
.size.active { background: var(--accent); }
.size.active i { background: var(--accent-ink); }

.tools .primary { margin-left: auto; }

/* ── Präsentation & Album ───────────────────────────────── */

.chain { display: grid; gap: 14px; }

.chain .step {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  animation: rise .35s ease both;
}

.chain .step .who { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.chain .step .said { font-family: var(--font); font-size: clamp(19px, 3.4vw, 26px); line-height: 1.4; }
.chain .step.missed .said { color: var(--muted); font-style: italic; }
.chain .step img, .chain .step canvas.replay {
  width: 100%; height: auto; border-radius: 8px; background: #fff; display: block;
}
.chain .step canvas.replay { cursor: pointer; }
.replay-btn { display: block; margin: 10px auto 0; }
.invite-card { border-color: var(--accent); }

.invite-maker {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
  display: grid;
  gap: 8px;
}
.invite-maker-row { display: flex; gap: 8px; }
.invite-maker-row input { flex: 1; }
.invite-maker .hint { margin: 0; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.album-book { margin: 0 0 34px; }
.album-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.album-head h3 { margin: 0; }
button.small { padding: 7px 13px; font-size: 13px; }

.album-book h3 { color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 17px; font-family: var(--font); }

/* ── Overlays ───────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 18px;
  z-index: 20;
  max-width: 90vw;
}

.offline {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--danger);
  color: #240404;
  font-weight: 600;
  text-align: center;
  padding: 8px;
  z-index: 30;
}

@media (max-width: 560px) {
  .tools .primary { margin-left: 0; width: 100%; }
  main { padding: 20px 14px 44px; }
}
