* { margin: 0; padding: 0; box-sizing: border-box; }

#bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
  transition: filter 0.6s ease;
}
#bg-video.blurred { filter: blur(14px) brightness(0.45); }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, rgba(26,26,46,0.55) 0%, rgba(22,33,62,0.55) 50%, rgba(15,52,96,0.55) 100%);
  color: #eee;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app { width: 100%; max-width: 640px; padding: 20px; }

.screen { display: none; text-align: center; animation: fadein 0.3s ease; }
.screen.active { display: block; }

@keyframes fadein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.logo {
  font-size: 3.4rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 4px;
}
.logo span { color: #e94560; }
.logo.small { font-size: 2.2rem; margin-bottom: 16px; }

.tagline { color: #9fb3d1; margin-bottom: 28px; }

.card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 28px;
  backdrop-filter: blur(6px);
}

label {
  display: block;
  text-align: left;
  font-size: 0.85rem;
  color: #9fb3d1;
  margin: 14px 0 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.1rem;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
  text-align: center;
}
input[type="text"]:focus { border-color: #e94560; }

/* Pseudo manquant : le champ pulse en rouge */
input.flash { animation: nameFlash 0.5s ease-in-out 2; }
@keyframes nameFlash {
  0%, 100% { transform: scale(1); border-color: rgba(255,255,255,0.25); box-shadow: none; }
  50% { transform: scale(1.05); border-color: #e94560; box-shadow: 0 0 0 4px rgba(233,69,96,0.35); }
}
#code-input { text-transform: uppercase; letter-spacing: 8px; font-weight: 700; font-size: 1.6rem; }

.btn {
  width: 100%;
  padding: 15px;
  font-size: 1.15rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 18px;
  transition: transform 0.1s, filter 0.2s;
  color: #fff;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: #e94560; }
.btn-secondary { background: #0f7b6c; }
.btn-success { background: #1a7a1a; }
.btn-danger { background: #8a1f1f; margin-top: 10px; }
.btn-muted { background: transparent; border: 1px solid rgba(255,255,255,0.25); color: #9fb3d1; font-size: 0.9em; }
.reveal-title { font-weight: bold; font-size: 1.1em; margin-bottom: 6px; }
.reveal-actions { display: flex; gap: 10px; justify-content: center; margin: 12px 0; }
.btn-pause { background: #44445e; }
.btn-pause.active { background: #b8860b; }

.category-box { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.category-box .cat {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.07); border: 2px solid rgba(255,255,255,0.12);
  border-radius: 10px; padding: 12px 14px; cursor: pointer;
  font-weight: 600; text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.category-box .cat:hover { border-color: rgba(255,255,255,0.35); }
.category-box .cat.checked { border-color: #e94560; background: rgba(233,69,96,0.18); }
.category-box .cat input[type="checkbox"] { width: 20px; height: 20px; accent-color: #e94560; cursor: pointer; }
.category-box .cat .cat-name { flex: 1; }
.category-box .cat .cat-count { color: #9fb3d1; font-size: 0.85rem; font-weight: 400; white-space: nowrap; }
.cat-num {
  width: 4.5em; padding: 3px 4px; font-size: 0.95rem;
  border-radius: 6px; border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.35); color: #fff; text-align: center;
}
.cat-num:focus { border-color: #e94560; outline: none; }
.cat.readonly { cursor: default; }
.cat.readonly input { cursor: default; }

.lobby-cats { color: #9fb3d1; font-size: 0.85rem; margin-bottom: 16px; }
.lobby-cats b { color: #ffd166; }

.reveal-extra { margin-top: 10px; }
.reveal-comment {
  font-style: italic; color: #c7d5ec; font-size: 0.9rem;
  background: rgba(255,255,255,0.06); border-radius: 8px;
  padding: 8px 12px; margin-bottom: 6px; display: inline-block;
}
.reveal-source { color: #9fb3d1; font-size: 0.8rem; text-decoration: none; display: block; }
a.reveal-source:hover { color: #ffd166; text-decoration: underline; }

/* ----- Reglages du lobby (hote) ----- */
.lobby-settings { margin-bottom: 14px; }
.lobby-time-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; padding: 10px 14px;
  background: rgba(255,255,255,0.07); border: 2px solid rgba(255,255,255,0.12);
  border-radius: 10px; font-weight: 600;
}
.lobby-time-row select {
  padding: 5px 10px; font-size: 0.95rem; border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.35); color: #fff;
}

/* ----- Feed "X a repondu" ----- */
.q-feed-count { color: #9fb3d1; font-size: 0.85rem; margin-top: 14px; min-height: 1.2em; }
.q-feed {
  max-height: 90px; overflow-y: auto; margin-top: 6px;
  display: flex; flex-direction: column; gap: 3px;
}
.feed-line {
  color: #9fb3d1; font-size: 0.8rem; font-style: italic;
  animation: feedIn 0.25s ease-out;
}
@keyframes feedIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ----- Bouton copie du code ----- */
.lobby-code-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.copy-btn {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px; font-size: 1.2rem; padding: 8px 12px; cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.copy-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1.08); }
.copy-feedback {
  display: inline-block; color: #06d6a0; font-weight: 700; font-size: 0.85rem;
  opacity: 0; transition: opacity 0.3s; min-height: 1.1em; margin-top: 4px;
}
.copy-feedback.show { opacity: 1; }

/* ----- Widget son ----- */
.sound-widget {
  position: fixed; bottom: 14px; right: 14px; z-index: 50;
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(15,23,42,0.85); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px; padding: 8px 12px;
}
.sound-widget .sound-row { display: flex; align-items: center; gap: 8px; }
.sound-widget button {
  background: none; border: none; font-size: 1.1rem; cursor: pointer; padding: 0;
  width: 24px; text-align: center;
}
.sound-widget button.muted { opacity: 0.35; }
.sound-widget input[type="range"] { width: 90px; accent-color: #e94560; }

/* ----- Confettis ----- */
#confetti-layer {
  position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden;
}
.confetti {
  position: absolute; top: -12px; width: 10px; height: 14px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}

.q-image-wrap { margin-bottom: 20px; }
.q-image-wrap img {
  max-width: 100%; max-height: 46vh;
  border-radius: 12px; border: 3px solid rgba(255,255,255,0.15);
  object-fit: contain;
}

.reveal-answer { font-size: 1.3rem; font-weight: 700; color: #9fb3d1; margin-bottom: 8px; }
.reveal-answer b { color: #ffd166; }

.divider {
  display: flex; align-items: center; gap: 12px;
  color: #9fb3d1; margin: 22px 0 6px;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: rgba(255,255,255,0.15);
}

.error { color: #ff6b81; min-height: 1.4em; margin-top: 12px; font-weight: 600; }
.hidden { display: none !important; }

/* ----- Lobby ----- */
.lobby-card { padding: 24px; }
.lobby-label { color: #9fb3d1; text-transform: uppercase; letter-spacing: 2px; font-size: 0.8rem; }
.lobby-code {
  font-size: 3.6rem; font-weight: 800; letter-spacing: 14px;
  color: #ffd166; margin: 8px 0 4px; font-family: monospace;
}
.lobby-hint { color: #9fb3d1; font-size: 0.9rem; margin-bottom: 20px; }
.lobby-card h3 { text-align: left; margin-bottom: 10px; color: #9fb3d1; }
.player-list { list-style: none; max-height: 220px; overflow-y: auto; }
.player-list li {
  background: rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600;
}
.player-list li .crown { color: #ffd166; }
.player-list li .pts { color: #9fb3d1; font-weight: 400; font-size: 0.85rem; }
.lobby-wait { color: #9fb3d1; margin-top: 14px; font-style: italic; }

/* ----- Question ----- */
.game-top { display: flex; justify-content: space-between; margin-bottom: 12px; font-weight: 700; }
.q-counter { color: #9fb3d1; }
.q-score { color: #ffd166; }

.timer-bar {
  height: 10px; background: rgba(255,255,255,0.1);
  border-radius: 5px; overflow: hidden; margin-bottom: 26px;
}
.timer-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #e94560, #ffd166);
  transition: width 0.1s linear;
}

.q-text { font-size: 1.6rem; margin-bottom: 26px; line-height: 1.35; min-height: 2.6em; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.choice {
  padding: 22px 14px;
  font-size: 1.05rem; font-weight: 700;
  border: none; border-radius: 12px;
  cursor: pointer; color: #fff;
  min-height: 80px;
  transition: transform 0.1s, opacity 0.2s, filter 0.15s;
}
.choice:hover:not(:disabled) { filter: brightness(1.15); transform: translateY(-2px); }
.choice:disabled { cursor: default; }
.choice:nth-child(1) { background: #e21b3c; }
.choice:nth-child(2) { background: #1368ce; }
.choice:nth-child(3) { background: #d89e00; }
.choice:nth-child(4) { background: #26890c; }
.choice.selected { outline: 4px solid #fff; }
.choice.dim { opacity: 0.35; }
.choice.correct { outline: 4px solid #7bff7b; }
.q-answered { margin-top: 18px; color: #7bff7b; font-weight: 600; }

@media (max-width: 480px) {
  .choices { grid-template-columns: 1fr; }
  .lobby-code { font-size: 2.6rem; letter-spacing: 8px; }
}

/* ----- Reveal ----- */
.reveal-verdict { font-size: 2.4rem; font-weight: 800; margin-bottom: 6px; }
.reveal-verdict.good { color: #7bff7b; }
.reveal-verdict.bad { color: #ff6b81; }
.reveal-delta { font-size: 1.4rem; color: #ffd166; margin-bottom: 22px; font-weight: 700; }

.ranking { list-style: none; text-align: left; }
.ranking li {
  display: flex; justify-content: space-between;
  padding: 9px 12px; margin-bottom: 5px;
  background: rgba(255,255,255,0.06); border-radius: 8px;
  font-weight: 600;
}
.ranking li.me { background: rgba(233, 69, 96, 0.35); }
.ranking li .delta { color: #7bff7b; font-size: 0.85rem; margin-left: 8px; }

/* ----- Podium ----- */
.podium {
  display: flex; justify-content: center; align-items: flex-end;
  gap: 14px; margin: 20px 0 26px; min-height: 150px;
}
.podium .step {
  flex: 1; max-width: 140px;
  border-radius: 10px 10px 0 0;
  padding: 14px 8px;
  font-weight: 700;
  background: rgba(255,255,255,0.08);
}
.podium .step .medal { font-size: 2rem; display: block; }
.podium .step .pname { display: block; margin: 6px 0 4px; word-break: break-word; }
.podium .step .pscore { color: #ffd166; }
.podium .step.first { min-height: 140px; background: rgba(255, 209, 102, 0.25); }
.podium .step.second { min-height: 110px; }
.podium .step.third { min-height: 85px; }
