/* ============================================================
   Quelmoi — feuille de style principale
   ============================================================ */

:root {
  --bg: #FBFAF8;
  --bg-alt: #F3F1ED;
  --surface: #FFFFFF;
  --surface-2: #F7F6F3;
  --text: #15131A;
  --text-muted: #6B6678;
  --border: #E7E4DE;
  --accent: #5B4BFF;
  --accent-soft: #EEEBFF;
  --accent-ink: #3A2DD6;
  --hot: #FF6B5B;
  --hot-soft: #FFEDEA;
  --good: #16A66A;
  --warn: #E3A008;
  /* Variantes « encre » : les couleurs d'état ci-dessus sont calibrées pour
     des aplats et du gros texte. En dessous de 18 px elles tombent sous le
     rapport de contraste 4,5:1 exigé par WCAG AA, d'où ces versions assombries
     réservées au petit texte. */
  --good-ink: #0F7A4D;
  --warn-ink: #8A6100;
  --hot-ink: #C62D1F;
  --on-good: #FFFFFF;
  --on-accent: #FFFFFF;
  /* Pastille « validé » : un aplat plein sur lequel le texte passe AA à
     n'importe quelle taille, en clair comme en sombre. */
  --ok-bg: #0F7A4D;
  --ok-ink: #FFFFFF;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 26px;
  --shadow: 0 1px 2px rgba(20,18,30,.05), 0 8px 24px -12px rgba(20,18,30,.12);
  --shadow-lg: 0 2px 4px rgba(20,18,30,.06), 0 24px 56px -20px rgba(20,18,30,.22);
  --font-head: "Outfit", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --maxw: 1180px;
}

html[data-theme="dark"] {
  --bg: #0D0C11;
  --bg-alt: #141219;
  --surface: #17151D;
  --surface-2: #1E1C26;
  --text: #F4F2F8;
  --text-muted: #9D97AC;
  --border: #2A2733;
  --accent: #8A7CFF;
  --accent-soft: #231F3D;
  --accent-ink: #B5ABFF;
  --hot: #FF8273;
  --hot-soft: #34211E;
  --good: #2BD48A;
  --warn: #F0B429;
  --good-ink: #2BD48A;
  --warn-ink: #F0B429;
  --hot-ink: #FF8273;
  /* Sur fond sombre, le vert et le violet sont clairs : c'est du texte foncé
     qu'il faut poser dessus, pas du blanc (1,9:1 avec le blanc). */
  --on-good: #06130D;
  --on-accent: #0E0A26;
  --ok-bg: #2BD48A;
  --ok-ink: #06130D;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.4), 0 24px 56px -20px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.9rem, 1.2rem + 2.6vw, 3.2rem); }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.9rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 14px; height: 64px; }
.logo { font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; letter-spacing: -.03em; display: flex; align-items: center; gap: 8px; flex: none; }
.logo-mark {
  width: 28px; height: 28px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--hot));
  display: grid; place-items: center; color: #fff; font-size: .85rem; font-weight: 700;
}
.header-nav { display: flex; gap: 4px; margin-inline-start: 8px; }
.header-nav a { padding: 8px 12px; border-radius: 999px; font-size: .92rem; font-weight: 500; color: var(--text-muted); }
.header-nav a:hover { background: var(--surface-2); color: var(--text); }
.header-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }

.search-box { position: relative; flex: 1; max-width: 300px; }
.search-box input {
  width: 100%; height: 38px; padding: 0 14px 0 36px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: .9rem;
}
[dir="rtl"] .search-box input { padding: 0 36px 0 14px; }
.search-box input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-box::before { content: "🔍"; position: absolute; inset-inline-start: 12px; top: 8px; font-size: .85rem; opacity: .6; }
.search-results {
  position: absolute; top: 46px; inset-inline-start: 0; width: min(420px, 90vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; display: none; max-height: 60vh; overflow: auto;
}
.search-results.open { display: block; }
.search-results a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: var(--radius-sm); font-size: .92rem; }
.search-results a:hover, .search-results a.active { background: var(--surface-2); }
.search-results .empty { padding: 14px; color: var(--text-muted); font-size: .9rem; }

.icon-btn {
  height: 38px; min-width: 38px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); cursor: pointer;
  font: inherit; font-size: .85rem; font-weight: 500;
}
.icon-btn:hover { background: var(--surface-2); }

