:root {
  --bg: #0b1411;
  --surface: #13201b;
  --surface-2: #1a2b24;
  --line: #24392f;
  --line-strong: #2f4a3e;
  --text: #eef3f0;
  --muted: #98ada3;
  --faint: #6f857b;
  --green: #22b573;
  --green-dark: #178a56;
  --green-soft: rgba(34, 181, 115, 0.14);
  --gold: #e2b44b;
  --gold-soft: rgba(226, 180, 75, 0.13);
  --red: #ef6b6b;
  --red-dark: #b94848;
  --red-soft: rgba(239, 107, 107, 0.13);
  --radius: 18px;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --lecture: 1.1875rem;
  color-scheme: dark;
}

html.grand { --lecture: 1.375rem; }
html.tres-grand { --lecture: 1.5625rem; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 600;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
svg { display: block; flex: none; }
h1, h2, h3, p { margin: 0; }

.page { max-width: 560px; margin: 0 auto; padding: 0 16px calc(40px + env(safe-area-inset-bottom)); }

/* ---- barre du haut ---- */
.barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  margin: 0 -16px 20px;
  background: var(--bg);
  border-bottom: 2px solid var(--line);
}
.marque { font-weight: 900; font-size: 1.5rem; color: var(--green); letter-spacing: -0.01em; margin-right: auto; }
.compteur { display: flex; align-items: center; gap: 5px; font-weight: 800; font-size: 1.05rem; color: var(--muted); }
.compteur.xp { color: var(--gold); }
.compteur.feu.actif { color: var(--gold); }
.icone-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); }
.icone-btn:active { background: var(--surface); }
.retour { display: flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 800; margin-right: auto; padding: 8px 4px; }

/* ---- accueil ---- */
.salut { font-size: 1.85rem; font-weight: 900; line-height: 1.15; letter-spacing: -0.01em; }
.sous { color: var(--muted); margin-top: 6px; font-size: 1.05rem; }
.bloc { margin-top: 18px; }
.carte {
  background: var(--surface);
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: var(--radius);
  padding: 16px;
}
button.carte { display: block; width: 100%; text-align: left; }
button.carte:active { transform: translateY(2px); border-bottom-width: 2px; margin-bottom: 2px; }

.objectif-tete { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; }
.objectif-tete span:last-child { color: var(--gold); }
.jauge { height: 12px; border-radius: 99px; background: var(--surface-2); margin-top: 10px; overflow: hidden; }
.jauge > i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .4s ease; }

