/* ── Variables ──────────────────────────────────────────── */
:root {
  --bg-deep:    #0a0118;
  --bg-mid:     #1a0638;
  --purple:     #6a1fc2;
  --purple-light:#9b59ff;
  --purple-glow:#c084fc;
  --blue-ray:   #3b82f6;
  --gold:       #f5c842;
  --gold-light: #ffe680;
  --gold-dark:  #c8960a;
  --silver:     #d0d8e8;
  --silver-dark:#8a94a8;
  --white:      #ffffff;
  --off-white:  #f0eeff;
  --muted:      rgba(220,210,255,0.5);
  --green:      #22c55e;
  --red:        #ef4444;
  --cyan:       #7dd3fc;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: var(--bg-deep);
  color: var(--white);
  font-family: 'Nunito', sans-serif;
  overflow: hidden;
}

/* ── Background rays (global, behind everything) ───────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    linear-gradient(125deg, rgba(130,60,255,0.35) 0%, transparent 45%),
    linear-gradient(235deg, rgba(60,100,255,0.25) 0%, transparent 45%),
    linear-gradient(170deg, rgba(90,30,200,0.2) 20%, transparent 60%),
    radial-gradient(ellipse at 50% 40%, #2a0d5e 0%, #0a0118 70%);
  pointer-events: none; z-index: 0;
}
body::after {
  content: '';
  position: fixed; inset: 0;
  background:
    repeating-linear-gradient(
      125deg,
      transparent 0px,
      transparent 60px,
      rgba(160,100,255,0.04) 60px,
      rgba(160,100,255,0.04) 61px
    );
  pointer-events: none; z-index: 0;
}

/* ── Light streaks ──────────────────────────────────────── */
.ray {
  position: fixed;
  pointer-events: none; z-index: 0;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.15;
}

/* ── Pages ─────────────────────────────────────────────── */
.page {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.6s ease;
  z-index: 1;
}
.page.active { opacity: 1; pointer-events: auto; }

/* ── Flash overlay ─────────────────────────────────────── */
#flash-overlay {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 1000; opacity: 0;
}
#flash-overlay.flash-good { background: var(--green); animation: flash 0.7s ease-out forwards; }
#flash-overlay.flash-bad  { background: var(--red);   animation: flash 0.7s ease-out forwards; }
@keyframes flash { 0% { opacity: 0.65; } 100% { opacity: 0; } }


/* ═══════════════════════════════════════════════════════════
   IDLE + LOBBY — layout partagé
══════════════════════════════════════════════════════════════ */
#page-IDLE, #page-LOBBY { background: transparent; padding: 2vh 2vw; }