.lang-wrap { position: relative; }
.lang-menu {
  position: absolute; top: 46px; inset-inline-end: 0; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 60;
}
.lang-menu.open { display: block; }
.lang-menu a { display: block; padding: 8px 12px; border-radius: var(--radius-sm); font-size: .9rem; }
.lang-menu a:hover { background: var(--surface-2); }
.lang-menu a[aria-current="true"] { color: var(--accent); font-weight: 600; }

.burger { display: none; }

/* ---------- Hero ---------- */
.hero { padding: 54px 0 32px; text-align: center; }
.hero h1 { max-width: 16ch; margin: 0 auto .4em; }
.hero .sub { color: var(--text-muted); font-size: 1.08rem; max-width: 56ch; margin: 0 auto 26px; }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 22px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .98rem; cursor: pointer; transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-lg { height: 54px; padding: 0 30px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- Sections & grids ---------- */
.section { padding: 26px 0; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.section-head h2 { margin: 0; }
.section-head .more { margin-inline-start: auto; font-size: .9rem; color: var(--accent); font-weight: 600; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.card .emoji { font-size: 1.7rem; line-height: 1; }
.card .title { font-family: var(--font-head); font-weight: 600; font-size: 1.02rem; line-height: 1.3; letter-spacing: -.01em; }
.card .meta { margin-top: auto; display: flex; gap: 8px; align-items: center; font-size: .78rem; color: var(--text-muted); flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px;
  border-radius: 999px; background: var(--surface-2); font-size: .74rem; font-weight: 500; color: var(--text-muted);
}
.chip-hot { background: var(--hot-soft); color: var(--hot-ink); }
.chip-new { background: var(--accent-soft); color: var(--accent-ink); }

.cat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.cat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .95rem; }
.cat-card:hover { border-color: var(--accent); }
.cat-card span.n { margin-inline-start: auto; font-weight: 500; font-size: .8rem; color: var(--text-muted); }

/* ---------- Test page ---------- */
.test-head { padding: 34px 0 10px; }
.test-head .emoji-xl { font-size: 3rem; line-height: 1; margin-bottom: 10px; }
.test-head .lede { color: var(--text-muted); font-size: 1.05rem; max-width: 65ch; }
.breadcrumb { font-size: .85rem; color: var(--text-muted); margin-bottom: 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.breadcrumb a:hover { color: var(--accent); }

.stage {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: clamp(18px, 3vw, 34px); box-shadow: var(--shadow); margin: 18px 0 28px;
}

.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 20px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--hot)); width: 0; transition: width .3s ease; }
.q-counter { font-size: .84rem; color: var(--text-muted); margin-bottom: 8px; font-weight: 500; }
.q-text { font-family: var(--font-head); font-size: clamp(1.2rem, 1rem + 1vw, 1.6rem); font-weight: 600; margin-bottom: 20px; }

.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-size: 1rem; cursor: pointer;
  transition: border-color .12s ease, background .12s ease, transform .1s ease;
}
.option:hover { border-color: var(--accent); background: var(--accent-soft); }
.option[aria-pressed="true"], .option.selected { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.option.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.option.wrong { border-color: var(--hot); background: var(--hot-soft); }
.option .key {
  flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2);
  display: grid; place-items: center; font-size: .78rem; font-weight: 600; color: var(--text-muted);
}
.option[aria-pressed="true"] .key, .option.selected .key { background: var(--accent); color: #fff; }

.scale { display: flex; gap: 6px; justify-content: space-between; }
.scale button { flex: 1; aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); cursor: pointer; max-width: 56px; }
.scale button:hover, .scale button.selected { border-color: var(--accent); background: var(--accent-soft); }
.scale-labels { display: flex; justify-content: space-between; font-size: .8rem; color: var(--text-muted); margin-top: 6px; }

.nav-row { display: flex; gap: 10px; margin-top: 22px; align-items: center; }
.nav-row .spacer { flex: 1; }

/* checklist */
.checklist { display: grid; gap: 2px; }
.check-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 13px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; }
.check-item:hover { background: var(--surface-2); }
.check-item input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.check-item.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

/* ---------- Result ---------- */
.result { text-align: center; }
.result .verdict-emoji { font-size: 4rem; line-height: 1; }
.result .verdict-title { font-family: var(--font-head); font-size: clamp(1.6rem, 1.2rem + 2vw, 2.6rem); font-weight: 700; margin: 6px 0 4px; }
.result .verdict-sub { color: var(--text-muted); max-width: 60ch; margin: 0 auto 18px; }
.score-ring { width: 160px; height: 160px; margin: 6px auto 14px; position: relative; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-size: 2.1rem; font-weight: 700; }
.score-ring .val small { display: block; font-size: .72rem; font-weight: 500; color: var(--text-muted); letter-spacing: .04em; text-transform: uppercase; }

