:root {
  --bg: #070b16;
  --bg-2: #10182b;
  --panel: color-mix(in srgb, var(--bg-2) 82%, transparent);
  --field: color-mix(in srgb, var(--bg-2) 50%, var(--bg));
  --line: color-mix(in srgb, var(--text) 10%, transparent);
  --text: #eef3ff;
  --muted: #93a0c2;
  --gold: #f3c14e;
  --mint: #3ee0b3;
  --rose: #ff6b8a;
  --blue: #6aa6ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font: "Outfit", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--blue) 18%, transparent), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, color-mix(in srgb, var(--gold) 12%, transparent), transparent 45%),
    var(--bg);
  color: var(--text);
}

a { color: var(--blue); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand strong { letter-spacing: 0.08em; text-transform: uppercase; font-size: 13px; color: var(--gold); }
.brand span { color: var(--muted); font-size: 14px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
}
.pill b { color: var(--text); font-weight: 600; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr 360px;
  gap: 18px;
  padding: 18px;
  min-height: calc(100vh - 74px);
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  backdrop-filter: blur(16px);
}
.panel h2, .panel h3 { margin: 0 0 12px; font-size: 16px; font-weight: 650; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { font-size: 13px; color: var(--muted); }
input, textarea, select {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus { border-color: color-mix(in srgb, var(--blue) 70%, transparent); }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--blue) 24%, var(--bg-2));
  color: var(--text);
}
.btn:hover { filter: brightness(1.08); }
.btn.gold { background: var(--gold); color: #1a1403; font-weight: 700; }
.btn.mint { background: var(--mint); color: #06241b; font-weight: 700; }
.btn.rose { background: var(--rose); color: #2a0710; font-weight: 700; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.tiny { padding: 6px 8px; border-radius: 9px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.qr {
  width: 100%;
  border-radius: 16px;
  background: white;
  padding: 10px;
  display: block;
}
.muted { color: var(--muted); font-size: 13px; line-height: 1.45; }
.mono { font-variant-numeric: tabular-nums; }
.warn { color: var(--rose); font-size: 13px; }

.answers { display: flex; flex-direction: column; gap: 8px; max-height: 42vh; overflow: auto; }
.answer, .team {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.answer .meta, .team .meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.answer .value { font-size: 22px; margin: 6px 0; word-break: break-word; }
.team { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.team .score { font-size: 28px; font-weight: 700; color: var(--gold); }
.team-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.display {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  padding: 28px;
}
.display .qr-wrap { text-align: center; }
/* QR masqué par l'hôte : la colonne latérale disparaît, les bandeaux (prompt/question) passent en pleine largeur. */
.display.qr-hidden { grid-template-columns: 1fr; }
.display.qr-hidden .qr-wrap { display: contents; }
.display .qr { max-width: 280px; margin: 0 auto 12px; }
.board { display: flex; flex-direction: column; gap: 12px; }
.rank {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.rank .pos { font-size: 28px; color: var(--muted); }
.rank .name { font-size: 32px; font-weight: 700; }
.rank .pts { font-size: 42px; font-weight: 800; color: var(--gold); }
/* Classement minimisé (réglage hôte) : une ligne fine par équipe. */
.board.compact { gap: 6px; }
.board.compact .rank {
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 12px;
}
.board.compact .rank .pos { font-size: 16px; }
.board.compact .rank .name { font-size: 18px; font-weight: 650; }
.board.compact .rank .pts { font-size: 22px; font-weight: 700; }
.board.compact .rank .muted { display: none; }
.prompt-banner {
  margin-top: 18px;
  padding: 18px 20px;
  border-radius: 18px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--mint) 16%, transparent), color-mix(in srgb, var(--blue) 12%, transparent));
  border: 1px solid var(--line);
}
.prompt-banner small { color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.prompt-banner h2 { margin: 6px 0 0; font-size: 34px; }

.play {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h1 { margin: 0 0 8px; font-size: 28px; }
.status { margin: 8px 0 16px; color: var(--muted); }
.waiting {
  padding: 28px 8px;
  text-align: center;
  color: var(--muted);
}
.waiting .pulse {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--mint); margin: 0 auto 12px;
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.5; }
}

.home {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.home .card { width: min(560px, 100%); }
.links { display: grid; gap: 10px; margin-top: 16px; }
.links a {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.links a strong { display: block; color: var(--gold); margin-bottom: 4px; }

@media (max-width: 1100px) {
  .layout, .display { grid-template-columns: 1fr; }
  .rank .name { font-size: 24px; }
  .rank .pts { font-size: 32px; }
  .tab-panel.active { grid-template-columns: 1fr; }
}

/* === Onglets (host) === */
.tabs {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 14px 18px 0;
}
.tab-btn {
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab-btn:hover { filter: brightness(1.08); color: var(--text); }
.tab-btn.active { background: var(--gold); color: #1a1403; border-color: transparent; }
.tab-badge {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--mint); display: inline-block;
}
.tab-panel { display: none; padding: 18px; min-height: calc(100vh - 140px); }
.tab-panel.active {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.tab-panel .panel.wide { grid-column: 1 / -1; }

/* === Boutons de thème (play) === */
#active-body .btn { width: 100%; }
/* Dans une ligne (verdicts ✓/✗, ±points…) : largeur auto pour ne pas empiler
   les boutons les uns sur les autres sur la carte de l'équipe. */
#active-body .row .btn { width: auto; }

/* === Timer (compte à rebours des questions) === */
.timer {
  margin: 8px 0 0;
  font-size: 26px; font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.timer.over { color: var(--rose); }
.play .timer { font-size: 20px; margin: 4px 0 8px; }
.timer-inline { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-inline.over { color: var(--rose); }

/* === Dé 10 === */
.d10-inline { font-size: 1.5rem; }
.d10-big {
  font-size: 4rem; font-weight: 800;
  text-align: center; padding: 12px 0;
  letter-spacing: 0.05em;
}

/* === Bannière question active (display) === */
.active-banner { margin-top: 12px; }
.reveal-winners {
  font-size: 1.5rem; font-weight: 800;
  color: var(--gold); text-align: center; margin-top: 8px;
}

/* === Formulaire banque (host) === */
#question-form textarea {
  width: 100%; font-family: inherit; resize: vertical;
}
#question-form select { width: 100%; }
#active-body .active-head { margin-bottom: 8px; }

/* === Charte graphique (panneau host) === */
.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.swatches label { display: flex; align-items: center; gap: 8px; }
.swatches input[type="color"] {
  width: 42px; height: 28px; padding: 2px; flex: none;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--field);
}
input[type="range"] { padding: 0; accent-color: var(--gold); }
#active-body .active-head h3 { margin: 4px 0; }
#active-body .d10-inline { margin: 8px 0; }

/* === Verdicts (contour vert/rouge) === */
.answer.verdict-correct {
  border-color: var(--mint);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--mint) 60%, transparent);
}
.answer.verdict-incorrect {
  border-color: var(--rose);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--rose) 60%, transparent);
}
.btn.tiny.on { outline: 2px solid var(--text); outline-offset: 1px; }

/* === Dé 3D (overlay display + play) === */
.dice-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(8px);
}
.dice-overlay[hidden] { display: none; }
.dice-stage { position: relative; width: min(72vmin, 560px); aspect-ratio: 1 / 1; }
.dice-stage canvas { width: 100%; height: 100%; display: block; }
.dice-value {
  position: absolute; left: 0; right: 0; bottom: 2%;
  text-align: center;
  font-size: clamp(3rem, 12vmin, 6rem); font-weight: 800;
  color: var(--gold);
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  opacity: 0; transform: scale(0.8);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.dice-value.show { opacity: 1; transform: scale(1); }
.play .dice-stage { width: min(64vmin, 340px); }

/* === Réponses affichées sur la projection === */
.answers-banner { text-align: left; max-height: 52vh; overflow: auto; }
.answers-banner .answers { max-height: none; margin-top: 8px; }
.answers-banner .answer .value { font-size: 24px; }
.display-answers { margin-top: 10px; max-height: 44vh; }
.display-answers .answer .value { font-size: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--field);
  font-size: 13px;
}
.chip.ok { border-color: var(--mint); color: var(--mint); }
.chip.bad { border-color: var(--rose); color: var(--rose); text-decoration: line-through; }
.chip.done { opacity: .5; text-decoration: line-through; }
/* Thème + sa question dédiée affichés pendant la sélection (plus proche gagne) */
.chip.theme-chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.chip.theme-chip small { color: var(--muted); font-weight: 400; font-size: 12px; }
#active-body .btn small { display: block; font-weight: 400; font-size: 12px; opacity: 0.85; text-align: left; }

/* === État des équipes sur la projection (a répondu / a voté / en attente) === */
.teams-status { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.team-status {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 12px;
  background: var(--field); border: 1px solid var(--line);
  font-size: 15px; font-weight: 600;
}
.team-status .tstate { color: var(--muted); font-size: 12px; font-weight: 400; }
.team-status.done { border-color: var(--mint); }
.team-status.done .tstate { color: var(--mint); font-weight: 700; }

/* === Estimation (slider + saisie manuelle) === */
.estimate-slider { width: 100%; }
.estimate-row { display: flex; gap: 8px; align-items: center; }
.estimate-row input { flex: 1; }
.estimate-unit { color: var(--muted); font-weight: 700; font-size: 18px; white-space: nowrap; }

/* === Cases à cocher (formulaire banque) === */

.check-row { display: flex; align-items: center; gap: 8px; }

.check-row input[type="checkbox"] { width: auto; }

/* === « Combien tu te mets » (TTMC, play) === */
.bid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.bid-grid .btn { width: auto; font-size: 20px; font-weight: 700; padding: 12px 8px; }

/* === Images (plein écran projection, vignettes host, téléphone) === */
.image-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 4vmin;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
}
.image-overlay[hidden] { display: none; }
.image-overlay img {
  max-width: 100%; max-height: 86vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.image-caption {
  position: fixed; left: 0; right: 0; bottom: 3vh;
  margin: 0; text-align: center;
  color: var(--muted); font-size: 20px;
}
.thumb {
  max-width: 120px; max-height: 80px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block; margin-top: 8px;
}
.thumb.big { max-width: 100%; max-height: 260px; object-fit: contain; }
#image-box img {
  width: 100%; max-height: 42vh;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--field);
  margin-bottom: 12px;
}
