:root {
  /* Helle Oberfläche (UI) */
  --paper: #f4f4f2;
  --surface: #ffffff;
  --ink: #1c1d22;
  --ink-muted: #63666f;
  --line: #e3e3e6;
  --line-strong: #c9cbd2;

  --brand: #24306e;
  --brand-hover: #2c3a85;
  --on-brand: #ffffff;

  /* Dunkle Bühne (Spielfeld, Siegerehrung) */
  --stage: #0f1330;
  --stage-text: #9aa3d6;
  --tile: #1a2154;
  --tile-hover: #232c6e;
  --tile-line: #29336e;
  --tile-played: #141939;
  --gold: #ecbe4b;
  --gold-deep: #a8841f;

  --danger: #b3261e;
  --danger-bg: #f9dedc;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow-pop: 0 16px 48px rgba(8, 10, 28, .28);

  --font-ui: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
}

* { box-sizing: border-box; }

html { height: 100%; }
body {
  margin: 0;
  height: 100dvh;
  display: flex; flex-direction: column;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.material-icons { user-select: none; }

/* ---------- App-Bar ---------- */
.app-bar {
  flex: none; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.app-bar__title { display: flex; align-items: center; gap: 10px; }
.app-bar__title h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 600; line-height: 1;
  text-transform: uppercase; letter-spacing: .14em;
}
.app-bar__actions { display: flex; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius);
  height: 38px; padding: 0 16px;
  font: inherit; font-size: .9rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:active { transform: translateY(1px); }
.btn .material-icons { font-size: 18px; }

.btn--filled { background: var(--brand); color: var(--on-brand); }
.btn--filled:hover { background: var(--brand-hover); }
.btn--tonal { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn--tonal:hover { border-color: var(--line-strong); background: #fafafa; }
.btn--accent { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn--accent:hover { border-color: var(--line-strong); background: #fafafa; }
.btn--accent .material-icons { color: var(--gold-deep); }
.btn--text { background: transparent; color: var(--brand); }
.btn--text:hover { background: rgba(36, 48, 110, .06); }
.btn--danger { background: var(--danger-bg); color: var(--danger); }
.btn:disabled, .btn--disabled { opacity: .4; cursor: default; pointer-events: none; }

.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--ink-muted);
  border-radius: 50%; width: 40px; height: 40px;
  display: grid; place-items: center; transition: background .15s;
}
.icon-btn:hover { background: rgba(28, 29, 34, .07); }

/* ---------- Scoreboard ---------- */
.scoreboard {
  margin-left: auto;
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center; justify-content: flex-end;
  max-width: 62%;
}
.score-chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 9px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  font: inherit; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.score-chip:hover { border-color: var(--line-strong); }
.score-chip__dot { width: 4px; height: 20px; border-radius: 2px; flex: none; }
.score-chip__name { font-weight: 500; font-size: .9rem; color: var(--ink); }
.score-chip__pts {
  font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--ink);
  min-width: 28px; text-align: right;
}

/* ---------- Board (dunkle Bühne) ---------- */
.board-wrapper {
  flex: 1; min-height: 0; overflow: auto;
  padding: 16px 20px 20px;
  display: flex;
}
.board {
  flex: 1; min-height: 100%;
  display: grid; gap: 6px;
  background: var(--stage);
  border-radius: var(--radius-lg);
  padding: 10px;
}
.board__head {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--tile); border: 1px solid var(--tile-line);
  color: #fff; border-radius: 8px; padding: 12px 8px;
  font-family: var(--font-display); font-weight: 600; line-height: 1.15;
  text-transform: uppercase; letter-spacing: .08em;
  font-size: clamp(1rem, 1.7vw, 1.4rem);
}
.cell {
  display: flex; align-items: center; justify-content: center;
  background: var(--tile); border: 1px solid var(--tile-line); border-radius: 8px;
  cursor: pointer; user-select: none;
  color: var(--gold);
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.8rem, 3.6vw, 3.4rem);
  font-variant-numeric: tabular-nums;
  transition: background .15s, border-color .15s;
}
.cell:hover { background: var(--tile-hover); border-color: #3a4694; }
.cell--played {
  background: var(--tile-played); border-color: transparent;
  color: rgba(154, 163, 214, .22); cursor: default;
}
.cell--played:hover { background: var(--tile-played); }

/* ---------- Overlay / Dialog ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 24px;
  background: rgba(10, 12, 28, .55);
  animation: fade .15s ease-out;
}
.overlay--light { background: rgba(10, 12, 28, .35); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.dialog, .popover {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  width: min(560px, 100%); max-height: 90vh; overflow: auto;
  animation: pop .18s cubic-bezier(.2,.7,.3,1);
}
.popover { width: min(380px, 100%); }
@keyframes pop { from { transform: scale(.96) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.dialog__header {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 16px 12px 28px;
}
.dialog__header h2 {
  margin: 0; flex: 1;
  font-family: var(--font-display); font-size: 1.6rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  display: flex; align-items: center; gap: 10px;
}
.dialog__points {
  background: var(--stage); color: var(--gold);
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 4px 14px; border-radius: 8px;
}
.dialog__body { padding: 8px 28px 28px; }
.dialog__hint { color: var(--ink-muted); margin: 0 0 20px; }
.dialog__label { font-weight: 600; margin: 0 0 14px; }

.team-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-choice {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font: inherit; font-weight: 600;
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.team-choice:hover { border-color: var(--brand); background: #f8f9fc; }
.team-choice:active { transform: translateY(1px); }
.team-choice__dot { width: 5px; height: 24px; border-radius: 2px; flex: none; }

/* ---------- Spielinhalt im Feld-Dialog ---------- */
/* Der Feld-Dialog ist breiter: Spielinhalt (Frage/Bild) ist der Hauptfokus. */
.dialog--field { width: min(760px, 100%); }
.field-game { margin-bottom: 20px; padding: 12px 0 24px; border-bottom: 1px solid var(--line); }
.field-game .dialog__hint { margin: 0; }
.game-question { margin: 0; font-size: 1.7rem; line-height: 1.45; font-weight: 500; }
.game-answer { margin-top: 22px; }
.game-answer__text {
  margin: 0; padding: 14px 18px;
  background: var(--paper); border-left: 4px solid var(--gold-deep);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-weight: 600; font-size: 1.5rem;
}
.game-image {
  display: block; margin: 0 auto;
  max-width: 100%; max-height: min(58vh, 560px);
  border-radius: var(--radius);
}

/* Punktevergabe kompakt – der Spielinhalt steht im Vordergrund */
.dialog--field .dialog__label {
  font-size: .8rem; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 10px;
}
.dialog--field .team-choices { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.dialog--field .team-choice { padding: 9px 12px; font-size: .9rem; }
.dialog--field .team-choice__dot { height: 18px; }

/* ---------- Felder / Popover ---------- */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.field > span { font-size: .85rem; color: var(--ink-muted); font-weight: 600; }
.field input, .field textarea, .field select {
  font: inherit; padding: 11px 13px; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 76px; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(36, 48, 110, .15);
}
.popover__actions { display: flex; justify-content: flex-end; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Siegerehrung (Vollbild-Bühne) ---------- */
.overlay--stage { background: var(--stage); padding: 0; }
.stage {
  position: relative;
  width: min(820px, 100%); max-height: 100dvh; overflow: auto;
  padding: 56px 32px 48px; text-align: center; color: #fff;
  animation: pop .25s cubic-bezier(.2,.7,.3,1);
}
.stage__close { position: fixed; top: 16px; right: 16px; color: var(--stage-text); }
.stage__close:hover { background: rgba(255, 255, 255, .08); }
.stage h2 {
  margin: 0;
  font-family: var(--font-display); font-size: clamp(2rem, 4vw, 3rem); font-weight: 700;
  text-transform: uppercase; letter-spacing: .18em; color: var(--gold);
}

.podium {
  display: flex; align-items: flex-end; justify-content: center; gap: 10px;
  margin: 44px 0 8px;
}
.podium__col { width: min(200px, 30%); display: flex; flex-direction: column; gap: 6px; }
.podium__name {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 1.05rem;
}
.podium__pts {
  font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1.2;
  color: var(--gold); font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
}
.podium__block {
  display: grid; place-items: center;
  background: var(--tile); border: 1px solid var(--tile-line);
  border-radius: 8px 8px 0 0;
  font-family: var(--font-display); font-size: 2rem; font-weight: 700;
  color: var(--stage-text);
}
.podium__col--1 .podium__block { height: 150px; background: var(--gold); border-color: var(--gold); color: var(--stage); }
.podium__col--2 .podium__block { height: 104px; }
.podium__col--3 .podium__block { height: 72px; }

.ranking { list-style: none; margin: 20px auto 0; padding: 0; width: min(440px, 100%); }
.ranking li {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; border-radius: var(--radius);
  background: rgba(255, 255, 255, .06);
  margin-bottom: 8px; font-weight: 500; text-align: left;
}
.ranking__rank {
  font-family: var(--font-display); font-weight: 700; font-size: 1.2rem;
  color: var(--stage-text); width: 24px; flex: none;
}
.ranking__dot { width: 4px; height: 20px; border-radius: 2px; flex: none; }
.ranking__name { flex: 1; }
.ranking__pts {
  font-family: var(--font-display); font-weight: 700; font-size: 1.2rem;
  color: var(--gold); font-variant-numeric: tabular-nums;
}

/* ---------- Snackbar ---------- */
.snackbar {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px;
  border-radius: var(--radius); box-shadow: var(--shadow-pop);
  z-index: 60; font-size: .9rem; font-weight: 500;
  animation: pop .18s ease-out;
}

[hidden] { display: none !important; }