.percentile { background: var(--surface-2); border-radius: var(--radius); padding: 14px 18px; margin: 16px auto; max-width: 540px; font-size: .95rem; }
.percentile strong { color: var(--accent); }
.percentile .bar { height: 8px; border-radius: 999px; background: var(--border); margin-top: 10px; position: relative; overflow: hidden; }
.percentile .bar > i { position: absolute; inset-block: 0; inset-inline-start: 0; background: linear-gradient(90deg, var(--accent), var(--hot)); border-radius: 999px; }

.dims { display: grid; gap: 12px; max-width: 560px; margin: 20px auto; text-align: start; }
.dim-row .dim-label { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: 5px; font-weight: 500; }
.dim-row .bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.dim-row .bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.share-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.share-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; font-size: 1.05rem; }
.share-btn:hover { background: var(--surface-2); transform: translateY(-2px); }

/* ---------- Jeux / tests mesurés ---------- */
.arena {
  position: relative; width: 100%; aspect-ratio: 16/10; min-height: 280px;
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: var(--surface-2); overflow: hidden; user-select: none; touch-action: none;
  display: grid; place-items: center; text-align: center; cursor: pointer;
}
.arena canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.arena .overlay { position: relative; z-index: 2; padding: 20px; }
.arena .big { font-family: var(--font-head); font-size: clamp(1.6rem, 1.2rem + 2.5vw, 3rem); font-weight: 700; }
.arena.state-wait { background: var(--warn); color: #1b1200; }
.arena.state-go { background: var(--ok-bg); color: var(--ok-ink); }
.arena.state-fail { background: var(--hot); color: #fff; }

.hud { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.hud-item { text-align: center; min-width: 76px; }
.hud-item .v { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.hud-item .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }

.typing-text { font-size: 1.15rem; line-height: 1.9; font-family: var(--font-body); background: var(--surface-2); padding: 18px; border-radius: var(--radius); margin-bottom: 14px; }
.typing-text span.ok { color: var(--good-ink); }
.typing-text span.ko { color: var(--hot-ink); background: var(--hot-soft); border-radius: 3px; }
.typing-text span.cur { border-bottom: 2px solid var(--accent); }
.typing-input { width: 100%; padding: 14px; font: inherit; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); }

/* ---------- Contenus texte ---------- */
.prose { max-width: 68ch; }
.prose h2 { margin-top: 1.6em; }
.prose ul, .prose ol { padding-inline-start: 1.3em; }
.prose li { margin-bottom: .4em; }
.note { background: var(--surface-2); border-inline-start: 3px solid var(--accent); padding: 12px 16px; border-radius: var(--radius-sm); font-size: .92rem; color: var(--text-muted); }

/* ---------- Pub ---------- */
/* La hauteur est réservée pour qu'une annonce qui arrive après coup ne
   pousse pas le contenu vers le bas (c'est le CLS des Core Web Vitals). */
.ad-slot { margin: 24px auto; text-align: center; min-height: 100px; display: grid; place-items: center; contain: layout; }
.ad-slot:empty::after { content: ""; }
/* Un emplacement vide ne laisse pas de trou quand la publicité est coupée. */
.ad-slot:not(:has(ins)) { min-height: 0; margin: 0; }
/* Pendant une partie, rien ne vient disputer l'attention à l'aire de jeu. */
.stage ~ .ad-slot { margin-top: 34px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 36px 0 28px; background: var(--bg-alt); }
.footer-grid { display: grid; gap: 26px; grid-template-columns: 2fr 1fr 1fr; }
.footer-grid h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: .8em; }
.footer-grid a { display: block; font-size: .9rem; color: var(--text-muted); padding: 3px 0; }
.footer-grid a:hover { color: var(--accent); }
.footer-bottom { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border); font-size: .82rem; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.footer-langs { display: flex; flex-wrap: wrap; gap: 6px; }
.footer-langs a { padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: .8rem; }

/* ---------- Cookie ---------- */
.cookie-bar {
  position: fixed; inset-inline: 12px; bottom: 12px; z-index: 80; display: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 14px 16px; gap: 12px; align-items: center; flex-wrap: wrap;
  max-width: 640px; margin-inline: auto; font-size: .88rem;
}
.cookie-bar.show { display: flex; }
.cookie-bar .btn { height: 36px; padding: 0 16px; font-size: .88rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; inset-inline-start: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: all .24s ease; z-index: 90;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .header-nav { display: none; }
  .burger { display: inline-flex; }
  .search-box { max-width: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .card { padding: 13px; }
  .card .title { font-size: .94rem; }
  .hero { padding: 34px 0 20px; }
}
@media (max-width: 520px) {
  .footer-grid { grid-template-columns: 1fr; }
  .header-inner { height: 58px; gap: 8px; }
  .logo span.word { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto; }
}

.mobile-nav { display: none; }
.mobile-nav.open { display: block; padding: 10px 0 16px; border-top: 1px solid var(--border); }
.mobile-nav a { display: block; padding: 10px 4px; font-weight: 500; }

/* ============================================================
   Ajouts issus du benchmark UX
   ============================================================ */

.skip { position: absolute; inset-inline-start: -9999px; }
.skip:focus { inset-inline-start: 12px; top: 10px; z-index: 100; background: var(--surface); padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); }

/* ---------- Menu principal (reco 4) ---------- */
.header-nav { display: flex; gap: 2px; margin-inline-start: 10px; }
.nav-item { position: relative; }
.nav-item > a, .header-nav a.plain {
  display: block; padding: 8px 12px; border-radius: 999px;
  font-size: .92rem; font-weight: 500; color: var(--text-muted); white-space: nowrap;
}
.nav-item > a:hover, .header-nav a.plain:hover, .nav-item:focus-within > a { background: var(--surface-2); color: var(--text); }
.nav-pop {
  position: absolute; top: calc(100% + 6px); inset-inline-start: 0; min-width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
  opacity: 0; visibility: hidden; transform: translateY(-4px); transition: all .14s ease;
}
.nav-item:hover .nav-pop, .nav-item:focus-within .nav-pop { opacity: 1; visibility: visible; transform: none; }
.nav-pop a { display: flex; justify-content: space-between; gap: 14px; padding: 8px 12px; border-radius: var(--radius-sm); font-size: .9rem; color: var(--text); }
.nav-pop a:hover { background: var(--surface-2); }
.nav-pop a span { color: var(--text-muted); font-size: .8rem; }

.mobile-nav { display: none; border-top: 1px solid var(--border); background: var(--bg); max-height: 70vh; overflow: auto; }
.mobile-nav.open { display: block; padding: 10px 0 18px; }
.mn-group { padding: 6px 0; border-bottom: 1px solid var(--border); }
.mn-group:last-of-type { border-bottom: 0; }
.mn-head { display: block; padding: 10px 2px; font-family: var(--font-head); font-weight: 600; font-size: 1.02rem; }
.mn-subs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px 8px; }
.mn-subs a { padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: .84rem; color: var(--text-muted); }

