:root {
  color-scheme: light;
  --lagon: #0fb5ba; --lagon-f: #0a8f96; --lagon-t: #0a6b70; --lagon-p: #dff6f6;
  --corail: #f2543d; --corail-f: #c93a25; --corail-p: #ffe7e2;
  --soleil: #ffc531; --soleil-f: #d99c00; --soleil-p: #fff3cf;
  --feuille: #1fa968; --feuille-f: #157f4d; --feuille-p: #dcf6e8;
  --lave: #5c2a1e;
  --fond: #fff8ec; --carte: #ffffff; --texte: #23323a; --doux: #5c6d75; --trait: #e7dfd0; --gris: #d9d9d3; --gris-f: #b4b4ad;
  --rayon: 18px;
  --ombre: 0 2px 10px rgba(60, 50, 30, .08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--fond); color: var(--texte);
  font: 16px/1.45 ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.ecran { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.ecran.sans-nav { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* Boutons façon touches de jeu */
.btn {
  display: block; width: 100%; min-height: 52px; padding: 12px 18px; border: 0; border-radius: 16px; cursor: pointer;
  background: var(--lagon); color: #fff; font-weight: 800; font-size: 1.05rem; letter-spacing: .01em;
  box-shadow: 0 4px 0 var(--lagon-f); text-align: center; text-decoration: none; transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--lagon-f); }
.btn:disabled { background: var(--gris); color: #77776f; box-shadow: 0 4px 0 var(--gris-f); cursor: default; transform: none; }
.btn.corail { background: var(--corail); box-shadow: 0 4px 0 var(--corail-f); }
.btn.vert { background: var(--feuille); box-shadow: 0 4px 0 var(--feuille-f); }
.btn.soleil { background: var(--soleil); color: var(--lave); box-shadow: 0 4px 0 var(--soleil-f); }
.btn.clair { background: var(--carte); color: var(--lagon-t); box-shadow: 0 0 0 2px var(--trait) inset, 0 4px 0 var(--trait); }
.lien { background: none; border: 0; padding: 8px; color: var(--lagon-t); font-weight: 700; text-decoration: underline; cursor: pointer; align-self: center; }
:focus-visible { outline: 3px solid var(--lave); outline-offset: 2px; }

.carte { background: var(--carte); border-radius: var(--rayon); padding: 16px; box-shadow: var(--ombre); display: flex; flex-direction: column; gap: 10px; }
.doux { color: var(--doux); font-size: .92rem; }
.centre { text-align: center; }
.titre { font-size: 1.45rem; font-weight: 900; line-height: 1.2; }

/* Connexion */
.logo { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 18px; }
.logo img { width: 92px; height: 92px; }
.logo h1 { font-size: 2.1rem; font-weight: 900; color: var(--lagon-t); letter-spacing: -.01em; }
.logo p { color: var(--doux); text-align: center; }
.onglets { display: grid; grid-template-columns: 1fr 1fr; background: var(--lagon-p); border-radius: 14px; padding: 4px; }
.onglets button { border: 0; background: none; border-radius: 11px; padding: 10px; font-weight: 800; color: var(--lagon-t); cursor: pointer; }
.onglets button.actif { background: #fff; box-shadow: var(--ombre); }
label.champ { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: .95rem; }
input.saisie { width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 13px; border: 2px solid var(--trait); background: #fff; font-size: 1.05rem; }
input.saisie:focus { border-color: var(--lagon); outline: none; }
.erreur { background: var(--corail-p); color: #9c2b19; border-radius: 12px; padding: 10px 12px; font-weight: 700; font-size: .95rem; }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.avatars button { aspect-ratio: 1; font-size: 1.6rem; border-radius: 13px; border: 2px solid var(--trait); background: #fff; cursor: pointer; padding: 0; }
.avatars button.actif { border-color: var(--lagon); background: var(--lagon-p); }
.code-salon { font-size: 2.1rem; font-weight: 900; letter-spacing: .14em; color: var(--lagon-t); background: var(--lagon-p); border-radius: 14px; padding: 12px; text-align: center; user-select: all; }
input.code { text-transform: uppercase; letter-spacing: .2em; text-align: center; font-weight: 800; font-size: 1.4rem; }

/* Barre du haut */
.haut { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stat { display: inline-flex; align-items: center; gap: 4px; font-weight: 900; font-size: 1.02rem; }
.stat.feu { color: #d9610e; } .stat.xp { color: var(--soleil-f); } .stat.coeur { color: var(--corail); }

/* Bannière du défi */
.banniere { background: linear-gradient(120deg, var(--corail), #ff8a3d); color: #fff; border: 0; border-radius: var(--rayon); padding: 14px 16px; text-align: left; cursor: pointer; display: flex; gap: 12px; align-items: center; box-shadow: 0 4px 0 var(--corail-f); width: 100%; }
.banniere:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--corail-f); }
.banniere .emo { font-size: 2rem; line-height: 1; }
.banniere b { display: block; font-size: 1.1rem; font-weight: 900; }
.banniere.fait { background: linear-gradient(120deg, var(--feuille), #39c78a); box-shadow: 0 4px 0 var(--feuille-f); }
.banniere.fait:active { box-shadow: 0 1px 0 var(--feuille-f); }
.banniere.salon { background: linear-gradient(120deg, var(--lagon), #4dcfd2); box-shadow: 0 4px 0 var(--lagon-f); }

/* Carte du parcours */
.niveau-tete { background: var(--lagon); color: #fff; border-radius: var(--rayon); padding: 12px 16px; margin-top: 8px; }
.niveau-tete.verrou { background: #a9b4b4; }
.niveau-tete b { font-size: 1.15rem; font-weight: 900; display: block; }
.niveau-tete span { font-size: .9rem; opacity: .95; }
.chemin { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 8px 0; }
.etape { --dx: 0px; transform: translateX(var(--dx)); display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; cursor: pointer; padding: 0; width: 132px; }
.rond { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 1.9rem; background: var(--lagon); box-shadow: 0 6px 0 var(--lagon-f); transition: transform .06s, box-shadow .06s; }
.etape:active .rond { transform: translateY(4px); box-shadow: 0 2px 0 var(--lagon-f); }
.etape.fini .rond { background: var(--soleil); box-shadow: 0 6px 0 var(--soleil-f); }
.etape.verrou .rond { background: var(--gris); box-shadow: 0 6px 0 var(--gris-f); filter: grayscale(1); opacity: .75; }
.etape.actuelle .rond { animation: pouls 1.8s infinite; }
@keyframes pouls { 0%, 100% { outline: 4px solid rgba(15, 181, 186, .55); outline-offset: 2px; } 50% { outline: 9px solid rgba(15, 181, 186, 0); outline-offset: 6px; } }
.etape small { font-weight: 800; font-size: .85rem; line-height: 1.15; text-align: center; }
.etoiles { color: var(--soleil-f); font-size: .8rem; letter-spacing: 1px; min-height: 1em; }

/* Navigation */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 2px solid var(--trait); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.nav div { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; max-width: 520px; }
.nav button { background: none; border: 0; padding: 8px 2px 9px; cursor: pointer; font-weight: 800; font-size: .76rem; color: var(--doux); display: flex; flex-direction: column; align-items: center; gap: 1px; position: relative; }
.nav button span { font-size: 1.45rem; line-height: 1.2; }
.nav button.actif { color: var(--lagon-t); }
.nav button.actif span { transform: scale(1.12); }
.nav .point { position: absolute; top: 6px; left: calc(50% + 10px); width: 11px; height: 11px; background: var(--corail); border-radius: 50%; border: 2px solid #fff; }

/* Exercice */
.jeu { min-height: 100dvh; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; padding: 12px 16px 0; }
.jeu-haut { display: flex; align-items: center; gap: 10px; }
.fermer { background: none; border: 0; font-size: 1.5rem; color: var(--doux); cursor: pointer; padding: 4px 8px 4px 0; line-height: 1; }
.barre { flex: 1; height: 14px; background: #efe8da; border-radius: 9px; overflow: hidden; }
.barre i { display: block; height: 100%; background: linear-gradient(90deg, var(--feuille), #5bd79a); border-radius: 9px; transition: width .3s; }
.jeu-corps { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 18px 0 16px; }
.enonce { font-size: 1.3rem; font-weight: 900; line-height: 1.25; }
.aide { color: var(--doux); font-weight: 700; }
.choix { display: flex; flex-direction: column; gap: 10px; }
.opt { width: 100%; min-height: 54px; padding: 12px 14px; text-align: left; background: #fff; border: 2px solid var(--trait); border-bottom-width: 5px; border-radius: 15px; font-weight: 700; font-size: 1.05rem; cursor: pointer; }
.opt.choisi { border-color: var(--lagon); background: var(--lagon-p); color: var(--lagon-t); }
.opt:disabled { cursor: default; }
.phrase { font-size: 1.3rem; font-weight: 800; background: #fff; padding: 14px; border-radius: 15px; border: 2px solid var(--trait); }
.phrase .blanc { display: inline-block; min-width: 72px; border-bottom: 3px solid var(--lagon); color: var(--lagon-t); text-align: center; padding: 0 6px; }
.zone-mots { min-height: 64px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; padding: 8px 0 12px; border-bottom: 2px solid var(--trait); }
.banque { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-top: 6px; }
.mot { padding: 10px 14px; background: #fff; border: 2px solid var(--trait); border-bottom-width: 4px; border-radius: 12px; font-weight: 800; cursor: pointer; font-size: 1.02rem; }
.mot.vide { visibility: hidden; }
.paires { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.paires .col { display: flex; flex-direction: column; gap: 9px; }
.paire { min-height: 56px; padding: 8px; background: #fff; border: 2px solid var(--trait); border-bottom-width: 4px; border-radius: 13px; font-weight: 800; cursor: pointer; font-size: .98rem; line-height: 1.15; }
.paire.choisi { border-color: var(--lagon); background: var(--lagon-p); }
.paire.lie { color: #fff; border-color: transparent; }
.lie-0 { background: #0a8f96 !important; } .lie-1 { background: #c2571d !important; } .lie-2 { background: #6b4bb5 !important; } .lie-3 { background: #157f4d !important; } .lie-4 { background: #b02a6b !important; }
.jeu-bas { position: sticky; bottom: 0; background: var(--fond); padding: 10px 0 calc(14px + env(safe-area-inset-bottom)); }
.retour { margin: 0 -16px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; animation: monte .18s ease-out; }
@keyframes monte { from { transform: translateY(30px); opacity: 0; } }
.retour.bon { background: var(--feuille-p); color: #0f5e39; }
.retour.mal { background: var(--corail-p); color: #8e2513; }
.retour b { font-size: 1.15rem; font-weight: 900; }
.retour .note { font-size: .95rem; font-weight: 600; }

/* Mots de la leçon */
.vocab { display: flex; flex-direction: column; gap: 0; }
.vocab div { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--trait); }
.vocab div:last-child { border: 0; }
.vocab .kr { font-weight: 800; color: var(--lagon-t); }

/* Fin de leçon et résultats */
.fin { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px; text-align: center; padding: 24px 0; }
.grosse-emo { font-size: 4.2rem; line-height: 1; }
.grosses-etoiles { font-size: 2.4rem; color: var(--soleil); letter-spacing: 4px; }
.grosses-etoiles .eteinte { color: var(--gris); }
.gains { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.gain { background: #fff; border: 2px solid var(--trait); border-radius: 14px; padding: 9px 14px; font-weight: 900; }
.badge-gagne { display: flex; align-items: center; gap: 10px; background: var(--soleil-p); border-radius: 14px; padding: 10px 14px; text-align: left; width: 100%; }
.badge-gagne span { font-size: 1.8rem; }
.confetti { position: fixed; top: -14px; width: 10px; height: 14px; z-index: 20; pointer-events: none; animation: tombe linear forwards; }
@keyframes tombe { to { transform: translateY(105vh) rotate(540deg); } }

/* Classement */
.duel { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; text-align: center; }
.joueuse .av { font-size: 2.3rem; line-height: 1.1; }
.joueuse b { display: block; font-weight: 900; overflow-wrap: anywhere; }
.score { font-size: 2rem; font-weight: 900; color: var(--lagon-t); }
.vs { font-weight: 900; color: var(--doux); }
.etat-joueuse { font-size: .82rem; color: var(--doux); font-weight: 700; }
.ligne-cl { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--fond); }
.ligne-cl.moi { background: var(--lagon-p); }
.ligne-cl .rang { font-weight: 900; font-size: 1.1rem; width: 26px; text-align: center; }
.ligne-cl .av { font-size: 1.6rem; }
.ligne-cl .nom { flex: 1; min-width: 0; font-weight: 800; }
.ligne-cl .nom small { display: block; font-weight: 700; color: var(--doux); }
.ligne-cl .pts { font-weight: 900; color: var(--soleil-f); white-space: nowrap; }
.sous-titre { font-weight: 900; font-size: 1.1rem; }
.histo { width: 100%; background: var(--fond); border: 0; border-radius: 13px; padding: 10px 12px; display: flex; justify-content: space-between; gap: 8px; align-items: center; cursor: pointer; font-weight: 700; text-align: left; }
.correction { border-radius: 13px; padding: 11px 12px; background: var(--feuille-p); display: flex; flex-direction: column; gap: 3px; }
.correction.mal { background: var(--corail-p); }
.correction .q { font-weight: 800; }
.correction small { color: var(--doux); }

/* Profil */
.tuiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tuile { background: var(--fond); border-radius: 14px; padding: 12px; text-align: center; }
.tuile b { display: block; font-size: 1.4rem; font-weight: 900; }
.tuile span { font-size: .85rem; color: var(--doux); font-weight: 700; }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.badge { text-align: center; padding: 9px 4px; border-radius: 13px; background: var(--soleil-p); }
.badge span { font-size: 1.8rem; display: block; line-height: 1.2; }
.badge b { font-size: .8rem; display: block; line-height: 1.15; }
.badge small { font-size: .7rem; color: var(--doux); display: block; line-height: 1.15; margin-top: 2px; }
.badge.non { background: #f1eee6; }
.badge.non span { filter: grayscale(1); opacity: .4; }

#toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--lave); color: #fff; padding: 10px 16px; border-radius: 13px; font-weight: 700; opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; width: max-content; text-align: center; z-index: 30; }
#toast.vu { opacity: 1; transform: translate(-50%, 0); }
.chargement { min-height: 70dvh; display: grid; place-items: center; font-size: 3rem; animation: tourne 1.6s ease-in-out infinite; }
@keyframes tourne { 50% { transform: scale(1.18) rotate(8deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
