:root {
  --bg: #0a0a18;
  --text: #f4f4ff;
  --muted: rgba(235, 235, 255, 0.66);
  --faint: rgba(235, 235, 255, 0.4);
  --glass: rgba(255, 255, 255, 0.055);
  --glass-2: rgba(255, 255, 255, 0.1);
  --stroke: rgba(255, 255, 255, 0.12);
  --ok: #22c55e;
  --ko: #f43f5e;
  --gold: #facc15;

  --a0: #7c3aed; --a0b: #a855f7;
  --a1: #2563eb; --a1b: #3b9cf6;
  --a2: #ea580c; --a2b: #f59e0b;
  --a3: #db2777; --a3b: #f472b6;

  --radius: 22px;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
::selection { background: rgba(236, 72, 153, .45); }

kbd {
  font-family: inherit;
  font-size: .78em;
  font-weight: 700;
  min-width: 1.95em;
  height: 1.95em;
  padding: 0 .45em;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .2);
  border-bottom-width: 3px;
  color: #fff;
  line-height: 1;
}
kbd[style] {
  background: color-mix(in srgb, var(--pc) 28%, transparent);
  border-color: color-mix(in srgb, var(--pc) 75%, transparent);
}

/* ---------- Fond animé ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(1200px 800px at 50% -10%, #1f1b52 0%, var(--bg) 62%);
}
.bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 52px 52px;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 72%);
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 72%);
}
.blob {
  position: absolute;
  width: 44vmax;
  height: 44vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .42;
  animation: float 22s ease-in-out infinite alternate;
}
.b1 { background: #7c3aed; top: -14%; left: -12%; }
.b2 { background: #db2777; bottom: -20%; right: -10%; animation-duration: 27s; animation-delay: -7s; }
.b3 { background: #0ea5e9; top: 32%; left: 42%; width: 30vmax; height: 30vmax; opacity: .26; animation-duration: 31s; animation-delay: -13s; }
@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(7vw, 5vh) scale(1.12); }
  100% { transform: translate(-5vw, 9vh) scale(.94); }
}

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

.flash { position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: 0; }
.flash.ok { background: radial-gradient(circle at 50% 65%, rgba(34, 197, 94, .32), transparent 70%); animation: flash 1s ease-out; }
.flash.ko { background: radial-gradient(circle at 50% 65%, rgba(244, 63, 94, .28), transparent 70%); animation: flash 1s ease-out; }
@keyframes flash { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Écrans ---------- */
#app { min-height: 100vh; display: flex; justify-content: center; }
.screen {
  display: none;
  width: 100%;
  max-width: 1100px;
  padding: clamp(16px, 3vw, 36px);
  flex-direction: column;
}
.screen.active { display: flex; animation: screenIn .6s var(--ease) backwards; }
@keyframes screenIn { from { opacity: 0; transform: translateY(18px) scale(.99); } }