/* ---------- 5 portes d'entrée ---------- */
.group-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.group-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; display: flex; flex-direction: column; gap: 3px; transition: transform .14s ease, border-color .14s ease;
}
.group-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.group-card .g-emoji { font-size: 1.8rem; line-height: 1; margin-bottom: 4px; }
.group-card .g-name { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; }
.group-card .g-sub { font-size: .84rem; color: var(--text-muted); }
.group-card .g-n { margin-top: 8px; font-size: .78rem; color: var(--accent); font-weight: 600; }

/* ---------- Rangées : débordement latéral sur mobile (reco 19) ---------- */
@media (max-width: 700px) {
  .section .grid.rail {
    grid-auto-flow: column; grid-auto-columns: 46vw; grid-template-columns: none;
    overflow-x: auto; scroll-snap-type: x mandatory;
    margin-inline: -20px; padding-inline: 20px; padding-bottom: 6px;
    scrollbar-width: none;
  }
  .section .grid.rail::-webkit-scrollbar { display: none; }
  .section .grid.rail > .card { scroll-snap-align: start; }
}

/* ---------- Carte déjà faite ---------- */
.card { position: relative; }
.card.is-done::after {
  content: "✓"; position: absolute; top: 10px; inset-inline-end: 10px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--good); color: var(--on-good);
  font-size: .7rem; display: grid; place-items: center;
}
.card.is-done { opacity: .72; }