.reprendre { border-color: var(--line-strong); }
.etiquette { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.reprendre h2 { font-size: 1.3rem; font-weight: 900; margin-top: 6px; line-height: 1.2; }
.reprendre p { color: var(--muted); margin-top: 4px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; padding: 12px 18px;
  border-radius: 16px; font-weight: 900; font-size: 1.05rem; letter-spacing: .02em; text-transform: uppercase;
  background: var(--green); color: #06130d;
  border-bottom: 4px solid var(--green-dark);
}
.btn:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
.btn:disabled { background: var(--surface-2); color: var(--faint); border-bottom-color: var(--line); cursor: default; }
.btn.secondaire { background: var(--surface); color: var(--text); border: 2px solid var(--line); border-bottom-width: 4px; }
.btn.rouge { background: var(--red); border-bottom-color: var(--red-dark); color: #1a0606; }
.reprendre .btn { margin-top: 14px; }

.raccourcis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.raccourci { display: flex; flex-direction: column; gap: 10px; min-height: 112px; }
.raccourci strong { font-weight: 900; font-size: 1.05rem; line-height: 1.2; }
.raccourci small { color: var(--muted); font-size: .9rem; font-weight: 700; }
.pastille { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); }
.pastille.or { background: var(--gold-soft); color: var(--gold); }
.pastille.rouge { background: var(--red-soft); color: var(--red); }

.titre-section { font-size: 1.2rem; font-weight: 900; margin: 28px 0 12px; }
.unites { display: grid; gap: 12px; }
.unite { display: flex; align-items: center; gap: 14px; }
.unite-num {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-weight: 900; font-size: 1.1rem;
  background: var(--surface-2); color: var(--muted); border: 2px solid var(--line);
}
.unite.finie .unite-num { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.unite-corps { flex: 1; min-width: 0; }
.unite-corps strong { display: block; font-weight: 900; font-size: 1.1rem; line-height: 1.2; }
.unite-corps small { display: block; color: var(--muted); font-size: .92rem; margin-top: 2px; }
.mini-jauge { height: 6px; border-radius: 99px; background: var(--surface-2); margin-top: 9px; overflow: hidden; }
.mini-jauge > i { display: block; height: 100%; background: var(--green); }
.chevron { color: var(--faint); }

/* ---- unité ---- */
.unite-tete h1 { font-size: 1.75rem; font-weight: 900; line-height: 1.15; }
.unite-tete p { color: var(--muted); margin-top: 6px; }
.lecons { display: grid; gap: 10px; margin-top: 20px; }
.lecon { display: flex; align-items: center; gap: 14px; }
.lecon-etat {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  border: 2px solid var(--line-strong); color: var(--faint); font-weight: 900;
}
.lecon.lue .lecon-etat { background: var(--green); border-color: var(--green); color: #06130d; }
.lecon.suivante { border-color: var(--green); }
.lecon.suivante .lecon-etat { border-color: var(--green); color: var(--green); }
.lecon-corps { flex: 1; min-width: 0; }
.lecon-corps strong { display: block; font-weight: 800; font-size: 1.05rem; line-height: 1.25; }
.lecon-meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; color: var(--muted); font-size: .85rem; font-weight: 700; }
.genre { text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; font-weight: 900; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.genre.histoire { color: var(--gold); background: var(--gold-soft); }

/* ---- lecteur ---- */
.lecteur {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.lecteur-tete { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 8px; max-width: 640px; width: 100%; margin: 0 auto; }
.progression { flex: 1; height: 14px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progression > i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width .3s ease; }
.lecteur-corps { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.scene { max-width: 600px; margin: 0 auto; padding: 18px 20px 28px; min-height: 100%; display: flex; flex-direction: column; justify-content: center; }
.scene.haut { justify-content: flex-start; }
.provenance { color: var(--faint); font-size: .85rem; font-weight: 800; margin-bottom: 14px; text-transform: uppercase; letter-spacing: .05em; }

.k-titre { color: var(--green); font-size: .9rem; font-weight: 900; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 10px; }
.k-texte p { font-size: var(--lecture); line-height: 1.55; font-weight: 600; }
.k-texte p + p { margin-top: .7em; }
.k-citation { border-left: 4px solid var(--gold); padding: 4px 0 4px 18px; }
.k-citation p { font-size: var(--lecture); line-height: 1.55; font-weight: 700; }
.ref { display: inline-block; margin-top: 14px; color: var(--gold); font-size: .9rem; font-weight: 800; }
.k-formule .translit { font-size: calc(var(--lecture) * 1.18); font-weight: 900; line-height: 1.35; color: var(--text); }
.k-formule .sens { font-size: var(--lecture); color: var(--muted); margin-top: 14px; line-height: 1.5; }
.k-formule .quand { margin-top: 16px; display: inline-flex; gap: 8px; align-items: flex-start; font-size: .95rem; color: var(--green); font-weight: 800; }
.k-retenir { background: var(--gold-soft); border: 2px solid rgba(226,180,75,.35); border-radius: var(--radius); padding: 20px; }
.k-retenir .k-titre { color: var(--gold); display: flex; align-items: center; gap: 8px; }
.k-retenir p { font-size: var(--lecture); font-weight: 800; line-height: 1.5; }
.k-nuance { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; }
.k-nuance .k-titre { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.k-nuance p { font-size: calc(var(--lecture) * .95); line-height: 1.55; }

.k-question .q { font-size: calc(var(--lecture) * 1.08); font-weight: 900; line-height: 1.35; }
.choix { display: grid; gap: 10px; margin-top: 20px; }
.choix button {
  text-align: left; padding: 15px 16px; border-radius: 16px; font-weight: 700; font-size: 1.05rem; line-height: 1.35;
  background: var(--surface); border: 2px solid var(--line); border-bottom-width: 4px;
  display: flex; gap: 12px; align-items: center;
}
.choix button .lettre { width: 30px; height: 30px; flex: none; border-radius: 9px; border: 2px solid var(--line-strong); display: grid; place-items: center; font-size: .85rem; font-weight: 900; color: var(--muted); }
.choix button.choisi { border-color: var(--green); background: var(--green-soft); }
.choix button.juste { border-color: var(--green); background: var(--green-soft); }
.choix button.juste .lettre { background: var(--green); border-color: var(--green); color: #06130d; }
.choix button.faux { border-color: var(--red); background: var(--red-soft); }
.choix button.faux .lettre { background: var(--red); border-color: var(--red); color: #1a0606; }
.choix button:disabled { cursor: default; }
.choix button.eteint { opacity: .55; }

.lecteur-pied { border-top: 2px solid var(--line); padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--bg); }
.lecteur-pied.juste { background: #10261c; border-top-color: transparent; }
.lecteur-pied.faux { background: #2a1416; border-top-color: transparent; }
.pied-int { max-width: 600px; margin: 0 auto; }
.verdict { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.2rem; }
.lecteur-pied.juste .verdict { color: var(--green); }
.lecteur-pied.faux .verdict { color: var(--red); }
.explication { margin-top: 8px; font-size: 1.02rem; line-height: 1.5; color: var(--text); max-height: 38dvh; overflow-y: auto; }
.pied-boutons { display: flex; gap: 10px; margin-top: 14px; }
.pied-boutons .btn.precedent { width: 60px; flex: none; padding: 0; background: var(--surface); color: var(--muted); border: 2px solid var(--line); border-bottom-width: 4px; }
.lecteur-pied:not(.juste):not(.faux) .pied-boutons { margin-top: 0; }

/* ---- fin de leçon ---- */
.fin { text-align: center; }
.fin .medaille { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); }
.fin h2 { font-size: 1.7rem; font-weight: 900; margin-top: 18px; }
.fin .gains { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }
.gain { min-width: 110px; border: 2px solid var(--line); border-radius: 16px; padding: 10px 14px; }
.gain b { display: block; font-size: 1.35rem; font-weight: 900; }
.gain.or b { color: var(--gold); }
.gain.vert b { color: var(--green); }
.gain span { font-size: .8rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.sources { text-align: left; margin-top: 24px; }
.sources ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); font-size: .95rem; }
.sources li + li { margin-top: 3px; }
.a-verifier { text-align: left; margin-top: 16px; border: 2px dashed rgba(226,180,75,.45); border-radius: 14px; padding: 14px; font-size: .95rem; }
.a-verifier b { color: var(--gold); display: block; margin-bottom: 4px; }

/* ---- réglages ---- */
.reglage { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.segment { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.segment button { padding: 8px 12px; border-radius: 9px; font-weight: 800; color: var(--muted); }
.segment button.actif { background: var(--green); color: #06130d; }
.profil-choix { display: grid; gap: 12px; margin-top: 24px; }
.profil-choix .carte { display: flex; align-items: center; gap: 14px; font-weight: 900; font-size: 1.2rem; }
.avatar { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: var(--green); font-weight: 900; font-size: 1.3rem; }
.note { color: var(--muted); font-size: .92rem; margin-top: 12px; }
.lien-danger { color: var(--red); font-weight: 800; padding: 10px 0; }

.vide { color: var(--muted); text-align: center; padding: 40px 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.apparait { animation: apparait .25s ease both; }
@keyframes apparait { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
