:root {
  --navy: #05122e;
  --surface: #0b2049;
  --surface-2: #123066;
  --line: #234579;
  --text: #f7fbff;
  --muted: #b7c8e8;
  --sky: #32d7ff;
  --blue: #0b5dff;
  --sun: #f9c846;
  --berry: #f23147;
  --green: #22c77a;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(90% 60% at 50% -10%, #12408f 0%, transparent 70%), var(--navy);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.45 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  overflow-x: hidden;
}

h1, h2, h3, p { margin: 0 0 .5rem; }
h1 { font-size: 1.8rem; line-height: 1.15; }
h2 { font-size: 1.3rem; line-height: 1.2; }
h3 { font-size: .85rem; margin-top: 1rem; color: var(--sky); text-transform: uppercase; letter-spacing: .06em; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
main.orga { max-width: 1180px; }

.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: #ff8a95; min-height: 1em; margin: .25rem 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; border: 0; border-radius: 12px; min-height: 44px; padding: 8px 14px; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

.primary { background: var(--sun); color: #2a1c00; font-weight: 700; }
.primary.danger { background: var(--berry); color: #fff; }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.danger-text { color: #ff8a95; }
.wide { width: 100%; margin-top: .75rem; }

input {
  width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  background: var(--navy);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* En-tête joueur */
.top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: rgba(5, 18, 46, .9); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-logo { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.top-me { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.top-me strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-me span { color: var(--sun); font-size: .85rem; }

/* Minuteur */
.timer { position: sticky; top: 53px; z-index: 4; height: 26px; background: var(--surface-2); overflow: hidden; }
.timer-fill { height: 100%; background: linear-gradient(90deg, var(--sky), var(--blue)); transition: width .1s linear; }
.timer span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
body:has(.orga) .timer { top: 0; }

.join { max-width: 420px; margin: 8vh auto 0; text-align: center; }
.logo { width: 110px; height: 110px; border-radius: 50%; object-fit: cover; margin-bottom: .5rem; }

.game-title { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.game-title .emoji { font-size: 2rem; }
.game-title h2, .game-title p { margin: 0; }

.wait { color: var(--sun); text-align: center; margin: 1rem 0 0; }
.big { font-size: 3.5rem; font-weight: 700; line-height: 1.1; text-align: center; color: var(--sun); margin: .5rem 0; font-variant-numeric: tabular-nums; }

.list { margin: 0; padding-left: 1.2rem; }
.list li { margin-bottom: .3rem; }
.points li::marker { color: var(--sun); }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: .5rem 0 0; }
.chips li { background: var(--surface-2); border-radius: 999px; padding: 4px 12px; }
.chips li.off { opacity: .5; }

.prog { list-style: none; margin: 0; padding: 0; }
.prog li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.prog li:last-child { border-bottom: 0; }
.prog li > span:nth-child(2) { flex: 1; }
.prog li.done { opacity: .55; }

/* Classements */
.rank { list-style: none; margin: .5rem 0 0; padding: 0; }
.rank li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; }
.rank li:nth-child(odd) { background: rgba(255, 255, 255, .04); }
.rank li.me { background: var(--surface-2); outline: 1px solid var(--sky); }
.rank li.off { opacity: .55; }
.rank-pos { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); font-weight: 700; font-size: .85rem; }
.pos1 .rank-pos { background: var(--sun); color: #2a1c00; }
.rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-gain { color: var(--sky); font-size: .9rem; white-space: nowrap; }
.rank-score { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }

dialog { width: min(480px, calc(100vw - 32px)); max-height: 85dvh; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }

/* Quiz */
.question { font-size: 1.25rem; font-weight: 700; text-align: center; margin: .5rem 0 1rem; }
.creature { display: block; width: min(240px, 60vw); aspect-ratio: 1; object-fit: contain; margin: 0 auto; }
.hidden-shape { filter: brightness(0) drop-shadow(0 0 6px rgba(50, 215, 255, .7)); }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 64px; background: var(--surface-2); border: 2px solid var(--line); text-align: left; overflow-wrap: anywhere; }
.option em { font-style: normal; color: var(--muted); }
.option:disabled { opacity: 1; }
.option.picked { border-color: var(--sun); }
.option.right { background: var(--green); border-color: var(--green); color: #03261a; }
.option.right em { color: inherit; }
.option.wrong { background: var(--berry); border-color: var(--berry); }
.option.wrong em { color: inherit; }
.gain { text-align: center; font-size: 1.6rem; font-weight: 700; color: var(--muted); margin: .75rem 0; }
.gain.win { color: var(--sun); }

/* Clic Éclair */
.arena { display: flex; flex-direction: column; min-height: calc(100dvh - 130px); gap: 12px; }
.tap { flex: 1; width: 100%; background: var(--sun); color: #2a1c00; font-size: 2rem; font-weight: 700; user-select: none; -webkit-user-select: none; }
.tap:active { transform: scale(.98); }
.two { flex: 1; display: flex; gap: 12px; }
.tap.half { font-size: 1.2rem; }
.tap.half:last-child { background: var(--sky); color: #02293a; }
.field { position: relative; flex: 1; min-height: 300px; border: 1px dashed var(--line); border-radius: var(--radius); overflow: hidden; }
.tap.small { position: absolute; left: 36%; top: 36%; width: 28%; height: 28%; min-height: 64px; font-size: 1.1rem; flex: none; }

/* Réflexe */
.zone { display: block; width: 100%; height: calc(100dvh - 120px); font-size: 2.2rem; font-weight: 700; color: #fff; user-select: none; -webkit-user-select: none; }
.zone.red { background: var(--berry); }
.zone.green { background: var(--green); color: #03261a; }
.zone.foul { background: #5a1520; }

/* Mini Bac */
.letter { font-size: 4rem; line-height: 1; font-weight: 700; color: var(--sun); text-align: center; margin: 0; }
.letter-line { font-size: 1.1rem; }
.letter-line b { color: var(--sun); font-size: 1.5rem; }
.field-line { display: block; margin-top: .6rem; }
.field-line span { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 2px; }
.bac-cat h3 { margin-bottom: .3rem; }
.bac-groups { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 6px; min-height: 40px; background: var(--surface-2); border: 2px solid var(--line); border-radius: 999px; text-align: left; overflow-wrap: anywhere; }
.pill:disabled { opacity: 1; }
.pill small { color: var(--sky); }
.pill .names { color: var(--muted); }
.pill.bad { background: transparent; border-style: dashed; }
.pill.bad span { text-decoration: line-through; color: var(--muted); }
.pill.mine-reject { border-color: var(--berry); }

/* Imposteur */
.secret { display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--surface-2); border: 2px solid var(--sky); border-radius: var(--radius); padding: 14px; text-align: center; }
.secret.imp { border-color: var(--berry); }
.secret small { color: var(--muted); }
.secret strong { font-size: 1.7rem; overflow-wrap: anywhere; }
.clues { list-style: none; margin: 1rem 0 0; padding: 0; }
.clues li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.clues li b { color: var(--sun); overflow-wrap: anywhere; text-align: right; }
.clues li.empty b { color: var(--muted); }
.inline { display: flex; gap: 8px; margin-top: 1rem; }
.inline .primary { flex: none; }
.votes { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 1rem; }
.votes .option { min-height: 52px; justify-content: center; text-align: center; }

/* Podium */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 1rem 0; }
.step { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.step strong { max-width: 100%; overflow-wrap: anywhere; }
.step span { color: var(--muted); font-size: .9rem; margin-bottom: 4px; }
.block { width: 100%; display: grid; place-items: center; font-size: 1.8rem; font-weight: 700; border-radius: 10px 10px 0 0; background: var(--surface-2); height: 70px; }
.step1 .block { height: 120px; background: var(--sun); color: #2a1c00; }
.step2 .block { height: 90px; }
.confetti { position: fixed; top: -12px; width: 9px; height: 14px; z-index: 20; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); } }

/* Organisateur */
.orga-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.orga-head h1 { margin: 0; font-size: 1.4rem; }
.orga-head .muted { margin-left: auto; overflow-wrap: anywhere; }
.orga-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; align-items: start; }
.orga-col .card { margin-bottom: 16px; }

.live-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.live-head h2 { margin: 0; }
.live-head strong { color: var(--sun); }
.live { list-style: none; margin: .75rem 0 0; padding: 0; }
.live li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-left: 4px solid var(--line); border-radius: 6px; margin-bottom: 4px; background: rgba(255, 255, 255, .04); }
.live li.live-ok { border-left-color: var(--green); }
.live li.live-bad { border-left-color: var(--berry); }
.live li.live-now { border-left-color: var(--sun); }
.live li.live-out { opacity: .5; }
.live li.live-wait .live-value { color: var(--muted); }
.dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--green); }
.dot.off { background: var(--berry); }
.live-name { width: 32%; flex: none; overflow-wrap: anywhere; font-weight: 700; }
.live-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--berry); color: #fff; font-weight: 400; }
.live-value { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.live-value small { display: block; color: var(--muted); }
.live-pts { width: 44px; flex: none; text-align: right; font-weight: 700; color: var(--sun); font-variant-numeric: tabular-nums; }
.tally { list-style: none; margin: .75rem 0 0; padding: 0; }
.tally li { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 24px; align-items: center; gap: 8px; margin-bottom: 4px; }
.tally li span:first-child { overflow-wrap: anywhere; }
.tally li.right span:first-child { color: var(--green); font-weight: 700; }
.tally li b { text-align: right; }
.bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--sky); transition: width .2s; }
.tally li.right .bar i { background: var(--green); }
.next { font-size: 1.15rem; min-height: 60px; }
.orga-rank li { flex-wrap: wrap; }
.row-tools { width: 100%; display: flex; gap: 6px; }
.row-tools input { flex: 1; min-width: 60px; min-height: 40px; }
.row-tools button { min-height: 40px; padding: 4px 10px; font-size: .85rem; }

@media (prefers-reduced-motion: reduce) {
  .timer-fill { transition: none; }
}
