:root {
  --felt: #0b3d2e;
  --felt-dark: #072a20;
  --felt-light: #13573f;
  --card: #10241d;
  --card-2: #183329;
  --line: #2a4a3e;
  --text: #f2f5f3;
  --muted: #9db5ab;
  --gold: #e8b64a;
  --gold-dark: #b98a24;
  --red: #d9534f;
  --green: #3cbf7a;
  --blue: #4aa3e8;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  --panel-h: 0px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at top, var(--felt-light), var(--felt) 45%, var(--felt-dark));
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

h1, h2 { margin: 0 0 0.6rem; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
a { color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- Kopfzeile ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 16px;
  padding-top: max(0.6rem, env(safe-area-inset-top));
  background: rgba(7, 42, 32, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: 0.02em; white-space: nowrap; }
.brand span { color: var(--gold); }
.brand small { font-weight: 500; font-size: 0.8rem; color: var(--muted); margin-left: 0.3rem; }

.me-info { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip-amount {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.chip-amount::before {
  content: '';
  width: 0.9em;
  height: 0.9em;
  border-radius: 50%;
  background: var(--gold);
  border: 2px dashed var(--gold-dark);
  flex: none;
}

.tabs { display: flex; gap: 0.25rem; overflow-x: auto; }
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { background: var(--card-2); color: var(--text); }

/* ---------- Karten & Layout ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.game, .admin-main {
  display: grid;
  gap: 12px;
  padding: 12px 16px calc(var(--panel-h) + 24px);
  max-width: 1200px;
  margin: 0 auto;
}
.col-main, .col-side { display: grid; gap: 12px; align-content: start; min-width: 0; }

@media (min-width: 900px) {
  .game, .admin-main { grid-template-columns: 1.4fr 1fr; padding-top: 20px; }
  .admin-main.single { grid-template-columns: 1fr; max-width: 900px; }
}

.join { display: grid; place-items: center; padding: 24px 16px; min-height: calc(100dvh - 60px); }
.join-card { width: 100%; max-width: 420px; display: grid; gap: 0.7rem; }

/* ---------- Formulare & Buttons ---------- */

label { display: grid; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }

input, select, textarea {
  font: inherit;
  font-size: 16px; /* verhindert Zoom auf iOS */
  color: var(--text);
  background: var(--felt-dark);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
textarea { resize: vertical; }

.btn {
  font: inherit;
  font-weight: 650;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  color: var(--text);
  background: var(--card-2);
  min-height: 44px;
  touch-action: manipulation;
  transition: transform 0.05s, filter 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--green); color: #05150e; }
.btn.gold { background: var(--gold); color: #1d1405; }
.btn.danger { background: var(--red); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.small { padding: 0.35rem 0.7rem; min-height: 34px; font-size: 0.85rem; }
.btn.big { padding: 0.85rem 1.2rem; font-size: 1.05rem; }
.file-btn { display: inline-flex; align-items: center; color: var(--text); font-size: 0.85rem; }

.input-row { display: flex; gap: 0.5rem; }
.input-row input { flex: 1; }
.control-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* ---------- Frage & Hinweise ---------- */

.question-card { border-color: var(--gold-dark); }
.q-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold); margin-bottom: 0.4rem; }
.q-text { font-size: clamp(1.2rem, 4.5vw, 1.7rem); font-weight: 700; line-height: 1.25; }
.q-unit { margin-top: 0.4rem; color: var(--muted); }
.my-answer, .admin-solution {
  margin-top: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  background: var(--felt-dark);
  border: 1px dashed var(--line);
}

.clues { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.clue {
  border-radius: var(--radius);
  padding: 0.6rem;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.clue.closed {
  background: repeating-linear-gradient(45deg, #7a1f1f, #7a1f1f 8px, #8d2727 8px, #8d2727 16px);
  border-color: #b33a3a;
}
.clue.open { background: #f6f1e4; color: #1b1b1b; animation: flip 0.45s ease-out; }
.clue.open.solution { background: #fff5d6; border: 2px solid var(--gold); }
.clue-head { display: flex; justify-content: space-between; gap: 0.3rem; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.clue.closed .clue-head { color: #ffd9d9; }
.clue-street { opacity: 0.7; }
.clue-body { font-size: 0.9rem; flex: 1; overflow-wrap: anywhere; }
.clue-back { display: grid; place-items: center; height: 100%; font-size: 2.4rem; font-weight: 800; color: rgba(255, 255, 255, 0.85); }
.clue-solution { display: grid; place-items: center; height: 100%; font-size: clamp(1.1rem, 4vw, 1.6rem); font-weight: 800; text-align: center; }

@keyframes flip {
  from { transform: rotateY(90deg); }
  to { transform: rotateY(0); }
}

@media (max-width: 480px) {
  .clue-street { display: none; }
}
@media (max-width: 420px) {
  .clue { min-height: 100px; padding: 0.5rem; }
  .clue-body { font-size: 0.8rem; }
}

/* ---------- Tisch / Spieler ---------- */

.pot {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.3rem;
  margin-bottom: 0.8rem;
}
.pot-label { color: var(--muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.08em; }

.seats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.seat {
  position: relative;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}
.seat.me { border-color: var(--blue); }
.seat.turn { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(232, 182, 74, 0.4); }
.seat.folded, .seat.out { opacity: 0.5; }
.seat-top { display: flex; justify-content: space-between; gap: 0.3rem; align-items: center; }
.seat-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-chips { font-variant-numeric: tabular-nums; }
.seat-status { font-size: 0.8rem; color: var(--muted); }
.seat.turn .seat-status { color: var(--gold); font-weight: 700; }
.seat.ok .seat-status { color: var(--green); }
.seat.allin .seat-status { color: var(--red); font-weight: 700; }
.seat-bet {
  justify-self: start;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--gold);
  color: #1d1405;
}
.seat-answer { font-size: 0.85rem; }
.seat-won { color: var(--green); font-weight: 800; }
.badges { display: flex; gap: 0.2rem; flex: none; }
.badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: var(--line);
  color: var(--text);
}
.badge.dealer { background: #fff; color: #111; }
.offline-dot { display: inline-block; width: 0.55em; height: 0.55em; border-radius: 50%; background: var(--red); margin-right: 0.35rem; vertical-align: middle; }

.log { font-size: 0.85rem; color: var(--muted); display: grid; gap: 0.2rem; }
.col-side > .log { padding: 0 0.3rem; }

/* ---------- Aktionsleiste ---------- */

.panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(7, 42, 32, 0.97);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}
.panel > * { max-width: 640px; margin-left: auto; margin-right: auto; }
.panel-msg { text-align: center; color: var(--muted); padding: 0.4rem 0; }
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.panel-row .panel-msg { text-align: left; }
.answer-form { display: grid; gap: 0.4rem; }
.answer-form label { color: var(--text); font-weight: 600; }
.turn-banner { text-align: center; font-weight: 800; color: var(--gold); margin-bottom: 0.5rem; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.actions .btn { min-height: 52px; font-size: 1.05rem; }
.raise-box { display: grid; gap: 0.5rem; margin-top: 0.6rem; }
.raise-box input[type='range'] { padding: 0; accent-color: var(--gold); }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
body.my-turn .panel { border-top: 2px solid var(--gold); }

/* Platz für die feste Aktionsleiste */
.player-view .game { padding-bottom: 240px; }

/* ---------- Ergebnis ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
}
.result-card { width: 100%; max-width: 460px; max-height: 90dvh; overflow: auto; display: grid; gap: 0.8rem; text-align: center; }
.result-solution { font-size: 1.2rem; }
.ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; text-align: left; }
.ranking li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  background: var(--card-2);
}
.ranking li.winner { background: rgba(60, 191, 122, 0.2); border: 1px solid var(--green); font-weight: 700; }
.pots { list-style: none; margin: 0; padding: 0; color: var(--muted); font-size: 0.9rem; }

/* ---------- Admin ---------- */

.control-card { display: grid; gap: 0.8rem; }
.control-status { font-size: 1.1rem; font-weight: 700; }
.control-row select { flex: 1 1 220px; width: auto; }
.control-row #btn-advance { flex: 1 1 200px; }
.control-row.secondary { justify-content: flex-end; }

.player-admin { margin-top: 0.8rem; }
.player-admin summary { cursor: pointer; color: var(--muted); padding: 0.3rem 0; }
.player-controls { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.4rem; padding: 0.45rem 0; border-top: 1px solid var(--line); }

.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; }
.card-head h2 { margin: 0; }
.qform { display: grid; gap: 0.7rem; }
.form-grid { display: grid; gap: 0.7rem; grid-template-columns: 1fr; }
@media (min-width: 560px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid.three { grid-template-columns: repeat(3, 1fr); }
}
.question-list { display: grid; gap: 8px; }
.question-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: space-between;
  padding: 0.7rem;
  border-radius: 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
}
.question-item.used { opacity: 0.6; }
.qi-main { flex: 1 1 260px; min-width: 0; display: grid; gap: 0.15rem; }
.qi-text { font-weight: 650; overflow-wrap: anywhere; }
.qi-meta { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.qi-actions { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: flex-start; }

/* ---------- Meldungen ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: 70px;
  z-index: 50;
  transform: translate(-50%, -20px);
  max-width: calc(100% - 32px);
  padding: 0.7rem 1rem;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--green); color: #05150e; }

.offline-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  padding: 0.4rem;
  text-align: center;
  background: var(--red);
  color: #fff;
  font-weight: 600;
}
body.offline .offline-banner { display: block; }

/* ---------- Räume ---------- */

.room-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--gold-dark);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  vertical-align: middle;
}

.code-input {
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3em;
}
.code-input::placeholder { font-size: 1rem; font-weight: 400; letter-spacing: normal; text-transform: none; }

.error-msg {
  margin: 0;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: rgba(217, 83, 79, 0.18);
  border: 1px solid var(--red);
}

.center { text-align: center; }

.room-code {
  display: inline-block;
  margin-right: 0.4rem;
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.12em;
}

.set-row { margin: 0.2rem 0 0.8rem; }
.set-row select { flex: 1 1 12rem; }

.join-info { display: grid; gap: 0.5rem; justify-items: center; text-align: center; word-break: break-all; }
.join-code { font-size: 2.2rem; font-weight: 800; letter-spacing: 0.25em; color: var(--gold); }
.qr { width: 180px; height: 180px; padding: 8px; border-radius: 10px; background: #fff; }
