:root {
  --bg: #0d1117;
  --card: #161b22;
  --line: #263040;
  --txt: #e6edf3;
  --muted: #8b97a7;
  --accent: #2ee6a6;
  --accent-d: #16a37a;
  --wrong: #ff5d5d;
  --pick: #3d8bff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #142031, var(--bg));
  color: var(--txt);
  min-height: 100vh;
}

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: 22px; letter-spacing: 1px; }
h1 span { color: var(--accent); }
.meta { display: flex; gap: 16px; align-items: center; font-size: 13px; color: var(--muted); }
.status::before { content: "● "; color: var(--accent); }

main { max-width: 1000px; margin: 28px auto; padding: 0 20px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px;
}
.center { text-align: center; max-width: 460px; margin: 60px auto; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.row { display: flex; gap: 10px; margin-top: 16px; }
input {
  flex: 1; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #0d1117; color: var(--txt); font-size: 15px;
}
button {
  cursor: pointer; border: 1px solid var(--line); border-radius: 10px;
  background: #1c2430; color: var(--txt); font-size: 15px; padding: 12px 18px;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}
button:active { transform: translateY(1px); }
.primary { background: var(--accent-d); border-color: var(--accent); color: #04130d; font-weight: 600; }

.game-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
@media (max-width: 760px) { .game-grid { grid-template-columns: 1fr; } }

.qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.badge {
  font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--accent); border: 1px solid var(--accent-d); border-radius: 999px; padding: 4px 10px;
}
.timeleft { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; }

.timer { height: 6px; background: #0d1117; border-radius: 999px; overflow: hidden; }
#timerbar {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--pick));
  transition: width .12s linear;
}

.question { font-size: 22px; line-height: 1.35; margin: 22px 0; min-height: 64px; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .choices { grid-template-columns: 1fr; } }
.choice {
  text-align: left; padding: 16px; font-size: 16px; min-height: 58px;
  border: 1px solid var(--line); background: #1a212c;
}
.choice:hover:not(.dim):not(.correct):not(.wrong) { border-color: var(--accent); }
.choice.dim { opacity: .45; }
.choice.picked { border-color: var(--pick); box-shadow: 0 0 0 1px var(--pick) inset; }
.choice.correct { border-color: var(--accent); background: #103024; animation: pop .3s ease; }
.choice.wrong { border-color: var(--wrong); background: #2a1416; }
@keyframes pop { 0% { transform: scale(.97); } 60% { transform: scale(1.02); } 100% { transform: scale(1); } }

.flash { text-align: center; font-size: 20px; font-weight: 700; height: 28px; margin-top: 16px; }
.flash.good { color: var(--accent); }
.flash.bad { color: var(--wrong); }

/* ── Salon de relecture (adminOnly) : Garder / Rejeter une question draft ── */
.review-controls { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.review-controls.hidden { display: none; }
.review-btn { padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); font-weight: 700; cursor: pointer; }
.review-btn.keep { background: #103024; border-color: var(--accent); color: var(--accent); }
.review-btn.reject { background: #2a1416; border-color: var(--wrong); color: var(--wrong); }

.board h3 { margin: 0 0 14px; font-size: 15px; }
#leaderboard { margin: 0; padding-left: 22px; }
#leaderboard li { padding: 5px 0; display: flex; justify-content: space-between; }
#leaderboard li span { color: var(--accent); font-variant-numeric: tabular-nums; }
.closed { font-size: 12px; color: var(--muted); margin-top: 12px; }

.me { color: var(--accent); font-weight: 600; }
.autherror { color: var(--wrong); font-size: 13px; min-height: 18px; margin-top: 12px; }

/* ── Mascotte ── */
.mascot {
  position: fixed; right: 18px; bottom: 14px; width: 150px; height: 160px; z-index: 50;
  pointer-events: none;
}
.mascot__img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .5));
  animation: mascot-float 3s ease-in-out infinite;
}
@keyframes mascot-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.mascot__bubble {
  position: absolute; right: 46%; bottom: 74%; min-width: 160px; max-width: 280px;
  background: var(--card); border: 1px solid var(--accent-d); color: var(--txt);
  border-radius: 14px; padding: 10px 13px; font-size: 14px; line-height: 1.35;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .45);
  opacity: 0; transform: translateY(6px) scale(.96); transition: opacity .2s ease, transform .2s ease;
}
.mascot__bubble.show { opacity: 1; transform: translateY(0) scale(1); }
.mascot__bubble::after {
  content: ''; position: absolute; right: 26px; bottom: -8px;
  border: 8px solid transparent; border-top-color: var(--accent-d); border-bottom: 0;
}
.mascot__bubble .cursor { opacity: .6; }

.mascot-picker {
  position: fixed; left: 14px; bottom: 14px; z-index: 50; display: flex; gap: 6px;
  padding: 6px; border-radius: 12px; background: rgba(13, 17, 23, .6);
  border: 1px solid var(--line); backdrop-filter: blur(4px);
}
.mascot-picker img {
  width: 40px; height: 40px; object-fit: contain; cursor: pointer; border-radius: 8px;
  border: 2px solid transparent; background: #0d1117; transition: border-color .15s, transform .1s;
}
.mascot-picker img:hover { transform: translateY(-2px); }
.mascot-picker img.active { border-color: var(--accent); }

@media (max-width: 760px) {
  .mascot { width: 104px; height: 116px; right: 8px; bottom: 8px; }
  .mascot__bubble { min-width: 130px; max-width: 200px; font-size: 13px; }
  .mascot-picker { left: 8px; bottom: 8px; }
  .mascot-picker img { width: 32px; height: 32px; }
}

/* ── Accueil : podium + scores du jour ── */
.home-panel { max-width: 720px; margin: 18px auto; }
.home-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
@media (max-width: 620px) { .home-cols { grid-template-columns: 1fr; } }
.home-panel h3 { margin: 0 0 12px; font-size: 15px; }
.live { color: var(--accent); font-size: 11px; }

.podium { list-style: none; margin: 0; padding: 0; }
.podium li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.podium li:last-child { border-bottom: 0; }
.podium .rk { width: 26px; text-align: center; }
.podium b { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .sc { color: var(--accent); font-variant-numeric: tabular-nums; }
.podium .sc em { color: var(--pick); font-style: normal; font-size: 12px; }
.podium.big li { font-size: 17px; padding: 9px 0; }

/* ── Fin de journée ── */
.eod {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(5, 9, 14, .82); backdrop-filter: blur(6px); animation: eod-in .3s ease;
}
@keyframes eod-in { from { opacity: 0; } to { opacity: 1; } }
.eod__card {
  background: var(--card); border: 1px solid var(--accent-d); border-radius: 18px; padding: 28px 30px;
  width: min(440px, 92vw); text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
.eod__card h2 { margin: 0 0 6px; }
.eod__card .podium { text-align: left; margin: 18px 0; }

/* ════ Ambiance festive ════ */
#bg { position: fixed; inset: 0; z-index: -2; }
#confetti { position: fixed; inset: 0; z-index: 200; pointer-events: none; }

body {
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(46, 230, 166, .10), transparent 60%),
    radial-gradient(900px 520px at 88% -6%, rgba(61, 139, 255, .12), transparent 60%),
    radial-gradient(1200px 820px at 50% 120%, rgba(255, 109, 160, .08), transparent 60%),
    #0b0f15;
}

header { position: sticky; top: 0; z-index: 40; backdrop-filter: blur(8px); background: rgba(13, 17, 23, .5); }

/* ── Safe-area : en app native (Android 15 / iOS edge-to-edge), le contenu va sous les
   barres système. On décale le header (barre de statut) et les éléments fixés en bas
   (barre de navigation/gestes). env() = 0 sur le web → aucun effet hors app. ── */
header {
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-left: calc(24px + env(safe-area-inset-left, 0px));
  padding-right: calc(24px + env(safe-area-inset-right, 0px));
}
.mascot { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
.mascot-picker { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }

/* ── Compte / suppression ── */
.account-card { border-color: rgba(229, 83, 75, .28); }
.account-card .small { font-size: 12px; opacity: .65; margin-top: 8px; }
button.danger {
  background: #b3261e; color: #fff; border: 1px solid #d3302a;
  padding: 10px 16px; border-radius: 10px; font-weight: 600; cursor: pointer;
}
button.danger:hover { background: #d3302a; }

.legal-links { text-align: center; font-size: 12.5px; margin-top: 14px; opacity: .8; }
.legal-links a { color: var(--accent); text-decoration: none; }
.legal-links a:hover { text-decoration: underline; }

/* ── Mon compte (rubrique) ── */
.home-account { margin-top: 16px; text-align: center; }
#me { cursor: pointer; }
.acc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.acc-head h2 { margin: 0; font-size: 20px; }
.acc-hero { text-align: center; padding: 10px 0 4px; }
.acc-pseudo { font-size: 26px; font-weight: 800; }
.acc-sub { color: var(--muted); margin-top: 4px; }
.trophies .troph-row { display: flex; gap: 18px; font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.acc-stats { list-style: none; padding: 0; margin: 0; }
.acc-stats li { padding: 7px 0; border-bottom: 1px solid var(--line); color: #cdd6df; }
.acc-stats li:last-child { border-bottom: 0; }
.affinities { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }
.aff-row { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr auto; align-items: center; gap: 10px; }
.aff-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aff-bar { height: 8px; background: #0b0f15; border-radius: 6px; overflow: hidden; }
.aff-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #3d8bff); }
.aff-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.acc-email-row { display: flex; gap: 10px; margin-top: 10px; }
.acc-email-row input { max-width: 320px; }
.acc-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.danger-link { color: #e5534b; font-size: 13px; cursor: pointer; text-decoration: underline; opacity: .85; }
.danger-link:hover { opacity: 1; }
h1 {
  background: linear-gradient(90deg, #2ee6a6, #3d8bff 55%, #ffd166);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 24px rgba(46, 230, 166, .25); font-weight: 800;
}
h1 span { -webkit-text-fill-color: #ffd166; }
#presence::before { content: '● '; color: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

main { max-width: 1080px; }

.quiz {
  min-height: 58vh; display: flex; flex-direction: column; justify-content: center;
  border-color: rgba(46, 230, 166, .25);
  background: linear-gradient(180deg, rgba(46, 230, 166, .05), transparent 28%), var(--card);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45), inset 0 0 60px rgba(46, 230, 166, .05);
}
.question { font-size: 27px; }
.choice {
  font-size: 17px; min-height: 66px;
  transition: transform .08s ease, border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.choice:hover:not(.dim):not(.correct):not(.wrong) {
  box-shadow: inset 0 0 0 1px var(--accent), 0 8px 22px rgba(46, 230, 166, .12); transform: translateY(-1px);
}
.choice.correct { box-shadow: inset 0 0 0 2px var(--accent), 0 0 30px rgba(46, 230, 166, .3); }
.badge { background: rgba(46, 230, 166, .08); }
.flash.good { text-shadow: 0 0 22px rgba(46, 230, 166, .55); }
.board { box-shadow: 0 14px 40px rgba(0, 0, 0, .4); }

/* ── Média (question musique/vidéo) ── */
.media { margin: 14px 0 6px; display: flex; justify-content: center; }
.media audio { width: 100%; max-width: 480px; }
.media video {
  width: 100%; max-width: 560px; border-radius: 12px; background: #000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.media img { width: 100%; max-width: 420px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }

/* ── Lobby : grille des salons ── */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.theme-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 10px;
  background: linear-gradient(180deg, rgba(46, 230, 166, .06), transparent), var(--card);
  border: 1px solid var(--line); border-radius: 14px; cursor: pointer; color: var(--txt);
  transition: transform .1s ease, border-color .15s ease, box-shadow .15s ease;
}
.theme-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 10px 26px rgba(46, 230, 166, .14); }
.theme-card.disabled { cursor: not-allowed; opacity: .45; filter: grayscale(1); background: var(--card); }
.theme-card.disabled:hover { transform: none; border-color: var(--line); box-shadow: none; }
.th-emoji { font-size: 30px; line-height: 1; }
.th-label { font-weight: 600; text-align: center; font-size: 14px; }
.th-players { font-size: 12px; color: var(--muted); }
.th-locked { font-size: 12px; color: var(--muted); }

/* ── Barre du salon ── */
.salon-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.salon-title { font-size: 18px; font-weight: 700; }
.ghost { background: transparent; border: 1px solid var(--line); }
.ghost:hover { border-color: var(--accent); }