@keyframes title-in {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pulse { 0%,100% { opacity: 0.3; } 50% { opacity: 1; } }

/* Layout image + panneau */
.split-layout {
  display: flex; flex-direction: row; align-items: center;
  width: 100%; height: 100%; gap: 2.5vw; z-index: 2;
}
.split-image {
  flex: 1; display: flex; align-items: center;
  justify-content: center; height: 100%;
}
.split-img {
  max-width: 100%; max-height: 92vh;
  object-fit: contain; border-radius: 16px;
  filter: drop-shadow(0 0 40px rgba(160,100,255,0.5)) drop-shadow(0 0 80px rgba(245,200,66,0.2));
  animation: title-in 1.2s ease-out both;
}

/* Panneau latéral */
.split-panel {
  flex: 0 0 28%; display: flex; flex-direction: column;
  align-items: center; gap: 2vh; text-align: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(160,100,255,0.25);
  border-radius: 20px;
  padding: 2.5vh 1.5vw;
  backdrop-filter: blur(10px);
  height: 92vh; justify-content: center;
  overflow: hidden; min-width: 0;
}
.split-panel-title {
  font-family: 'Oswald', sans-serif;
  font-size: 1.8vw; font-weight: 700; font-style: italic;
  letter-spacing: 0.2em; text-transform: uppercase;
  background: linear-gradient(180deg, #fff 0%, #b0b8d0 50%, #fff 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(1px 2px 0 #1a0638);
}
.split-soon {
  font-family: 'Dancing Script', cursive;
  font-size: 2.2vw;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 60%, var(--gold-dark) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(1px 2px 0 #6b4000);
}
.split-count {
  font-size: 1.3vw; font-weight: 800; color: var(--gold); letter-spacing: 0.05em;
}
.split-count.hidden { display: none; }
.split-count span { font-size: 1.8em; }
.split-chips {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  justify-content: center; max-height: 35vh; overflow: hidden;
}
.player-chip {
  background: linear-gradient(135deg, rgba(106,31,194,0.7), rgba(60,50,200,0.7));
  border: 1px solid rgba(160,100,255,0.6);
  border-radius: 100px; padding: 0.35rem 1.1rem;
  font-size: 1.3vw; font-weight: 700; color: var(--off-white);
  animation: chip-pop 0.4s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@keyframes chip-pop { from { opacity:0; transform: scale(0.4); } to { opacity:1; transform: scale(1); } }

/* QR dans le panneau lobby */
.split-qr { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
#qr-code-small svg { width: 10vw; height: 10vw; border-radius: 6px; }
.split-qr-url { font-size: 1.1vw; color: var(--muted); }
.split-qr-url strong { color: var(--gold); display: block; font-size: 1.4vw; }

.waiting-pulse {
  font-size: 1.2vw; color: var(--muted);
  animation: pulse 2s ease-in-out infinite;
}
.audio-unlock-btn {
  font-size: 0.95vw; padding: 0.5rem 1.2rem;
  background: rgba(100,60,200,0.2);
  border: 1px solid rgba(160,100,255,0.5);
  color: var(--purple-glow); cursor: pointer;
  border-radius: 100px; font-family: inherit;
  transition: background 0.2s;
}
.audio-unlock-btn:hover { background: rgba(100,60,200,0.4); }
.audio-unlock-btn.unlocked { border-color: var(--green); color: var(--green); }

/* ═══════════════════════════════════════════════════════════
   QUESTION
══════════════════════════════════════════════════════════════ */
#page-QUESTION { }
.question-layout {
  display: flex; flex-direction: column; align-items: center;
  gap: 3vh; width: 100%; padding: 4vh 4vw; z-index: 2;
}
.question-meta { display: flex; justify-content: space-between; width: 100%; }
.q-num-badge {
  background: linear-gradient(135deg, var(--purple), #3b1f8a);
  border-radius: 100px; padding: 0.3rem 1.2rem;
  font-size: 1.8vw; font-weight: 900;
  border: 1px solid rgba(160,100,255,0.5);
}
.q-answers-badge {
  background: rgba(125,211,252,0.1);
  border: 1px solid rgba(125,211,252,0.4);
  border-radius: 100px; padding: 0.3rem 1.2rem;
  font-size: 1.6vw; color: var(--cyan);
  animation: pulse 1.5s ease-in-out infinite;
}
.question-text {
  font-family: 'Oswald', sans-serif;
  font-size: 5.5vw; font-weight: 700; font-style: italic;
  text-align: center; line-height: 1.25;
  color: var(--white);
  text-shadow: 2px 2px 0 rgba(30,0,80,0.8), 0 0 40px rgba(160,100,255,0.3);
  max-width: 100%;
  animation: q-in 0.5s ease-out;
}
@keyframes q-in { from { opacity:0; transform: translateY(30px); } to { opacity:1; transform:none; } }

/* Timer */
.timer-container { position: relative; width: 15vw; height: 15vw; }
.timer-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-track { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 7; }
.timer-arc {
  fill: none; stroke: var(--purple-light); stroke-width: 7; stroke-linecap: round;
  stroke-dasharray: 339.3; stroke-dashoffset: 0;
  transition: stroke 0.5s, stroke-dashoffset 0.5s linear;
}
.timer-arc.urgent { stroke: var(--red); }
.timer-value {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Oswald', sans-serif;
  font-size: 4.5vw; color: var(--purple-glow); font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════
   RÉVÉLATION
══════════════════════════════════════════════════════════════ */
#page-REVEAL { overflow: hidden; }
#page-REVEAL.result-good { background: radial-gradient(ellipse at center, #051a0f 0%, var(--bg-deep) 60%); }
#page-REVEAL.result-bad  { background: radial-gradient(ellipse at center, #1a0505 0%, var(--bg-deep) 60%); }

.reveal-layout {
  display: flex; flex-direction: column; align-items: center;
  gap: 1.5vh; width: 100%; height: 100%; padding: 2vh 4vw; z-index: 2;
  justify-content: center;
}

/* Header : verdict + SHOT côte à côte */
.reveal-header {
  display: flex; align-items: center; justify-content: center;
  gap: 3vw; flex-wrap: wrap;
}
.reveal-verdict {
  font-family: 'Oswald', sans-serif;
  font-size: 6vw; font-weight: 700; font-style: italic; line-height: 1;
  animation: verdict-pop 0.6s cubic-bezier(0.34,1.56,0.64,1) both;
}
.reveal-verdict.good {
  background: linear-gradient(180deg, #aaffcc 0%, #22c55e 50%, #16a34a 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 30px rgba(34,197,94,0.6));
}
.reveal-verdict.bad {
  background: linear-gradient(180deg, #ffaaaa 0%, #ef4444 50%, #dc2626 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 30px rgba(239,68,68,0.6));
}
@keyframes verdict-pop {
  from { opacity:0; transform: scale(0.3) rotate(-8deg); }
  to   { opacity:1; transform: scale(1) rotate(0); }
}
.shot-display {
  font-family: 'Oswald', sans-serif;
  font-size: 6vw; font-weight: 700; font-style: italic;
  color: var(--white);
  text-shadow: 0 0 40px var(--red), 0 0 80px rgba(239,68,68,0.5);
  animation: shot-pulse 0.7s ease-in-out infinite;
}
.shot-display.hidden { display: none; }
@keyframes shot-pulse { 0%,100% { transform: scale(1) rotate(-1deg); } 50% { transform: scale(1.06) rotate(1deg); } }

/* Choices exit animation */
@keyframes card-exit {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-60px); }
}
.reveal-answers-view.exiting .choice-card {
  animation: card-exit 0.45s ease-in both;
}
.reveal-answers-view.exiting .choice-card:nth-child(1) { animation-delay: 0s; }
.reveal-answers-view.exiting .choice-card:nth-child(2) { animation-delay: 0.06s; }
.reveal-answers-view.exiting .choice-card:nth-child(3) { animation-delay: 0.12s; }
.reveal-answers-view.exiting .choice-card:nth-child(4) { animation-delay: 0.18s; }

/* Grille 2x2 des réponses */
.reveal-choices {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1vw; width: 100%; min-width: 0;
}
.reveal-image {
  max-height: 40vh; max-width: 80%;
  margin: 1.5vh auto 0;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 0 30px rgba(0,0,0,0.5);
  animation: card-in 0.5s ease-out both;
}
.choice-card {
  border-radius: 12px; padding: 1.2vh 1.2vw;
  display: flex; flex-direction: column; gap: 0.5vh;
  animation: card-in 0.5s ease-out both;
  min-height: 10vh; min-width: 0; overflow: hidden;
}
.choice-card:nth-child(1) { animation-delay: 0.05s; }
.choice-card:nth-child(2) { animation-delay: 0.15s; }
.choice-card:nth-child(3) { animation-delay: 0.25s; }
.choice-card:nth-child(4) { animation-delay: 0.35s; }
@keyframes card-in { from { opacity:0; transform: translateY(16px); } to { opacity:1; transform:none; } }

.choice-card.correct {
  background: rgba(34,197,94,0.18);
  border: 2px solid rgba(34,197,94,0.7);
  box-shadow: 0 0 20px rgba(34,197,94,0.2);
}
.choice-card.wrong {
  background: rgba(239,68,68,0.1);
  border: 2px solid rgba(239,68,68,0.35);
}
.choice-card.empty {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
}

.choice-top {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.choice-text {
  font-family: 'Oswald', sans-serif;
  font-size: 1.8vw; font-weight: 700; font-style: italic;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.choice-card.correct .choice-text { color: #86efac; }
.choice-card.wrong   .choice-text { color: #fca5a5; }
.choice-card.empty   .choice-text { color: var(--muted); }

.choice-count {
  font-family: 'Oswald', sans-serif;
  font-size: 2.2vw; font-weight: 900;
  min-width: 3ch; text-align: right;
}
.choice-card.correct .choice-count { color: #22c55e; }
.choice-card.wrong   .choice-count { color: #ef4444; }
.choice-card.empty   .choice-count { color: var(--muted); }

.choice-players {
  font-size: 1.1vw; color: rgba(255,255,255,0.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-style: italic;
}

/* Full-screen leaderboard view (top 5) */
.reveal-lb-view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3vh; padding: 5vh 8vw; z-index: 10;
  background: radial-gradient(ellipse at 50% 40%, #1a0540 0%, var(--bg-deep) 70%);
  animation: lb-view-in 0.5s cubic-bezier(0.34,1.1,0.64,1) both;
}
.reveal-lb-view.hidden { display: none; }
@keyframes lb-view-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: none; }
}

.reveal-lb-title {
  font-family: 'Oswald', sans-serif;
  font-size: 4vw; font-weight: 900; font-style: italic;
  letter-spacing: 0.1em; text-transform: uppercase;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 60%, var(--gold-dark) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(1px 3px 0 #6b4000);
}

.reveal-lb-list {
  display: flex; flex-direction: column; gap: 1.2vh; width: 100%; max-width: 900px;
}

@keyframes lb-item-in {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: none; }
}

.lb-full-item {
  display: flex; align-items: center; gap: 2vw;
  padding: 1.6vh 2.5vw; border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(160,100,255,0.2);
  will-change: transform;
  transition: box-shadow 0.4s;
  animation: lb-item-in 0.45s ease-out both;
}
.lb-full-item:nth-child(1) { background: rgba(245,200,66,0.14); border-color: rgba(245,200,66,0.55); }
.lb-full-item:nth-child(2) { background: rgba(192,192,200,0.1); border-color: rgba(192,192,200,0.45); }
.lb-full-item:nth-child(3) { background: rgba(180,100,30,0.1);  border-color: rgba(180,100,30,0.45); }

.lb-full-item.rank-up   { box-shadow: 0 0 20px rgba(34,197,94,0.5); border-color: rgba(34,197,94,0.6) !important; }
.lb-full-item.rank-down { box-shadow: 0 0 16px rgba(239,68,68,0.35); }

.lb-full-rank {
  font-family: 'Oswald', sans-serif;
  font-size: 3.5vw; font-weight: 900; color: var(--gold);
  min-width: 3.5ch; text-align: center;
}
.lb-full-name {
  flex: 1; font-family: 'Oswald', sans-serif;
  font-size: 3vw; font-weight: 700; color: var(--white);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb-full-score {
  font-family: 'Oswald', sans-serif;
  font-size: 3vw; font-weight: 900; color: var(--cyan);
  min-width: 8ch; text-align: right;
}
.lb-full-change {
  font-size: 2vw; font-weight: 900; min-width: 5ch; text-align: right;
}
.lb-full-change.up   { color: var(--green); }
.lb-full-change.down { color: var(--red); }
.lb-full-change.new  { color: var(--muted); font-size: 1.2vw; }

/* ═══════════════════════════════════════════════════════════
   TRANSITION
══════════════════════════════════════════════════════════════ */
.transition-layout {
  display: flex; align-items: center; justify-content: center;
  padding: 5vw; z-index: 2;
}
.transition-text {
  font-family: 'Dancing Script', cursive;
  font-size: 5vw; text-align: center; line-height: 1.5;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 60%, var(--gold-dark) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(1px 3px 0 #6b4000);
  max-width: 85%;
  animation: transition-anim 0.9s ease-out both;
}
@keyframes transition-anim {
  from { opacity:0; filter: blur(12px) drop-shadow(1px 3px 0 #6b4000); transform: scale(0.92); }
  to   { opacity:1; filter: blur(0)    drop-shadow(1px 3px 0 #6b4000); transform: scale(1); }
}

/* ═══════════════════════════════════════════════════════════
   FIN
══════════════════════════════════════════════════════════════ */
.end-layout {
  display: flex; flex-direction: column; align-items: center;
  gap: 3vh; width: 90%; max-width: 1000px; z-index: 2;
}
.end-title {
  font-family: 'Oswald', sans-serif;
  font-size: 6vw; font-weight: 700; font-style: italic;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 50%, var(--gold-dark) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(2px 3px 0 #6b4000);
  text-align: center;
}
.final-leaderboard { display: flex; flex-direction: column; gap: 0.8rem; width: 100%; max-width: 600px; }
.final-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.8rem 1.5rem; border-radius: 8px;
  animation: lb-in 0.5s ease-out both;
}
.final-item:nth-child(1) { background: linear-gradient(90deg,rgba(245,200,66,0.2),transparent); border-left: 3px solid var(--gold); font-size: 3.5vw; }
.final-item:nth-child(2) { background: linear-gradient(90deg,rgba(192,192,200,0.15),transparent); border-left: 3px solid #b0b8c8; font-size: 3vw; }
.final-item:nth-child(3) { background: linear-gradient(90deg,rgba(180,100,30,0.15),transparent); border-left: 3px solid #c87830; font-size: 2.5vw; }
.final-item .f-rank  { color: var(--gold); font-weight: 900; min-width: 3ch; }
.final-item .f-name  { flex: 1; color: var(--white); }
.final-item .f-score { color: var(--cyan); font-weight: 900; }
.end-tagline { font-size: 2.5vw; text-align: center; color: var(--muted); font-style: italic; line-height: 1.8; }