/* ---------- Reprise ---------- */
.resume-card {
  display: flex; align-items: center; gap: 14px; margin: 6px 0 4px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--radius-lg); padding: 14px 18px;
}
.resume-card .emoji { font-size: 1.7rem; }
.resume-card .rc-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.resume-card small { font-size: .78rem; color: var(--text-muted); }
.resume-card b { font-family: var(--font-head); font-size: 1.02rem; }
.resume-card .btn { height: 38px; padding: 0 16px; font-size: .9rem; }

/* ---------- Filtres du catalogue ---------- */
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 18px; }
.fchip {
  padding: 8px 15px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; font-weight: 500; cursor: pointer;
}
.fchip:hover { background: var(--surface-2); }
.fchip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.card[hidden] { display: none; }

/* ---------- Recherche enrichie ---------- */
.sr-head { padding: 9px 12px 4px; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); }
.sr-all { display: block; padding: 10px 12px; font-size: .86rem; color: var(--accent); font-weight: 600; border-top: 1px solid var(--border); margin-top: 4px; }

/* ---------- Questionnaire : cibles plus grandes (reco 12) ---------- */
.option { display: flex; width: 100%; min-height: 56px; padding: 16px 18px; }
.option:active { transform: scale(.985); }
.options { gap: 10px; }
.length-line { font-size: .88rem; color: var(--text-muted); margin: 2px 0 18px; }
.milestone { text-align: center; font-size: .86rem; color: var(--accent); font-weight: 500; margin: 14px 0 0; }

/* ---------- Résultat ---------- */
.percentile { min-height: 86px; }
.percentile .skeleton {
  height: 56px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--border) 25%, var(--surface-2) 50%, var(--border) 75%);
  background-size: 200% 100%; animation: qm-shine 1.4s linear infinite;
}
@keyframes qm-shine { to { background-position: -200% 0; } }

.cta-stack { display: flex; flex-direction: column; gap: 10px; align-items: center; margin: 18px 0 6px; }
.cta-stack .btn { max-width: 460px; width: 100%; }
.btn-link { background: none; border: none; color: var(--text-muted); text-decoration: underline; height: auto; padding: 6px; font-size: .9rem; }
.btn-link:hover { color: var(--text); }
.streak { font-size: .86rem; color: var(--text-muted); margin: 10px 0 0; }

.share-card {
  margin: 22px auto 10px; max-width: 460px; aspect-ratio: 1.91/1;
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 18px; position: relative;
}
.share-card .sc-emoji { font-size: 2.4rem; line-height: 1; }
.share-card .sc-title { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; text-align: center; }
.share-card .sc-score { font-family: var(--font-head); font-size: 1.9rem; font-weight: 700; color: var(--accent); }
.share-card .sc-brand { position: absolute; bottom: 12px; font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }

.share-btn.wide { width: auto; padding: 0 18px; border-radius: 999px; font: inherit; font-size: .9rem; font-weight: 600; gap: 7px; display: inline-flex; align-items: center; }

/* ---------- Barre « suite » collante (reco 8) ---------- */
.next-bar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 70;
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -8px 28px -18px rgba(0,0,0,.5);
  transform: translateY(110%); transition: transform .22s ease;
}
.next-bar.show { transform: none; }
.next-bar .emoji { font-size: 1.5rem; }
.next-bar .t { display: flex; flex-direction: column; flex: 1; min-width: 0; font-weight: 600; font-size: .95rem; }
.next-bar .t small { font-weight: 500; font-size: .74rem; color: var(--text-muted); }
.next-bar .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next-bar .btn { height: 40px; padding: 0 18px; }
.next-bar .x { background: none; border: 0; color: var(--text-muted); font-size: 1.3rem; cursor: pointer; padding: 0 4px; }
@media (max-width: 520px) { .next-bar .t small { display: none; } }

/* ============================================================
   Écran de fin de partie : niveau, gains, record
   ============================================================ */

.level-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 16px 8px 8px; margin: 0 auto 18px; max-width: 420px;
}
.level-bar .lvl {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 1.05rem;
  color: var(--accent); background: var(--surface);
  border: 2px solid var(--accent);
}
.level-bar .lvl.up { animation: qm-pop .5s ease both; background: var(--accent); color: #fff; }
@keyframes qm-pop { 0% { transform: scale(.7); } 55% { transform: scale(1.18); } 100% { transform: scale(1); } }
.level-bar .lb-body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; text-align: start; }
.level-bar small { font-size: .78rem; font-weight: 600; }
.level-bar small.muted { font-weight: 500; color: var(--text-muted); font-size: .72rem; }
.level-bar .bar { height: 7px; border-radius: 999px; background: var(--border); overflow: hidden; }
.level-bar .bar > i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--hot));
  border-radius: 999px; transition: width 1s cubic-bezier(.2,.8,.2,1);
}

