:root {
  --violet: #46178f; --violet-2: #25076b; --violet-3: #864cbf;
  --rouge: #e21b3c; --bleu: #1368ce; --jaune: #d89e00; --vert: #26890c;
  --gris: #f2f2f2; --texte: #333; --ok: #66bf39; --ko: #f35;
  --r: 6px;
  font-family: "Montserrat", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--violet); color: #fff; font-weight: 700; overflow-x: hidden; }
body.light { background: var(--gris); color: var(--texte); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; border-radius: var(--r); }
button:disabled { opacity: .5; cursor: not-allowed; }
.hidden { display: none !important; }
a { color: inherit; }

/* fond animé */
.bg-shapes { position: fixed; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.bg-shapes i { position: absolute; width: 40vmax; height: 40vmax; background: rgba(255,255,255,.05); }
.bg-shapes i:nth-child(1) { top: -15vmax; left: -10vmax; transform: rotate(45deg); }
.bg-shapes i:nth-child(2) { bottom: -20vmax; right: -12vmax; border-radius: 50%; }

/* logo */
.logo { font-size: clamp(2.2rem, 8vw, 4rem); font-weight: 900; letter-spacing: -1px; text-align: center; margin: 0; line-height: 1; }
.logo span { color: #ffd23f; }
.logo small { display: block; font-size: .9rem; font-weight: 600; letter-spacing: 0; opacity: .8; margin-top: .4rem; }

/* boutons */
.btn { background: #333; color: #fff; padding: .85rem 1.2rem; font-weight: 800; font-size: 1rem; box-shadow: inset 0 -4px rgba(0,0,0,.25); transition: transform .05s; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 -2px rgba(0,0,0,.25); }
.btn.big { width: 100%; padding: 1rem; font-size: 1.15rem; }
.btn.white { background: #fff; color: var(--texte); }
.btn.violet { background: var(--violet); }
.btn.green { background: var(--vert); }
.btn.red { background: var(--rouge); }
.btn.blue { background: var(--bleu); }
.btn.ghost { background: rgba(255,255,255,.15); box-shadow: none; }
.btn.small { padding: .45rem .7rem; font-size: .85rem; }
.light .btn.ghost { background: #e4e4e4; color: var(--texte); }

/* cartes / formulaires */
.card { background: #fff; color: var(--texte); border-radius: 8px; padding: 1.1rem; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.input { width: 100%; padding: .9rem; border: 2px solid #ccc; border-radius: var(--r); font-weight: 800; font-size: 1.1rem; text-align: center; color: var(--texte); background: #fff; }
.input:focus { outline: none; border-color: #333; }
.input.left { text-align: left; font-weight: 600; font-size: 1rem; }
label.lbl { display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: #666; margin: .7rem 0 .3rem; }
.err { color: var(--rouge); font-size: .9rem; min-height: 1.2em; margin: .5rem 0 0; text-align: center; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 1rem; gap: 1.2rem; }
.stack { display: flex; flex-direction: column; gap: .7rem; width: 100%; max-width: 340px; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.muted { opacity: .75; font-weight: 600; }
.foot { position: fixed; bottom: .6rem; left: 0; right: 0; text-align: center; font-size: .8rem; font-weight: 600; opacity: .8; }
.foot a { margin: 0 .5rem; }

/* formes */
.shape { width: 1.6em; height: 1.6em; flex: none; fill: #fff; filter: drop-shadow(0 2px 0 rgba(0,0,0,.2)); }
.c0 { background: var(--rouge); } .c1 { background: var(--bleu); } .c2 { background: var(--jaune); } .c3 { background: var(--vert); }

/* toast */
#toast { position: fixed; left: 50%; top: 1rem; transform: translateX(-50%); background: #222; color: #fff; padding: .7rem 1.1rem; border-radius: 6px; z-index: 99; font-size: .95rem; max-width: 92vw; box-shadow: 0 3px 10px rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }

/* ---------------- JOUEUR ---------------- */
.ptop { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: .55rem .8rem; background: #fff; color: var(--texte); font-size: .95rem; z-index: 5; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.pbot { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: .6rem .8rem; background: #fff; color: var(--texte); z-index: 5; box-shadow: 0 -1px 4px rgba(0,0,0,.2); }
.pbot .score { background: #333; color: #fff; padding: .25rem .7rem; border-radius: 4px; }
.pscreen { position: fixed; inset: 3rem 0 3.2rem; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; text-align: center; gap: 1rem; overflow-y: auto; }
.pgrid { position: fixed; inset: 3rem 0 3.2rem; display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; padding: .6rem; }
.pgrid.two { grid-template-columns: 1fr; }
.pgrid.vf { grid-template-columns: 1fr 1fr; }
.pqtext { position: fixed; top: 3rem; left: 0; right: 0; padding: .5rem .8rem; background: rgba(0,0,0,.25); text-align: center; font-size: 1rem; z-index: 4; }
.pq { position: fixed; inset: 3rem 0 3.2rem; display: flex; flex-direction: column; }
.pq .pqtext { position: static; max-height: 35%; overflow-y: auto; flex: none; }
.pq .pgrid { position: static; flex: 1; min-height: 0; }
.pans { border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; color: #fff; font-size: 1.05rem; padding: .5rem; box-shadow: inset 0 -6px rgba(0,0,0,.2); text-align: center; word-break: break-word; }
.pans .shape { width: 3.2rem; height: 3.2rem; }
.pans:active { filter: brightness(.9); }
.pans.dim { opacity: .25; }
.big-emoji { font-size: 4rem; line-height: 1; }
.result-ok { background: var(--ok) !important; }
.result-ko { background: var(--ko) !important; }
.pill { background: rgba(0,0,0,.3); padding: .5rem 1rem; border-radius: 6px; font-size: 1.1rem; }
.spinner { width: 54px; height: 54px; border: 6px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0 } 70% { transform: scale(1.08) } 100% { transform: scale(1); opacity: 1 } }

/* ---------------- HÔTE ---------------- */
.hbar { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(6px); padding: .5rem; display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; z-index: 35; }
.hbar .btn { padding: .55rem .8rem; font-size: .9rem; }
.hmain { padding: 1rem 1rem 5.5rem; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.lobby-top { display: flex; gap: 1rem; align-items: stretch; justify-content: center; flex-wrap: wrap; }
.pinbox { background: #fff; color: var(--texte); border-radius: 8px; padding: .8rem 1.4rem; text-align: center; }
.pinbox .lab { font-size: 1rem; }
.pinbox .pin { font-size: clamp(3rem, 9vw, 6rem); font-weight: 900; letter-spacing: 2px; line-height: 1; }
.pinbox .url { font-size: .9rem; color: #555; word-break: break-all; }
.qrbox { background: #fff; border-radius: 8px; padding: .5rem; display: flex; align-items: center; }
.qrbox img { width: clamp(140px, 20vw, 230px); height: auto; display: block; }
.lobby-mid { display: flex; justify-content: space-between; align-items: center; margin: 1rem 0; gap: 1rem; flex-wrap: wrap; }
.count { background: rgba(0,0,0,.3); padding: .5rem 1rem; border-radius: 6px; font-size: 1.3rem; }
.names { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; align-content: flex-start; flex: 1; }
.name { background: #fff; color: var(--texte); padding: .55rem 1rem; border-radius: 6px; font-size: 1.15rem; animation: pop .35s; cursor: pointer; position: relative; }
.name.off { opacity: .5; }
.name:hover::after { content: "✕"; position: absolute; top: -.5rem; right: -.5rem; background: var(--rouge); color: #fff; width: 1.3rem; height: 1.3rem; border-radius: 50%; font-size: .75rem; display: flex; align-items: center; justify-content: center; }
.hq-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.hq-text { background: #fff; color: var(--texte); border-radius: 6px; padding: 1rem; font-size: clamp(1.3rem, 3.4vw, 2.6rem); text-align: center; flex: 1; }
.hq-mid { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; }
.timer { width: clamp(80px, 11vw, 140px); height: clamp(80px, 11vw, 140px); border-radius: 50%; background: var(--violet-3); display: flex; align-items: center; justify-content: center; font-size: clamp(2rem, 5vw, 3.6rem); flex: none; }
.timer.low { background: var(--rouge); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.07) } }
.answered-box { text-align: center; font-size: clamp(1.6rem, 4vw, 3rem); flex: none; }
.answered-box small { display: block; font-size: 1rem; }
.hgrid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.hans { display: flex; align-items: center; gap: .8rem; padding: 1rem; border-radius: 6px; font-size: clamp(1rem, 2.4vw, 1.8rem); min-height: 4.5rem; box-shadow: inset 0 -5px rgba(0,0,0,.2); word-break: break-word; }
.hans.wrong { opacity: .3; }
.hans .tick { margin-left: auto; font-size: 1.6em; }
.chart { display: flex; align-items: flex-end; justify-content: center; gap: 1.2rem; height: 32vh; padding: 0 1rem; }
.bar { width: clamp(50px, 10vw, 120px); display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.bar .fill { width: 100%; border-radius: 4px 4px 0 0; transition: height .6s ease-out; min-height: 6px; }
.bar .lab { display: flex; align-items: center; gap: .3rem; padding: .3rem; width: 100%; justify-content: center; font-size: 1.3rem; }
.bar .lab .shape { width: 1.2em; height: 1.2em; }
.bar.wrong .fill { opacity: .35; }
.intro { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 1.2rem; }
.intro .qn { background: #fff; color: var(--texte); padding: .4rem 1rem; border-radius: 30px; }
.intro .qt { font-size: clamp(1.8rem, 5vw, 3.6rem); max-width: 1100px; }
.progress { width: min(600px, 80vw); height: 10px; background: rgba(255,255,255,.25); border-radius: 5px; overflow: hidden; }
.progress div { height: 100%; background: #fff; width: 0; }
.lb { max-width: 900px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: .5rem; }
.lb h2 { text-align: center; font-size: 2.4rem; margin: .5rem 0 1rem; }
.lbrow { display: flex; justify-content: space-between; align-items: center; background: #fff; color: var(--texte); padding: .8rem 1.1rem; border-radius: 6px; font-size: 1.4rem; animation: pop .4s; }
.lbrow:first-of-type { background: #ffd23f; }
.lbrow .up { color: var(--vert); font-size: .9rem; margin-left: .5rem; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 1rem; flex: 1; padding-top: 2rem; }
.pod { display: flex; flex-direction: column; align-items: center; width: clamp(100px, 22vw, 240px); }
.pod .who { font-size: clamp(1.1rem, 2.5vw, 2rem); margin-bottom: .5rem; text-align: center; word-break: break-word; }
.pod .block { width: 100%; background: var(--violet-3); border-radius: 6px 6px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 1rem; font-size: clamp(1rem, 2vw, 1.4rem); animation: rise 1s ease-out both; }
.pod .medal { font-size: clamp(2.5rem, 6vw, 4.5rem); }
.pod.p1 .block { height: 46vh; background: #ffd23f; color: var(--texte); animation-delay: 2s; }
.pod.p2 .block { height: 34vh; background: #c0c0c0; color: var(--texte); animation-delay: 1s; }
.pod.p3 .block { height: 26vh; background: #cd7f32; animation-delay: 0s; }
.pod.p1 .who { animation: pop .5s 2.6s both; } .pod.p2 .who { animation: pop .5s 1.6s both; } .pod.p3 .who { animation: pop .5s .6s both; }
@keyframes rise { from { transform: scaleY(0); transform-origin: bottom } to { transform: scaleY(1); transform-origin: bottom } }

/* panneaux hôte */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); background: #fff; color: var(--texte); z-index: 30; padding: 1rem 1rem 5rem; overflow-y: auto; box-shadow: -4px 0 16px rgba(0,0,0,.4); transform: translateX(105%); transition: transform .2s; }
.drawer.open { transform: none; }
.drawer h3 { margin: .3rem 0 .8rem; display: flex; justify-content: space-between; align-items: center; }
.qitem { display: flex; gap: .5rem; align-items: center; padding: .55rem; border-radius: 6px; border: 2px solid #eee; margin-bottom: .4rem; font-size: .9rem; }
.qitem.cur { border-color: var(--violet); }
.qitem .num { background: #eee; border-radius: 4px; padding: .1rem .4rem; flex: none; }
.qitem.played .num { background: var(--ok); color: #fff; }
.qitem.skipped .num { background: #aaa; color: #fff; }
.qitem .t { flex: 1; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qitem input { width: 3.6rem; padding: .3rem; border: 1px solid #ccc; border-radius: 4px; text-align: center; }
.switch { display: flex; justify-content: space-between; align-items: center; padding: .5rem 0; border-bottom: 1px solid #eee; gap: .6rem; font-weight: 600; }
.switch input[type=checkbox] { width: 1.3rem; height: 1.3rem; }
.badge { background: var(--rouge); color: #fff; border-radius: 10px; padding: 0 .45rem; font-size: .75rem; margin-left: .3rem; }

/* ---------------- ÉDITEUR / LISTE ---------------- */
.wrap { max-width: 900px; margin: 0 auto; padding: 1rem 1rem 6rem; }
.topnav { background: #fff; color: var(--texte); display: flex; align-items: center; justify-content: space-between; padding: .6rem 1rem; box-shadow: 0 1px 4px rgba(0,0,0,.15); position: sticky; top: 0; z-index: 10; gap: .5rem; }
.topnav .logo { font-size: 1.5rem; color: var(--violet); text-align: left; }
.topnav .logo span { color: var(--jaune); }
.qcard { background: #fff; border-radius: 8px; padding: 1rem; margin: .8rem 0; box-shadow: 0 1px 4px rgba(0,0,0,.12); color: var(--texte); }
.qcard .qhead { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }
.qcard textarea { width: 100%; border: 2px solid #ddd; border-radius: 6px; padding: .7rem; font-weight: 700; font-size: 1.05rem; resize: vertical; min-height: 3.2rem; text-align: center; }
.agrid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .6rem; }
@media (max-width: 560px) { .agrid { grid-template-columns: 1fr; } }
.aedit { display: flex; align-items: center; gap: .4rem; border-radius: 6px; padding: .45rem; }
.aedit input[type=text] { flex: 1; border: 0; border-radius: 4px; padding: .55rem; font-weight: 700; min-width: 0; }
.aedit .chk { width: 2rem; height: 2rem; border-radius: 50%; border: 3px solid #fff; background: transparent; color: #fff; font-size: 1rem; flex: none; display: flex; align-items: center; justify-content: center; padding: 0; }
.aedit .chk.on { background: var(--ok); }
select.sel { padding: .45rem; border-radius: 4px; border: 1px solid #ccc; background: #fff; font-weight: 700; }
.qlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .8rem; }
.qtile { background: #fff; color: var(--texte); border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.15); display: flex; flex-direction: column; }
.qtile .cover { background: linear-gradient(135deg, var(--violet), var(--violet-3)); color: #fff; padding: 1.2rem 1rem; min-height: 90px; display: flex; align-items: flex-end; font-size: 1.1rem; }
.qtile .meta { padding: .6rem 1rem; font-size: .85rem; color: #666; font-weight: 600; flex: 1; }
.qtile .acts { display: flex; gap: .4rem; padding: 0 .8rem .8rem; flex-wrap: wrap; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.modal .card { width: 100%; max-width: 460px; max-height: 92dvh; overflow-y: auto; }
.tabs { display: flex; gap: .4rem; margin-bottom: .6rem; }
.tabs button { flex: 1; padding: .6rem; background: #eee; color: var(--texte); font-weight: 800; }
.tabs button.on { background: var(--violet); color: #fff; }
.card .btn.ghost, .drawer .btn.ghost, .qcard .btn.ghost { background: #e4e4e4; color: var(--texte); }

.pinbox { display: flex; flex-direction: column; justify-content: center; }
.topnav .row { flex-wrap: nowrap; }

/* ---------- Thème gendarmerie ---------- */
body.theme-gend { --violet: #0b1f4b; --violet-2: #06122e; --violet-3: #2d4f9e; background: radial-gradient(circle at 50% -20%, #1d3a7a 0%, #0b1f4b 55%, #06122e 100%) fixed; }
body.theme-gend::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: 5px; z-index: 60;
  background: linear-gradient(90deg, #002395 0 33.3%, #fff 33.3% 66.6%, #ed2939 66.6%); }
body.theme-gend .bg-shapes i { background: rgba(255,255,255,.04); }
body.theme-gend .logo span { color: #c9a227; }
body.theme-gend .badge-gend { display: inline-flex; align-items: center; justify-content: center; width: 4.2rem; height: 4.2rem; border-radius: 50%;
  background: radial-gradient(circle, #e9c75a, #b38b1d); color: #0b1f4b; font-size: 2.1rem; box-shadow: 0 0 0 4px #fff, 0 0 0 7px #0b1f4b, 0 6px 18px rgba(0,0,0,.5); margin-bottom: .6rem; }
body:not(.theme-gend) .badge-gend { display: none; }
body.theme-gend .timer { background: #2d4f9e; border: 4px solid #c9a227; }
body.theme-gend .pinbox { border-top: 6px solid #c9a227; }
body.theme-gend .lbrow:first-of-type { background: #c9a227; }
body.theme-gend .pod.p1 .block { background: #c9a227; }
body.theme-gend .grade { display: inline-block; background: #c9a227; color: #0b1f4b; border-radius: 4px; padding: .2rem .6rem; font-size: .95rem; }
body.theme-gend .gyro { position: fixed; top: 12px; left: calc(50% - 7px); width: 14px; height: 14px; border-radius: 50%; z-index: 61; animation: gyro .5s infinite alternate; }
@keyframes gyro { from { background: #2b6cff; box-shadow: 0 0 14px 6px #2b6cff; } to { background: #ff2b2b; box-shadow: 0 0 14px 6px #ff2b2b; } }
body:not(.theme-gend) .gyro { display: none; }
body.light.theme-gend { background: var(--gris); }
