:root {
  --violet: #46178f;
  --violet-d: #2d0e5e;
  --violet-l: #f1ebfa;
  --ink: #1f1a2b;
  --muted: #6b6578;
  --line: #e2dcea;
  --bg: #f6f4f9;
  --card: #fff;
  --ok: #26890c;
  --ko: #e21b3c;
  --a0: #e21b3c; /* triangle rouge */
  --a1: #1368ce; /* losange bleu */
  --a2: #d89e00; /* rond jaune */
  --a3: #26890c; /* carré vert */
  --radius: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.45; -webkit-tap-highlight-color: transparent;
}
a { color: var(--violet); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- barre du haut ---------- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--violet); color: #fff; }
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: .5px; display: flex; align-items: baseline; gap: 8px; }
.brand small { font-weight: 500; opacity: .8; font-size: .75rem; letter-spacing: 0; }
.topbar nav { margin-left: auto; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.topbar nav a { opacity: .9; font-weight: 600; font-size: .95rem; }
.topbar nav a:hover { opacity: 1; text-decoration: underline; }
.who { font-size: .85rem; opacity: .85; }

main.page { max-width: 1000px; margin: 0 auto; padding: 24px 16px 60px; }
main.narrow { max-width: 460px; }

/* ---------- éléments ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: 0 1px 2px rgba(40,10,80,.04); }
.card + .card { margin-top: 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 700; cursor: pointer;
  background: var(--violet); color: #fff; text-decoration: none; box-shadow: 0 3px 0 var(--violet-d);
  transition: transform .05s, filter .15s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--violet-d); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.light { background: #fff; color: var(--violet); box-shadow: 0 3px 0 #d8cdea; border: 1px solid #d8cdea; }
.btn.ghost { background: transparent; color: var(--violet); box-shadow: none; padding: 8px 10px; }
.btn.danger { background: #fff; color: var(--ko); border: 1px solid #f3c0c9; box-shadow: none; }
.btn.ok { background: var(--ok); box-shadow: 0 3px 0 #185a07; }
.btn.big { font-size: 1.15rem; padding: 14px 22px; }
.btn.block { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

label.f { display: block; font-weight: 600; margin: 14px 0 6px; font-size: .95rem; }
input.i, select.i, textarea.i { width: 100%; padding: 11px 12px; border: 2px solid var(--line); border-radius: 8px; background: #fff; }
input.i:focus, select.i:focus, textarea.i:focus { outline: none; border-color: var(--violet); }
textarea.i { resize: vertical; min-height: 70px; }

.msg { padding: 10px 14px; border-radius: 8px; margin: 12px 0; font-size: .95rem; }
.msg.err { background: #fde8ec; color: #9c1028; }
.msg.ok { background: #e6f4e1; color: #1d5f0a; }
.msg.info { background: var(--violet-l); color: var(--violet-d); }
.hidden { display: none !important; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 700; background: var(--violet-l); color: var(--violet); }
.badge.pending { background: #fff3cd; color: #7a5a00; }
.badge.active { background: #e6f4e1; color: #1d5f0a; }
.badge.refused, .badge.disabled { background: #fde8ec; color: #9c1028; }
.badge.approved { background: #e0ecfb; color: #0c4a94; }

table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th, table.t td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-size: .8rem; text-transform: uppercase; color: var(--muted); letter-spacing: .4px; }
.scroll-x { overflow-x: auto; }

/* ---------- tableau de bord ---------- */
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.quiz-card { display: flex; flex-direction: column; gap: 8px; }
.quiz-card + .quiz-card { margin-top: 0; }
.quiz-card h3 { margin: 0; font-size: 1.1rem; word-break: break-word; }
.quiz-card .row { margin-top: auto; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ---------- éditeur ---------- */
.editor { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
.qlist { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 40px); overflow: auto; }
.qthumb { border: 2px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px; cursor: pointer; text-align: left; font-size: .85rem; display: flex; gap: 8px; align-items: flex-start; }
.qthumb .n { font-weight: 800; color: var(--violet); }
.qthumb.on { border-color: var(--violet); background: var(--violet-l); }
.qthumb.bad { border-color: #f3a7b5; }
.qthumb .tx { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qedit .qtext { font-size: 1.25rem; font-weight: 700; text-align: center; }
.qimg { margin: 14px 0; text-align: center; }
.qimg img { max-width: 100%; max-height: 240px; border-radius: 8px; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 16px; text-align: center; color: var(--muted); cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--violet); color: var(--violet); }
.ansgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.ans { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: #fff; min-height: 64px; }
.ans input[type=text] { flex: 1; background: transparent; border: 0; color: #fff; font-weight: 700; font-size: 1.05rem; padding: 6px; min-width: 0; }
.ans input[type=text]::placeholder { color: rgba(255,255,255,.8); }
.ans input[type=text]:focus { outline: 2px solid rgba(255,255,255,.6); border-radius: 6px; }
.ans .fixed { flex: 1; font-weight: 700; font-size: 1.05rem; padding: 6px; }
.tick { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; background: transparent; cursor: pointer; flex: none; display: grid; place-items: center; color: transparent; font-weight: 900; }
.tick.on { background: #fff; color: var(--ok); }
.bg0 { background: var(--a0); } .bg1 { background: var(--a1); } .bg2 { background: var(--a2); } .bg3 { background: var(--a3); }
.shape { width: 26px; height: 26px; flex: none; }
.qopts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.save-state { font-size: .85rem; color: var(--muted); }

/* ---------- écrans de jeu (joueur + animateur) ---------- */
body.game { background: var(--violet); color: #fff; min-height: 100vh; min-height: 100dvh; }
body.game .card { color: var(--ink); }
.game-wrap { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.join-box { width: 100%; max-width: 360px; margin: auto; padding: 20px 16px; text-align: center; }
.join-box .logo { font-size: 2.6rem; font-weight: 900; letter-spacing: 1px; margin-bottom: 4px; }
.join-box .sub { opacity: .85; margin-bottom: 18px; font-size: .95rem; }
.join-box .card { padding: 18px; }
.join-box input.i { text-align: center; font-size: 1.3rem; font-weight: 800; padding: 13px; }
.join-box .btn { width: 100%; margin-top: 10px; background: #333; box-shadow: 0 3px 0 #000; font-size: 1.15rem; padding: 13px; }
.join-foot { margin-top: 26px; font-size: .9rem; opacity: .9; }
.join-foot a { color: #fff; }

.pbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: rgba(0,0,0,.18); font-weight: 700; }
.pbar .sc { margin-left: auto; background: #fff; color: var(--ink); padding: 3px 12px; border-radius: 6px; }
.pstage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; text-align: center; }
.pstage h1 { font-size: 1.7rem; }
.pbig { font-size: 1.25rem; font-weight: 700; }
.pq { padding: 12px 16px 0; text-align: center; font-weight: 700; font-size: 1.05rem; }
.ptimer { text-align: center; font-weight: 800; padding: 6px; }
.pbtns { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; }
.pbtns.two { grid-template-columns: 1fr 1fr; }
.pbtn { border: 0; border-radius: 10px; color: #fff; font-weight: 800; font-size: 1.05rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px; box-shadow: inset 0 -6px 0 rgba(0,0,0,.2); min-height: 90px; word-break: break-word; }
.pbtn .shape { width: 44px; height: 44px; }
.pbtn:active { transform: scale(.98); }
.result.good { background: var(--ok); }
.result.bad { background: var(--ko); }
.result-ic { font-size: 4rem; line-height: 1; font-weight: 900; }
.pts { background: rgba(0,0,0,.25); display: inline-block; padding: 8px 18px; border-radius: 8px; font-weight: 800; font-size: 1.3rem; margin-top: 12px; }
.spin { width: 54px; height: 54px; border: 6px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; margin: 18px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* animateur */
.hbar { display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: rgba(0,0,0,.2); flex-wrap: wrap; }
.hbar .btn { box-shadow: none; }
.hbar .ttl { font-weight: 800; }
.lobby { flex: 1; padding: 24px; }
.pinbox { background: #fff; color: var(--ink); border-radius: 14px; padding: 16px 26px; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; justify-content: center; }
.pinbox .lbl { font-size: 1rem; font-weight: 700; color: var(--muted); }
.pinbox .pin { font-size: clamp(2.6rem, 7vw, 5rem); font-weight: 900; letter-spacing: 4px; line-height: 1; }
.pinbox .qr { width: 150px; height: 150px; }
.pinbox .qr svg { width: 100%; height: 100%; }
.lobby-mid { display: flex; align-items: center; gap: 14px; margin-top: 22px; flex-wrap: wrap; }
.plist { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; justify-content: center; }
.chip { background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font-weight: 800; font-size: 1.1rem; cursor: pointer; animation: pop .25s; border: 0; }
.chip.off { opacity: .45; }
.chip:hover { text-decoration: line-through; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.count { font-size: 1.3rem; font-weight: 800; background: rgba(0,0,0,.25); padding: 8px 16px; border-radius: 8px; }

.hq { flex: 1; display: flex; flex-direction: column; padding: 16px 20px 20px; gap: 14px; }
.hq-title { background: #fff; color: var(--ink); border-radius: 10px; padding: 16px 20px; font-size: clamp(1.3rem, 3vw, 2.2rem); font-weight: 800; text-align: center; }
.hq-mid { flex: 1; display: grid; grid-template-columns: 110px minmax(0, 1fr) 110px; align-items: center; gap: 16px; min-height: 180px; }
.hq-mid .media { text-align: center; }
.hq-mid .media img { max-width: 100%; max-height: 38vh; border-radius: 10px; }
.timer { width: 96px; height: 96px; border-radius: 50%; background: #fff; color: var(--violet); font-size: 2.4rem; font-weight: 900; display: grid; place-items: center; }
.anscount { text-align: center; font-weight: 800; font-size: 2rem; line-height: 1; }
.anscount small { display: block; font-size: .9rem; font-weight: 600; }
.hq-ans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hans { display: flex; align-items: center; gap: 14px; border-radius: 8px; padding: 16px 18px; font-size: clamp(1.05rem, 2.2vw, 1.6rem); font-weight: 800; min-height: 74px; box-shadow: inset 0 -5px 0 rgba(0,0,0,.18); }
.hans .shape { width: 40px; height: 40px; }
.hans .okm { margin-left: auto; font-size: 2rem; }
.dim { opacity: .35; }
.bars { display: flex; gap: 20px; align-items: flex-end; justify-content: center; height: 30vh; min-height: 140px; }
.bar { width: 90px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; font-weight: 800; }
.bar .fill { width: 100%; border-radius: 6px 6px 0 0; min-height: 8px; transition: height .6s; }
.explain { background: rgba(255,255,255,.15); border-radius: 8px; padding: 10px 14px; text-align: center; font-weight: 600; }
.ready { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; gap: 20px; }
.ready .qn { font-size: 1.3rem; font-weight: 700; opacity: .85; }
.ready .big { font-size: clamp(1.6rem, 4vw, 3rem); font-weight: 900; max-width: 1000px; }
.readybar { width: min(600px, 80vw); height: 10px; background: rgba(255,255,255,.25); border-radius: 99px; overflow: hidden; }
.readybar div { height: 100%; background: #fff; width: 100%; }
.board { width: min(760px, 94vw); margin: 10px auto; display: flex; flex-direction: column; gap: 10px; }
.board .line { display: flex; align-items: center; gap: 14px; background: #fff; color: var(--ink); border-radius: 8px; padding: 12px 18px; font-size: 1.35rem; font-weight: 800; animation: pop .3s backwards; }
.board .line .r { width: 34px; color: var(--violet); }
.board .line .s { margin-left: auto; }
.board .line .g { font-size: .9rem; color: var(--ok); font-weight: 700; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; margin: 20px auto 10px; }
.podium .step { width: min(220px, 28vw); text-align: center; }
.podium .nm { font-weight: 900; font-size: clamp(1rem, 2.2vw, 1.6rem); margin-bottom: 8px; word-break: break-word; }
.podium .blk { background: #fff; color: var(--violet); border-radius: 8px 8px 0 0; display: flex; flex-direction: column; align-items: center; padding-top: 14px; font-weight: 900; font-size: 2.6rem; animation: rise .8s backwards; transform-origin: bottom; }
.podium .blk small { font-size: 1rem; color: var(--ink); }
.podium .p1 .blk { height: 220px; animation-delay: 1.4s; }
.podium .p2 .blk { height: 160px; animation-delay: .7s; }
.podium .p3 .blk { height: 115px; }
@keyframes rise { from { transform: scaleY(0); opacity: 0; } }
.hfoot { padding: 0 20px 16px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .topbar nav { margin-left: 0; width: 100%; }
  .editor { grid-template-columns: 1fr; }
  .qlist { position: static; flex-direction: row; overflow-x: auto; max-height: none; }
  .qthumb { min-width: 130px; }
  .ansgrid, .hq-ans { grid-template-columns: 1fr; }
  .qopts { grid-template-columns: 1fr 1fr; }
  .lobby { padding: 16px; }
  .hq-mid { grid-template-columns: 64px minmax(0, 1fr) 64px; }
  .timer { width: 60px; height: 60px; font-size: 1.5rem; }
  .bar { width: 56px; }
  .pinbox .qr { width: 110px; height: 110px; }
}