.rewards { display: flex; gap: 10px; justify-content: center; margin: 0 auto 6px; max-width: 420px; }
.rw {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.rw .ic { font-size: 1.2rem; line-height: 1; }
.rw b { font-family: var(--font-head); font-size: 1.45rem; font-weight: 700; color: var(--accent); }
.rw small { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); }
.bonus { font-size: .82rem; color: var(--good-ink); font-weight: 600; margin: 6px 0 0; }

.badge-record {
  display: inline-block; margin: 2px 0 6px; padding: 4px 14px;
  border-radius: 999px; background: var(--warn); color: #1b1200;
  font-family: var(--font-head); font-weight: 700; font-size: .78rem;
  letter-spacing: .08em; text-transform: uppercase;
  animation: qm-pop .5s ease both;
}

.big-score {
  font-family: var(--font-head); font-weight: 700; line-height: 1;
  font-size: clamp(3.4rem, 2rem + 9vw, 6rem);
  letter-spacing: -.04em; margin: 6px 0 0;
}
.big-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); margin-bottom: 10px; }

.ic-replay { display: inline-block; font-size: 1.1em; }

@media (prefers-reduced-motion: reduce) {
  .level-bar .bar > i { transition: none; }
  .level-bar .lvl.up, .badge-record { animation: none; }
}

/* ============================================================
   Bandeau de progression (en-tête) et page de profil
   ============================================================ */

/* La place est réservée ici : le remplissage côté client ne décale rien. */
.qm-hud {
  flex: none; display: flex; align-items: center; gap: 8px;
  height: 38px; padding-inline: 4px 12px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-size: .82rem; font-weight: 600; line-height: 1;
}
.qm-hud[hidden] { display: none; }
.qm-hud:hover { background: var(--surface-2); }
.hud-lvl {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: .9rem;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--hot));
}
.hud-bar { flex: none; width: 56px; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.hud-bar > i {
  display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--hot));
  transition: width .8s cubic-bezier(.2,.8,.2,1);
}
.hud-gold { display: inline-flex; align-items: center; gap: 4px; }
.hud-gold b { min-width: 3ch; text-align: end; font-family: var(--font-head); font-weight: 700; }
.hud-coin { font-size: .95rem; }

.profile-card { margin: 18px 0 22px; }
.profile-card .skeleton { height: 58px; border-radius: var(--radius); background: var(--surface-2); }
.pf-head {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 18px 8px 8px; margin-bottom: 12px;
}
[dir="rtl"] .pf-head { padding: 8px 8px 8px 18px; }
.pf-lvl {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 1.15rem;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--hot));
}
.pf-body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.pf-body small { font-size: .8rem; font-weight: 600; }
.pf-body small.muted { font-weight: 500; font-size: .72rem; color: var(--text-muted); }
.pf-body .bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.pf-body .bar > i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--hot));
  transition: width .8s cubic-bezier(.2,.8,.2,1);
}
.profile-card .rewards { max-width: none; }

.profile-bests h2 { font-family: var(--font-head); font-size: 1.1rem; margin: 26px 0 10px; }
.best-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.best-list a {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: .95rem;
}
.best-list a:hover { background: var(--surface-2); }
.best-list .emoji { font-size: 1.2rem; line-height: 1; flex: none; }
.best-list .bl-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.best-list .bl-score { flex: none; font-family: var(--font-head); font-weight: 700; color: var(--accent); }
.best-list .bl-score small { font-weight: 500; font-size: .7rem; color: var(--text-muted); }

#qm-reset.is-armed { border-color: var(--hot-ink); color: var(--hot-ink); background: var(--hot-soft); font-weight: 600; }

