/* Révision — mobile d'abord : tout se joue au pouce, en bas de l'écran. */
:root {
  --fond: #f4f5f9;
  --carte: #ffffff;
  --texte: #171a2b;
  --doux: #6b7089;
  --bord: #e1e3ee;
  --accent: #f26b1d;
  --accent-texte: #ffffff;
  --rate: #d9364b;
  --difficile: #e08a00;
  --facile: #1f9d61;
  --ombre: 0 6px 24px rgba(23, 26, 43, .08);
  --rayon: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #10121c;
    --carte: #1b1e2e;
    --texte: #eef0fa;
    --doux: #9298b5;
    --bord: #2b2f45;
    --ombre: 0 6px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

.ecran {
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Accueil ── */
.entete { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.entete h1 { margin: 0; font-size: 1.35rem; letter-spacing: -.01em; }
.entete .serie { color: var(--doux); font-size: .9rem; }
.entete nav { display: flex; gap: 4px; }
.lien { color: var(--doux); padding: 8px 10px; border-radius: 10px; font-size: .9rem; text-decoration: none; }
.lien:hover { background: var(--bord); }

.btn {
  display: block; width: 100%;
  padding: 16px; border-radius: var(--rayon);
  font-weight: 650; font-size: 1.05rem; text-align: center;
  background: var(--carte); border: 1px solid var(--bord);
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-principal {
  background: var(--accent); color: var(--accent-texte); border-color: transparent;
  padding: 22px 16px; font-size: 1.25rem; box-shadow: var(--ombre);
}
.btn-principal small { display: block; font-weight: 500; font-size: .9rem; opacity: .9; margin-top: 2px; }

.bloc { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px; }
.bloc h2 { margin: 0 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--doux); }
.bloc + .bloc { margin-top: -4px; }

.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puce {
  padding: 10px 14px; border-radius: 999px; min-height: 44px;
  border: 1px solid var(--bord); background: var(--fond); font-size: .95rem;
}
.puce[aria-pressed="true"] { background: var(--texte); color: var(--fond); border-color: var(--texte); }

.chapitres summary { cursor: pointer; font-weight: 600; padding: 4px 0; list-style-position: inside; }
.chapitre {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; border-top: 1px solid var(--bord); min-height: 48px;
}
.chapitre input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.chapitre .nom { flex: 1; min-width: 0; }
.chapitre .nom small { display: block; color: var(--doux); }
.jauge { height: 5px; border-radius: 3px; background: var(--bord); overflow: hidden; margin-top: 5px; }
.jauge i { display: block; height: 100%; background: var(--facile); }
.badge { font-size: .8rem; padding: 3px 9px; border-radius: 999px; background: var(--accent); color: #fff; flex: none; }
.badge.zero { background: var(--bord); color: var(--doux); }

.info { color: var(--doux); font-size: .9rem; text-align: center; margin: 0; }
.bandeau { background: var(--difficile); color: #fff; border-radius: 12px; padding: 8px 12px; font-size: .88rem; text-align: center; }

/* ── Session ── */
.barre { display: flex; align-items: center; gap: 12px; }
.barre .quitter { font-size: 1.4rem; padding: 6px 10px; color: var(--doux); border-radius: 10px; }
.barre .avance { flex: 1; height: 8px; border-radius: 4px; background: var(--bord); overflow: hidden; }
.barre .avance i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.barre .reste { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.carte {
  flex: 1; min-height: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--carte); border: 1px solid var(--bord); border-radius: 24px;
  box-shadow: var(--ombre); padding: 24px 20px; text-align: center; width: 100%;
  user-select: none;
}
.carte .sens { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--doux); }
.carte .question { font-size: clamp(1.6rem, 7vw, 2.4rem); font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.carte .trait { width: 48px; height: 3px; border-radius: 2px; background: var(--accent); }
.carte .reponse { font-size: clamp(1.4rem, 6vw, 2rem); font-weight: 600; color: var(--accent); overflow-wrap: anywhere; }
.carte .remarque { color: var(--doux); font-size: .95rem; white-space: pre-line; }
.carte .chap { font-size: .78rem; color: var(--doux); }
.carte .nouvelle { font-size: .75rem; padding: 2px 10px; border-radius: 999px; background: var(--bord); }
.ecouter { font-size: 1.3rem; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--bord); }

.notes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.notes.deux { grid-template-columns: repeat(2, 1fr); }
.note { padding: 18px 4px; border-radius: var(--rayon); color: #fff; font-weight: 700; font-size: 1.05rem; min-height: 68px; }
.note kbd, .btn kbd { display: none; }
.note.rate { background: var(--rate); }
.note.difficile { background: var(--difficile); }
.note.facile { background: var(--facile); }
@media (hover: hover) and (pointer: fine) {
  .note kbd, .btn kbd {
    display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 6px;
    font: 600 .75rem ui-monospace, monospace; background: rgba(255, 255, 255, .25);
  }
  .btn:not(.btn-principal) kbd { background: var(--bord); }
}

/* ── Fin & stats ── */
.score { text-align: center; padding: 12px 0 0; }
.score .gros { font-size: 3.2rem; font-weight: 800; line-height: 1; color: var(--accent); }
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--bord); }
.liste li:first-child { border-top: 0; }
.liste .nl { font-weight: 600; }
.liste .fr, .liste .meta { color: var(--doux); text-align: right; }

/* ── Connexion & admin ── */
.champ { display: block; margin-bottom: 12px; }
.champ span { display: block; font-size: .85rem; color: var(--doux); margin-bottom: 4px; }
.champ input, .champ select, .champ textarea {
  width: 100%; padding: 13px; border-radius: 12px; border: 1px solid var(--bord); background: var(--fond);
}
.champ textarea { min-height: 200px; font: .85rem/1.4 ui-monospace, monospace; }
.erreur { color: var(--rate); font-size: .92rem; min-height: 1.3em; margin: 0; }
.succes { color: var(--facile); }
.large { max-width: 860px; }
.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.ligne-boutons { display: flex; gap: 10px; flex-wrap: wrap; }
.ligne-boutons .btn { width: auto; flex: 1; padding: 12px; font-size: .95rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--bord); vertical-align: top; }
th { color: var(--doux); font-weight: 600; border-top: 0; }
.defile { overflow-x: auto; }
.mini { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--bord); font-size: .85rem; }
.mini.danger { color: var(--rate); }
pre { background: var(--fond); border: 1px solid var(--bord); border-radius: 12px; padding: 12px; overflow: auto; font-size: .8rem; margin: 8px 0 0; }

/* Définitions et formules : un texte long se lit mieux en plus petit. */
.carte .question.long { font-size: clamp(1.15rem, 4.6vw, 1.5rem); font-weight: 600; }
.carte .reponse.long { font-size: clamp(1.1rem, 4.4vw, 1.4rem); }
/* ── Saisie de la réponse (FR → NL) ── */
.saisie { width: 100%; max-width: 340px; padding: 12px; border-radius: 12px; border: 2px solid var(--bord); background: var(--fond); text-align: center; font-size: 1.1rem; }
.saisie:focus { outline: none; border-color: var(--accent); }
.saisie-bilan { font-size: .95rem; padding: 4px 12px; border-radius: 999px; }
.saisie-bilan.juste { background: var(--facile); color: #fff; }
.saisie-bilan.faux { background: var(--bord); text-decoration: line-through; }

/* ── Photos ── */
.vignettes { display: flex; gap: 8px; overflow-x: auto; }
.vignettes img, .vignettes .pdf { width: 72px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--bord); display: grid; place-items: center; font-weight: 700; color: var(--doux); }
.erreur-eval { display: grid; gap: 4px; padding: 10px 0; border-top: 1px solid var(--bord); }
.erreur-eval:first-of-type { border-top: 0; }
.erreur-eval .badge { justify-self: start; }
.erreur-eval small { color: var(--doux); display: block; }
.erreur-eval summary { cursor: pointer; color: var(--accent); font-size: .92rem; padding: 4px 0; }
.carte-edit { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--bord); }
.carte-edit > input { width: 22px; height: 22px; margin-top: 10px; accent-color: var(--accent); flex: none; }
.carte-edit > div { flex: 1; display: grid; gap: 4px; min-width: 0; }
.carte-edit input:not([type=checkbox]) { width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--bord); background: var(--fond); }
.carte-edit .rem { font-size: .85rem; color: var(--doux); }