.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .06);
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 26px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 17px;
  transition: transform .25s var(--spring), box-shadow .25s, background .25s;
}
.btn:active { transform: scale(.97); }
.btn kbd { background: rgba(0, 0, 0, .2); border-color: rgba(255, 255, 255, .28); font-size: .7em; }
.btn.primary { background: linear-gradient(135deg, #a855f7, #ec4899); box-shadow: 0 10px 30px rgba(236, 72, 153, .38); }
.btn.primary:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 14px 40px rgba(236, 72, 153, .55); }
.btn.ghost { background: var(--glass); border: 1px solid var(--stroke); }
.btn.ghost:hover { background: var(--glass-2); transform: translateY(-2px); }
.btn.danger { background: linear-gradient(135deg, #ef4444, #f43f5e); box-shadow: 0 10px 30px rgba(244, 63, 94, .35); }
.btn.danger:hover { transform: translateY(-2px) scale(1.03); }

.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: background .2s, transform .25s var(--spring);
}
.icon-btn:hover { background: var(--glass-2); transform: scale(1.07); }

.sound-toggle { position: fixed; right: 18px; bottom: 18px; z-index: 30; border-radius: 50%; }
.sound-toggle.muted { opacity: .6; }
.music-toggle { position: fixed; right: 72px; bottom: 18px; z-index: 30; border-radius: 50%; }
.music-toggle.muted { opacity: .45; }
.music-toggle.muted::after { content: ''; position: absolute; inset: 0; margin: auto; width: 60%; height: 2px; border-radius: 2px; background: #fff; transform: rotate(-45deg); }
.foot .credit { flex-basis: 100%; justify-content: center; font-size: 12px; }
.foot a { color: inherit; text-underline-offset: 2px; }
.foot a:hover { color: var(--muted); }

/* ================================================================== */
/* ACCUEIL                                                             */
/* ================================================================== */
.hero { text-align: center; margin: clamp(6px, 4vh, 40px) 0 26px; }
.logo { display: inline-flex; align-items: center; gap: 16px; }
.logo-emoji {
  font-size: clamp(42px, 6vw, 66px);
  display: inline-block;
  animation: wobble 4s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(236, 72, 153, .45));
}
@keyframes wobble {
  0%, 100% { transform: rotate(0) scale(1); }
  10% { transform: rotate(-14deg) scale(1.08); }
  20% { transform: rotate(10deg) scale(1.08); }
  30% { transform: rotate(0) scale(1); }
}
.hero h1 { font-size: clamp(42px, 7.5vw, 80px); font-weight: 900; letter-spacing: -.035em; line-height: 1; }
.grad {
  background: linear-gradient(90deg, #f472b6, #a855f7, #38bdf8, #a855f7, #f472b6);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shine 9s linear infinite;
}
@keyframes shine { to { background-position: 300% 0; } }
.tagline { color: var(--muted); font-size: clamp(15px, 1.8vw, 19px); margin-top: 12px; }

.setup { padding: 20px; display: grid; gap: 18px; margin-bottom: 36px; }
.setup-row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center; }

.segmented {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: rgba(0, 0, 0, .28);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 4px;
}
.segmented button {
  position: relative;
  z-index: 1;
  padding: 9px 18px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--muted);
  border-radius: 999px;
  transition: color .3s;
}
.segmented button.on { color: #fff; }
.seg-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 3);
  border-radius: 999px;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  box-shadow: 0 6px 18px rgba(168, 85, 247, .45);
  transition: transform .5s var(--spring);
}
.segmented[data-mode="duo"] .seg-indicator { transform: translateX(100%); }
.segmented[data-mode="tel"] .seg-indicator { transform: translateX(200%); }

.timer-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-weight: 500; font-size: 15px; }
.chips { display: flex; gap: 6px; }
.chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, .04);
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  transition: all .25s var(--ease);
}
.chip:hover { color: #fff; border-color: rgba(255, 255, 255, .3); }
.chip.on { background: #fff; color: #17172f; border-color: #fff; transform: scale(1.06); }

.players { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.players.solo { grid-template-columns: minmax(0, 520px); justify-content: center; }
.player-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px 14px 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--pc) 20%, transparent), rgba(255, 255, 255, .025));
  border: 1px solid color-mix(in srgb, var(--pc) 42%, transparent);
  animation: popIn .55s var(--spring) backwards;
  animation-delay: calc(var(--d) * 80ms);
}
@keyframes popIn { from { opacity: 0; transform: scale(.92) translateY(8px); } }
.avatar {
  width: 60px;
  height: 60px;
  flex: none;
  border-radius: 50%;
  font-size: 33px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .28);
  box-shadow: 0 0 0 3px var(--pc), 0 8px 24px color-mix(in srgb, var(--pc) 45%, transparent);
  transition: transform .3s var(--spring);
}
.avatar:hover { transform: scale(1.08) rotate(-7deg); }
.avatar.pop { animation: avatarPop .5s var(--spring); }
@keyframes avatarPop { 0% { transform: scale(.6) rotate(-30deg); } 100% { transform: scale(1); } }
.player-info { flex: 1; min-width: 0; display: grid; gap: 7px; }
.player-info input {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  font-size: 21px;
  font-weight: 700;
  padding: 2px 0;
  outline: none;
  transition: border-color .2s;
}
.player-info input:hover { border-bottom-color: rgba(255, 255, 255, .15); }
.player-info input:focus { border-bottom-color: var(--pc); }
.keys-hint { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; color: var(--faint); font-size: 13px; }
.keys-hint span { margin: 0 3px; }

