
:root {
  --nuit: #1F2A44;      /* bleu nuit : titres, en-tête */
  --creme: #FBF8F1;     /* fond */
  --encre: #333C52;     /* texte courant (contraste 10:1 sur crème) */
  --doux: #5A6378;      /* texte secondaire (contraste 5,6:1) */
  --ligne: #E3DED2;
  --carte: #FFFFFF;
  --orange: #B5491A;    /* bouton principal (contraste 5:1 avec blanc) */
  --orange-vif: #D9622B;
  --orange-clair: #FCE9DF;
  --bleu: #2F6FB0;
  --bleu-clair: #E6EFF9;
  --vert: #2E7D4F;
  --vert-clair: #E3F2E8;
  --rouge: #B23A48;
  --rouge-clair: #F8E3E6;
  --violet: #6B4FA0;
  --or: #B8860B;
  --rayon: 16px;
  --ombre: 0 1px 3px rgba(31, 42, 68, .08), 0 6px 20px rgba(31, 42, 68, .06);
  --titre: 'Fredoka', 'Nunito', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font: 400 17px/1.55 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--encre); background: var(--creme);
}
main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 24px 18px 48px; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { font-family: var(--titre); color: var(--nuit); line-height: 1.2; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: clamp(28px, 6vw, 44px); }
h2 { font-size: clamp(22px, 4vw, 28px); }
h3 { font-size: 20px; }
p { margin: 0 0 1em; }
a { color: var(--bleu); text-underline-offset: 3px; }
a:hover { color: var(--nuit); }
:focus-visible { outline: 3px solid var(--orange-vif); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cache { display: none !important; }
.lien-evitement { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 100; }
.lien-evitement:focus { left: 8px; }

/* ---------- en-tête ---------- */
.entete { background: var(--nuit); color: var(--creme); }
.entete .interieur { max-width: 1080px; margin: 0 auto; padding: 12px 18px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--creme); text-decoration: none; font-family: var(--titre); font-size: 20px; font-weight: 600; }
.logo img { width: 36px; height: 36px; }
.logo:hover { color: #fff; }
.entete nav { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.entete nav a, .entete nav button { color: #DCE3F0; text-decoration: none; font-weight: 600; font-size: 15px; background: none; border: 0; padding: 8px 10px; border-radius: 10px; cursor: pointer; font-family: inherit; }
.entete nav a:hover, .entete nav button:hover { background: rgba(255,255,255,.1); color: #fff; }
.qui { font-size: 14px; color: #C9D3E6; }

/* ---------- pied de page ---------- */
.pied { background: #fff; border-top: 1px solid var(--ligne); color: var(--doux); font-size: 14px; }
.pied .interieur { max-width: 1080px; margin: 0 auto; padding: 18px; display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between; }
.pied nav { display: flex; gap: 14px; flex-wrap: wrap; }
.pied a { color: var(--doux); }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 20px; border-radius: 12px; border: 2px solid transparent;
  font: 800 16px/1.2 'Nunito', sans-serif; text-decoration: none; cursor: pointer;
  background: var(--orange); color: #fff; transition: transform .08s, background .15s;
}
.btn:hover { background: #963A12; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.grand { min-height: 56px; padding: 14px 28px; font-size: 18px; border-radius: 14px; }
.btn.second { background: var(--bleu-clair); color: var(--nuit); }
.btn.second:hover { background: #D3E2F3; }
.btn.contour { background: transparent; color: var(--nuit); border-color: var(--ligne); }
.btn.contour:hover { border-color: var(--nuit); }
.btn.danger { background: var(--rouge); }
.btn.danger:hover { background: #8E2C38; }
.btn.petit { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }

/* ---------- cartes et grilles ---------- */
.carte { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 22px; margin-bottom: 18px; }
.carte.liseret { border-top: 6px solid var(--bleu); }
.grille { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grille-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.surtitre { font-size: 13px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--orange); margin-bottom: 4px; }
.doux { color: var(--doux); }
.etiquette { display: inline-block; font-size: 13px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--bleu-clair); color: var(--nuit); }
.etiquette.vert { background: var(--vert-clair); color: #1E5535; }
.etiquette.orange { background: var(--orange-clair); color: #8A3510; }
.etiquette.rouge { background: var(--rouge-clair); color: #7F2531; }

/* ---------- accueil ---------- */
.heros { background: var(--nuit); color: var(--creme); border-radius: 24px; padding: clamp(28px, 6vw, 56px); margin-bottom: 26px; position: relative; overflow: hidden; }
.heros h1 { color: #fff; max-width: 680px; }
.heros p { color: #DCE3F0; font-size: 19px; max-width: 620px; }
.heros .symboles { position: absolute; right: -10px; bottom: -20px; font-family: var(--titre); font-size: 140px; color: rgba(255,255,255,.06); line-height: 1; pointer-events: none; user-select: none; }
.atout { text-align: left; }
.atout .icone { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; margin-bottom: 10px; }

/* ---------- formulaires ---------- */
.formulaire { max-width: 520px; margin: 0 auto; }
.champ { margin-bottom: 16px; }
.champ label { display: block; font-weight: 800; color: var(--nuit); margin-bottom: 6px; }
.champ .aide { font-size: 14px; color: var(--doux); margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; font: inherit; color: var(--encre);
  background: #fff; border: 2px solid var(--ligne); border-radius: 12px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--bleu); outline: none; box-shadow: 0 0 0 3px var(--bleu-clair); }
input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--rouge); }
.erreur-champ { color: var(--rouge); font-size: 14px; font-weight: 600; margin-top: 4px; min-height: 0; }
.case { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.case input { width: 22px; height: 22px; margin-top: 2px; flex: none; }
.mdp { position: relative; }
.mdp input { padding-right: 90px; }
.mdp button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: var(--bleu-clair); color: var(--nuit); font-weight: 800; font-size: 13px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.pot-de-miel { position: absolute !important; left: -5000px !important; width: 1px; height: 1px; overflow: hidden; }
.onglets { display: flex; gap: 6px; background: #EEE9DD; padding: 6px; border-radius: 14px; margin-bottom: 20px; }
.onglets button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; font: 800 15px 'Nunito', sans-serif; color: var(--doux); cursor: pointer; }
.onglets button[aria-selected=true] { background: #fff; color: var(--nuit); box-shadow: var(--ombre); }
.message { padding: 12px 16px; border-radius: 12px; margin: 12px 0; font-weight: 600; }
.message.erreur { background: var(--rouge-clair); color: #7F2531; }
.message.succes { background: var(--vert-clair); color: #1E5535; }
.message.info { background: var(--bleu-clair); color: var(--nuit); }
.turnstile { min-height: 70px; margin: 8px 0 14px; }

/* ---------- espace élève ---------- */
.bonjour { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.tuile { background: #fff; border-radius: var(--rayon); padding: 18px; box-shadow: var(--ombre); }
.tuile .valeur { font-family: var(--titre); font-size: 40px; color: var(--nuit); line-height: 1.1; }
.tuile .libelle { font-weight: 800; color: var(--doux); font-size: 14px; text-transform: uppercase; letter-spacing: 1px; }
.barre { height: 12px; background: #EEE9DD; border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.barre > div { height: 100%; background: linear-gradient(90deg, var(--orange-vif), var(--or)); border-radius: 999px; transition: width .6s; }
.barre.verte > div { background: var(--vert); }
.badges { display: flex; flex-wrap: wrap; gap: 10px; }
.badge { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: #F3F0E8; color: var(--doux); font-weight: 700; font-size: 14px; }
.badge .ic { font-size: 22px; filter: grayscale(1); opacity: .45; }
.badge.gagne { background: var(--orange-clair); color: #6E2A0C; }
.badge.gagne .ic { filter: none; opacity: 1; }
.lecon { display: flex; flex-direction: column; text-decoration: none; color: inherit; border-top: 6px solid var(--bleu); transition: transform .12s, box-shadow .12s; }
.lecon:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(31,42,68,.12); color: inherit; }
.lecon.geometrie { border-top-color: var(--vert); }
.lecon h3 { margin: 6px 0; }
.lecon .bas { margin-top: auto; padding-top: 10px; font-size: 14px; color: var(--doux); }

/* graphique de progression */
.graphique { position: relative; }
.graphique svg { display: block; width: 100%; height: auto; overflow: visible; }
.graphique .axe { stroke: #D9D3C4; stroke-width: 1; }
.graphique .grille-h { stroke: #EEE9DD; stroke-width: 1; }
.graphique .courbe { fill: none; stroke: var(--bleu); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.graphique .aire { fill: var(--bleu); opacity: .08; }
.graphique .point { fill: var(--bleu); stroke: #fff; stroke-width: 2; }
.graphique text { fill: var(--doux); font-size: 12px; font-family: 'Nunito', sans-serif; }
.graphique .viseur { stroke: var(--nuit); stroke-width: 1; stroke-dasharray: 3 3; }
.infobulle { position: absolute; pointer-events: none; background: var(--nuit); color: #fff; padding: 8px 10px; border-radius: 10px; font-size: 13px; white-space: nowrap; transform: translate(-50%, -110%); box-shadow: var(--ombre); }

/* ---------- leçon ---------- */
.video { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; }
.video iframe, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cartes-mentales a { display: block; border-radius: 12px; overflow: hidden; border: 1px solid var(--ligne); margin-bottom: 12px; }
.liste-jeux { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.jeu { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 14px; background: #fff; border: 2px solid var(--ligne); text-decoration: none; color: inherit; }
.jeu:hover { border-color: var(--bleu); color: inherit; }
.jeu .titre { font-family: var(--titre); font-size: 18px; color: var(--nuit); }
.etoiles { color: #8F6A00; letter-spacing: 2px; font-size: 18px; }

/* ---------- page de jeu ---------- */
body.page-jeu main { max-width: none; padding: 0; display: flex; flex-direction: column; }
.barre-jeu { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--ligne); flex-wrap: wrap; }
.barre-jeu .titre { font-family: var(--titre); font-size: 18px; color: var(--nuit); }
.barre-jeu .infos { margin-left: auto; font-size: 14px; color: var(--doux); font-weight: 700; }
.cadre-jeu { flex: 1; width: 100%; min-height: calc(100vh - 140px); border: 0; display: block; background: var(--creme); }
.toast-zone { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 460px); }
.toast { background: var(--nuit); color: #fff; padding: 14px 18px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 600; animation: monte .25s ease-out; }
.toast.succes { background: #1E5535; }
.toast.erreur { background: #7F2531; }
@keyframes monte { from { transform: translateY(20px); opacity: 0; } }

/* ---------- quiz ---------- */
.question { font-size: 20px; margin: 12px 0 16px; }
.choix { display: grid; gap: 10px; }
.choix button { text-align: left; min-height: 52px; padding: 12px 16px; border-radius: 12px; border: 2px solid var(--ligne); background: #fff; font: 600 17px 'Nunito', sans-serif; color: var(--encre); cursor: pointer; }
.choix button:hover:not(:disabled) { border-color: var(--bleu); }
.choix button.bon { border-color: var(--vert); background: var(--vert-clair); }
.choix button.faux { border-color: var(--rouge); background: var(--rouge-clair); }
.progression { height: 10px; background: #EEE9DD; border-radius: 999px; overflow: hidden; }
.progression div { height: 100%; background: var(--bleu); transition: width .3s; }
.chrono { font-family: var(--titre); font-size: 22px; color: var(--nuit); }

/* ---------- tableaux (enseignante) ---------- */
.tableau-defile { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 15px; background: #fff; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--ligne); vertical-align: middle; }
th { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--doux); background: #FAF8F3; position: sticky; top: 0; }
tbody tr:hover { background: #FAF8F3; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.outils { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.outils .champ { margin: 0; min-width: 200px; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 800; letter-spacing: 2px; background: #F3F0E8; padding: 3px 8px; border-radius: 6px; }
dialog { border: 0; border-radius: 18px; padding: 24px; width: min(94vw, 640px); box-shadow: 0 20px 60px rgba(0,0,0,.3); color: var(--encre); }
dialog::backdrop { background: rgba(31, 42, 68, .55); }
.question-editeur { border: 2px solid var(--ligne); border-radius: 14px; padding: 14px; margin-bottom: 12px; background: #FDFCF9; }

/* ---------- bandeau cookies ---------- */
.bandeau-cookies { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60; max-width: 720px; margin: 0 auto; background: #fff; border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.2); padding: 18px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.bandeau-cookies p { margin: 0; flex: 1 1 320px; font-size: 15px; }
.bandeau-cookies .actions { flex: 0 0 auto; }

/* ---------- pages de texte ---------- */
.texte { max-width: 760px; }
.texte h2 { margin-top: 1.4em; }
.texte li { margin-bottom: .4em; }

/* ---------- 404 ---------- */
.page-404 { text-align: center; padding-top: 30px; }
.page-404 .grand-nombre { font-family: var(--titre); font-size: clamp(90px, 22vw, 180px); color: var(--nuit); line-height: 1; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  main { padding: 16px 12px 40px; }
  .carte { padding: 16px; }
  .entete nav { margin-left: 0; width: 100%; }
  .tuile .valeur { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .entete, .pied, .bandeau-cookies, .btn { display: none !important; }
}
.champ label.case { font-weight: 600; color: var(--encre); }
