:root {
  --bg: #120f24;
  --bg2: #1c1838;
  --panel: #231e45;
  --panel2: #2d2757;
  --line: #3a3370;
  --text: #f4f1ff;
  --muted: #a9a3cf;
  --yellow: #ffd23f;
  --pink: #ff4f81;
  --cyan: #2fd9c4;
  --violet: #8b6cff;
  --orange: #ff8a3d;
  --green: #3ddc84;
  --red: #ff5b5b;
  --radius: 18px;
  --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(139,108,255,.25), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(255,79,129,.18), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--cyan); }
.hidden { display: none !important; }

.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px 60px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.logo {
  font-weight: 800; font-size: 28px; letter-spacing: -0.02em;
  display: inline-flex; align-items: center; gap: 8px;
}
.logo .q {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--yellow); color: #1b1630; font-size: 26px; transform: rotate(-6deg);
  box-shadow: 0 4px 0 #c99a00;
}
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }

.hero { text-align: center; margin: 24px 0 32px; }
.hero h1 { font-size: clamp(40px, 9vw, 86px); line-height: .95; margin: 0 0 12px; letter-spacing: -0.04em; font-weight: 800; }
.hero h1 span { color: var(--yellow); }
.hero p { color: var(--muted); font-size: 18px; margin: 0; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.card h2 { margin: 0 0 14px; font-size: 22px; letter-spacing: -0.01em; }
.card h2 .tag { font-size: 12px; vertical-align: middle; margin-left: 6px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; letter-spacing: .02em; }
input[type=text], input[type=number], input[type=password], input:not([type]), select, textarea {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 2px solid var(--line);
  background: #15122b; outline: none; transition: border-color .15s;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--violet); }
.code-input { text-transform: uppercase; letter-spacing: .35em; font-size: 28px !important; font-weight: 800; text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: 14px; border: 0; cursor: pointer; font-weight: 700; font-size: 16px;
  background: var(--panel2); color: var(--text); transition: transform .08s, filter .15s; text-decoration: none;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; }
.btn.primary { background: var(--yellow); color: #1b1630; box-shadow: 0 4px 0 #c99a00; }
.btn.pink { background: var(--pink); color: #fff; box-shadow: 0 4px 0 #b8264f; }
.btn.cyan { background: var(--cyan); color: #082a26; box-shadow: 0 4px 0 #1a9183; }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.danger { background: transparent; border: 2px solid var(--red); color: var(--red); }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; margin-top: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 12px; border-radius: 999px; border: 2px solid var(--line); background: transparent; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--muted); user-select: none;
}
.chip.on { border-color: var(--yellow); color: var(--yellow); background: rgba(255,210,63,.08); }
.chip small { opacity: .7; margin-left: 4px; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--text); font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--yellow); }

.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--panel2); color: var(--muted); }
.tag.qcm { background: rgba(139,108,255,.2); color: #c5b6ff; }
.tag.nombre { background: rgba(47,217,196,.18); color: var(--cyan); }
.tag.texte { background: rgba(255,138,61,.18); color: var(--orange); }

.error { color: #ffb3b3; background: rgba(255,91,91,.12); border: 1px solid rgba(255,91,91,.4); padding: 10px 12px; border-radius: 12px; margin-top: 12px; font-size: 14px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Salle d'attente */
.bigcode {
  font-size: clamp(56px, 16vw, 120px); font-weight: 800; letter-spacing: .12em; color: var(--yellow);
  text-shadow: 0 6px 0 rgba(0,0,0,.35); line-height: 1; margin: 8px 0;
}
.joinurl { font-size: 15px; color: var(--muted); word-break: break-all; }
.players { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 18px 0; }
.pl {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px;
  background: var(--panel2); font-weight: 700; animation: pop .25s ease-out;
}
.pl .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.pl.off .dot { background: #666; }
.pl.done { background: rgba(61,220,132,.18); color: var(--green); }
.pl .x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 0 0 4px; font-size: 16px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.qrbox { width: 220px; max-width: 70vw; margin: 14px auto 10px; padding: 0; border-radius: 16px; overflow: hidden; background: #fff; box-shadow: 0 0 0 6px rgba(255,210,63,.25); }
.qrbox svg { display: block; width: 100%; height: auto; }
.qrbox.big { width: 300px; }
@media (min-width: 900px) { .qrbox { width: 260px; } }

/* Jeu */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.hud .num { font-weight: 800; font-size: 18px; }
.hud .score { font-weight: 800; color: var(--yellow); font-size: 18px; }
.timer { position: relative; height: 14px; border-radius: 999px; background: #15122b; overflow: hidden; border: 1px solid var(--line); margin-bottom: 18px; }
.timer > div { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, var(--cyan), var(--yellow)); }
.timer.low > div { background: linear-gradient(90deg, var(--orange), var(--red)); }
.countdown { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 22px; min-width: 52px; text-align: right; }
.qtext { font-size: clamp(24px, 4.6vw, 42px); font-weight: 800; line-height: 1.15; letter-spacing: -0.02em; margin: 6px 0 22px; }
.qmeta { display: flex; gap: 8px; flex-wrap: wrap; }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.choice {
  position: relative; display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 18px; border-radius: 16px; border: 0; cursor: pointer; font-size: 19px; font-weight: 700;
  color: #1b1630; min-height: 76px; transition: transform .08s, opacity .2s, filter .2s;
}
.choice .letter { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: rgba(0,0,0,.18); font-weight: 800; color: #fff; }
.choice:nth-child(6n+1) { background: var(--yellow); box-shadow: 0 5px 0 #c99a00; }
.choice:nth-child(6n+2) { background: var(--pink); box-shadow: 0 5px 0 #b8264f; color: #fff; }
.choice:nth-child(6n+3) { background: var(--cyan); box-shadow: 0 5px 0 #1a9183; }
.choice:nth-child(6n+4) { background: var(--violet); box-shadow: 0 5px 0 #5b3fd1; color: #fff; }
.choice:nth-child(6n+5) { background: var(--orange); box-shadow: 0 5px 0 #c25c18; }
.choice:nth-child(6n+6) { background: var(--green); box-shadow: 0 5px 0 #1f9a55; }
.choice:hover:not(:disabled) { filter: brightness(1.08); }
.choice:active:not(:disabled) { transform: translateY(3px); }
.choice:disabled { cursor: default; }
.choices.answered .choice:not(.mine), .choices.revealed .choice:not(.good) { opacity: .35; filter: grayscale(.5); }
.choice.mine { outline: 4px solid #fff; outline-offset: 3px; }
.choice.good { opacity: 1 !important; filter: none !important; outline: 4px solid var(--green); outline-offset: 3px; }
.choice .count { margin-left: auto; background: rgba(0,0,0,.25); color: #fff; border-radius: 999px; padding: 3px 10px; font-size: 15px; }

.freeform { display: flex; gap: 10px; flex-wrap: wrap; }
.freeform input { flex: 1 1 240px; font-size: 24px !important; font-weight: 700; padding: 16px !important; }
.freeform .unit { align-self: center; font-size: 20px; font-weight: 700; color: var(--muted); }
.sent { margin-top: 18px; padding: 14px 16px; border-radius: 14px; background: rgba(61,220,132,.12); border: 1px solid rgba(61,220,132,.4); color: var(--green); font-weight: 700; }

.answer-box {
  padding: 18px 20px; border-radius: 16px; background: rgba(61,220,132,.12); border: 2px solid var(--green); margin-bottom: 16px;
}
.answer-box .lbl { font-size: 13px; color: var(--green); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.answer-box .val { font-size: 30px; font-weight: 800; margin-top: 4px; }
.answer-box .exp { color: var(--muted); margin-top: 8px; font-size: 15px; }
.verdict { font-size: 26px; font-weight: 800; margin: 0 0 14px; }
.verdict.ok { color: var(--green); }
.verdict.ko { color: var(--red); }
.verdict.near { color: var(--yellow); }

.results { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.results li {
  display: grid; grid-template-columns: 26px 1fr auto auto; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); animation: slide .3s ease-out both;
}
.results li .ic { font-weight: 800; }
.results li.ok .ic { color: var(--green); }
.results li.ko .ic { color: var(--red); }
.results li.near .ic { color: var(--yellow); }
.results li .who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results li .what { color: var(--muted); font-size: 15px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results li .pts { font-weight: 800; color: var(--yellow); min-width: 64px; text-align: right; }
.results li.me { border-color: var(--yellow); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.board li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-weight: 700; }
.board li .rk { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); font-weight: 800; flex: none; }
.board li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li .sc { color: var(--yellow); font-variant-numeric: tabular-nums; }
.board li.me { border-color: var(--yellow); }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 12px; margin: 30px 0 26px; }
.podium .step { flex: 0 1 170px; text-align: center; }
.podium .step .nm { font-weight: 800; font-size: 18px; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .step .sc { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.podium .block { border-radius: 14px 14px 4px 4px; display: grid; place-items: center; font-size: 40px; font-weight: 800; color: #1b1630; }
.podium .p1 .block { height: 170px; background: var(--yellow); }
.podium .p2 .block { height: 120px; background: #d5d9e6; }
.podium .p3 .block { height: 90px; background: #e39a5c; }

.hostbar { z-index: 45;
  position: sticky; bottom: 12px; margin-top: 22px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  padding: 12px; border-radius: 16px; background: rgba(28,24,56,.92); border: 1px solid var(--line); backdrop-filter: blur(8px);
}
.hostbar .lbl { align-self: center; color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 12px 18px; border-radius: 12px; z-index: 50; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100% - 32px); }

/* Pause */
.pause-overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(18,15,36,.72); backdrop-filter: blur(3px); animation: fadein .2s ease-out; }
.pause-box { text-align: center; background: linear-gradient(180deg, var(--panel), var(--bg2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px 26px; max-width: 420px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.pause-box h2 { margin: 6px 0 6px; font-size: 30px; letter-spacing: -0.02em; }
.pause-icon { width: 76px; height: 76px; margin: 0 auto; border-radius: 22px; display: grid; place-items: center; font-size: 38px; background: var(--yellow); color: #1b1630; box-shadow: 0 5px 0 #c99a00; animation: pulse 1.6s ease-in-out infinite; }
#vPlay.is-paused .qtext, #vPlay.is-paused .choices, #vPlay.is-paused .freeform { filter: blur(8px); }
#vPlay.is-paused .hostbar { position: fixed; left: 16px; right: 16px; bottom: 12px; max-width: 948px; margin: 0 auto; }
.pause-overlay { padding-bottom: 96px; }
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes fadein { from { opacity: 0; } }

/* Admin */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 12px 16px; cursor: pointer; color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--yellow); border-bottom-color: var(--yellow); }
.setting { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting .t { font-weight: 700; font-size: 16px; }
.setting .d { color: var(--muted); font-size: 14px; grid-column: 1; }
.setting .ctl { grid-row: 1 / span 2; grid-column: 2; display: flex; align-items: center; gap: 10px; }
.setting .ctl input[type=number] { width: 96px; text-align: center; font-weight: 800; font-size: 18px; }
.setting input[type=range] { width: 100%; grid-column: 1 / -1; accent-color: var(--yellow); }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); cursor: pointer; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--yellow); }
.switch input:checked + span::after { transform: translateX(22px); }

.qlist { display: grid; gap: 8px; }
.qitem { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 14px 16px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.qitem .qq { font-weight: 700; }
.qitem .qa { color: var(--muted); font-size: 14px; margin-top: 4px; }
.qitem .qa b { color: var(--green); font-weight: 700; }
.qitem .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.qitem .acts { display: flex; gap: 6px; align-items: flex-start; }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.choice-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.choice-row input[type=radio] { width: 22px; height: 22px; accent-color: var(--green); flex: none; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 12px; }
pre.code { background: #0d0b1d; border: 1px solid var(--line); border-radius: 12px; padding: 14px; overflow-x: auto; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; }
.copyline { display: flex; gap: 8px; }
.copyline input { font-family: ui-monospace, monospace; font-size: 13px !important; }

dialog { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(640px, calc(100% - 24px)); max-height: calc(100% - 24px); }
dialog::backdrop { background: rgba(5,4,15,.7); }
dialog .dlg { padding: 22px; }
dialog h3 { margin: 0 0 6px; font-size: 22px; }

@media (max-width: 600px) {
  .wrap { padding: 14px 16px 40px; }
  .filters { grid-template-columns: 1fr; }
  .results li { grid-template-columns: 22px 1fr auto; }
  .results li .what { grid-column: 2 / -1; grid-row: 2; max-width: none; }
  .choice { font-size: 17px; min-height: 64px; padding: 14px; }
  .podium .block { font-size: 30px; }
}