/* ---------- Mode téléphones : QR code de chaque joueur ---------- */
.phone-box { position: relative; padding-right: 12px; }
.phone-box .qr {
  flex: none;
  width: 108px;
  height: 108px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 0 3px var(--pc);
  transition: opacity .3s, transform .4s var(--spring);
}
.phone-box .qr svg { display: block; width: 100%; height: 100%; }
.phone-box .qr.wait { opacity: .25; }
.phone-box .qr-ok {
  display: none;
  flex: none;
  width: 64px;
  height: 64px;
  margin: 22px;
  border-radius: 50%;
  place-items: center;
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  background: var(--ok);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 35%, transparent), 0 8px 30px color-mix(in srgb, var(--ok) 45%, transparent);
  animation: avatarPop .5s var(--spring);
}
.phone-box.on .qr { display: none; }
.phone-box.on .qr-ok { display: grid; }
.phone-state { margin: 0 !important; font-size: 14px; }
.phone-box.on .phone-state b { color: #4ade80; }
.tel-aide { text-align: center; color: var(--muted); font-size: 15px; line-height: 1.6; margin-top: -4px; }
.tel-aide b { color: #fff; }
.tel-aide .room-code { font-size: 20px; letter-spacing: .12em; padding: 1px 8px; border-radius: 8px; background: rgba(255, 255, 255, .1); }
.tel-aide .faint { display: block; color: var(--faint); font-size: 14px; }

.tally { display: flex; align-items: center; justify-content: center; gap: 8px 14px; color: var(--muted); font-size: 15px; flex-wrap: wrap; }
.tally-score { font-weight: 600; }
.tally b { color: #fff; font-size: 19px; font-weight: 800; }
.tally .faint { color: var(--faint); }
.tally .link { font-size: 12px; color: var(--faint); text-decoration: underline; text-underline-offset: 3px; }
.tally .link:hover { color: var(--muted); }

.section-title { font-size: 22px; font-weight: 800; margin-bottom: 16px; letter-spacing: -.01em; }

.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.quiz-card {
  position: relative;
  overflow: hidden;
  text-align: left;
  padding: 22px;
  min-height: 178px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--c1) 40%, transparent), color-mix(in srgb, var(--c2) 10%, transparent) 72%),
    rgba(255, 255, 255, .035);
  display: flex;
  flex-direction: column;
  gap: 6px;
  isolation: isolate;
  transition: transform .4s var(--spring), box-shadow .35s, border-color .35s;
}
.quiz-item {
  position: relative;
  display: flex;
  animation: cardIn .65s var(--spring) backwards;
  animation-delay: calc(150ms + var(--i) * 60ms);
}
.quiz-item .quiz-card { flex: 1; min-width: 0; }
.qc-sections {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: rgba(10, 10, 24, .35);
  border: 1px solid rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background .2s, transform .3s var(--spring), border-color .2s;
}
.qc-sections:hover { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .45); transform: scale(1.06); }
.qc-sections:active { transform: scale(.96); }
@keyframes cardIn { from { opacity: 0; transform: translateY(26px) scale(.94); } }
.quiz-card::before {
  content: '';
  position: absolute;
  z-index: -1;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: var(--c1);
  filter: blur(50px);
  opacity: .35;
  right: -55px;
  top: -65px;
  transition: opacity .4s, transform .6s var(--ease);
}
.quiz-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: color-mix(in srgb, var(--c1) 75%, white 10%);
  box-shadow: 0 20px 44px color-mix(in srgb, var(--c1) 35%, transparent);
}
.quiz-card:hover::before { opacity: .65; transform: scale(1.35); }
.quiz-card:active { transform: scale(.98); }
.quiz-card.mix { border-style: dashed; }
.qc-emoji { font-size: 42px; margin-bottom: 6px; display: inline-block; width: max-content; transition: transform .45s var(--spring); }
.quiz-card:hover .qc-emoji { transform: scale(1.18) rotate(-9deg); }
.qc-title { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.qc-desc { color: var(--muted); font-size: 14px; line-height: 1.4; flex: 1; }
.qc-meta { font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .09em; margin-top: 8px; }
.qc-play {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  background: #fff;
  color: #17172f;
  opacity: 0;
  transform: scale(.5) translateX(-10px);
  transition: all .35s var(--spring);
}
.quiz-card:hover .qc-play { opacity: 1; transform: none; }

.foot { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 24px; margin: 38px 0 8px; color: var(--faint); font-size: 13px; }
.foot span { display: inline-flex; align-items: center; gap: 7px; }

/* ================================================================== */
/* PARTIE                                                              */
/* ================================================================== */
#screen-game { min-height: 100vh; gap: clamp(12px, 2.2vh, 22px); }

.topbar { display: flex; align-items: center; gap: 16px; }
.progress-wrap { flex: 1; min-width: 0; display: grid; gap: 8px; }
.progress-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); font-weight: 600; }
.progress-label > span:last-child { white-space: nowrap; }
.pill {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--glass-2);
  border: 1px solid var(--stroke);
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #a855f7, #ec4899, #f59e0b);
  box-shadow: 0 0 16px rgba(236, 72, 153, .6);
  transition: width .9s var(--ease);
}

