/* ───────── Jetons dérivés (les palettes sont dans themes.css) ───────── */
:root, [data-theme] {
  --surface-2: color-mix(in srgb, var(--text) 5%, var(--surface));
  --surface-3: color-mix(in srgb, var(--text) 9%, var(--surface));
  --line-soft: color-mix(in srgb, var(--line) 55%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --accent-text: color-mix(in srgb, var(--accent) 78%, var(--text));
  --accent-hover: color-mix(in srgb, var(--accent) 88%, var(--text));
  --good-soft: color-mix(in srgb, var(--good) 16%, var(--surface));
  --bad-soft: color-mix(in srgb, var(--bad) 16%, var(--surface));
  --warn-soft: color-mix(in srgb, var(--warn) 18%, var(--surface));
  --nav-muted: color-mix(in srgb, var(--nav-text) 62%, var(--nav-bg));
  --nav-hover: color-mix(in srgb, var(--nav-text) 9%, var(--nav-bg));
  --nav-active: color-mix(in srgb, var(--nav-text) 15%, var(--nav-bg));
  --nav-line: color-mix(in srgb, var(--nav-text) 14%, var(--nav-bg));
  --stage-panel: color-mix(in srgb, var(--stage-text) 7%, var(--stage-bg));
  --stage-line: color-mix(in srgb, var(--stage-text) 18%, var(--stage-bg));
  --stage-muted: color-mix(in srgb, var(--stage-text) 62%, var(--stage-bg));
  --shadow: 0 1px 2px color-mix(in srgb, #000 10%, transparent), 0 8px 24px -16px color-mix(in srgb, #000 30%, transparent);
  --tab-h: 62px;
  --top-h: 56px;
  --side-w: 244px;
}
[data-theme="contrast"] { --shadow: none; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); accent-color: var(--accent); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15.5px/1.55 var(--font-body); min-height: 100vh; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 16px; }
.stack.tight { gap: 8px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }

/* ───────── Boutons et champs ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 16px; min-height: 42px;
  font-weight: 600; background: var(--surface); color: var(--text); text-decoration: none;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 86%, #000); }
.btn.block { width: 100%; }
.btn.small { min-height: 34px; padding: 5px 12px; font-size: .88rem; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: .88rem; }
.input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px;
  background: var(--surface); min-height: 42px;
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent); }
textarea.input { resize: vertical; min-height: 120px; }
select.input { appearance: auto; }
.error-box { background: var(--bad-soft); color: color-mix(in srgb, var(--bad) 80%, var(--text)); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); border-radius: var(--radius-sm); padding: 9px 12px; font-weight: 500; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
a.card { text-decoration: none; }
a.card:hover { border-color: var(--accent); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; white-space: nowrap;
  background: var(--surface-3); font-weight: 600; font-size: .78rem; color: var(--text);
}
.chip.amber { background: var(--warn-soft); color: color-mix(in srgb, var(--warn) 70%, var(--text)); }
.chip.good { background: var(--good-soft); color: color-mix(in srgb, var(--good) 75%, var(--text)); }
.chip.bad { background: var(--bad-soft); color: color-mix(in srgb, var(--bad) 75%, var(--text)); }
.chip.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ───────── Écran de connexion ───────── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--nav-bg); }
.auth-box { width: min(420px, 100%); display: grid; gap: 22px; }
.brand { color: var(--nav-text); display: grid; gap: 6px; }
.brand-mark { display: flex; align-items: center; gap: 10px; }
.brand-mark svg { width: 38px; height: 38px; flex: none; color: var(--accent); }
.brand h1 { font-size: 2rem; }
.brand p { color: var(--nav-muted); }
.auth .card { padding: 24px; }
.auth .btn.ghost { color: var(--nav-text); border-color: var(--nav-line); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; }
.tabs button { flex: 1 1 auto; border: 0; background: transparent; border-radius: calc(var(--radius-sm) - 2px); padding: 7px 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs { overflow-x: auto; }

/* ───────── Coque de l'application ───────── */
.shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
.topbar {
  grid-column: 1 / -1; background: var(--nav-bg); color: var(--nav-text); padding: 0 16px; min-height: var(--top-h);
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--nav-line);
}
.wordmark { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); font-size: 1.1rem; white-space: nowrap; }
.wordmark svg { width: 22px; height: 22px; color: var(--accent); flex: none; }
.subject-btn {
  display: flex; align-items: center; gap: 8px; background: transparent; border: 1px solid var(--nav-line); color: var(--nav-text);
  padding: 6px 10px 6px 12px; border-radius: var(--radius-sm); max-width: 62%; min-width: 0;
}
.subject-btn:hover { background: var(--nav-hover); }
.subject-btn .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-btn svg { width: 16px; height: 16px; flex: none; opacity: .7; }
.lvl-badge {
  flex: none; height: 26px; padding: 0 10px; border-radius: 99px; display: grid; place-items: center; font-size: .78rem; white-space: nowrap;
  background: var(--accent); color: var(--on-accent); font-weight: 700;
}
.topbar .spacer { flex: 1; }
.topbar .btn { background: transparent; color: var(--nav-text); border-color: var(--nav-line); }
.topbar .btn:hover { background: var(--nav-hover); }
.admin-btn svg { width: 17px; height: 17px; }
.pip { position: absolute; top: 4px; right: calc(50% - 26px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; }
.page { width: min(980px, 100%); margin: 0 auto; padding: 22px 16px 32px; display: grid; gap: 20px; align-content: start; min-width: 0; }
.page h1 { margin: 0; }

/* Navigation : barre basse sur mobile, menu latéral sur grand écran */
.tabbar, .sidenav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(6, 1fr);
}
.tabbar a {
  display: grid; place-items: center; align-content: center; gap: 3px; text-decoration: none; color: var(--muted);
  font-weight: 600; font-size: .72rem; position: relative;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--accent-text); }
