:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1d1d1b;
  --muted: #6b6a66;
  --line: #e2dfd7;
  --accent: #1f4e79;
  --accent-ink: #ffffff;
  --accent-soft: #e4ecf4;
  --ok: #2e7d4f;
  --ok-soft: #e2f1e8;
  --bad: #b33a3a;
  --bad-soft: #f7e3e3;
  --warn: #9a6b00;
  --warn-soft: #fbf0d3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 0.4em; line-height: 1.2; font-weight: 650; }
p { margin: 0 0 0.8em; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.narrow { max-width: 520px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 16px; }
@media (min-width: 900px) { .grid.two { grid-template-columns: 2fr 1fr; } }

button, .btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 10px 16px; border-radius: 10px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
button:hover, .btn:hover { border-color: #c9c5bb; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; }
button.big { font-size: 1.15rem; padding: 16px 20px; width: 100%; justify-content: center; }
button.sm, .btn.sm { padding: 6px 10px; font-size: 0.875rem; font-weight: 500; }

input, textarea, select { font: inherit; width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 0.95rem; }
.check input { width: auto; }

.badge { display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.neutral { background: #eeece6; color: var(--muted); }

.notice { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 0.95rem; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }

.code-big { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 2.2rem; letter-spacing: 0.18em; font-weight: 700; }

/* Choix (participant) */
.choices { display: grid; gap: 10px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 1.05rem; cursor: pointer; text-align: left; width: 100%; font-weight: 500; }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice .letter { flex: 0 0 32px; height: 32px; border-radius: 8px; background: #eeece6; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.choice.selected .letter { background: var(--accent); color: #fff; }

/* Barres de résultats */
.bars { display: grid; gap: 10px; }
.bar { position: relative; }
.bar .label { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; margin-bottom: 4px; }
.bar .track { height: 18px; background: #eeece6; border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 999px; width: 0; transition: width 0.4s ease; }
.bar.correct .fill { background: var(--ok); }
.bar.wrong-reveal .fill { background: #b7b3a8; }

/* Nuage de mots */
.cloud { position: relative; width: 100%; overflow: hidden; --cloud-colors: #1f4e79, #b8521f, #2e7d4f, #7a3e9d, #b0892a, #c2453f, #2a7f8f; }
.cloud span { cursor: default; }

/* Réponses ouvertes */
.answers { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.answers .ans { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }

/* Classement */
.ranks { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.ranks li { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.ranks li:nth-child(1) { border-color: #d4a73b; }

.timer { font-variant-numeric: tabular-nums; font-weight: 700; }

/* Écran projeté */
body.screen { background: #0f1d2b; color: #f4f1ea; }
body.screen .wrap { max-width: 1500px; }
body.screen .card { background: #16283a; border-color: #223a50; box-shadow: none; }
body.screen .bar .track { background: #223a50; }
body.screen .bar .fill { background: #6fb1e8; }
body.screen .bar.correct .fill { background: #5fd08a; }
body.screen .bar.wrong-reveal .fill { background: #4a5f73; }
body.screen .cloud { --cloud-colors: #9cd0ff, #ffb86b, #7fe0a4, #d7a6ff, #ffe27a, #ff8c8c, #7fe6e0, #f4f1ea; }
body.screen .answers .ans { background: #16283a; border-color: #223a50; }
body.screen .ranks li { background: #16283a; border-color: #223a50; }
body.screen .muted { color: #a9b6c3; }
body.screen .badge { background: #223a50; color: #9cd0ff; }
body.screen .notice { background: #1e3246; color: #e8f0f8; }
.screen-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 10px 0 20px; }
.screen-head .join { display: flex; align-items: center; gap: 16px; font-size: 1.1rem; }
.screen-head .join img { width: 84px; height: 84px; border-radius: 8px; background: #fff; padding: 4px; }
.screen-q { font-size: clamp(1.6rem, 3.4vw, 2.8rem); font-weight: 700; margin: 0 0 24px; }
.screen-lobby { text-align: center; padding: 40px 0; }
.screen-lobby img { width: min(50vh, 420px); background: #fff; padding: 12px; border-radius: 16px; }
.screen-lobby .code-big { font-size: clamp(3rem, 8vw, 6rem); margin: 20px 0 8px; }
.ai-panel { border-left: 4px solid #9cd0ff; padding: 14px 18px; background: #1e3246; border-radius: 0 12px 12px 0; font-size: 1.25rem; line-height: 1.5; }
.ai-panel .tag { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: #9cd0ff; font-weight: 700; margin-bottom: 6px; }
.conn { position: fixed; right: 12px; bottom: 12px; font-size: 0.75rem; padding: 4px 8px; border-radius: 999px; background: rgba(0,0,0,0.08); color: var(--muted); }
.conn.off { background: var(--warn-soft); color: var(--warn); }
body.screen .conn { background: rgba(255,255,255,0.08); color: #a9b6c3; }

/* Régie */
.qlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.qitem { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.qitem.current { border-color: var(--accent); background: var(--accent-soft); }
.qitem .qtext { flex: 1; min-width: 0; }
.qitem .qtext .t { font-weight: 600; }
.qitem .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.kpi { display: flex; gap: 16px; flex-wrap: wrap; }
.kpi div { padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.kpi b { display: block; font-size: 1.4rem; }
.opts-editor .opt { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.opts-editor .opt input[type=text] { flex: 1; }
.opts-editor .opt input[type=checkbox] { width: auto; }
dialog { border: none; border-radius: 14px; padding: 0; max-width: 640px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
dialog::backdrop { background: rgba(0,0,0,0.35); }
dialog .inner { padding: 22px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand { font-weight: 700; letter-spacing: 0.02em; }
.brand span { color: var(--accent); }
body.screen .card.results { min-height: 38vh; display: flex; flex-direction: column; justify-content: center; }
body.screen .card.results > .bars, body.screen .card.results > .answers { width: 100%; }

/* Échelle */
.scale-cols { display: flex; gap: 8px; align-items: flex-end; height: 160px; margin-bottom: 6px; }
.scale-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.scale-track { flex: 1; width: 100%; display: flex; align-items: flex-end; background: #eeece6; border-radius: 8px; overflow: hidden; }
.scale-fill { width: 100%; background: var(--accent); border-radius: 8px 8px 0 0; transition: height 0.4s ease; }
.scale-val { font-weight: 700; margin-top: 6px; }
.scale-n { font-size: 0.8rem; }
.scale-mean { margin: 10px 0 0; font-size: 1.1rem; }
body.screen .scale-cols { height: 300px; }
body.screen .scale-track { background: #223a50; }
body.screen .scale-fill { background: #6fb1e8; }
body.screen .scale-val { font-size: 1.6rem; }
body.screen .scale-n { font-size: 1.2rem; }
body.screen .scale .small { font-size: 1.1rem; }
body.screen .scale-mean { font-size: 1.6rem; }

/* Saisie de l'échelle (téléphone) */
.scale-pick { display: flex; gap: 8px; }
.scale-pick button { flex: 1; padding: 18px 0; font-size: 1.3rem; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); justify-content: center; }
.scale-pick button:hover { border-color: var(--accent); }

/* Classement (téléphone) : liste réordonnable */
.rank-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.rank-list li { display: flex; align-items: center; gap: 10px; padding: 12px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 500; }
.rank-list .pos { flex: 0 0 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.rank-list .txt { flex: 1; }
.rank-list .mv { display: flex; flex-direction: column; gap: 2px; }
.rank-list .mv button { padding: 2px 10px; font-size: 0.9rem; line-height: 1.2; }

/* Mur de questions */
.wall { display: grid; gap: 10px; }
.post { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.post.answered { opacity: 0.55; }
.post-text { flex: 1; font-size: 1.05rem; line-height: 1.35; }
.post-actions { display: flex; gap: 4px; }
.vote { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 0.85rem; line-height: 1.1; min-width: 44px; }
.vote span { font-weight: 700; font-size: 1rem; }
.vote.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.vote.static { cursor: default; }
body.screen .post { background: #16283a; border-color: #223a50; }
body.screen .wall-big .post-text { font-size: 1.5rem; }
body.screen .vote { background: #223a50; border-color: #223a50; color: #9cd0ff; font-size: 1rem; min-width: 56px; }
body.screen .vote span { font-size: 1.4rem; }