.scoreboard { display: flex; gap: 10px; }
.sb-player {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--pc) 24%, transparent), rgba(255, 255, 255, .04));
  border: 1px solid color-mix(in srgb, var(--pc) 45%, transparent);
}
.sb-player.answered { animation: ping .55s var(--ease); }
.sb-player.turn { box-shadow: 0 0 0 3px var(--pc), 0 0 24px color-mix(in srgb, var(--pc) 55%, transparent); }
.sb-player.offline .sb-avatar { opacity: .45; }
.sb-player.offline .sb-name::after { content: ' · 📵'; }
.sb-player.scored { animation: scored .6s var(--spring); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pc) 70%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
@keyframes scored { 40% { transform: scale(1.1); } }
.sb-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: rgba(0, 0, 0, .3);
  box-shadow: 0 0 0 2px var(--pc);
}
.sb-check {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--pc);
  color: #0b0b1a;
  font-size: 11px;
  font-weight: 900;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 2px var(--bg);
  transform: scale(0);
  transition: transform .4s var(--spring);
}
.sb-player.answered .sb-check { transform: scale(1); }
.sb-meta { display: grid; line-height: 1.1; }
.sb-name { font-size: 13px; color: var(--muted); font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-score { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sb-float {
  position: absolute;
  left: 50%;
  top: 100%;
  font-weight: 900;
  font-size: 19px;
  color: #4ade80;
  text-shadow: 0 2px 14px rgba(34, 197, 94, .7);
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
}
.sb-float.show { animation: floatUp 1.4s var(--ease) forwards; }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 18px) scale(.6); }
  20% { opacity: 1; transform: translate(-50%, 2px) scale(1.2); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -16px) scale(1); }
}

.stage { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: clamp(12px, 2.4vh, 24px); }