.tabbar a[aria-current="page"]::before { content: ""; position: absolute; top: 0; width: 28px; height: 2px; background: var(--accent); border-radius: 0 0 3px 3px; }
.tabbar a:hover { color: var(--text); }

/* Interface d'administration : menu des panneaux (défilant sur mobile, latéral sur ordinateur) */
.shell.admin { padding-bottom: 0; grid-template-rows: auto auto 1fr; }
.sidenav {
  position: sticky; top: var(--top-h); bottom: auto; height: auto; z-index: 15; display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px;
  border-top: 0; border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.sidenav::-webkit-scrollbar { display: none; }
.sidenav .group { display: none; }
.sidenav a {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--muted);
  font-weight: 600; font-size: .9rem; white-space: nowrap; flex: none;
}
.sidenav a:hover { background: var(--surface-2); color: var(--text); }
.sidenav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.sidenav a svg { width: 18px; height: 18px; flex: none; }
.shell.admin .page { grid-column: 1; }

@media (min-width: 960px) {
  .shell { padding-bottom: 0; grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .shell.admin { grid-template-rows: auto 1fr; }
  .shell > .page { grid-column: 2; grid-row: 2; }
  .tabbar, .sidenav {
    position: sticky; top: var(--top-h); left: auto; right: auto; bottom: auto; grid-column: 1; grid-row: 2;
    height: calc(100vh - var(--top-h)); padding: 16px 12px; border-top: 0; border-right: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overflow-x: hidden; align-self: start;
  }
  .tabbar a {
    display: flex; justify-content: flex-start; gap: 12px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: .95rem;
  }
  .tabbar a svg { width: 20px; height: 20px; }
  .tabbar a[aria-current="page"] { background: var(--accent-soft); }
  .tabbar a[aria-current="page"]::before { display: none; }
  .tabbar a:hover { background: var(--surface-2); }
  .tabbar .pip { position: static; margin-left: auto; }
  .sidenav a { display: flex; padding: 8px 12px; }
  .sidenav .group { display: block; margin: 14px 12px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .sidenav .group:first-child { margin-top: 0; }
  .shell.admin .page { grid-column: 2; }
}

/* ───────── Accueil ───────── */
.hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center;
}
.hero .title { color: var(--accent-text); font-weight: 600; font-size: .9rem; }
.hero h1 { font-size: 1.5rem; }
.xpbar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 12px; }
.xpbar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.hero .xptext { font-size: .84rem; color: var(--muted); margin-top: 8px; }
.modes { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .modes { grid-template-columns: 1fr 1fr; } }
.mode {
  border: 1px solid var(--line); background: var(--surface); text-align: left; border-radius: var(--radius); padding: 20px; color: var(--text);
  display: grid; gap: 6px; min-height: 140px; align-content: end; position: relative; overflow: hidden; text-decoration: none;
  box-shadow: var(--shadow); transition: border-color .15s, transform .12s;
}
.mode:hover { border-color: var(--accent); transform: translateY(-1px); }
.mode h2 { font-size: 1.35rem; }
.mode small { color: var(--muted); font-size: .92rem; }
.mode svg.art { position: absolute; right: 18px; top: 18px; width: 44px; height: 44px; padding: 10px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); }
.mode .chip { justify-self: start; background: var(--accent); color: var(--on-accent); }
.list { display: grid; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); text-decoration: none; width: 100%; text-align: left; color: var(--text);
}
button.item, a.item { cursor: pointer; }
button.item:hover, a.item:hover { border-color: var(--accent); background: var(--surface-2); }
.item.me, .item[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.item .rank { width: 32px; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.item .rank.top1 { color: var(--warn); } .item .rank.top2 { color: color-mix(in srgb, var(--text) 55%, var(--surface)); } .item .rank.top3 { color: color-mix(in srgb, var(--warn) 55%, var(--bad)); }
.item > .grow { min-width: 150px; }
.item > .row.wrap { margin-left: auto; }
.avatar { border-radius: 50%; flex: none; background: var(--surface-3); display: block; }

/* ───────── Choix de chapitre ───────── */
.chapters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.chapter {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 14px 16px; text-align: left; color: var(--text);
  display: grid; gap: 3px; transition: border-color .12s, background .12s;
}
.chapter:hover:not([disabled]) { border-color: var(--accent); }
.chapter[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.chapter[disabled] { opacity: .5; cursor: not-allowed; }
.chapter strong { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.02rem; }

/* ───────── Scène de jeu ───────── */
.stage {
  min-height: 100vh; background: var(--stage-bg); color: var(--stage-text); color-scheme: normal;
  display: grid; grid-template-rows: auto 1fr auto; padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
}
.stage-inner { width: min(760px, 100%); margin: 0 auto; display: grid; gap: 18px; grid-template-rows: auto 1fr auto; }
.stage-top { display: flex; align-items: center; gap: 12px; }
.pips { display: flex; gap: 4px; flex: 1; }
.pips i { height: 5px; flex: 1; border-radius: 99px; background: var(--stage-line); }
.pips i.done { background: var(--stage-muted); } .pips i.ok { background: var(--good); } .pips i.ko { background: var(--bad); }
.pips i.now { background: var(--stage-text); }
.quit { background: transparent; border: 0; color: var(--stage-muted); font-weight: 600; padding: 8px; }
.quit:hover { color: var(--stage-text); }
.timer { position: relative; width: 52px; height: 52px; flex: none; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 4; }
.timer .bg { stroke: var(--stage-line); }
.timer .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke .3s; }
.timer.low .fg { stroke: var(--bad); }
.timer b { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 1rem; font-variant-numeric: tabular-nums; }
.q-wrap { display: grid; align-content: center; gap: 16px; }
.q-meta { color: var(--stage-muted); font-weight: 600; font-size: .9rem; }
.q-text { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); font-size: clamp(1.3rem, 4.4vw, 1.95rem); line-height: 1.3; text-wrap: balance; }
.answers { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .answers { grid-template-columns: 1fr 1fr; } }
.answer {
  border: 1px solid var(--stage-line); border-radius: var(--radius-sm); padding: 13px 14px; min-height: 64px; background: var(--stage-panel);
  color: var(--stage-text); text-align: left; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; font-weight: 500;
  transition: border-color .12s, background .12s, transform .08s;
}
.answer .tag {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--stage-line); color: var(--stage-muted);
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: .85rem;
}
.answer:hover:not([disabled]) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--stage-panel)); }
.answer:hover:not([disabled]) .tag { border-color: var(--accent); color: var(--stage-text); }
.answer:active:not([disabled]) { transform: scale(.995); }
.answer[disabled] { cursor: default; }
.answer.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 20%, var(--stage-bg)); }
.answer.correct .tag { background: var(--good); border-color: var(--good); color: #fff; }
.answer.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 20%, var(--stage-bg)); animation: shake .3s; }
.answer.wrong .tag { background: var(--bad); border-color: var(--bad); color: #fff; }
.answer.dim { opacity: .5; }
.answer .mark { font-size: 1.15rem; font-weight: 700; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.feedback { background: var(--stage-panel); border: 1px solid var(--stage-line); border-radius: var(--radius-sm); padding: 14px 16px; display: grid; gap: 10px; }
.feedback .verdict { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.15rem; }
.feedback .verdict.ok { color: var(--good); } .feedback .verdict.ko { color: var(--bad); }
.xp-pop { color: var(--accent); font-weight: 700; animation: pop .5s cubic-bezier(.2, 1.4, .4, 1); display: inline-block; }
@keyframes pop { from { transform: scale(.6) translateY(6px); opacity: 0; } }
.stage .btn { background: var(--stage-panel); border-color: var(--stage-line); color: var(--stage-text); }
.stage .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.stage .btn.ghost { background: transparent; }

/* ───────── Résultats ───────── */
.result-score { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 3.4rem; line-height: 1; letter-spacing: -.03em; }
.review { display: grid; gap: 10px; }
.review-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 8px; border-left: 4px solid var(--line); }
.review-item.ok { border-left-color: var(--good); } .review-item.ko { border-left-color: var(--bad); }
.review-item ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.review-item li { padding: 6px 10px; border-radius: 6px; background: var(--surface-2); font-size: .93rem; }
.review-item li.right { background: var(--good-soft); font-weight: 600; } .review-item li.mine:not(.right) { background: var(--bad-soft); }

/* ───────── Duels ───────── */
.duel-card { display: grid; gap: 10px; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; text-align: center; }
.vs .score { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 2.2rem; line-height: 1; }
.rounds { display: grid; gap: 8px; }
.round { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.round .n { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; }
.state-play { background: var(--accent-soft); }

/* ───────── Profil, badges ───────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.6rem; font-weight: var(--display-weight); line-height: 1.2; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 12px; text-align: center; display: grid; gap: 4px; }
.badge .ico { font-size: 1.8rem; }
.badge.locked { opacity: .5; filter: grayscale(1); }
.mini-bar { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; } .mini-bar i { display: block; height: 100%; background: var(--accent); }
.catalog { display: grid; gap: 14px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 7px 12px; font-weight: 500; display: grid; gap: 2px; text-align: left; }
.opt:hover:not([disabled]) { border-color: var(--accent); }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.opt[disabled] { opacity: .5; cursor: not-allowed; }
.swatch { width: 34px; height: 34px; padding: 0; border: 2px solid var(--line); border-radius: 50%; background: none; }
.swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.initial { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-grid; place-items: center; font-family: var(--font-display); font-weight: 700; flex: none; }
.vs .initial { width: 52px; height: 52px; font-size: 1.3rem; }

/* ───────── Choix du thème ───────── */
.themes { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.theme-card {
  position: relative; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 8px; text-align: left; display: grid; gap: 8px; color: var(--text);
}
.theme-card:hover { border-color: var(--accent); }
.theme-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-card .name { font-weight: 600; padding: 0 4px; }
.theme-card .desc { color: var(--muted); font-size: .8rem; padding: 0 4px 2px; }
.theme-card .tick { position: absolute; top: 14px; right: 14px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: .8rem; font-weight: 800; }
.mock { border-radius: 6px; overflow: hidden; border: 1px solid color-mix(in srgb, #000 12%, transparent); display: grid; grid-template-columns: 22% 1fr; height: 82px; background: var(--bg); }
.mock .nav { background: var(--nav-bg); display: grid; align-content: start; gap: 5px; padding: 8px 6px; }
.mock .nav i { display: block; height: 5px; border-radius: 3px; background: var(--nav-text); opacity: .5; }
.mock .nav i:first-child { background: var(--accent); opacity: 1; }
.mock .body { padding: 9px; display: grid; gap: 6px; align-content: start; }
.mock .body .card-m { background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 6px; display: grid; gap: 4px; }
.mock .body .card-m i { display: block; height: 4px; border-radius: 2px; background: var(--text); opacity: .7; width: 70%; }
.mock .body .card-m i + i { width: 45%; opacity: .35; }
.mock .body b { display: block; height: 8px; width: 38%; border-radius: 4px; background: var(--accent); }

/* ───────── Feuille modale et notifications ───────── */
.sheet-back { position: fixed; inset: 0; background: color-mix(in srgb, #000 55%, transparent); z-index: 50; display: grid; align-items: end; }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 0 0; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); width: min(560px, 100%); margin: 0 auto; display: grid; gap: 14px; max-height: 88vh; overflow: auto; }
@media (min-width: 880px) { .sheet-back { align-items: center; } .sheet { border-radius: var(--radius); } }
#toasts { position: fixed; z-index: 80; left: 0; right: 0; top: 12px; display: grid; gap: 8px; justify-items: center; pointer-events: none; padding: 0 12px; }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 16px; box-shadow: 0 14px 30px -10px color-mix(in srgb, #000 55%, transparent); max-width: 520px; font-weight: 500; pointer-events: auto; animation: drop .3s cubic-bezier(.2, 1.1, .4, 1); }
.toast.good { border-left: 4px solid var(--good); } .toast.bad { border-left: 4px solid var(--bad); } .toast.badge { border-left: 4px solid var(--accent); }
@keyframes drop { from { transform: translateY(-24px); opacity: 0; } }
.empty { text-align: center; padding: 30px 16px; display: grid; gap: 10px; justify-items: center; }
.empty svg { width: 56px; height: 56px; color: var(--muted); }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .9; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ───────── Divers ───────── */
a.muted { text-decoration: none; font-weight: 500; }
a.btn { text-decoration: none; }
#live { position: fixed; inset: 0; z-index: 100; overflow-y: auto; }
#live .btn.ghost { color: var(--stage-text); border-color: var(--stage-line); }
.vs .score { line-height: 1; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 560px) {
  .wordmark .wm-text, .topbar .btn .btn-label { display: none; }
  .topbar { padding: 0 12px; gap: 8px; }
  .subject-btn { flex: 0 1 auto; max-width: 70%; }
  .page { padding: 18px 14px 28px; }
  h1 { font-size: 1.5rem; }
  .hero { grid-template-columns: 1fr; justify-items: start; }
}
input[type="file"] { max-width: 100%; color: var(--muted); }
input[type="file"]::file-selector-button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); padding: 6px 12px; margin-right: 10px; font: inherit; font-weight: 600; cursor: pointer; }

/* ───────── Graphiques et statistiques ───────── */
.chart { margin: 0; }
.chart.scroll-x { overflow-x: auto; }
svg.ch { width: 100%; height: auto; display: block; overflow: visible; }
svg.ch.heat { min-width: 640px; }
.ch-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; opacity: .8; }
.ch-axis { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.ch-line { stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ch-area { opacity: .14; stroke: none; }
.ch-dot { stroke: var(--surface); stroke-width: 1.5; }
.ch-bar { transition: opacity .15s; } .ch-bar:hover { opacity: .8; }
.c-accent { stroke: var(--accent); fill: var(--accent); } .c-good { stroke: var(--good); fill: var(--good); }
.c-bad { stroke: var(--bad); fill: var(--bad); } .c-warn { stroke: var(--warn); fill: var(--warn); }
.c-muted { stroke: color-mix(in srgb, var(--text) 35%, var(--surface)); fill: color-mix(in srgb, var(--text) 35%, var(--surface)); }
.ch-line.c-accent, .ch-line.c-good, .ch-line.c-bad, .ch-line.c-warn, .ch-line.c-muted, .ch-stroke { fill: none; }
.ch-area.c-accent, .ch-area.c-good, .ch-area.c-warn { stroke: none; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .85rem; color: var(--muted); list-style: none; margin: 8px 0 0; padding: 0; align-items: center; }
.ch-legend.col { flex-direction: column; align-items: flex-start; gap: 6px; margin: 0; color: var(--text); }
.ch-legend span, .ch-legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; stroke: none; }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 0; }
.donut-bg { stroke: var(--surface-2); }
.donut-c { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 26px; fill: var(--text); }
.heat-c { stroke: none; } .heat-c.l0 { fill: var(--surface-2); } .heat-c.l1 { fill: color-mix(in srgb, var(--accent) 28%, var(--surface-2)); }
.heat-c.l2 { fill: color-mix(in srgb, var(--accent) 52%, var(--surface-2)); } .heat-c.l3 { fill: color-mix(in srgb, var(--accent) 76%, var(--surface-2)); } .heat-c.l4 { fill: var(--accent); }
i.sw.heat-c { stroke: none; }
.hbars { display: grid; gap: 12px; }
.hb { display: grid; gap: 4px; } .hb-top { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.hb-track i { display: block; height: 100%; background: var(--accent); border-radius: 99px; } .hb-track i.good { background: var(--good); } .hb-track i.warn { background: var(--warn); } .hb-track i.bad { background: var(--bad); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 2px; align-content: start; }
.kpi b { font-family: var(--font-display); font-size: 1.75rem; font-weight: var(--display-weight); line-height: 1.15; letter-spacing: var(--display-tracking); font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .88rem; }
.kpi.accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); } .kpi.accent b { color: var(--accent-text); }
.kpi.good b { color: var(--good); } .kpi.bad b { color: var(--bad); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: .88rem; padding: 6px 12px; border-radius: calc(var(--radius-sm) - 2px); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button:hover { color: var(--text); }
.cal { display: grid; gap: 10px; max-width: 340px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal-h { text-align: center; font-size: .78rem; color: var(--muted); font-weight: 600; }
.cal-c { aspect-ratio: 1; min-width: 0; width: 100%; display: grid; place-items: center; font-size: .85rem; border-radius: 50%; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-c.empty { visibility: hidden; } .cal-c.future { opacity: .4; }
.cal-c.on { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.cal-c.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.week-strip { display: flex; gap: 8px; } .week-strip span { flex: 1; text-align: center; display: grid; gap: 4px; font-size: .78rem; color: var(--muted); }
.week-strip i { width: 100%; aspect-ratio: 1; max-width: 34px; margin: 0 auto; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-style: normal; font-weight: 700; color: var(--on-accent); }
.week-strip i.on { background: var(--accent); }
.form-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.form-chips b { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; color: #fff; }
.form-chips b.W { background: var(--good); } .form-chips b.D { background: var(--warn); } .form-chips b.L { background: var(--bad); }
.flame { color: var(--warn); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table.data { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data th { background: var(--surface-2); font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; position: sticky; top: 0; }
table.data th[aria-sort] { color: var(--text); } table.data tr.click { cursor: pointer; } table.data tr.click:hover td { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; }

/* ───────── Podium ───────── */
.podium { display: grid; grid-template-columns: 1fr 1.12fr 1fr; gap: 10px; align-items: end; padding-top: 6px; }
.pod { display: grid; justify-items: center; gap: 6px; text-align: center; min-width: 0; background: none; border: 0; font: inherit; color: inherit; cursor: pointer; padding: 0; }
.pod .name { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .val { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.pod .step { width: 100%; border-radius: var(--radius-sm) var(--radius-sm) 0 0; display: grid; place-items: start center; padding-top: 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; border: 1px solid var(--line); border-bottom: 0; background: var(--surface-2); color: var(--text); }
.pod.p1 .step { height: 108px; background: color-mix(in srgb, var(--warn) 24%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.pod.p2 .step { height: 78px; background: color-mix(in srgb, var(--text) 10%, var(--surface)); }
.pod.p3 .step { height: 58px; background: color-mix(in srgb, var(--bad) 12%, color-mix(in srgb, var(--warn) 18%, var(--surface))); }
.pod.me .name { color: var(--accent-text); }
.pod .crown { color: var(--warn); width: 24px; height: 24px; }
.pod .tt { font-size: .78rem; font-weight: 700; }
.rank-controls { display: grid; gap: 10px; }

/* ───────── Messagerie ───────── */
.chat-layout { display: grid; gap: 14px; }
.chat { display: grid; grid-template-rows: auto 1fr auto; height: min(70vh, 640px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chat-body { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.bubble { max-width: 82%; padding: 8px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.4; align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble.mine { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-color: transparent; border-bottom-left-radius: 16px; border-bottom-right-radius: 5px; }
.bubble time { display: block; font-size: .7rem; opacity: .7; margin-top: 2px; }
.day-sep { align-self: center; font-size: .75rem; color: var(--muted); margin: 8px 0 2px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-form textarea { flex: 1; resize: none; max-height: 110px; }
.unread { background: var(--accent); color: var(--on-accent); border-radius: 99px; min-width: 20px; height: 20px; padding: 0 6px; font-size: .75rem; font-weight: 700; display: inline-grid; place-items: center; }
.tabbar a .pip.social { position: absolute; top: 4px; right: calc(50% - 22px); }
svg .ch-dot { stroke: var(--surface); stroke-width: 1.5; }
.sw.c-accent { background: var(--accent); } .sw.c-good { background: var(--good); } .sw.c-bad { background: var(--bad); } .sw.c-warn { background: var(--warn); } .sw.c-muted { background: color-mix(in srgb, var(--text) 35%, var(--surface)); }
h2 svg { width: 20px; height: 20px; vertical-align: -3px; margin-right: 4px; }
.week-strip i svg { width: 16px; height: 16px; }
.pod .crown svg { width: 24px; height: 24px; }
.item .unread, .chat-head .grow { min-width: 0; }
.chat-form { align-items: flex-end; }
.chat-form textarea { height: 44px; min-height: 44px; }
.chat-form .btn { height: 44px; }

/* Couleur d'un chapitre : liseré à gauche (--chap), choisi par l'administration */
.chapter, .answer { box-shadow: inset 5px 0 0 var(--chap, transparent); }
.chap-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--chap, var(--line)); margin-right: 6px; vertical-align: -1px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 18%, transparent); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; background: var(--c); cursor: pointer; padding: 0; box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 20%, transparent); }
.swatches button[aria-pressed="true"] { border-color: var(--surface); box-shadow: 0 0 0 2px var(--text); }
.swatches button.none { background: var(--surface-2); position: relative; } .swatches button.none::after { content: ""; position: absolute; inset: 11px 3px; height: 2px; background: var(--muted); transform: rotate(-45deg); }
.swatches input[type=color] { width: 34px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }

/* ───────── Tickets ───────── */
.tickets { --tk: var(--accent); display: inline-flex; align-items: center; gap: 4px; position: relative; flex-wrap: wrap; }
.tickets.solo { --tk: #3b82f6; } .tickets.duel { --tk: #ef4444; } .tickets.live { --tk: #10b981; }
.tk { display: inline-grid; place-items: center; width: 30px; height: 30px; color: var(--tk); transition: transform .2s, opacity .3s; }
.tickets.big .tk { width: 40px; height: 40px; }
.tk svg { width: 100%; height: 100%; overflow: visible; }
.tk .body { fill: color-mix(in srgb, var(--tk) 20%, var(--surface)); stroke: var(--tk); stroke-width: 1.4; }
.tk.used { color: var(--muted); opacity: .55; }
.tk.used .body { fill: none; stroke-dasharray: 2.4 2; stroke: var(--line); }
.tk.used svg path:not(.body) { opacity: .35; }
.tk-n { font-family: var(--font-display); font-size: 1.15rem; margin-left: 2px; color: var(--text); }
.tk-of { color: var(--muted); font-size: .86rem; }
.tickets.empty .tk.used { animation: tk-shake .5s .1s; }
.tk.burn { animation: tk-burn .7s forwards; }
.tk.pulse { animation: tk-pulse .5s; }
.tk-minus { position: absolute; right: -6px; top: -4px; font-weight: 800; color: var(--tk); animation: tk-float .75s ease-out forwards; pointer-events: none; text-shadow: 0 1px 0 var(--surface); }
@keyframes tk-burn { 0% { transform: scale(1); } 25% { transform: scale(1.25) rotate(-8deg); } 100% { transform: translateY(-14px) rotate(14deg) scale(.7); opacity: 0; } }
@keyframes tk-pulse { 50% { transform: scale(1.3); } }
@keyframes tk-float { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-26px); opacity: 0; } }
@keyframes tk-shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.mode .tickets { margin-top: 4px; }
.tickets-bar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { .tk.burn, .tk.pulse, .tk-minus, .tickets.empty .tk.used { animation: none; } }

/* ───────── Scène de jeu : sobre et statique (aucune animation au choix de la réponse) ───────── */
.stage-inner:has(> .hud, > .versus) { grid-template-rows: auto auto 1fr auto; }
.stage-top { gap: 10px; }
.quit { width: 36px; height: 36px; border-radius: var(--radius-sm); display: grid; place-items: center; padding: 0; background: transparent; border: 1px solid var(--stage-line); font-size: .95rem; }
.pips i { height: 4px; }
.pips i.now { background: var(--stage-text); }
.timer { width: 56px; height: 56px; }
.timer .fg, .timer .bg { stroke-width: 4; }
.timer b { font-size: 1.05rem; }

.pav { border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 0 0 2px var(--stage-line); background: var(--stage-panel); line-height: 0; }
.pav svg { display: block; }
.hud, .versus { display: grid; align-items: center; gap: 12px; }
.hud { grid-template-columns: 1fr auto; }
.hud-me { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pinfo { display: grid; gap: 3px; min-width: 0; }
.pinfo strong { font-family: var(--font-display); font-weight: var(--display-weight); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-xp { width: 96px; height: 4px; border-radius: 99px; background: var(--stage-line); overflow: hidden; }
.mini-xp i { display: block; height: 100%; background: var(--stage-text); border-radius: inherit; }

.versus { grid-template-columns: 1fr auto 1fr; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--stage-panel); border: 1px solid var(--stage-line); }
.pcard { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pcard.right { flex-direction: row-reverse; text-align: right; }
.plvl { display: inline-block; justify-self: start; font-size: .78rem; font-weight: 600; color: var(--stage-muted); }
.pcard.right .plvl { justify-self: end; }
.pscore { font-family: var(--font-display); font-size: 1.7rem; line-height: 1; margin: 0 4px; font-variant-numeric: tabular-nums; }
.vs-badge { font-weight: 600; color: var(--stage-muted); font-size: .9rem; }
@media (max-width: 480px) { .pcard .pav svg { width: 44px; height: 44px; } .pinfo strong { max-width: 78px; } }

.q-card { padding: 18px 18px 20px; border-radius: var(--radius-sm); background: var(--stage-panel); border: 1px solid var(--stage-line); display: grid; gap: 12px; }
.q-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.q-num { font-family: var(--font-display); font-size: 1.05rem; color: var(--stage-text); } .q-num small { font-size: .85rem; color: var(--stage-muted); }
.q-label { font-size: .8rem; font-weight: 600; color: var(--stage-muted); }
.time-bar { height: 3px; border-radius: 99px; background: var(--stage-line); overflow: hidden; }
.time-bar i { display: block; height: 100%; background: var(--stage-text); }

.answers { gap: 10px; }
.answer { min-height: 64px; font-size: 1rem; animation: none; }
.answer .tag { width: 30px; height: 30px; border-radius: 6px; background: transparent; border: 1px solid var(--stage-line); color: var(--stage-muted); box-shadow: none; font-size: .85rem; }
.answer:hover:not([disabled]) { transform: none; box-shadow: none; }
.answer.picked:not(.correct):not(.wrong) { border-color: var(--stage-text); }
.answer .mark { width: auto; height: auto; background: none; font-size: 1.05rem; }
.answer.correct { animation: none; box-shadow: none; }
.answer.correct .mark { color: var(--good); } .answer.wrong .mark { color: var(--bad); }
.answer.wrong { animation: none; }

.feedback { animation: none; border-radius: var(--radius-sm); }
.feedback.ok { border-left: 3px solid var(--good); } .feedback.ko { border-left: 3px solid var(--bad); }
.feedback .verdict { font-size: 1.1rem; }
.fb-right { display: flex; align-items: center; gap: 10px; }
.expl { color: var(--stage-muted); font-size: .94rem; }
.xp-pop { animation: none; font-size: 1rem; }

/* Historique : ligne cliquable + croix de suppression */
.item.hist { display: flex; align-items: center; gap: 10px; }
.hist-link, .item-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.hist-link { flex-direction: column; align-items: flex-start; gap: 0; }
.btn.x { min-height: 34px; padding: 4px 10px; color: var(--muted); }
.btn.x:hover { color: var(--bad); }

/* ───────── Symboles, indices, exposants et formules ─────────
   Les polices du thème ne couvrent pas tous les symboles (₂ ⁻¹ ⇌ → ≥ √ π σ ν ‡…) : on ajoute des polices
   mathématiques en secours, caractère par caractère, pour que rien ne s'affiche en « carré vide » ou décalé. */
:root { --font-math: "Noto Sans Math", "Noto Sans Symbols 2", "STIX Two Math", "Cambria Math", "Segoe UI Symbol", "Apple Symbols", "DejaVu Sans"; }
body, .answer, .answer .txt { font-family: var(--font-body), var(--font-math); }
h1, h2, h3, .q-text { font-family: var(--font-display), var(--font-math); }
.q-text, .answer .txt, .expl, .review-item { white-space: pre-line; overflow-wrap: anywhere; }
.q-text .katex, .answer .katex { letter-spacing: normal; }
.math:not(.math-ok) { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; opacity: .85; }
.math-block { display: block; text-align: center; margin: .35em 0; overflow-x: auto; overflow-y: hidden; }
.math-block .katex-display { margin: 0; }
.katex { font-size: 1.06em; text-indent: 0; }
.rich-preview { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.rich-preview ul { margin: .4em 0 0; padding-left: 1.2em; }


/* ───── Éditeur d'avatar ───── */
.av-editor { gap: 12px; }
.av-top { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.av-stage { width: 168px; height: 168px; border-radius: 50%; transition: transform .18s ease-out; will-change: transform; box-shadow: 0 14px 30px rgba(0,0,0,.35); }
.av-stage .avatar { display: block; background: none; }
.av-stage svg g { transition: transform .18s ease-out; }
.av-actions { display: grid; gap: 8px; }
.av-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.av-tab { flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: .88rem; cursor: pointer; }
.av-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.av-panel { display: grid; gap: 16px; }
.av-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.av-tile { position: relative; display: grid; justify-items: center; gap: 4px; padding: 6px 4px 7px; border: 2px solid var(--line); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); cursor: pointer; font-size: .74rem; line-height: 1.15; text-align: center; }
.av-tile:hover:not([disabled]) { border-color: var(--accent); }
.av-tile[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.av-tile[disabled] { opacity: .5; cursor: not-allowed; }
.av-tile .avatar { border-radius: 10px; }
.av-lock { font-style: normal; font-size: .66rem; color: var(--muted); }
.av-save { position: sticky; bottom: 0; }
@media (prefers-reduced-motion: reduce) { .av-stage, .av-stage svg g { transition: none; } }


/* ───── Duel en direct : avatar de l'adversaire sur le choix qu'il a fait ───── */
.answer { position: relative; }
.answer.has-opp { padding-right: 44px; }
.opp-pin { position: absolute; top: -11px; right: 10px; width: 34px; height: 34px; border-radius: 50%; background: var(--stage-panel, #16171a); border: 2px solid var(--stage-text, #fff); box-shadow: 0 4px 10px rgba(0,0,0,.45); display: grid; place-items: center; line-height: 0; overflow: hidden; animation: oppPop .38s cubic-bezier(.2,1.5,.4,1) both; z-index: 2; }
.opp-pin .avatar { display: block; background: none; }
.answer.dim.has-opp { opacity: 1; }
.answer.dim.has-opp > :not(.opp-pin) { opacity: .5; }
@keyframes oppPop { from { transform: translateY(8px) scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .opp-pin { animation: none; } }
