:root {
  --bg: #140c2b;
  --bg2: #25154d;
  --card: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .14);
  --txt: #fff;
  --muted: rgba(255, 255, 255, .6);
  --pink: #ff4d8d;
  --gold: #ffd700;
  --ok: #3ddc97;
  --ko: #ff5d5d;
  --a0: #ff4d8d;
  --a1: #2d9cff;
  --a2: #ffb020;
  --a3: #3ddc97;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--txt);
  background: radial-gradient(circle at 20% 0%, #3a1d78 0%, transparent 50%),
              radial-gradient(circle at 100% 100%, #5a1446 0%, transparent 45%),
              linear-gradient(160deg, var(--bg), var(--bg2));
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: .2em 0; line-height: 1.1; }
p { line-height: 1.4; }
.muted { color: var(--muted); }
.lead { font-size: 1.15em; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.who { white-space: nowrap; font-weight: 600; }

/* ── Boutons et formulaires ─────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  padding: .75em 1.3em; border: 0; border-radius: 999px;
  background: linear-gradient(135deg, #ff4d8d, #a66bff); color: #fff;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  box-shadow: 0 6px 18px rgba(255, 77, 141, .3);
  transition: transform .1s, opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.big { font-size: 1.2em; padding: .85em 1.8em; }
.btn.sm { font-size: .85em; padding: .5em .9em; }
.btn.ghost { background: var(--card); box-shadow: none; border: 1px solid var(--line); }
.btn.ok { background: linear-gradient(135deg, #2fbf7f, #3ddc97); box-shadow: 0 6px 18px rgba(61, 220, 151, .25); }
.btn.ko { background: linear-gradient(135deg, #e0404f, #ff6b6b); box-shadow: 0 6px 18px rgba(255, 93, 93, .25); }

input[type=text], input:not([type]), input[name=name], input[name=code] {
  width: 100%; padding: .8em 1em; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, .25); color: #fff; font: inherit; font-size: 1.1em;
}
input[name=code] { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 800; }

.label { display: block; margin: 1.1em 0 .45em; font-weight: 700; color: var(--muted); font-size: .9em; text-transform: uppercase; letter-spacing: .05em; }

.seg { display: flex; gap: .4rem; }
.seg.wrap { flex-wrap: wrap; }
.seg label { flex: 1; }
.seg.wrap label { flex: 0 1 auto; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; padding: .7em .9em; border-radius: 12px; text-align: center; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); font-weight: 600; white-space: nowrap;
}
.seg input:checked + span { background: linear-gradient(135deg, rgba(255, 77, 141, .45), rgba(166, 107, 255, .45)); border-color: #ff8db5; }

.badge {
  display: inline-block; padding: .3em .8em; border-radius: 999px; font-weight: 700; font-size: .9em;
  background: color-mix(in srgb, var(--cat, #fff) 25%, transparent); border: 1px solid color-mix(in srgb, var(--cat, #fff) 60%, transparent);
}
.badge.hot { background: #ff3d3d; border-color: #ff8080; animation: pulse 1s infinite; }
.badge.big { font-size: 1.1em; padding: .5em 1em; }


.toast {
  position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%); z-index: 50;
  padding: .8em 1.2em; border-radius: 14px; background: rgba(20, 12, 43, .95); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4); max-width: 90vw; font-weight: 600;
  animation: toast-in .3s ease-out;
}
.toast.err { border-color: var(--ko); }
.toast.out { opacity: 0; transition: opacity .5s; }

.center-msg { min-height: 80vh; display: grid; place-content: center; text-align: center; padding: 2rem; gap: 1rem; }
.center-msg h1 { font-size: 4rem; }
.center { justify-content: center; }
.tag {
  display: inline-flex; align-items: center; gap: .4em; padding: .35em .8em; border-radius: 999px; font-weight: 700;
  background: color-mix(in srgb, var(--c) 22%, transparent); border: 1px solid var(--c);
}
.tag small { font-weight: 600; opacity: .85; }
.tag.done { background: color-mix(in srgb, var(--c) 45%, transparent); }

/* ── Accueil ─────────────────────────────────────────────────────────── */

.home-wrap { max-width: 600px; margin: 0 auto; padding: 2rem 1.2rem 4rem; }
.home-hero { text-align: center; margin-bottom: 1.5rem; }
.home-hero .logo { font-size: 4.5rem; animation: bounce 2s infinite; }
.home-hero h1 { font-size: 2.4rem; font-weight: 900; }
.home-hero h1 span { background: linear-gradient(90deg, #ffd700, #ff4d8d, #a66bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.home-hero p { color: var(--muted); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; margin-bottom: 1.2rem; backdrop-filter: blur(6px); }
.panel h2 { font-size: 1.3rem; margin-bottom: .6rem; }
.panel .hint { color: var(--muted); margin-top: 0; font-size: .95em; }
.panel form .btn.big { width: 100%; margin-top: 1.4rem; }
.panel .row input { flex: 1; }
#resume { margin-top: 1rem; text-align: center; }

.rounds-pick { display: grid; gap: .45rem; }
.rounds-pick input { position: absolute; opacity: 0; pointer-events: none; }
.rounds-pick span {
  display: block; padding: .7em 1em; border-radius: 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--c);
}
.rounds-pick small { display: block; color: var(--muted); margin-top: .15em; }
.rounds-pick input:checked + span { background: color-mix(in srgb, var(--c) 25%, transparent); border-color: var(--c); }

/* ── Écran animateur ─────────────────────────────────────────────────── */

body.host { height: 100vh; overflow: hidden; display: flex; flex-direction: column; font-size: clamp(14px, 1.15vw, 24px); }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem; border-bottom: 1px solid var(--line); }
.brand { font-weight: 900; font-size: 1.2em; white-space: nowrap; }
.progress { flex: 1; display: flex; gap: .3rem; justify-content: center; flex-wrap: wrap; }
.progress .step { display: flex; align-items: center; gap: .3em; padding: .25em .7em; border-radius: 999px; background: var(--card); font-size: .85em; opacity: .5; }
.progress .step small { display: none; }
.progress .step.on { opacity: 1; background: linear-gradient(135deg, #ff4d8d, #a66bff); }
.progress .step.on small { display: inline; font-weight: 700; }
.progress .step.past { opacity: .8; }
.join-mini { display: flex; align-items: center; gap: .6rem; }
.join-mini small { display: block; color: var(--muted); font-size: .75em; }
.join-mini b { font-size: 1.4em; letter-spacing: .15em; }
.mini-qr { width: 3.6em; background: #fff; border-radius: 6px; line-height: 0; }
.mini-qr svg, .lobby-qr svg { width: 100%; height: auto; }

.host-grid { flex: 1; display: grid; grid-template-columns: 1fr minmax(240px, 22%); min-height: 0; }
.stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 1.5rem 2rem; overflow: auto; }
.side { border-left: 1px solid var(--line); padding: 1rem; overflow: auto; }
.side h3 { margin: 0 0 .6rem; }

.board { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.board li {
  display: flex; align-items: center; gap: .5em; padding: .5em .7em; border-radius: 12px;
  background: color-mix(in srgb, var(--c, #fff) 14%, transparent); border-left: 5px solid var(--c, transparent);
}
.board li.off { opacity: .6; }
.board .rk { display: grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 50%; background: var(--card); font-weight: 800; font-size: .85em; flex: none; }
.board li:nth-child(1) .rk { background: var(--gold); color: #000; }
.board li:nth-child(2) .rk { background: #cfd8e3; color: #000; }
.board li:nth-child(3) .rk { background: #d98c4a; color: #000; }
.board .nm { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board b { font-size: 1.2em; }
.board .adj { display: none; gap: .2em; }
.board li:hover .adj { display: flex; }
.board .adj button { width: 1.6em; height: 1.6em; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: #fff; cursor: pointer; font-weight: 800; }

.controls { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 1.2rem; border-top: 1px solid var(--line); background: rgba(0, 0, 0, .2); }
.ctl-main, .ctl-side { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.lobby { display: flex; align-items: center; gap: 3rem; animation: pop-in .4s; }
.lobby-qr { width: min(34vw, 60vh); background: #fff; border-radius: 20px; padding: .6rem; line-height: 0; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.lobby-info { max-width: 44vw; }
.lobby-info .lead { margin: .2em 0; color: var(--muted); }
.lobby-info .url { font-size: 1.6em; font-weight: 800; margin: .1em 0 .4em; }
.big-code { font-size: 5em; font-weight: 900; letter-spacing: .15em; background: linear-gradient(90deg, #ffd700, #ff4d8d); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lobby-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(12em, 1fr)); gap: .6rem; margin-top: 1rem; }

.team-card {
  display: block; width: 100%; text-align: left; padding: .8em 1em; border-radius: 14px; cursor: pointer; color: #fff; font: inherit;
  background: color-mix(in srgb, var(--c) 20%, transparent); border: 2px solid var(--c); animation: pop-in .3s;
}
.team-card b { display: block; font-size: 1.15em; }
.team-card small { color: var(--muted); }

.round-head { display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap; width: 100%; }
.round-head .badge { font-size: 1.1em; }

.intro { text-align: center; animation: pop-in .5s; max-width: 70vw; }
.intro-emoji { font-size: 8em; animation: bounce 2s infinite; }
.intro h1 { font-size: 3.5em; font-weight: 900; color: var(--cat); }
.intro .lead { font-size: 1.6em; }

.timer {
  --p: 1; position: relative; display: grid; place-items: center; width: 4.5em; height: 4.5em; border-radius: 50%; flex: none;
  background: conic-gradient(var(--ok) calc(var(--p) * 360deg), rgba(255, 255, 255, .1) 0);
}
.timer::before { content: ""; position: absolute; inset: .4em; border-radius: 50%; background: var(--bg); }
.timer .t-num { position: relative; font-size: 1.4em; font-weight: 900; }
.timer.urgent { background: conic-gradient(var(--ko) calc(var(--p) * 360deg), rgba(255, 255, 255, .1) 0); animation: pulse .5s infinite; }

.sheet-tv { width: 100%; max-width: 1400px; margin: 0; padding-left: 2.2em; display: grid; gap: .45em; font-size: 1.25em; }
.sheet-tv.cols { grid-template-columns: 1fr 1fr; column-gap: 3em; }
.sheet-tv li { padding: .35em .6em; border-radius: 10px; background: var(--card); line-height: 1.3; }
.sheet-tv li::marker { font-weight: 900; color: var(--gold); }
.sheet-tv.big { grid-template-columns: repeat(auto-fill, minmax(8em, 1fr)); font-size: 2.2em; padding-left: 0; list-style-position: inside; text-align: center; }
.status { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; }

.question { font-size: 2.4em; font-weight: 800; text-align: center; max-width: 85%; line-height: 1.25; animation: pop-in .4s; }
.question.big { font-size: 6em; letter-spacing: .1em; }
.solution { font-size: 2em; font-weight: 900; padding: .4em 1.2em; border-radius: 16px; background: var(--card); border: 2px dashed var(--line); color: var(--muted); }
.solution.shown { color: #fff; background: linear-gradient(135deg, #2fbf7f, #3ddc97); border: 0; animation: pop-in .4s; box-shadow: 0 10px 40px rgba(61, 220, 151, .35); }

.copies { display: grid; grid-template-columns: repeat(auto-fit, minmax(14em, 1fr)); gap: .8rem; width: 100%; max-width: 1400px; }
.copy { padding: .8em 1em; border-radius: 16px; background: color-mix(in srgb, var(--c) 15%, transparent); border: 2px solid var(--c); display: flex; flex-direction: column; gap: .5em; }
.copy-head { display: flex; justify-content: space-between; font-weight: 800; }
.copy-head small { color: var(--muted); }
.copy-text { font-size: 1.5em; font-weight: 700; font-family: "Segoe Print", "Comic Sans MS", "Bradley Hand", cursive; color: #9cc8ff; flex: 1; }
.copy-text.empty { color: var(--muted); font-size: 1em; font-family: inherit; font-style: italic; }
.marks { display: flex; gap: .4em; }
.mark { flex: 1; padding: .4em; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: #fff; font: inherit; font-weight: 900; font-size: 1.2em; cursor: pointer; }
.mark.on.m1 { background: var(--ok); border-color: var(--ok); color: #000; }
.mark.on.m05 { background: var(--a2); border-color: var(--a2); color: #000; }
.mark.on.m0 { background: var(--ko); border-color: var(--ko); }

.bars { width: 100%; max-width: 1100px; display: grid; gap: .6rem; }
.bar { display: grid; grid-template-columns: minmax(10em, 22%) 1fr auto auto; gap: 1em; align-items: center; font-size: 1.3em; }
.bar span { font-weight: 800; }
.bar i { height: 1.4em; border-radius: 999px; background: var(--c); transform-origin: left; transform: scaleX(var(--w)); animation: grow 1s ease-out; min-width: 2px; }
.bar b { font-size: 1.3em; }
.bar small { color: var(--muted); }

.end { text-align: center; width: 100%; animation: pop-in .5s; }
.end h1 { font-size: 2.6em; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 1.2rem; margin: 1.5rem 0; }
.podium-step { display: flex; flex-direction: column; align-items: center; gap: .15em; width: 13em; animation: rise .8s both; }
.podium-step .av { font-size: 4em; }
.podium-step small { color: var(--muted); }
.podium-step .block { width: 100%; margin-top: .4em; border-radius: 14px 14px 0 0; display: grid; place-items: center; font-size: 2.5em; font-weight: 900; background: color-mix(in srgb, var(--c) 60%, #000); }
.podium-step.s1 .block { height: 9em; background: linear-gradient(var(--gold), #b8860b); color: #000; }
.podium-step.s2 .block { height: 6em; }
.podium-step.s3 .block { height: 4em; }
.podium-step.s1 { animation-delay: .6s; }
.podium-step.s2 { animation-delay: .3s; }
.recap { margin: 0 auto; border-collapse: collapse; font-size: 1.1em; }
.recap th, .recap td { padding: .4em .9em; border-bottom: 1px solid var(--line); }
.recap td:first-child { text-align: left; font-weight: 700; }

/* ── Téléphone ───────────────────────────────────────────────────────── */

body.player { min-height: 100vh; }
.join, .pmain { max-width: 560px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.join h1 { text-align: center; }
.team-list { display: grid; gap: .5rem; }
.or { text-align: center; color: var(--muted); margin: 1.2em 0 0; }
.join .btn.big { width: 100%; margin-top: 1rem; }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: .4rem; margin-top: .7rem; }
.avatar { aspect-ratio: 1; font-size: 1.7rem; border-radius: 12px; border: 2px solid transparent; background: color-mix(in srgb, var(--c) 18%, transparent); cursor: pointer; }
.avatar.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 50%, transparent); transform: scale(1.08); }

.me { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .7rem; padding: .7rem 1rem; background: rgba(20, 12, 43, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.me .av { display: grid; place-items: center; width: 2.4em; height: 2.4em; border-radius: 50%; font-size: 1.3em; background: color-mix(in srgb, var(--c) 35%, transparent); border: 2px solid var(--c); }
.me div:nth-child(2) { flex: 1; min-width: 0; }
.me small { display: block; color: var(--muted); font-size: .8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .score { text-align: right; }
.me .score b { font-size: 1.5em; }

.pcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; display: flex; flex-direction: column; gap: .8rem; text-align: center; animation: pop-in .3s; }
.pcard .card-emoji { font-size: 3.5rem; }
.pcard h2 { margin: 0; }
.pcard .timer { align-self: center; }
.card-head { display: flex; justify-content: center; gap: .4rem; flex-wrap: wrap; }

.sheet { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; text-align: left; counter-reset: q; }
.sheet li { counter-increment: q; padding: .7rem; border-radius: 14px; background: rgba(0, 0, 0, .2); border: 1px solid var(--line); }
.sheet li p { margin: 0 0 .5em; font-weight: 600; }
.sheet li p::before { content: counter(q) ". "; color: var(--gold); font-weight: 900; }
.sheet.big li p { font-size: 1.8em; letter-spacing: .05em; }
.sheet input { font-size: 1.05em; }
.sheet input.saved { border-color: color-mix(in srgb, var(--ok) 60%, transparent); }
.sheet .given { display: flex; justify-content: space-between; gap: .5em; align-items: center; font-family: "Segoe Print", "Comic Sans MS", "Bradley Hand", cursive; color: #9cc8ff; font-size: 1.1em; }
.sheet .expected { margin-top: .3em; color: var(--ok); font-weight: 700; }
.sheet li.current { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.sheet li.m1 { border-color: var(--ok); }
.sheet li.m05 { border-color: var(--a2); }
.sheet li.m0 { border-color: var(--ko); }
.mark-chip { flex: none; min-width: 2em; padding: .1em .5em; border-radius: 999px; font-family: system-ui, sans-serif; font-weight: 900; text-align: center; color: #000; background: var(--muted); }
.m1 .mark-chip { background: var(--ok); }
.m05 .mark-chip { background: var(--a2); }
.m0 .mark-chip { background: var(--ko); color: #fff; }
.pmain .board { text-align: left; }

/* ── Animations ──────────────────────────────────────────────────────── */

@keyframes pop-in { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes rise { from { transform: translateY(60px); opacity: 0; } }
@keyframes toast-in { from { transform: translate(-50%, 20px); opacity: 0; } }

@media (max-width: 900px) {
  body.host { height: auto; overflow: auto; }
  .host-grid { grid-template-columns: 1fr; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .lobby { flex-direction: column; gap: 1.5rem; }
  .lobby-qr { width: 70vw; }
  .lobby-info { max-width: 100%; }
  .sheet-tv.cols { grid-template-columns: 1fr; }
  .question.big { font-size: 3.5em; }
}

body.demo { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.demo-bar { display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap; padding: .6rem 1rem; border-bottom: 1px solid var(--line); }
.demo-bar .brand { color: inherit; text-decoration: none; }
.demo-bar p { flex: 1; margin: 0; font-size: .9em; min-width: 12em; }
.demo-tabs { display: none; }
.demo-stage { flex: 1; min-height: 0; display: flex; gap: 32px; align-items: center; justify-content: center; padding: 24px; overflow: hidden; }
.device { flex: none; position: relative; overflow: hidden; background: var(--bg); box-shadow: 0 0 0 8px #0b0b0f, 0 20px 60px rgba(0, 0, 0, .5); }
.device iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; background: var(--bg); }
.device.tv { border-radius: 6px; box-shadow: 0 0 0 8px #0b0b0f, 0 14px 0 8px #0b0b0f, 0 30px 60px rgba(0, 0, 0, .5); }
.device.phone { border-radius: 28px; box-shadow: 0 0 0 10px #0b0b0f, 0 20px 60px rgba(0, 0, 0, .5); }

body.tabs .demo-bar p, body.tabs .demo-actions span, body.tabs .brand span { display: none; }
body.tabs .demo-tabs { display: flex; gap: .3rem; margin-left: auto; }
body.tabs .demo-tabs button { font: inherit; font-weight: 700; color: #fff; padding: .45em .8em; border-radius: 999px; border: 1px solid var(--line); background: var(--card); }
body.tabs .demo-tabs button.on { background: linear-gradient(135deg, #ff4d8d, #a66bff); border-color: transparent; }
body.tabs .demo-stage { padding: 12px; }
body.tabs .demo-stage[data-view=tv] .phone, body.tabs .demo-stage[data-view=phone] .tv { display: none; }

@media (max-width: 499px) {
  body.tabs .demo-stage[data-view=phone] { padding: 0; align-items: stretch; }
  body.tabs .demo-stage[data-view=phone] .phone { flex: 1; border-radius: 0; box-shadow: none; }
}

.demo-link { display: flex; margin: 0 auto 1.2rem; }