/* ---------- Chrono ---------- */
.timer {
  --size: clamp(84px, 12vh, 112px);
  position: relative;
  width: var(--size);
  height: var(--size);
  flex: none;
  transition: height .5s var(--ease), opacity .35s, transform .5s var(--ease), margin .5s var(--ease);
}
.stage.revealed .timer { height: 0; opacity: 0; transform: scale(.4); margin-bottom: calc(-1 * clamp(12px, 2.4vh, 24px)); }
.timer::before {
  content: '';
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .09), rgba(255, 255, 255, .02) 70%);
}
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.timer circle { fill: none; stroke-width: 9; }
.timer .track { stroke: rgba(255, 255, 255, .08); }
.timer .ring {
  stroke: hsl(135 85% 58%);
  color: hsl(135 85% 58%);
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 7px currentColor);
}
.timer-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(30px, 4.6vh, 42px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.timer-num.bump { animation: bump .4s var(--spring); }
@keyframes bump { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
.timer.urgent { animation: urgent .5s ease-in-out infinite alternate; }
.timer.urgent .timer-num { color: #ff7b7b; }
@keyframes urgent { from { transform: scale(1); } to { transform: scale(1.09); } }
.timer.done .timer-num { animation: bump .5s var(--spring); }

/* ---------- Question ---------- */
.question-card {
  width: 100%;
  min-height: clamp(110px, 18vh, 180px);
  padding: clamp(22px, 4vh, 40px) clamp(20px, 4vw, 52px);
  display: grid;
  place-items: center;
  text-align: center;
}
.question-card.enter { animation: qIn .65s var(--spring) backwards; }
@keyframes qIn { from { opacity: 0; transform: translateY(26px) scale(.94); } }
#questionText { font-size: clamp(22px, 3.3vw, 36px); font-weight: 800; line-height: 1.25; letter-spacing: -.01em; text-wrap: balance; }

/* ---------- Mode téléphones : tour de l'autre joueur ---------- */
.turn-banner {
  padding: 10px 22px;
  border-radius: 999px;
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 600;
  background: color-mix(in srgb, var(--pc) 22%, rgba(0, 0, 0, .35));
  box-shadow: inset 0 0 0 2px var(--pc), 0 10px 30px color-mix(in srgb, var(--pc) 30%, transparent);
}
.turn-banner b { color: #fff; font-weight: 800; }
.turn-banner.enter { animation: qIn .55s var(--spring) backwards; }

.answers.lettered .shape { font-size: 24px; font-weight: 900; }
.answer.eliminated { opacity: .4; filter: grayscale(.8); transform: scale(.97); }
.answer.eliminated .shape { background: var(--ko); }

/* ---------- Réponses ---------- */
.answers { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 1.8vw, 18px); }
.answer {
  --c: var(--a0);
  --c2: var(--a0b);
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: clamp(70px, 11vh, 104px);
  padding: 14px 18px 14px 14px;
  border-radius: 20px;
  text-align: left;
  background: linear-gradient(135deg, var(--c), var(--c2));
  box-shadow: 0 7px 0 color-mix(in srgb, var(--c) 55%, black), 0 14px 30px color-mix(in srgb, var(--c) 32%, transparent);
  transition: transform .3s var(--spring), opacity .45s, filter .45s, box-shadow .3s;
  animation: ansIn .6s var(--spring) backwards;
  animation-delay: calc(140ms + var(--d) * 75ms);
  cursor: default;
}
.a1 { --c: var(--a1); --c2: var(--a1b); }
.a2 { --c: var(--a2); --c2: var(--a2b); }
.a3 { --c: var(--a3); --c2: var(--a3b); }
@keyframes ansIn { from { opacity: 0; transform: translateY(22px) scale(.9); } }

.answers.live .answer { cursor: pointer; }
.answers.live .answer:hover { transform: translateY(-3px); filter: brightness(1.08); }
.answers.live .answer:active { transform: translateY(4px); box-shadow: 0 3px 0 color-mix(in srgb, var(--c) 55%, black), 0 8px 20px color-mix(in srgb, var(--c) 30%, transparent); }

.shape {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: rgba(255, 255, 255, .2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
}
.answer-text { flex: 1; font-size: clamp(16px, 2vw, 21px); font-weight: 700; line-height: 1.25; text-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.answer-keys { display: flex; gap: 5px; font-size: 15px; }
.answer-keys kbd { background: rgba(0, 0, 0, .22); border-color: rgba(255, 255, 255, .3); }
.answer-keys kbd[style] { background: color-mix(in srgb, var(--pc) 35%, rgba(0, 0, 0, .3)); border-color: var(--pc); }
.answers.revealed .answer-keys { opacity: 0; transition: opacity .3s; }
.answer-picks { position: absolute; top: -15px; right: 14px; display: flex; gap: 6px; }
.pick {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 21px;
  background: #16162f;
  box-shadow: 0 0 0 3px var(--pc), 0 6px 16px rgba(0, 0, 0, .45);
  animation: pickIn .55s var(--spring) backwards;
}
@keyframes pickIn { from { opacity: 0; transform: scale(0) rotate(-40deg); } }

.answer.selected { transform: scale(1.03); box-shadow: 0 0 0 4px #fff, 0 7px 0 color-mix(in srgb, var(--c) 55%, black), 0 18px 40px color-mix(in srgb, var(--c) 50%, transparent); }
.answer.dim { opacity: .5; filter: saturate(.6); }

.answer.correct {
  --c: #16a34a;
  --c2: #22c55e;
  z-index: 1;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .92), 0 7px 0 #14532d, 0 0 50px rgba(34, 197, 94, .6);
  animation: correctPop .8s var(--spring);
}
.answer.correct .shape { background: #fff; color: #16a34a; font-weight: 900; font-size: 24px; }
@keyframes correctPop { 0% { transform: scale(1); } 35% { transform: scale(1.07); } 100% { transform: scale(1.02); } }
.answer.correct { transform: scale(1.02); }
.answer.wrong { opacity: .3; filter: grayscale(.75); transform: scale(.97); }
.answer.wrong.picked-wrong { opacity: .8; filter: grayscale(.35); box-shadow: 0 0 0 3px var(--ko), 0 7px 0 color-mix(in srgb, var(--c) 55%, black); animation: shake .55s ease-in-out .3s; }
.answer.wrong.picked-wrong .shape { background: var(--ko); font-weight: 900; }
@keyframes shake {
  0%, 100% { transform: scale(.97) translateX(0); }
  20% { transform: scale(.97) translateX(-9px); }
  40% { transform: scale(.97) translateX(8px); }
  60% { transform: scale(.97) translateX(-6px); }
  80% { transform: scale(.97) translateX(4px); }
}

/* ---------- Panneau de résultat ---------- */
.reveal-panel {
  width: 100%;
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px);
  transition: opacity .45s var(--ease), transform .5s var(--spring), visibility .45s;
}
.reveal-panel.show { opacity: 1; visibility: visible; transform: none; }
.headline { font-size: clamp(22px, 2.8vw, 30px); font-weight: 800; display: grid; gap: 2px; }
.headline small { font-size: 15px; font-weight: 500; color: var(--muted); }
.headline small b { color: #4ade80; }
.results { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.res {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px 7px 7px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  animation: popIn .5s var(--spring) backwards;
  animation-delay: calc(650ms + var(--d) * 120ms);
}
.res.ok { border-color: rgba(34, 197, 94, .55); background: rgba(34, 197, 94, .12); }
.res-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 19px; background: rgba(0, 0, 0, .3); box-shadow: 0 0 0 2px var(--pc); }
.res-name { font-weight: 700; }
.res-detail { color: var(--muted); font-size: 14px; }
.res-pts { font-weight: 900; font-variant-numeric: tabular-nums; color: var(--faint); }
.res.ok .res-pts { color: #4ade80; }
.streak { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: rgba(251, 146, 60, .2); color: #fdba74; }
.fact { max-width: 720px; color: var(--muted); font-size: 15px; line-height: 1.5; padding: 10px 16px; border-radius: 14px; background: rgba(250, 204, 21, .06); border: 1px solid rgba(250, 204, 21, .16); }
.fact b { color: var(--gold); font-weight: 700; }

.hint-bar { display: flex; flex-wrap: wrap; gap: 8px 26px; justify-content: center; color: var(--faint); font-size: 13px; padding-top: 4px; }
.hint-bar span { display: inline-flex; align-items: center; gap: 5px; }
.hint-bar b { color: var(--pc, var(--muted)); font-weight: 700; margin-right: 4px; }

/* ---------- Compte à rebours ---------- */
.countdown {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  background: rgba(8, 8, 22, .55);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s;
}
.countdown.show { opacity: 1; pointer-events: auto; }
.cd-title { font-size: clamp(20px, 3vw, 30px); font-weight: 700; color: var(--muted); animation: popIn .5s var(--spring) backwards; }
.cd-slot { height: clamp(140px, 26vw, 240px); display: grid; place-items: center; }
.cd-num {
  font-size: clamp(120px, 22vw, 220px);
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, #ffffff, #f0abfc 60%, #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 10px 40px rgba(168, 85, 247, .55));
  animation: cdPop .76s var(--spring) both;
}
.cd-num.go { font-size: clamp(80px, 14vw, 150px); background-image: linear-gradient(135deg, #fde68a, #f472b6); }
@keyframes cdPop {
  0% { opacity: 0; transform: scale(2.3); }
  35% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; transform: scale(.95); }
  100% { opacity: 0; transform: scale(.6); }
}

/* ---------- Modale & toast ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(6, 6, 18, .6); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.modal-card { width: min(380px, 100%); padding: 28px; text-align: center; display: grid; gap: 8px; background: rgba(28, 26, 60, .85); animation: popIn .4s var(--spring); }
.modal-emoji { font-size: 42px; }
.modal-card p { font-size: 20px; font-weight: 700; }
.modal-card small { color: var(--faint); }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.modal-actions .btn { padding: 12px 20px; font-size: 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: 14px;
  background: rgba(30, 28, 64, .92);
  border: 1px solid var(--stroke);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .4);
  font-weight: 600;
  font-size: 15px;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 20px);
  pointer-events: none;
  transition: opacity .3s, transform .4s var(--spring);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Choix des sous-sections ---------- */
.sections-card {
  width: min(620px, 100%);
  max-height: min(86vh, 760px);
  padding: 22px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--c1) 22%, transparent), transparent 55%),
    rgba(24, 22, 52, .94);
}
.sections-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sections-head h3 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.sections-head p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.sections-tools { display: flex; gap: 16px; }
.link { font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: #fff; }
.sections-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 2px;
  margin: 0 -2px;
}
.sec {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 14px;
  cursor: pointer;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--stroke);
  transition: background .2s, border-color .2s, transform .25s var(--spring);
  animation: popIn .4s var(--spring) backwards;
  animation-delay: calc(var(--d) * 25ms);
  user-select: none;
}
.sec:hover { background: rgba(255, 255, 255, .08); }
.sec:active { transform: scale(.98); }
.sec input { position: absolute; opacity: 0; pointer-events: none; }
.sec-box {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  color: transparent;
  border: 2px solid rgba(255, 255, 255, .3);
  transition: all .25s var(--spring);
}
.sec-name { flex: 1; font-size: 14px; font-weight: 600; line-height: 1.25; }
.sec-n { font-size: 12px; font-weight: 700; color: var(--faint); font-variant-numeric: tabular-nums; }
.sec:has(input:checked) {
  background: color-mix(in srgb, var(--c1) 22%, transparent);
  border-color: color-mix(in srgb, var(--c1) 70%, transparent);
}
.sec input:checked + .sec-box { background: var(--c1); border-color: var(--c1); color: #fff; transform: scale(1.08); }
.sec input:focus-visible + .sec-box { box-shadow: 0 0 0 3px rgba(255, 255, 255, .5); }
.sections-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
#sectionsCount { color: var(--muted); font-size: 14px; font-weight: 600; }
.sections-foot .btn { padding: 12px 24px; }
.btn:disabled { opacity: .4; pointer-events: none; }

.cd-sub { font-size: clamp(15px, 2vw, 19px); font-weight: 600; color: var(--faint); margin-top: -4px; animation: popIn .5s var(--spring) .08s backwards; }

/* ================================================================== */
/* RÉSULTATS                                                           */
/* ================================================================== */
#screen-final { align-items: center; justify-content: center; min-height: 100vh; }
.final-wrap { width: 100%; max-width: 840px; display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.trophy {
  font-size: clamp(84px, 12vw, 124px);
  line-height: 1;
  filter: drop-shadow(0 14px 44px rgba(250, 204, 21, .5));
  animation: trophyIn 1s var(--spring) backwards, floaty 3.2s ease-in-out 1s infinite;
}
@keyframes trophyIn { from { opacity: 0; transform: scale(0) rotate(-40deg); } }
@keyframes floaty { 50% { transform: translateY(-10px) rotate(3deg); } }
.final-title { font-size: clamp(34px, 6vw, 62px); font-weight: 900; letter-spacing: -.025em; line-height: 1.08; animation: popIn .6s var(--spring) .2s backwards; }
.final-sub { color: var(--muted); font-size: 18px; animation: popIn .6s var(--spring) .3s backwards; }

.final-players { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; width: 100%; margin-top: 18px; }
.fp {
  position: relative;
  padding: 30px 20px 22px;
  border-radius: 24px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--pc) 24%, transparent), rgba(255, 255, 255, .03));
  border: 1px solid color-mix(in srgb, var(--pc) 42%, transparent);
  display: grid;
  gap: 4px;
  justify-items: center;
  animation: cardIn .7s var(--spring) backwards;
  animation-delay: calc(350ms + var(--d) * 150ms);
}
.fp.winner { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 20px 60px rgba(250, 204, 21, .22); }
.crown { position: absolute; top: -28px; font-size: 42px; filter: drop-shadow(0 6px 16px rgba(250, 204, 21, .6)); animation: crownIn .8s var(--spring) 1s backwards; }
@keyframes crownIn { from { opacity: 0; transform: translateY(-40px) rotate(-30deg) scale(.4); } }
.fp-avatar { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; font-size: 44px; background: rgba(0, 0, 0, .3); box-shadow: 0 0 0 3px var(--pc); margin-bottom: 6px; }
.fp-name { font-size: 20px; font-weight: 700; }
.fp-score { font-size: 50px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; margin-top: 4px; }
.fp-label { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .12em; }
.fp-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.fp-stats span { font-size: 13px; color: var(--muted); padding: 5px 11px; border-radius: 99px; background: rgba(255, 255, 255, .07); }
.fp-stats b { color: #fff; }

.recap { width: 100%; text-align: left; padding: 4px 18px; margin-top: 6px; }
.recap summary { cursor: pointer; padding: 14px 0; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.recap summary::-webkit-details-marker { display: none; }
.recap .chev { transition: transform .3s var(--ease); color: var(--faint); }
.recap[open] .chev { transform: rotate(180deg); }
.recap ol { list-style: none; display: grid; gap: 8px; padding-bottom: 16px; max-height: 360px; overflow: auto; }
.recap li { display: grid; grid-template-columns: 28px 1fr auto; gap: 2px 12px; align-items: center; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, .04); }
.rn { grid-row: span 2; font-weight: 800; color: var(--faint); text-align: center; }
.rq { font-weight: 600; font-size: 14px; }
.ra { grid-column: 2; font-size: 13px; color: #4ade80; }
.rp { grid-row: 1 / span 2; grid-column: 3; display: flex; gap: 6px; }
.rp span { position: relative; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; background: rgba(0, 0, 0, .25); }
.rp i { position: absolute; right: -4px; bottom: -4px; width: 16px; height: 16px; border-radius: 50%; font-size: 10px; font-style: normal; font-weight: 900; display: grid; place-items: center; color: #fff; }
.rp .ok i { background: var(--ok); }
.rp .ko i { background: var(--ko); }

.final-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* ================================================================== */
/* Responsive                                                          */
/* ================================================================== */
@media (max-width: 760px) {
  .players { grid-template-columns: 1fr; }
  .sections-list { grid-template-columns: 1fr; }
  .sections-card { padding: 18px; }
  .setup-row { justify-content: center; }
  .answers { grid-template-columns: 1fr; }
  .answer { min-height: 62px; }
  .shape { width: 38px; height: 38px; font-size: 17px; }
  .topbar { flex-wrap: wrap; gap: 12px; }
  .progress-wrap { order: 3; flex-basis: 100%; }
  .scoreboard { margin-left: auto; }
  .sb-player { padding-right: 12px; }
  .sb-name { max-width: 70px; }
  .sound-toggle { right: 12px; bottom: 12px; width: 40px; height: 40px; }
  .music-toggle { right: 60px; bottom: 12px; width: 40px; height: 40px; }
}
@media (hover: none) {
  .answer-keys { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
