:root {
  --accent: #e0b64b;
  --accent-soft: rgba(224, 182, 75, 0.16);
  --bg: #14101a;
  --bg-2: #1d1725;
  --card: #241d2e;
  --card-2: #2c2438;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f1ea;
  --muted: #a89fb4;
  --good: #58d68d;
  --warn: #f5b041;
  --bad: #ec7063;
  --radius: 18px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(224, 182, 75, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(180, 90, 160, 0.14), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .serif {
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

a { color: var(--accent); }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 16px 64px;
}
.wrap.narrow { max-width: 620px; }

/* ---------- Header ---------- */

.hero {
  text-align: center;
  padding: 22px 10px 10px;
}
.hero .kicker {
  text-transform: uppercase;
  letter-spacing: 0.34em;
  font-size: 11px;
  color: var(--accent);
  opacity: 0.9;
}
.hero h1 {
  margin: 6px 0 4px;
  font-size: clamp(28px, 7vw, 46px);
  line-height: 1.05;
}
.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- Cards ---------- */

.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 12px; font-size: 22px; }
.card h3 { margin: 0 0 8px; font-size: 18px; }

.grid { display: grid; gap: 14px; }
@media (min-width: 760px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- Forms ---------- */

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input[type="text"], input[type="number"], input[type="password"], input[type="url"], select, textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.06s ease, filter 0.15s ease;
}
button:hover, .btn:hover { filter: brightness(1.15); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent), #c99b2e);
  border-color: rgba(0, 0, 0, 0.2);
  color: #201a08;
}
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(236, 112, 99, 0.18); border-color: rgba(236, 112, 99, 0.4); }
.btn-big { width: 100%; padding: 18px; font-size: 18px; border-radius: 14px; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }

/* ---------- Badges / pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--accent-soft);
  border: 1px solid rgba(224, 182, 75, 0.35);
  color: var(--accent);
}
.pill.grey { background: rgba(255, 255, 255, 0.06); border-color: var(--line); color: var(--muted); }
.pill.good { background: rgba(88, 214, 141, 0.15); border-color: rgba(88, 214, 141, 0.4); color: var(--good); }
.pill.bad { background: rgba(236, 112, 99, 0.15); border-color: rgba(236, 112, 99, 0.4); color: var(--bad); }

/* ---------- Timer ---------- */

.timer {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
}
.timer.big { font-size: clamp(52px, 16vw, 120px); line-height: 1; }
.timer.urgent { color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.progress {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #f0864b);
  width: 0%;
  transition: width 0.25s linear;
}

/* ---------- Lists ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }

.rank {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.08);
}
.rank.gold { background: linear-gradient(180deg, #f7d774, #c99b2e); color: #241d08; }
.rank.silver { background: linear-gradient(180deg, #e8e8ee, #a9a9b8); color: #24242c; }
.rank.bronze { background: linear-gradient(180deg, #e0a878, #a5703f); color: #2b1c0d; }

.score { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.center { text-align: center; }
.big-number { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Answer rows (animateur) ---------- */

.answers { list-style: none; margin: 0; padding: 0; }
.answers li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.24);
}
.answers li.s90 { border-color: rgba(88, 214, 141, 0.5); background: rgba(88, 214, 141, 0.08); }
.answers li.s70 { border-color: rgba(245, 176, 65, 0.45); background: rgba(245, 176, 65, 0.07); }
.answers li.winner { box-shadow: 0 0 0 2px var(--accent); }
.answers .body { min-width: 0; flex: 1; }
.answers .who { font-size: 12px; color: var(--muted); }
.answers .txt { font-size: 17px; font-weight: 600; }
.answers .pct {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
}
.answers .rank-first { font-size: 11px; color: var(--accent); }

/* ---------- QR ---------- */

.qr-box { background: #fff; border-radius: 14px; padding: 10px; display: inline-block; }
.qr-box img { display: block; width: 100%; height: auto; }
.qr-sm { width: 96px; }
.qr-md { width: 150px; }

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  background: #2c2438;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 999;
  max-width: 90vw;
  text-align: center;
  font-size: 14px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: rgba(236, 112, 99, 0.6); }
#toast.ok { border-color: rgba(88, 214, 141, 0.6); }

/* ---------- Overlay modal ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 12, 0.78);
  backdrop-filter: blur(4px);
  display: none;
  place-items: center;
  z-index: 500;
  padding: 18px;
}
.overlay.show { display: grid; }
.overlay .card { max-width: 520px; width: 100%; margin: 0; }

/* ---------- Confetti ---------- */

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 400; display: none; }
#confetti.show { display: block; }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button.active { background: var(--accent-soft); border-color: rgba(224, 182, 75, 0.4); color: var(--accent); }

.jackpot { animation: pop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes pop { 0% { transform: scale(0.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.bar-chart {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #f0864b);
  margin-top: 5px;
}

/* ---------- Affiche des mariés (hero) ---------- */

.poster-hero {
  margin: 0 auto 16px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(224, 182, 75, 0.25);
  line-height: 0;
}
.poster-hero img {
  width: 100%;
  height: auto;
  display: block;
}
.hero-text {
  text-align: center;
  padding: 0 6px 12px;
}
.hero-text .kicker {
  text-transform: uppercase;
  letter-spacing: 0.34em;
  font-size: 11px;
  color: var(--accent);
}
.hero-text h1 {
  margin: 4px 0 2px;
  font-size: clamp(24px, 6vw, 40px);
}
.hero-text p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- Choix de la table (gros boutons tactiles) ---------- */

.table-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  margin-bottom: 4px;
}
.table-grid button {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.28);
}
.table-grid button.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent) inset;
}
.table-grid button .tiny { display: block; font-weight: 500; }

/* ---------- Bandeau d'alerte (animateur) ---------- */

#alertBanner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 600;
  padding: 14px 18px;
  background: linear-gradient(180deg, #2f7d4f, #1f5c39);
  color: #fff;
  font-weight: 700;
  text-align: center;
  transform: translateY(-110%);
  transition: transform 0.25s ease;
  box-shadow: var(--shadow);
  font-size: 15px;
}
#alertBanner.show { transform: translateY(0); }

/* ---------- Barre d'action collante (animateur, mobile) ---------- */

.actionbar {
  position: sticky;
  bottom: 0;
  z-index: 300;
  display: grid;
  gap: 8px;
  margin: 0 -16px -64px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(20, 16, 26, 0.6), rgba(20, 16, 26, 0.98) 35%);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
}
.actionbar .row { gap: 8px; }

/* ---------- Mes essais (invité) ---------- */

.attempts { list-style: none; margin: 10px 0 0; padding: 0; }
.attempts li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.attempts li:last-child { border-bottom: 0; }
.attempts .n {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}
.pulse {
  animation: pulse 1.4s ease-in-out infinite;
}

.hidden { display: none !important; }

/* ---------- Bandeau affiche compact (pages animateur / mariés) ---------- */

.poster-hero.slim img {
  width: 100%;
  height: auto;
  display: block;
}

/* ---------- Réponses : mise en page téléphone ---------- */

@media (max-width: 560px) {
  .answers li {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "pct body del"
      "pct body val";
    gap: 6px 10px;
    align-items: center;
  }
  .answers .pct { grid-area: pct; min-width: 46px; }
  .answers .body { grid-area: body; }
  .answers [data-validate] { grid-area: val; }
  .answers [data-delete] { grid-area: del; }
  .answers .pct { align-self: start; }
}
