/* Révisions de Zael — styles (grand, clair, calme) */
:root {
  --fond: #f4f6fb;
  --carte: #ffffff;
  --texte: #1f2a44;
  --doux: #5d6b89;
  --ligne: #dfe5f1;
  --vert: #22a06b;
  --vert-clair: #e3f6ec;
  --rouge: #e5484d;
  --rouge-clair: #fdeaea;
  --orange: #f08c00;
  --bleu: #3b6fe0;
  --violet: #7c5cd6;
  --jaune: #ffc53d;
  --ombre: 0 4px 14px rgba(31, 42, 68, .08);
  --rayon: 18px;
}
* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--bleu); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
h1 { font-size: 1.8rem; margin: .2em 0 .3em; }
h2 { font-size: 1.3rem; }
h3 { margin: 0 0 .5em; }
small { font-size: .8rem; }

/* ---------- barre du haut ---------- */
.barre-haut {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1.4rem; background: #fff; border-bottom: 1px solid var(--ligne);
}
.logo { font-weight: 800; font-size: 1.15rem; color: var(--texte); }
.niveaux { display: flex; gap: .3rem; }
.niv { border: 2px solid var(--ligne); background: #fff; border-radius: 999px; padding: .15rem .8rem; font-weight: 700; }
.niv.on { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.stats { margin-left: auto; display: flex; gap: 1.1rem; align-items: center; font-weight: 700; }
.stats a { color: var(--texte); }

main { max-width: 1060px; margin: 0 auto; padding: 1.2rem 1.4rem 4rem; }

/* ---------- accueil ---------- */
.hero {
  display: grid; grid-template-columns: 1fr; gap: 1rem;
  background: linear-gradient(135deg, #e9efff, #f3ecff); border-radius: var(--rayon);
  padding: 1.3rem 1.5rem; box-shadow: var(--ombre);
}
.hero h1 { margin-top: 0; }
.sous { margin: 0 0 .5rem; color: var(--doux); }
.actions { display: flex; gap: .8rem; flex-wrap: wrap; }
.conseil { color: var(--doux); margin: 1rem .2rem; }
.barre { display: block; height: 10px; background: #e3e8f3; border-radius: 99px; overflow: hidden; }
.barre i { display: block; height: 100%; background: linear-gradient(90deg, var(--vert), #5bd49b); border-radius: 99px; transition: width .4s; }
.hero .barre { max-width: 420px; }

.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.matiere {
  display: flex; flex-direction: column; gap: .35rem; text-align: left;
  background: var(--carte); border: 0; border-radius: var(--rayon); padding: 1.1rem 1.2rem;
  box-shadow: var(--ombre); border-top: 7px solid var(--c); transition: transform .12s;
}
.matiere:hover { transform: translateY(-3px); }
.matiere .ic { font-size: 2.1rem; line-height: 1; }
.matiere .nom { font-size: 1.2rem; font-weight: 800; }
.matiere .info { color: var(--doux); font-size: .85rem; }
.matiere .barre i { background: var(--c); }

/* ---------- gros boutons ---------- */
.gros {
  display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center;
  border: 0; border-radius: 14px; padding: .75rem 1.2rem; font-weight: 800; font-size: 1.05rem;
  color: #fff; background: var(--bleu); box-shadow: var(--ombre); min-height: 3.2rem;
}
.gros small { font-weight: 500; opacity: .9; }
.gros.vert { background: var(--vert); }
.gros.orange { background: var(--orange); }
.gros.bleu { background: var(--bleu); }
.gros.violet { background: var(--violet); }
.gros.gris { background: #8a94ab; }
.gros:hover:not(:disabled) { filter: brightness(1.07); }
.btn {
  border: 2px solid var(--ligne); background: #fff; border-radius: 12px; padding: .45rem .9rem; font-weight: 700;
}
.btn:hover { border-color: var(--bleu); }

/* ---------- matière ---------- */
.fil { margin-bottom: .4rem; color: var(--doux); }
.fil a { font-weight: 700; }
.titre { border-left: 8px solid var(--c, var(--bleu)); padding-left: .7rem; }
.filtres { display: flex; gap: .5rem; flex-wrap: wrap; margin: .6rem 0 1rem; }
.chip { border: 2px solid var(--ligne); background: #fff; border-radius: 999px; padding: .3rem .9rem; font-weight: 700; }
.chip.on { background: var(--texte); border-color: var(--texte); color: #fff; }
.partie { margin: 1.4rem 0 .5rem; color: var(--doux); text-transform: uppercase; letter-spacing: .04em; font-size: 1rem; }
.liste { display: flex; flex-direction: column; gap: .5rem; }
.ligne { display: flex; gap: .5rem; align-items: stretch; }
.ligne .lien {
  flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 1rem; text-align: left;
  background: #fff; border: 2px solid transparent; border-radius: 14px; padding: .7rem 1rem; box-shadow: var(--ombre); font-weight: 600;
}
.ligne .lien:hover { border-color: var(--bleu); }
.ligne.fait .lien { background: #f6fbf8; }
.etoiles { white-space: nowrap; letter-spacing: .05em; }
.etoiles .off { opacity: .22; filter: grayscale(1); }
.fait-btn {
  min-width: 9.5rem; border: 2px dashed #b9c3d8; background: #fff; border-radius: 14px; padding: .4rem .7rem; font-weight: 700; color: var(--doux);
}
.fait-btn.on { border: 2px solid var(--vert); background: var(--vert-clair); color: #146c47; }

/* ---------- chapitre ---------- */
.entete-chap { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .9rem; margin-top: 1rem; }
.mode {
  display: flex; flex-direction: column; gap: .2rem; text-align: left; background: #fff; border: 2px solid transparent;
  border-radius: var(--rayon); padding: 1rem 1.1rem; box-shadow: var(--ombre);
}
.mode:hover { border-color: var(--bleu); }
.mode .ic { font-size: 2rem; }
.mode b { font-size: 1.1rem; }
.mode span { color: var(--doux); font-size: .88rem; }
.record { color: var(--doux); }

/* ---------- leçon ---------- */
.lecon, .texte, .mots { background: #fff; border-radius: var(--rayon); padding: 1.1rem 1.4rem; box-shadow: var(--ombre); margin-bottom: 1rem; }
.lecon ul { margin: 0; padding-left: 1.3rem; }
.lecon li { margin: .45rem 0; font-size: 1.08rem; }
.lecon-tete { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.texte { background: #fffdf5; border: 2px solid #f1e3b3; font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; line-height: 1.7; }
.texte.petit { font-size: .95rem; max-height: 70vh; overflow: auto; margin: 0; }
.mots table { width: 100%; border-collapse: collapse; }
.mots td { padding: .45rem .5rem; border-bottom: 1px solid var(--ligne); vertical-align: top; }
.mots td:first-child { font-weight: 700; width: 40%; }
.say {
  display: inline-block; background: #eef3ff; border: 1px solid #c9d6fb; color: #23408f; border-radius: 8px;
  padding: 0 .35rem; cursor: pointer; font-weight: 600;
}
.say:hover { background: #dfe8ff; }
.bas { margin-top: 1rem; }

/* ---------- jeux ---------- */
.jeu-tete { display: flex; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.jeu-tete .barre { flex: 1; height: 14px; }
.jeu-tete .compte { font-weight: 800; color: var(--doux); white-space: nowrap; }
.tag { display: inline-block; border-left: 6px solid var(--c); background: #fff; padding: .2rem .7rem; border-radius: 8px; margin-bottom: .6rem; color: var(--doux); font-weight: 600; }
.deux { display: grid; grid-template-columns: 1fr 1.15fr; gap: 1rem; align-items: start; }
.carte-q { background: #fff; border-radius: var(--rayon); padding: 1.3rem 1.5rem; box-shadow: var(--ombre); }
.carte-q .type { color: var(--doux); font-weight: 700; font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; }
.carte-q .q { font-size: 1.35rem; font-weight: 700; margin: .4rem 0 1rem; }
.choix { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.choix.vf { grid-template-columns: 1fr 1fr; }
.rep {
  display: flex; align-items: center; gap: .7rem; text-align: left; background: #f7f9fd; border: 3px solid var(--ligne);
  border-radius: 14px; padding: .8rem 1rem; font-size: 1.08rem; font-weight: 600; min-height: 3.4rem;
}
.rep:hover:not(:disabled) { border-color: var(--bleu); background: #fff; }
.rep .num {
  flex: none; display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 8px;
  background: #e3e8f3; font-weight: 800; font-size: .9rem;
}
.rep.bon { border-color: var(--vert); background: var(--vert-clair); }
.rep.faux { border-color: var(--rouge); background: var(--rouge-clair); }
.rep:disabled { opacity: 1; }
.fb { margin-top: 1rem; padding: .8rem 1rem; border-radius: 14px; font-size: 1.08rem; }
.fb p { margin: .35rem 0 0; }
.fb.ok { background: var(--vert-clair); color: #145c3d; font-weight: 700; }
.fb.ok p { font-weight: 500; }
.fb.ko { background: var(--rouge-clair); color: #8b1d22; font-weight: 700; }
.fb.ko p { font-weight: 500; color: var(--texte); }
.suite { margin-top: .9rem; }

/* chrono */
.chrono { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-bottom: 1rem; }
.temps { width: 5.5rem; height: 5.5rem; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; font-weight: 900; color: #fff; background: var(--violet); box-shadow: var(--ombre); }
.temps.urgent { background: var(--rouge); animation: pouls 1s infinite; }
.score-live { font-size: 1.4rem; font-weight: 800; }
@keyframes pouls { 50% { transform: scale(1.07); } }
.flash-ok { animation: flashok .4s; }
.flash-ko { animation: flashko .4s; }
@keyframes flashok { 0% { box-shadow: 0 0 0 6px var(--vert); } }
@keyframes flashko { 0% { box-shadow: 0 0 0 6px var(--rouge); } }

/* cartes mémo */
.scene { perspective: 1200px; max-width: 640px; margin: 0 auto; }
.flip { position: relative; height: 290px; cursor: pointer; transition: transform .55s; transform-style: preserve-3d; }
.flip.retourne { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 22px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .7rem; padding: 1.5rem; text-align: center;
  box-shadow: var(--ombre); font-size: 1.45rem; font-weight: 700;
}
.face small { position: absolute; top: .8rem; left: 1rem; color: var(--doux); font-size: .85rem; text-transform: uppercase; }
.face em { position: absolute; bottom: .8rem; color: var(--doux); font-size: .85rem; font-weight: 500; }
.avant { background: #fff; border: 3px solid var(--ligne); }
.arriere { background: #f1f6ff; border: 3px solid #bcd0fb; transform: rotateY(180deg); }
.boutons { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; margin-top: 1.1rem; }
.cache { visibility: hidden; }

/* memory */
.memo { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; }
.tuile {
  position: relative; min-height: 118px; border-radius: 14px; border: 3px solid var(--ligne); background: var(--violet);
  color: #fff; font-weight: 700; padding: .5rem; display: grid; place-items: center; font-size: .95rem; transition: transform .15s;
}
.tuile .txt { display: none; }
.tuile .dos { font-size: 2rem; }
.tuile.ouverte, .tuile.trouvee { background: #fff; color: var(--texte); }
.tuile.v.ouverte, .tuile.v.trouvee { background: #f1f6ff; }
.tuile.ouverte .txt, .tuile.trouvee .txt { display: block; }
.tuile.ouverte .dos, .tuile.trouvee .dos { display: none; }
.tuile.trouvee { border-color: var(--vert); background: var(--vert-clair) !important; }
.tuile:hover:not(.trouvee) { transform: scale(1.03); }

/* ordre */
.consigne { font-size: 1.2rem; font-weight: 700; margin-bottom: 1rem; }
.ordre { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.ordre ol { background: #fff; border-radius: var(--rayon); box-shadow: var(--ombre); padding: 1rem 1rem 1rem 2.6rem; min-height: 200px; margin: 0; }
.ordre ol li { margin: .35rem 0; font-weight: 600; color: #145c3d; }
.ordre ol:empty::before { content: "Tes réponses vont s'afficher ici, dans l'ordre."; color: var(--doux); font-style: italic; margin-left: -1.6rem; }
.pioche { display: flex; flex-direction: column; gap: .5rem; }
.piece { text-align: left; background: #fff; border: 3px solid var(--ligne); border-radius: 12px; padding: .6rem .9rem; font-weight: 600; }
.piece:hover:not(:disabled) { border-color: var(--bleu); }
.piece.placee { visibility: hidden; height: 0; padding: 0; border: 0; margin: -0.25rem 0; }
.secoue { animation: secoue .45s; border-color: var(--rouge) !important; background: var(--rouge-clair) !important; }
@keyframes secoue { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

/* fin de jeu */
.fin { text-align: center; background: #fff; border-radius: var(--rayon); box-shadow: var(--ombre); padding: 1.6rem; }
.gros-emoji { font-size: 4rem; line-height: 1.1; }
.fin h1 { font-size: 2.4rem; margin: .2rem 0; }
.etoiles.grand { font-size: 2.4rem; }
.pts { font-size: 1.3rem; font-weight: 800; color: var(--orange); }
.fin details { text-align: left; max-width: 760px; margin: 1rem auto 0; background: #f7f9fd; border-radius: 14px; padding: .8rem 1rem; }
.fin summary { font-weight: 800; cursor: pointer; }
.fin li { margin: .55rem 0; }

/* badges, réglages, erreurs */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; }
.badge { background: #fff; border-radius: var(--rayon); padding: 1rem; box-shadow: var(--ombre); text-align: center; }
.badge .ic { font-size: 2.4rem; }
.badge.non { opacity: .45; filter: grayscale(1); }
.badge b { display: block; }
.badge span { color: var(--doux); font-size: .85rem; }
.boite-blanche { background: #fff; border-radius: var(--rayon); padding: 1.1rem 1.4rem; box-shadow: var(--ombre); margin-bottom: 1rem; }
.rangee { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }

/* toasts, modale, confettis */
#toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 50; }
.toast { background: var(--texte); color: #fff; padding: .7rem 1.1rem; border-radius: 12px; box-shadow: var(--ombre); font-weight: 700; animation: monte .3s; }
@keyframes monte { from { transform: translateY(20px); opacity: 0; } }
.fond { position: fixed; inset: 0; background: rgba(20, 28, 48, .45); display: grid; place-items: center; z-index: 60; }
.boite { background: #fff; border-radius: 22px; padding: 1.6rem; max-width: 520px; width: 92%; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.boite .gros-emoji { font-size: 3.2rem; }
.confetti { position: fixed; top: -40px; z-index: 70; font-size: 1.6rem; pointer-events: none; animation: tombe linear forwards; }
@keyframes tombe { to { transform: translateY(110vh) rotate(540deg); } }

@media (max-width: 760px) {
  .deux, .ordre { grid-template-columns: 1fr; }
  .choix { grid-template-columns: 1fr; }
  .memo { grid-template-columns: repeat(3, 1fr); }
  .stats { margin-left: 0; }
}