/* ── Fiche de vocabulaire ── */
.fiche h2 { font-size: 1rem; margin: 8px 0; }
.fiche h2 small { color: var(--doux); font-weight: 400; }
.fiche table { background: var(--carte); border: 1px solid var(--bord); border-radius: 12px; border-collapse: separate; border-spacing: 0; overflow: hidden; }
.fiche table { table-layout: fixed; }
.fiche th:nth-child(3) { width: 24%; }
.fiche td, .fiche th { padding: 9px 10px; overflow-wrap: anywhere; }
.fiche td:first-child { font-weight: 600; }
.fiche td.rem { color: var(--doux); font-size: .85rem; }
.fiche td.cache { color: transparent; background: repeating-linear-gradient(45deg, var(--bord), var(--bord) 6px, transparent 6px, transparent 12px); cursor: pointer; user-select: none; }
@media print {
  :root { --fond: #fff; --carte: #fff; --texte: #000; --doux: #444; --bord: #999; }
  .no-print { display: none !important; }
  .ecran { max-width: none; padding: 0; min-height: 0; }
  .fiche { break-inside: avoid-page; }
  .fiche td.cache { background: none; }
  .fiche tr { break-inside: avoid; }
}

/* ── Ambiance : chaleureux pour un ado de 12 ans, sans faire « bébé » ── */
body { font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 500px at 50% -200px, color-mix(in srgb, var(--accent) 16%, transparent), transparent), var(--fond); }
.salut { display: flex; align-items: center; gap: 10px; }
.mascotte { font-size: 2.2rem; line-height: 1; animation: coucou 2.4s ease-in-out 1; transform-origin: 50% 90%; }
@keyframes coucou { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-12deg); } 40% { transform: rotate(10deg); } 60% { transform: rotate(-6deg); } }
.objectif { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 10px 14px; font-weight: 600; font-size: .95rem; }
.objectif .jauge { height: 9px; border-radius: 5px; margin-top: 7px; }
.objectif .jauge i { background: linear-gradient(90deg, #f5c518, var(--accent)); transition: width .5s; }
.btn-principal { background: linear-gradient(135deg, #ff8a3d, var(--accent)); box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn, .note, .puce { transition: transform .08s ease; }
.note:active, .puce:active { transform: scale(.96); }
.carte { animation: arrivee .18s ease-out; }
@keyframes arrivee { from { opacity: .4; transform: translateY(6px) scale(.985); } }
.score .gros { animation: rebond .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes rebond { from { transform: scale(.3); opacity: 0; } }
.confettis { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confettis i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: chute linear forwards; }
@keyframes chute { to { transform: translateY(105vh) rotate(720deg); opacity: .9; } }
@media (prefers-reduced-motion: reduce) { .mascotte, .carte, .score .gros { animation: none; } }
@media print { body { background: #fff; } }