@media (max-width: 860px) {
  .hud-bar { display: none; }
}
@media (max-width: 520px) {
  .qm-hud { padding-inline: 3px 10px; gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .hud-bar > i, .pf-body .bar > i { transition: none; }
}

/* ---------- Fiche de statistiques du joueur ---------- */
.stat-sheet-wrap { margin: 30px 0 10px; }
.stat-sheet-wrap > h2 { font-family: var(--font-head); font-size: 1.1rem; margin: 0 0 4px; }
.stat-sheet-wrap > .lede { color: var(--text-muted); font-size: .92rem; margin: 0 0 14px; }
#qm-sheet .skeleton { height: 220px; border-radius: var(--radius); background: var(--surface-2); }

.sheet {
  position: relative; overflow: hidden; border-radius: var(--radius-lg);
  padding: 22px 20px 20px; color: #fff;
  background:
    radial-gradient(520px 320px at 100% 0%, rgba(138,124,255,.38), transparent 70%),
    linear-gradient(150deg, #201A44 0%, #15121F 55%, #0D0C11 100%);
  box-shadow: var(--shadow-lg);
}
.sheet .sh-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sheet .sh-brand { font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; }
.sheet .sh-kicker { color: rgba(255,255,255,.6); font-size: .86rem; }

.sheet .sh-level { display: flex; align-items: center; gap: 14px; margin: 18px 0 16px; }
.sheet .sh-lvl {
  flex: none; width: 56px; height: 56px; display: grid; place-items: center;
  border-radius: 50%; font-family: var(--font-head); font-weight: 800; font-size: 1.5rem;
  background: linear-gradient(140deg, #8A7CFF, #FF8273); color: #fff;
}
.sheet .sh-lvl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.sheet .sh-lvl-body strong { font-family: var(--font-head); font-size: .98rem; }
.sheet .sh-lvl-body small { color: rgba(255,255,255,.55); font-size: .8rem; }
.sheet .bar { display: block; height: 8px; border-radius: 99px; background: rgba(255,255,255,.14); overflow: hidden; }
.sheet .bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #8A7CFF, #FF8273); }

.sheet .sh-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sheet .sh-tile {
  background: rgba(255,255,255,.07); border-radius: var(--radius-sm);
  padding: 12px 12px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.sheet .sh-ic { font-size: 1rem; line-height: 1; }
.sheet .sh-tile b { font-family: var(--font-head); font-size: 1.25rem; font-weight: 800; }
.sheet .sh-tile small { color: rgba(255,255,255,.55); font-size: .74rem; line-height: 1.25; }

.sheet .sh-top { margin-top: 18px; }
.sheet .sh-top h3 { font-family: var(--font-head); font-size: .95rem; margin: 0 0 8px; }
.sheet .sh-top ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.sheet .sh-top li { display: flex; align-items: center; gap: 9px; font-size: .88rem; }
.sheet .sh-top .emoji { flex: none; }
.sheet .sh-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgba(255,255,255,.88); }
.sheet .sh-bar { flex: none; width: 96px; height: 8px; border-radius: 99px; background: rgba(255,255,255,.14); overflow: hidden; }
.sheet .sh-bar > i { display: block; height: 100%; background: linear-gradient(90deg, #8A7CFF, #FF8273); }
.sheet .sh-s { flex: none; width: 2.2em; text-align: right; font-family: var(--font-head); font-weight: 800; }
.sheet .sh-fav { margin: 14px 0 0; font-size: .85rem; color: rgba(255,255,255,.7); }
.sheet .sh-foot { margin: 6px 0 0; font-size: .78rem; color: rgba(255,255,255,.45); }

.sheet-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 0; }
.sheet-tools .btn.is-busy { opacity: .6; pointer-events: none; }
.sheet-networks { display: inline-flex; gap: 6px; margin-inline-start: auto; }

.stats-link {
  display: block; text-align: center; margin: 16px auto 0; font-weight: 600;
  font-size: .92rem; color: var(--accent); text-decoration: none;
}
.stats-link:hover { text-decoration: underline; }

@media (max-width: 560px) {
  .sheet .sh-grid { grid-template-columns: repeat(2, 1fr); }
  .sheet .sh-bar { width: 62px; }
  .sheet-networks { margin-inline-start: 0; }
}

/* Statistiques communautaires : état pionnier et estimation assumée */
.percentile.is-pioneer {
  display: flex; align-items: flex-start; gap: 10px; text-align: start;
  background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px;
  color: var(--text-muted); font-size: .9rem; line-height: 1.45;
}
.percentile.is-pioneer .pio-ic { font-size: 1.1rem; line-height: 1.3; flex: none; }
.q-counter.is-est { color: var(--warn-ink); }

/* ---------- Page de résultat partageable ---------- */
.result-page { max-width: 46rem; margin: 10px auto 0; text-align: center; padding: 10px 0 4px; }
.rp-kicker {
  text-transform: uppercase; letter-spacing: .08em; font-size: .74rem;
  color: var(--text-muted); margin: 0 0 14px;
}
.rp-kicker a { color: var(--text-muted); }
.rp-emoji { font-size: clamp(3.4rem, 16vw, 5.4rem); line-height: 1; margin-bottom: 8px; }
.result-page h1 { font-family: var(--font-head); font-size: clamp(1.7rem, 6vw, 2.5rem); margin: 0 0 14px; }
.rp-text { font-size: 1.05rem; line-height: 1.68; color: var(--text); margin: 0 auto 26px; max-width: 40rem; text-align: start; }
.rp-cta {
  background: var(--accent-soft); border-radius: var(--radius-lg);
  padding: 22px 20px; margin: 0 0 20px;
}
.rp-ask { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; margin: 0 0 12px; color: var(--accent-ink); }
.rp-cta .note { margin: 12px 0 0; }
.rp-share { justify-content: center; margin-top: 4px; }
.rp-others { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.rp-others a {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text);
}
.rp-others a:hover { background: var(--surface-2); }
.rp-others .emoji { font-size: 1.2rem; flex: none; }

/* ---------- Duel par lien ---------- */
.duel-bar {
  display: flex; align-items: center; gap: 10px; margin: 0 0 12px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent-ink);
  font-weight: 600; font-size: .94rem;
}
.duel-bar .dl-ic { font-size: 1.15rem; line-height: 1; flex: none; }

.duel-face { margin: 18px auto 4px; max-width: 24rem; }
.df-line {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px;
}
.df-side { flex: 1; min-width: 0; text-align: center; }
.df-side small { display: block; color: var(--text-muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
.df-side b { font-family: var(--font-head); font-size: 1.5rem; font-weight: 800; }
.df-me b { color: var(--accent); }
.duel-face.is-win .df-me b { color: var(--good-ink); }
.duel-face.is-lose .df-me b { color: var(--hot-ink); }
.df-vs { font-size: 1.1rem; flex: none; opacity: .7; }
.df-verdict { margin: 10px 0 0; text-align: center; font-weight: 600; }
.duel-face.is-win .df-verdict { color: var(--good-ink); }
.duel-face.is-lose .df-verdict { color: var(--text-muted); }

/* ---------- Défi du jour, série, installation ---------- */
.daily {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 0 0 18px; padding: 16px 18px; text-decoration: none; color: var(--text);
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: linear-gradient(120deg, var(--accent-soft), var(--surface) 70%);
  box-shadow: var(--shadow);
}
.daily:hover { box-shadow: var(--shadow-lg); }
.daily .dy-kicker {
  flex-basis: 100%; font-size: .72rem; text-transform: uppercase; letter-spacing: .09em;
  font-weight: 700; color: var(--accent-ink);
}
.daily .dy-emoji { font-size: 2rem; line-height: 1; flex: none; }
.daily .dy-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.daily .dy-name { font-family: var(--font-head); font-weight: 700; font-size: 1.08rem; }
.daily .dy-sub { font-size: .84rem; color: var(--text-muted); }
.daily .dy-go { flex: none; font-weight: 700; color: var(--accent); }
.daily.is-done { background: var(--surface-2); }
.daily.is-done .dy-emoji { opacity: .55; }

.hud-streak {
  display: inline-flex; align-items: center; gap: 2px; margin-inline-start: 6px;
  font-size: .78rem; font-weight: 700; color: var(--hot-ink);
}
.hud-streak.at-risk { animation: qm-pulse 1.8s ease-in-out infinite; }
@keyframes qm-pulse { 0%, 100% { opacity: 1 } 50% { opacity: .45 } }
@media (prefers-reduced-motion: reduce) { .hud-streak.at-risk { animation: none; text-decoration: underline dotted; } }

/* ---------- Accessibilité des jeux ---------- */
/* Les cases de jeu sont créées en JavaScript avec des styles en ligne : la
   bague de focus doit donc être imposée ici, et assez contrastée pour rester
   visible sur une case déjà colorée. */
#app button:focus-visible,
.arena button:focus-visible,
.sheet-tools .btn:focus-visible,
.share-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
html[data-theme="dark"] #app button:focus-visible { outline-color: #B5ABFF; }

/* Espace ne doit jamais faire défiler la page pendant une partie. */
.arena, .arena * { overscroll-behavior: contain; }
