/* =========================================================
   Học tiếng Việt — thème « Bao cấp » (Hanoï d'autrefois)
   Source unique des couleurs, polices et composants.
   ========================================================= */

@import url("https://fonts.googleapis.com/css2?family=Bitter:wght@500;700;800&family=Be+Vietnam+Pro:wght@400;500;600&family=Patrick+Hand&display=swap");

:root {
  /* Papier et encre */
  --htv-papier: #EFE4C8;
  --htv-papier-clair: #F7F0DE;
  --htv-papier-fonce: #DCCDA6;
  --htv-papier-eteint: #EADFC3;
  --htv-encre: #2A2620;
  --htv-texte-2: #4A443A;
  --htv-texte-3: #5E584C;
  --htv-pointille: #8C7A58;

  /* Couleurs de l'époque */
  --htv-olive: #4F5D33;
  --htv-olive-fonce: #2E3A22;
  --htv-rouge: #A8322A;
  --htv-rouge-fonce: #7E2219;
  --htv-bois: #6E4630;
  --htv-bois-clair: #8C5A3C;
  --htv-tableau: #2F3A2A;
  --htv-craie: #F3E9CF;
  --htv-craie-2: #E8D9B5;
  --htv-succes-fond: #DDE6C8;
  --htv-succes: #2B4A27;
  --htv-erreur-fond: #F3D9D2;

  /* Les 6 tons — fond clair */
  --ton-ngang: #5E584C;
  --ton-huyen: #2E5A87;
  --ton-sac: #A8322A;
  --ton-hoi: #8A5E0E;
  --ton-nga: #3F6B3A;
  --ton-nang: #5B3A6B;

  /* Polices */
  --htv-titre: "Bitter", Georgia, serif;
  --htv-texte: "Be Vietnam Pro", "Noto Sans", system-ui, sans-serif;
  --htv-main: "Patrick Hand", "Comic Neue", cursive;

  /* Formes */
  --htv-trait: 2px solid var(--htv-encre);
  --htv-rayon: 4px;
  --htv-ombre: 5px 5px 0 var(--htv-encre);
  --htv-ombre-olive: 6px 6px 0 var(--htv-olive);
  --htv-largeur: 1180px;
  --htv-rayon-tuile: 6px;

  /* Mouvement — durées et courbes uniques pour tout le site (CSS et JS via getComputedStyle) */
  --htv-duree-rapide: 180ms;
  --htv-duree: 420ms;
  --htv-duree-lente: 800ms;
  --htv-ressort: cubic-bezier(.34, 1.56, .64, 1); /* rebond */
  --htv-sortie: cubic-bezier(.22, 1, .36, 1);     /* douce */

  /* Grain de papier : bruit SVG en niveaux de gris, posé en calque fixe (voir body::after) */
  --htv-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.4 -.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  --htv-grain-opacite: .05;

  /* Couleur du mur de l'illustration du café (cafe-hero.svg), pour la prolonger */
  --htv-illu-mur: var(--htv-craie-2);

  /* Le Hà Nội du soir (jeux) : nuit plus sombre que le tableau noir */
  --htv-nuit: #1F261B;
}

/* Les tons sur tableau noir, et le soir (jeux) */
.tableau, .mode-soiree {
  --ton-ngang: #F3E9CF;
  --ton-huyen: #9DBFE3;
  --ton-sac: #F0A48F;
  --ton-hoi: #E8C277;
  --ton-nga: #A9CF94;
  --ton-nang: #C9A6DA;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--htv-papier);
  color: var(--htv-encre);
  font-family: var(--htv-texte);
  font-size: 16px;
  line-height: 1.6;
}
h1, h2, h3 { font-family: var(--htv-titre); font-weight: 700; color: var(--htv-olive-fonce); line-height: 1.1; margin: 0; }
h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.25rem); }
h3 { font-size: 1.375rem; color: var(--htv-encre); }
/* Grain de papier sur tout le site : calque fixe, ne capte aucun clic */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 1000; pointer-events: none;
  background-image: var(--htv-grain); background-size: 220px 220px;
  opacity: var(--htv-grain-opacite);
}
a { color: var(--htv-rouge); }
a:hover { color: var(--htv-rouge-fonce); }
:focus-visible { outline: 3px solid var(--htv-rouge); outline-offset: 2px; }

.conteneur { max-width: var(--htv-largeur); margin: 0 auto; padding: 0 24px; }
.manuscrit { font-family: var(--htv-main); color: var(--htv-rouge); font-size: 1.4rem; }
.discret { color: var(--htv-texte-3); }

/* ---------- Tons ---------- */
.ton-ngang { color: var(--ton-ngang); }
.ton-huyen { color: var(--ton-huyen); }
.ton-sac   { color: var(--ton-sac); }
.ton-hoi   { color: var(--ton-hoi); }
.ton-nga   { color: var(--ton-nga); }
.ton-nang  { color: var(--ton-nang); }

/* ---------- En-tête ---------- */
.entete { background: var(--htv-olive); border-bottom: 4px solid var(--htv-olive-fonce); }
.entete .conteneur { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-block: 14px; }
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.plaque { background: var(--htv-rouge); padding: 4px; border-radius: var(--htv-rayon); }
.plaque > span {
  display: flex; align-items: center; gap: 10px;
  border: 2px solid var(--htv-craie); border-radius: 2px; padding: 4px 14px;
  font-family: var(--htv-titre); font-weight: 700; font-size: 1.25rem; letter-spacing: .06em; color: var(--htv-craie);
}
.logo .manuscrit { color: var(--htv-craie-2); font-size: 1.25rem; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a { color: var(--htv-craie); text-decoration: none; padding: 10px 16px; border-radius: var(--htv-rayon); font-weight: 500; font-size: .95rem; }
.nav a:hover { background: var(--htv-olive-fonce); color: var(--htv-craie); }
.nav a[aria-current="page"] { background: var(--htv-craie); color: var(--htv-encre); }

/* ---------- Pied de page ---------- */
.pied { background: var(--htv-olive-fonce); color: var(--htv-craie-2); border-top: 4px solid var(--htv-olive); font-size: .875rem; }
.pied .conteneur { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-block: 22px; }

/* ---------- Sections ---------- */
.section { padding: 40px 0 56px; border-top: var(--htv-trait); }
.section-tete { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.section-tete p { margin: 4px 0 0; color: var(--htv-texte-2); }

/* ---------- Boutons ---------- */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 22px;
  font: 600 1rem var(--htv-texte); text-decoration: none; cursor: pointer;
  background: var(--htv-papier-clair); color: var(--htv-encre);
  border: var(--htv-trait); border-radius: var(--htv-rayon);
}
.bouton:hover { background: var(--htv-papier-fonce); color: var(--htv-encre); }
.bouton--principal { background: var(--htv-rouge); color: var(--htv-papier-clair); box-shadow: 3px 3px 0 var(--htv-encre); }
.bouton--principal:hover { background: var(--htv-rouge-fonce); color: var(--htv-papier-clair); }
.bouton--principal:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--htv-encre); }
.bouton, .ticket, .carte-ton { transition: transform var(--htv-duree-rapide) var(--htv-sortie); }
.bouton-audio {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  border: var(--htv-trait); background: transparent; color: inherit; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.tableau .bouton-audio { border-color: var(--htv-craie); }

/* ---------- Barre de progression ---------- */
.progression { height: 12px; background: var(--htv-papier-fonce); border: 1.5px solid var(--htv-encre); border-radius: 2px; overflow: hidden; }
.progression > span { display: block; height: 100%; background: var(--htv-olive); }
.progression--rouge > span { background: var(--htv-rouge); }

/* ---------- Carte papier ---------- */
.carte { background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon); padding: 24px 28px; }
.carte--ombre { box-shadow: var(--htv-ombre-olive); }

/* ---------- Ticket de leçon (tem phiếu) ---------- */
.tickets { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.ticket {
  position: relative; display: flex; flex-direction: column;
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon);
  padding: 10px; color: var(--htv-encre); text-decoration: none;
}
.ticket__interieur { border: 1.5px dashed var(--htv-pointille); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ticket__numero { display: flex; justify-content: space-between; font: 700 .8rem var(--htv-titre); letter-spacing: .1em; color: var(--htv-texte-3); }
.ticket__image { background: #EFE2C2; border: 1.5px solid var(--htv-encre); }
.ticket__image img { display: block; width: 100%; height: auto; }
.ticket__pied { border-top: 1.5px dashed var(--htv-pointille); padding-top: 8px; font-size: .875rem; font-weight: 600; }
.ticket--encours { border: 3px solid var(--htv-rouge); padding: 9px; box-shadow: var(--htv-ombre); }
.ticket--encours .ticket__numero { color: var(--htv-rouge); }
.ticket--verrou { background: var(--htv-papier-eteint); border-color: var(--htv-pointille); }
.ticket:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--htv-encre); }

/* Tampon « ĐÃ HỌC » */
.tampon {
  position: absolute; right: 18px; top: 112px; transform: rotate(-14deg);
  width: 74px; height: 74px; border: 3px solid var(--htv-rouge); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font: 700 .875rem/1.1 var(--htv-titre); color: var(--htv-rouge);
  background: rgba(247, 240, 222, .8);
}

/* Onde d'encre au moment où le tampon touche le papier (js/animations.js) */
.tampon-onde {
  position: absolute; right: 18px; top: 112px; width: 74px; height: 74px;
  border: 2px solid var(--htv-rouge); border-radius: 50%; opacity: 0; pointer-events: none;
}

/* ---------- Tableau noir ---------- */
.tableau {
  background: var(--htv-tableau); color: var(--htv-craie);
  border: 10px solid var(--htv-bois); border-radius: var(--htv-rayon);
  padding: 28px 32px; box-shadow: 6px 6px 0 var(--htv-encre);
  font-family: var(--htv-main);
}
.tableau .grand { font-size: clamp(2.5rem, 6vw, 4rem); line-height: 1.05; margin: 0; }

/* ---------- Calendrier à feuilles (lịch bóc) ---------- */
.calendrier { background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon); overflow: hidden; }
.calendrier__tete { background: var(--htv-rouge); color: var(--htv-papier-clair); padding: 12px 24px; border-bottom: var(--htv-trait); font: 700 1rem var(--htv-titre); letter-spacing: .08em; }
.calendrier__chiffre { font: 700 6.5rem/1 var(--htv-titre); color: var(--htv-rouge); }

/* ---------- Carte de ton ---------- */
.tons { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.carte-ton {
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon);
  padding: 0 0 16px; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; font: inherit; color: inherit;
}
.carte-ton::before { content: ""; width: 100%; height: 8px; background: currentColor; }
.carte-ton__nom { font-size: .8rem; font-weight: 600; letter-spacing: .08em; padding-top: 8px; }
.carte-ton__mot { font: 700 3rem/1.1 var(--htv-titre); }
.carte-ton__sens { font-size: .95rem; color: var(--htv-texte-2); }

/* ---------- Dialogue ---------- */
.replique { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; border: var(--htv-trait);
  display: flex; align-items: center; justify-content: center;
  font: 700 1rem var(--htv-titre); color: var(--htv-craie); background: var(--htv-olive);
}
.avatar--moi { background: var(--htv-rouge); }
.replique__vi { margin: 0; font-size: 1.25rem; font-weight: 500; }
.replique__fr { margin: 0; font-size: .95rem; color: var(--htv-texte-3); }

/* ---------- Quiz ---------- */
.choix { display: flex; gap: 12px; flex-wrap: wrap; }
.choix button {
  min-width: 120px; min-height: 48px; padding: 10px 22px; cursor: pointer;
  font: 700 1.375rem var(--htv-titre); background: var(--htv-papier-clair); color: var(--htv-encre);
  border: var(--htv-trait); border-radius: var(--htv-rayon);
}
.choix button[data-etat="bon"] { background: var(--ton-nga); color: var(--htv-papier-clair); }
.choix button[data-etat="faux"] { background: var(--htv-rouge); color: var(--htv-papier-clair); }
.retour { margin: 0; padding: 12px 16px; font-weight: 500; overflow-wrap: anywhere; } /* chemins de fichiers longs dans les messages d'erreur */
.retour--bon { background: var(--htv-succes-fond); border: 1.5px solid var(--ton-nga); color: var(--htv-succes); }
.retour--faux { background: var(--htv-erreur-fond); border: 1.5px solid var(--htv-rouge); color: var(--htv-rouge-fonce); }

/* ---------- Animations des illustrations ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =========================================================
   Composants des pages (accueil, leçon) — mêmes variables
   ========================================================= */

/* ---------- Utilitaires ---------- */
[hidden] { display: none !important; }
.visuellement-cache {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
main { display: block; }
.fil { padding: 18px 0 0; font-size: .95rem; }
.fil a { font-weight: 600; text-decoration: none; }
.fil a:hover { text-decoration: underline; }
.etiquette { font: 700 .8rem var(--htv-titre); letter-spacing: .12em; color: var(--htv-texte-3); text-transform: uppercase; }
.lien-fleche { font-weight: 600; text-decoration: none; }
.lien-fleche:hover { text-decoration: underline; }
.message-erreur { margin: 40px 0; }

/* ---------- Bouton audio : états ---------- */
.bouton-audio:hover { background: var(--htv-papier-fonce); }
.tableau .bouton-audio:hover { background: var(--htv-olive-fonce); }
.bouton-audio[data-etat="lecture"] { background: var(--htv-olive); color: var(--htv-craie); }
.bouton-audio[data-etat="indispo"] { border-style: dashed; opacity: .55; }

/* ---------- Annonce (zone aria-live) ---------- */
.annonce {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 10;
  max-width: calc(100% - 32px); padding: 12px 18px;
  background: var(--htv-encre); color: var(--htv-papier-clair);
  border-radius: var(--htv-rayon); box-shadow: 4px 4px 0 var(--htv-rouge);
  font-weight: 500; font-size: .95rem;
}
.annonce:empty, .annonce[data-visible="non"] { display: none; }

/* ---------- Accueil : la une ---------- */
.une { padding: 44px 0 52px; }
.une .conteneur { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; }
.une__titre { margin: 6px 0 12px; }
.une__intro { margin: 0 0 24px; font-size: 1.1rem; color: var(--htv-texte-2); max-width: 34em; }
.une__illustration { border: var(--htv-trait); border-radius: var(--htv-rayon); box-shadow: var(--htv-ombre); background: var(--htv-papier-clair); overflow: hidden; }
.une__illustration img { display: block; width: 100%; height: auto; }
.reprise { display: flex; flex-direction: column; gap: 12px; }
.reprise__titre { font: 700 1.5rem var(--htv-titre); margin: 0; }
.reprise__fr { margin: 0; color: var(--htv-texte-2); }
.reprise__ligne { display: flex; align-items: center; gap: 12px; font-size: .9rem; color: var(--htv-texte-3); }
.reprise__ligne .progression { flex: 1; }

/* ---------- Accueil : mot du jour + série ---------- */
.duo { display: grid; grid-template-columns: 2fr 1fr; gap: 28px; align-items: stretch; }
.mot-jour__tete { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--htv-craie-2); font-size: 1.25rem; }
.mot-jour__ligne { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 12px 0 8px; }
.mot-jour__fr { margin: 0; font-size: 1.6rem; }
.mot-jour__note { margin: 6px 0 0; font-size: 1.15rem; color: var(--htv-craie-2); }
.calendrier__corps { padding: 18px 24px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.calendrier__texte { margin: 0; font-weight: 600; }
.calendrier__date { margin: 8px 0 0; font-family: var(--htv-main); font-size: 1.2rem; color: var(--htv-texte-3); }

/* ---------- Tickets : compléments ---------- */
.ticket__titre { margin: 0; font: 700 1.5rem var(--htv-titre); }
.ticket__fr { margin: 0; color: var(--htv-texte-2); font-size: .95rem; }
.ticket--verrou { color: var(--htv-texte-3); cursor: default; }
.ticket--verrou .ticket__image { opacity: .55; }
.ticket--verrou:hover { transform: none; box-shadow: none; }
.ticket--encours:hover { box-shadow: 7px 7px 0 var(--htv-encre); }
.ticket .tampon { pointer-events: none; }

/* ---------- Page leçon : en-tête ---------- */
.lecon-tete { padding: 18px 0 32px; }
.lecon-tete__grille { display: grid; grid-template-columns: 1fr 300px; gap: 32px; align-items: center; }
.lecon-tete h1 { margin: 6px 0 10px; }
.lecon-tete__fr { margin: 0 0 18px; font-size: 1.1rem; color: var(--htv-texte-2); }
.lecon-tete__image { margin: 0; background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon); padding: 8px; box-shadow: var(--htv-ombre); }
.lecon-tete__image img { display: block; width: 100%; height: auto; border: 1.5px dashed var(--htv-pointille); }
.lecon-tete__avance { display: flex; align-items: center; gap: 12px; font-size: .9rem; color: var(--htv-texte-3); max-width: 480px; }
.lecon-tete__avance .progression { flex: 1; }

/* ---------- Page leçon : étapes ---------- */
.etapes { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 24px; padding: 0; list-style: none; counter-reset: etape; }
.etapes button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px; cursor: pointer;
  font: 600 .95rem var(--htv-texte); color: var(--htv-encre);
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon);
}
.etapes button::before {
  counter-increment: etape; content: counter(etape);
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border: 1.5px solid currentColor; border-radius: 50%; font: 700 .8rem var(--htv-titre);
}
.etapes button:hover { background: var(--htv-papier-fonce); }
.etapes button[data-faite] { color: var(--htv-olive-fonce); border-color: var(--htv-olive); }
.etapes button[aria-current="step"] { background: var(--htv-olive); color: var(--htv-craie); border-color: var(--htv-olive-fonce); box-shadow: 3px 3px 0 var(--htv-encre); }

.panneau { min-height: 280px; }
.panneau > h2 { margin-bottom: 6px; }
.panneau__intro { margin: 0 0 24px; color: var(--htv-texte-2); }
.navigation-etapes { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 24px 0 56px; }

/* ---------- Vocabulaire ---------- */
.vocab { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
.vocab__item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--htv-papier); border: var(--htv-trait); border-radius: var(--htv-rayon); }
.vocab__texte { min-width: 0; }
.vocab__vi { margin: 0; font: 700 1.5rem/1.2 var(--htv-titre); }
.vocab__fr { margin: 0; }
.vocab__note { margin: 2px 0 0; font-family: var(--htv-main); font-size: 1.1rem; color: var(--htv-rouge); }

/* ---------- Prononciation ---------- */
.legende-tons { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 24px; padding: 12px 16px; list-style: none; border: 1.5px dashed var(--htv-pointille); border-radius: var(--htv-rayon); font-size: .9rem; }
.legende-tons li { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.legende-tons li::before { content: ""; width: 14px; height: 14px; border-radius: 2px; background: currentColor; border: 1px solid var(--htv-encre); }
.pron { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.pron__ligne { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1.5px dashed var(--htv-pointille); }
.pron__ligne:last-child { border-bottom: 0; }
.pron__fr { flex: 1; min-width: 120px; color: var(--htv-texte-2); }
.syllabes { display: flex; gap: 8px; flex-wrap: wrap; }
.syllabe {
  display: inline-flex; flex-direction: column; align-items: center; min-width: 64px; padding: 6px 10px; cursor: pointer;
  background: var(--htv-papier-clair); color: inherit; font: inherit;
  border: 2px solid currentColor; border-radius: var(--htv-rayon);
}
.syllabe:hover { background: var(--htv-papier-fonce); }
.syllabe__mot { font: 700 1.5rem/1.1 var(--htv-titre); }
.syllabe__ton { font-size: .75rem; font-weight: 600; letter-spacing: .04em; }

/* ---------- Dialogue ---------- */
.dialogue { display: flex; flex-direction: column; gap: 18px; margin: 0 0 24px; padding: 0; list-style: none; }
.replique__bulle { flex: 1; min-width: 0; }
.replique__nom { margin: 0 0 2px; font-size: .8rem; font-weight: 600; letter-spacing: .06em; color: var(--htv-texte-3); text-transform: uppercase; }
.replique--moi { flex-direction: row-reverse; text-align: right; }
.dialogue[data-traduction="cachee"] .replique__fr { visibility: hidden; }
.astuces { display: flex; flex-direction: column; gap: 10px; margin: 24px 0 0; padding: 16px 20px; list-style: none; border-left: 4px solid var(--htv-rouge); background: var(--htv-papier); }
.astuces li { font-family: var(--htv-main); font-size: 1.25rem; line-height: 1.35; }
.astuces li::before { content: "Astuce — "; color: var(--htv-rouge); }

/* ---------- Écoute et quiz ---------- */
.exercice { display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.exercice__compteur { margin: 0; }
.exercice__question { margin: 0; font-size: 1.2rem; font-weight: 500; }
.ecoute__outils { display: flex; gap: 12px; flex-wrap: wrap; }
.ecoute__bouton { gap: 12px; }
.ecoute__bouton svg { width: 24px; height: 24px; }
.choix button[data-etat] [class^="ton-"] { color: inherit; }
.choix button:disabled { cursor: default; }
.choix button:not(:disabled):hover { background: var(--htv-papier-fonce); }
.indice { margin: 0; font-family: var(--htv-main); font-size: 1.25rem; color: var(--htv-rouge); }

/* ---------- Fin de leçon ---------- */
.fin { position: relative; text-align: center; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.fin__ticket { width: min(300px, 100%); text-align: left; box-shadow: var(--htv-ombre); }
.fin__ticket:hover { transform: none; box-shadow: var(--htv-ombre); }
.fin__ticket .tampon, .fin__ticket .tampon-onde { width: 92px; height: 92px; top: 96px; }
.fin__ticket .tampon { font-size: 1.05rem; }
.fin__actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ---------- Téléphone ---------- */
@media (max-width: 860px) {
  .une .conteneur, .duo, .lecon-tete__grille { grid-template-columns: 1fr; }
  .lecon-tete__image { max-width: 340px; }
}
@media (max-width: 600px) {
  .conteneur { padding: 0 16px; }
  .carte { padding: 18px 16px; }
  .tableau { padding: 20px 18px; border-width: 8px; }
  .nav a { padding: 8px 10px; }
  .replique--moi { flex-direction: row; text-align: left; }
  .calendrier__chiffre { font-size: 5rem; }
}

/* ---------- Pages tons et vocabulaire : en-tête court ---------- */
.une--courte { padding: 36px 0 32px; }
.une--courte .une__simple { display: block; }
.une--courte .une__intro { margin-bottom: 0; }
.une--courte h1 { margin: 4px 0 12px; }

/* ---------- Fiches des tons ---------- */
.fiches-tons { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.fiche-ton {
  display: flex; flex-direction: column; gap: 8px; padding: 0 20px 18px;
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon); overflow: hidden;
}
.fiche-ton::before { content: ""; display: block; height: 8px; margin: 0 -20px 6px; background: currentColor; }
.fiche-ton__tete { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.fiche-ton__tete h3 { font-size: 1.3rem; }
.fiche-ton__tete .bouton-audio { color: var(--htv-encre); }
.fiche-ton__corps { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fiche-ton__mot { margin: 0; font: 700 3.5rem/1 var(--htv-titre); }
.fiche-ton__sens { margin: 0; font-family: var(--htv-main); font-size: 1.3rem; color: var(--htv-rouge); }
.fiche-ton__desc { margin: 0; color: var(--htv-encre); }
.fiche-ton__marque { margin: 0; font-size: .9rem; }
.contour { width: 120px; height: 70px; flex-shrink: 0; }
.contour__grille { stroke: var(--htv-pointille); stroke-width: 1; stroke-dasharray: 2 3; }
.contour__ligne { fill: none; stroke: currentColor; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.contour__coupure { stroke: var(--htv-encre); stroke-width: 3; stroke-linecap: round; }

/* ---------- Exercice des tons ---------- */
.choix-tons { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; width: 100%; }
.choix-ton {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px; padding: 10px; cursor: pointer;
  background: var(--htv-papier-clair); color: inherit; font: inherit;
  border: 2px solid currentColor; border-radius: var(--htv-rayon); box-shadow: 3px 3px 0 currentColor;
}
.choix-ton:not(:disabled):hover { background: var(--htv-papier-fonce); }
.choix-ton:disabled { cursor: default; }
.choix-ton__nom { font: 700 1.15rem var(--htv-titre); }
.choix-ton__ex { font-size: .95rem; }
.choix-ton[data-etat="bon"] { background: var(--htv-succes-fond); outline: 3px solid var(--ton-nga); outline-offset: 2px; }
.choix-ton[data-etat="faux"] { background: var(--htv-erreur-fond); outline: 3px solid var(--htv-rouge); outline-offset: 2px; }

/* ---------- Réglages (pastilles à bascule) ---------- */
.reglages { display: flex; flex-direction: column; gap: 16px; margin-bottom: 28px; }
.reglages__groupe { display: flex; flex-direction: column; gap: 8px; }
.pastilles { display: flex; gap: 8px; flex-wrap: wrap; }
.pastilles button {
  min-height: 44px; padding: 8px 16px; cursor: pointer;
  font: 600 .95rem var(--htv-texte); color: var(--htv-encre);
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: 999px;
}
.pastilles button:hover { background: var(--htv-papier-fonce); }
.pastilles button[aria-pressed="true"] { background: var(--htv-encre); color: var(--htv-papier-clair); }
.pastilles button[aria-pressed="true"] [class^="ton-"] { color: inherit; }

/* ---------- Flashcards ---------- */
.zone-cartes { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.flashcard {
  position: relative; width: 100%; min-height: 260px; padding: 14px;
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon); box-shadow: var(--htv-ombre-olive);
}
.flashcard::after { content: ""; position: absolute; inset: 10px; border: 1.5px dashed var(--htv-pointille); pointer-events: none; }
.flashcard__coin { position: absolute; top: 18px; right: 22px; }
.flashcard__face { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 110px; padding: 28px 16px 8px; text-align: center; position: relative; z-index: 1; }
.flashcard__verso { border-top: 1.5px dashed var(--htv-pointille); margin: 8px 16px 0; position: relative; z-index: 1; text-align: center; }
.flashcard__vi { margin: 0; font: 700 clamp(2.2rem, 7vw, 3.5rem)/1.1 var(--htv-titre); }
.flashcard__fr { margin: 0; font-size: 1.5rem; font-weight: 500; }
.flashcard__note { margin: 0 0 12px; font-family: var(--htv-main); font-size: 1.2rem; color: var(--htv-rouge); }
.flashcard__actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.flashcard__stats { margin: 0; font-size: .9rem; }
.bilan { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.bilan p { margin: 0; }
.bilan__liste { margin: 0; padding-left: 20px; }
.bilan__liste span { font-weight: 600; }

/* =========================================================
   Accueil « rétro moderne » : grille bento + typographie expressive
   ========================================================= */
.bento {
  display: grid; gap: clamp(16px, 2.2vw, 28px);
  padding-block: clamp(28px, 5vw, 64px) 72px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-areas:
    "titre   titre   titre   titre   cafe  cafe"
    "reprise reprise reprise defi    defi  defi"
    "reprise reprise reprise mot     mot   serie"
    "tons    tons    tons    tons    tons  tons"
    "lecons  lecons  lecons  lecons  lecons lecons";
}
.tuile--titre   { grid-area: titre; }
.tuile--reprise { grid-area: reprise; }
.tuile--cafe    { grid-area: cafe; }
.tuile--mot     { grid-area: mot; }
.tuile--serie   { grid-area: serie; }
.tuile--tons    { grid-area: tons; }
.tuile--defi    { grid-area: defi; }
.tuile--lecons  { grid-area: lecons; margin-top: clamp(16px, 4vw, 48px); }
.bento > * { min-width: 0; }

.tuile {
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon-tuile);
  padding: clamp(20px, 2.5vw, 32px);
}
.bento .tableau, .bento .calendrier { border-radius: var(--htv-rayon-tuile); }
.tuile__tete { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; }
.tuile__intro { margin: 6px 0 18px; color: var(--htv-texte-2); max-width: 36em; }

/* Titre géant */
.tuile--titre { align-self: end; padding-top: 4px; }
.surtitre {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin: 0 0 clamp(12px, 2vw, 24px); padding-top: 10px; border-top: var(--htv-trait);
  font: 700 .8rem var(--htv-titre); letter-spacing: .14em; text-transform: uppercase; color: var(--htv-texte-3);
}
.surtitre__main { font: 400 1.3rem var(--htv-main); letter-spacing: 0; text-transform: none; }
.titre-geant {
  margin: 0; font-family: var(--htv-titre); font-weight: 800;
  font-size: clamp(3rem, 8vw, 7rem); line-height: .95; letter-spacing: -.03em;
}
.titre-geant__ligne { display: block; }
.titre-geant__ligne + .titre-geant__ligne { padding-left: .55em; } /* décalage façon affiche */
.tuile--titre__intro { margin: clamp(16px, 2.5vw, 28px) 0 0; max-width: 32em; font-size: 1.15rem; color: var(--htv-texte-2); }
.tuile--titre__intro .manuscrit { display: block; margin-bottom: 2px; }

/* Reprise : la tuile vedette */
.tuile--reprise {
  display: flex; flex-direction: column; justify-content: flex-end; gap: 14px;
  box-shadow: var(--htv-ombre-olive); position: relative; overflow: hidden;
}
.reprise__numero {
  font: 800 clamp(6rem, 13vw, 11rem)/.8 var(--htv-titre); letter-spacing: -.04em;
  color: transparent; -webkit-text-stroke: 2px var(--htv-rouge);
  padding-bottom: 12px;
}
/* En-tête de la reprise : grand numéro + illustration de la leçon, posée comme une photo */
.reprise__tete { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: auto; }
.reprise__image { width: min(48%, 260px); flex-shrink: 0; transform: rotate(2deg); box-shadow: 4px 4px 0 var(--htv-encre); }
/* Les étapes de la leçon, cochées au fil de l'avancement */
.reprise__etapes { display: grid; gap: 6px; margin: 4px 0; padding: 0; list-style: none; counter-reset: etape; }
.reprise__etapes li {
  display: flex; align-items: center; gap: 12px; padding: 7px 12px;
  border: 1.5px dashed var(--htv-pointille); border-radius: var(--htv-rayon); counter-increment: etape;
}
.reprise__etapes li::before {
  content: counter(etape); flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 .8rem var(--htv-titre); border: 1.5px solid var(--htv-encre);
}
.reprise__etape { flex: 1; font-weight: 600; }
.reprise__etat { font: 700 .72rem var(--htv-titre); letter-spacing: .1em; text-transform: uppercase; color: var(--htv-texte-3); }
.reprise__etapes li[data-etat="faite"] { border-style: solid; border-color: var(--htv-olive); }
.reprise__etapes li[data-etat="faite"]::before { background: var(--htv-olive); border-color: var(--htv-olive-fonce); color: var(--htv-craie); }
.reprise__etapes li[data-etat="faite"] .reprise__etat { color: var(--htv-olive-fonce); }
.reprise__etapes li[data-etat="en cours"] { border: 2px solid var(--htv-rouge); box-shadow: 3px 3px 0 var(--htv-encre); }
.reprise__etapes li[data-etat="en cours"]::before { background: var(--htv-rouge); border-color: var(--htv-rouge-fonce); color: var(--htv-papier-clair); }
.reprise__etapes li[data-etat="en cours"] .reprise__etat { color: var(--htv-rouge); }
.tuile--reprise .reprise__titre { font: 800 clamp(2rem, 4vw, 3.25rem)/1 var(--htv-titre); letter-spacing: -.02em; }
.tuile--reprise .reprise__fr { font-size: 1.1rem; }

/* Illustration */
/* Illustration du café : jamais rognée (contain), calée en bas ; la place en trop au-dessus
   prolonge le mur de l'image. */
.illustration--mur { background: var(--htv-illu-mur); }
.illustration--mur img { object-fit: contain; object-position: center bottom; }
.tuile--cafe { margin: 0; padding: 0; overflow: hidden; display: flex; }
.tuile--cafe img { display: block; width: 100%; height: 100%; }

/* Mot du jour et série dans la grille */
.tuile--mot { display: flex; flex-direction: column; justify-content: center; }
.tuile--serie { display: flex; flex-direction: column; }
.tuile--serie .calendrier__corps { flex: 1; justify-content: center; padding-inline: 12px; }
.tuile--serie .calendrier__chiffre { font-size: clamp(4.5rem, 7vw, 6.5rem); }

/* Tons */
.titre-tuile { font: 800 clamp(1.6rem, 2.5vw, 2.25rem)/1 var(--htv-titre); letter-spacing: -.01em; }
.tons--bento { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 1001px) { .tons--bento { grid-template-columns: repeat(6, minmax(0, 1fr)); } } /* tons sur toute la largeur */
.tons--bento .carte-ton__mot { font-size: clamp(2rem, 3vw, 2.6rem); }

/* Leçons : grand titre de section */
.tuile__tete--section { align-items: flex-end; padding-top: 12px; border-top: var(--htv-trait); margin-bottom: 24px; }
.titre-section { font: 800 clamp(2.5rem, 6vw, 5rem)/.9 var(--htv-titre); letter-spacing: -.03em; }
.tuile__tete--section .tuile__intro { margin: 0; }

/* Tablette : deux colonnes */
@media (max-width: 1000px) {
  .bento {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "titre   titre"
      "reprise cafe"
      "mot     serie"
      "defi    defi"
      "tons    tons"
      "lecons  lecons";
  }
}
/* Téléphone : une colonne, dans l'ordre de lecture */
@media (max-width: 640px) {
  .bento {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "titre" "reprise" "defi" "mot" "serie" "tons" "cafe" "lecons";
  }
  .titre-geant__ligne + .titre-geant__ligne { padding-left: 0; }
  .tuile--cafe img { height: auto; }
}
@media (max-width: 380px) {
  .tons--bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =========================================================
   Tableau de bord (index.html) : toutes les langues
   ========================================================= */

/* Couleur d'accent d'une langue (champ « couleur » de data/langues.json), prise dans la palette */
.accent-rouge { --accent: var(--htv-rouge); }
.accent-olive { --accent: var(--htv-olive); }
.accent-bois  { --accent: var(--htv-bois); }
.accent-bleu  { --accent: var(--ton-huyen); }
.accent-prune { --accent: var(--ton-nang); }
.accent-ocre  { --accent: var(--ton-hoi); }

.bento--tableau {
  grid-template-areas:
    "titre   titre   titre   titre   serie    serie"
    "langues langues langues langues revision revision"
    "langues langues langues langues semaine  semaine";
  grid-template-rows: auto auto 1fr;
}
.tuile--langues  { grid-area: langues; }
.tuile--revision { grid-area: revision; }
.tuile--semaine  { grid-area: semaine; }
.bento--tableau .tuile--serie { align-self: end; }

/* Cartes des langues */
.langues { display: grid; gap: clamp(16px, 2vw, 24px); }
.carte-langue {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon-tuile);
  box-shadow: 6px 6px 0 var(--accent, var(--htv-olive)); overflow: hidden;
}
.carte-langue__image { border-right: var(--htv-trait); }
.carte-langue__image img { display: block; width: 100%; height: 100%; }
.carte-langue__corps { display: flex; flex-direction: column; gap: 14px; padding: clamp(20px, 2.5vw, 32px); min-width: 0; }
.carte-langue__surtitre { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 12px; flex-wrap: wrap; margin: 0; }
.carte-langue__surtitre .manuscrit { font-size: 1.25rem; letter-spacing: 0; text-transform: none; }
.carte-langue__nom { margin: 0; font: 800 clamp(2.4rem, 5vw, 4rem)/.95 var(--htv-titre); letter-spacing: -.03em; }
.carte-langue__accroche { margin: 0; color: var(--htv-texte-2); }
.carte-langue__recompense { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; margin: 0; }
.carte-langue__titre-joueur { font: 400 1.2rem var(--htv-main); color: var(--htv-texte-2); }
.carte-langue__lecon {
  display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 12px 14px;
  border: 1.5px dashed var(--htv-pointille); border-radius: var(--htv-rayon);
}
.carte-langue__titre-lecon { font: 700 1.5rem/1.15 var(--htv-titre); }
.carte-langue__actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: auto; }
.progression--accent > span { background: var(--accent, var(--htv-olive)); }

.carte-langue--bientot {
  grid-template-columns: minmax(0, 1fr); background: var(--htv-papier-eteint);
  border: 2px dashed var(--htv-pointille); box-shadow: none; color: var(--htv-texte-3);
}
.carte-langue--bientot .carte-langue__nom { color: var(--htv-texte-3); font-size: clamp(1.8rem, 3vw, 2.4rem); }
.carte-langue--ajout .carte-langue__corps { gap: 4px; padding-block: 16px; }
.carte-langue--ajout p { margin: 0; }

/* À réviser aujourd'hui (tableau noir) */
.tuile--revision { display: flex; flex-direction: column; gap: 10px; border-radius: var(--htv-rayon-tuile); }
.revision__titre { margin: 0; font: 400 1.35rem var(--htv-main); color: var(--htv-craie-2); }
.revision__chiffre { display: flex; align-items: baseline; gap: 12px; margin: 0; }
.revision__chiffre .grand { font-size: clamp(3.5rem, 7vw, 5.5rem); }
.revision__unite { font-size: 1.6rem; }
.revision__liste { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 0; padding: 10px 0 0; list-style: none; border-top: 1.5px dashed var(--htv-craie-2); }
.revision__liste li { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; font-size: 1.25rem; }
.revision__langue { font: 700 1.3rem var(--htv-titre); }
.revision__nombre { color: var(--htv-craie-2); }
.lien-craie { margin-left: auto; color: var(--htv-craie); font-weight: 400; }
.lien-craie:hover { color: var(--htv-papier-clair); }
.tableau :focus-visible { outline-color: var(--htv-craie); }

/* Activité de la semaine : sept colonnes empilées par langue */
.tuile--semaine { display: flex; flex-direction: column; }
.tuile--semaine .tuile__intro { margin-bottom: 14px; }
.semaine { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin: auto 0 0; padding: 0; list-style: none; }
.semaine__jour { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.semaine__colonne {
  display: flex; flex-direction: column-reverse; width: 100%; height: 96px; margin-bottom: 4px;
  border: 1.5px solid var(--htv-encre); border-radius: 2px; background: var(--htv-papier); overflow: hidden;
}
.semaine__part { display: block; width: 100%; background: var(--accent, var(--htv-olive)); }
.semaine__part + .semaine__part { border-bottom: 1.5px solid var(--htv-papier-clair); }
.semaine__jour--vide .semaine__colonne { border-style: dashed; border-color: var(--htv-pointille); }
.semaine__nombre { font: 700 .95rem var(--htv-titre); }
.semaine__nom { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--htv-texte-3); }
.semaine__date { font-family: var(--htv-main); font-size: 1.1rem; color: var(--htv-texte-3); }
.semaine__jour--auj .semaine__colonne { border: 2px solid var(--htv-rouge); box-shadow: 3px 3px 0 var(--htv-encre); }
.semaine__jour--auj .semaine__nom, .semaine__jour--auj .semaine__date { color: var(--htv-rouge); }
.semaine__legende { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 14px 0 0; padding: 0; list-style: none; font-size: .9rem; font-weight: 600; }
.semaine__legende li { display: flex; align-items: center; gap: 6px; }
.semaine__legende li::before { content: ""; width: 14px; height: 14px; border: 1px solid var(--htv-encre); border-radius: 2px; background: var(--accent); }

@media (max-width: 1000px) {
  .bento--tableau {
    grid-template-areas:
      "titre    titre"
      "serie    revision"
      "langues  langues"
      "semaine  semaine";
    grid-template-rows: none;
  }
  .bento--tableau .tuile--serie { align-self: stretch; }
}
@media (max-width: 760px) {
  .carte-langue { grid-template-columns: minmax(0, 1fr); }
  .carte-langue__image { border-right: 0; border-bottom: var(--htv-trait); }
  .carte-langue__image img { height: auto; }
}
@media (max-width: 640px) {
  .bento--tableau { grid-template-areas: "titre" "langues" "revision" "serie" "semaine"; }
  .semaine { gap: 4px; }
  .semaine__colonne { height: 72px; }
}

/* =========================================================
   Jeux : le « mode soirée » (le Hà Nội du soir) — voir CLAUDE.md « Mise en scène »
   Les leçons sont le jour (papier crème) ; les jeux, le soir : nuit, lanternes, lumière chaude.
   ========================================================= */
.mode-soiree {
  --soir-fond: var(--htv-nuit);
  --soir-fond-2: var(--htv-tableau);
  --soir-carte: #2A3324;
  --soir-trait: #4A5440;
  --soir-texte: var(--htv-craie);
  --soir-texte-2: #D8CCAE;
  --soir-texte-3: #A89E86;
  --soir-lumiere: #E8C277;      /* lumière chaude des lanternes */
  --soir-rouge: #C8453A;        /* rouge émail sous la lumière du soir */
  --soir-rouge-clair: #F0A48F;
  --soir-bon: #A9CF94;
  --lanterne-1: #E8B33A; --lanterne-1-cote: #B5821C;
  --lanterne-2: #C2477A; --lanterne-2-cote: #8E2C57;
  --lanterne-3: #C8453A; --lanterne-3-cote: #8E2A22;
  --lanterne-4: #3E8C6E; --lanterne-4-cote: #26604A;
  --lanterne-5: #E07A36; --lanterne-5-cote: #A8531E;
  --lanterne-6: #7A4E9A; --lanterne-6-cote: #553570;
  --lanterne-laiton: #B88A2A;
  --soir-ombre: #0E120C;        /* ombres décalées pleines, version nuit */
  background: var(--soir-fond);
  color: var(--soir-texte);
}
.mode-soiree h1, .mode-soiree h2, .mode-soiree h3 { color: var(--soir-texte); }
.mode-soiree a { color: var(--soir-lumiere); }
.mode-soiree a:hover { color: var(--soir-texte); }
.mode-soiree :focus-visible { outline-color: var(--soir-lumiere); }

/* Lanternes (dessinées par HTVEntracte.lanternes) : elles se balancent doucement */
.lanternes { position: absolute; left: 0; top: 0; width: 100%; height: 190px; pointer-events: none; }
.lanternes__corde { fill: none; stroke: var(--htv-bois); stroke-width: 2; }
.lanterne { transform-box: fill-box; transform-origin: top center; animation: lanterne-balance 3.2s ease-in-out infinite; }
.lanterne:nth-of-type(3n+2) { animation-duration: 3.8s; animation-delay: -1.1s; }
.lanterne:nth-of-type(3n) { animation-delay: -2s; }
@keyframes lanterne-balance { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
.lanterne__halo { fill: var(--l); opacity: .2; animation: lanterne-halo 2.4s ease-in-out infinite; }
@keyframes lanterne-halo { 0%, 100% { opacity: .14; } 50% { opacity: .28; } }
.lanterne__fil { stroke: var(--htv-bois); stroke-width: 2; }
.lanterne__corps { fill: var(--l); stroke: var(--htv-encre); stroke-width: 2; }
.lanterne__cote { fill: none; stroke: var(--c); stroke-width: 1.6; }
.lanterne__reflet { fill: var(--htv-papier-clair); opacity: .45; }
.lanterne__laiton { fill: var(--lanterne-laiton); stroke: var(--htv-encre); stroke-width: 1.5; }
.lanterne__pompon { fill: none; stroke: var(--soir-rouge); stroke-width: 2; stroke-linecap: round; }
.lanterne--1 { --l: var(--lanterne-1); --c: var(--lanterne-1-cote); }
.lanterne--2 { --l: var(--lanterne-2); --c: var(--lanterne-2-cote); }
.lanterne--3 { --l: var(--lanterne-3); --c: var(--lanterne-3-cote); }
.lanterne--4 { --l: var(--lanterne-4); --c: var(--lanterne-4-cote); }
.lanterne--5 { --l: var(--lanterne-5); --c: var(--lanterne-5-cote); }
.lanterne--6 { --l: var(--lanterne-6); --c: var(--lanterne-6-cote); }

/* Boutons du soir */
.bouton-soir {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 14px 22px; cursor: pointer; text-decoration: none;
  font: 600 1rem var(--htv-texte); color: var(--htv-papier-clair);
  background: var(--soir-rouge); border: 2px solid var(--soir-texte); border-radius: 6px;
  box-shadow: 4px 4px 0 var(--soir-ombre);
}
.mode-soiree a.bouton-soir, .mode-soiree a.bouton-soir:hover { color: var(--htv-papier-clair); }
.bouton-soir:hover { background: var(--htv-rouge); }
.bouton-soir:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--soir-ombre); }
.bouton-soir--discret { background: transparent; color: var(--soir-lumiere); border-color: var(--soir-trait); box-shadow: none; }
.bouton-soir--discret:hover { background: var(--soir-carte); }
.lien-soir {
  min-height: 44px; padding: 10px 4px; background: none; border: 0; cursor: pointer;
  font: inherit; font-size: .9rem; color: var(--soir-texte-3); text-decoration: underline;
}
.lien-soir:hover { color: var(--soir-texte); }

/* ---------- Entracte : la cérémonie (js/jeux/entracte.js) ---------- */
.entracte { position: fixed; inset: 0; z-index: 900; display: flex; justify-content: center; background: transparent; }
.entracte__voile { position: absolute; inset: 0; background: var(--soir-fond); }
.entracte__cadre {
  position: relative; width: 100%; max-width: 600px; height: 100%; overflow-x: hidden; overflow-y: auto;
  display: flex; flex-direction: column; padding: 16px 20px max(16px, env(safe-area-inset-bottom));
}
.entracte__cadre > .lanternes { height: 190px; transition: opacity var(--htv-duree) var(--htv-sortie); }
/* Pendant le jeu, les lanternes s'effacent : rien ne doit gêner la lecture (comme sur la maquette) */
.entracte__cadre[data-phase="jeu"] > .lanternes { opacity: 0; }
.entracte__scene { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.entracte__son { position: absolute; top: 12px; right: 12px; z-index: 2; }
.entracte__pied { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: auto; padding-top: 12px; min-height: 60px; }
/* Pendant l'entracte, la page recule : la transformation est posée par HTVAnimations.reculerPage */
.page-reculee { transform-origin: 50% 0; }

/* Entrée */
.entree { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding-top: 170px; }
.entree__surtitre { margin: 0; font: 400 1.5rem var(--htv-main); color: var(--soir-lumiere); }
.entree__titre { margin: 0; font: 800 clamp(3.2rem, 16vw, 5rem)/1 var(--htv-titre); letter-spacing: -.01em; }
.lettre { display: inline-block; white-space: pre; }
.entree__sous-titre { margin: 6px 0 0; color: var(--soir-texte-2); }
.compte {
  margin-top: 30px; width: 160px; height: 160px; border-radius: 50%; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--soir-fond); color: var(--soir-rouge-clair);
  border: 5px solid var(--soir-rouge); transform: rotate(-8deg); font: inherit;
}
.compte__chiffre { font: 700 5.25rem/.9 var(--htv-titre); }
.compte__mot { font: 700 .8rem var(--htv-titre); letter-spacing: .14em; }

/* Confettis de papier (HTVAnimations.confettis) */
.confettis { position: absolute; left: 50%; top: 40%; width: 0; height: 0; pointer-events: none; }
.confetti { position: absolute; left: -4px; top: -6px; width: 8px; height: 12px; background: currentColor; }

/* Sortie */
.sortie { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 180px; }
.sortie__titre { margin: 0; font: 800 clamp(2.8rem, 13vw, 3.6rem)/1 var(--htv-titre); }
.mode-soiree .sortie__titre { color: var(--soir-lumiere); }
.sortie__traduction { margin: 6px 0 0; font: 400 1.4rem var(--htv-main); color: var(--soir-texte-2); }
.etoiles { display: flex; gap: 14px; margin: 24px 0 10px; padding: 0; list-style: none; }
.etoile {
  width: 78px; height: 78px; border-radius: 50%; border: 4px solid var(--soir-rouge);
  display: flex; align-items: center; justify-content: center; transform: rotate(-8deg);
}
.etoile svg { width: 40px; height: 40px; }
.etoile path { fill: var(--soir-rouge-clair); }
.etoile--vide { border: 4px dashed var(--soir-trait); }
.etoile--vide path { fill: none; stroke: var(--soir-trait); stroke-width: 1.5; }
.sortie__score { margin: 0; color: var(--soir-texte-2); }
.sortie__score strong { font: 700 1.6rem var(--htv-titre); color: var(--soir-texte); }
.sortie__tickets { position: relative; width: 240px; height: 84px; margin: 18px auto 0; }
.tem {
  position: absolute; top: 12px; width: 92px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  background: var(--htv-papier); color: var(--htv-encre);
  border: 2px dashed var(--htv-pointille); outline: 2px solid var(--htv-encre);
  font: 700 .75rem var(--htv-titre); letter-spacing: .08em;
}
.sortie__gain { margin: 8px 0 0; font: 400 1.4rem var(--htv-main); color: var(--soir-lumiere); }
.bandeau {
  width: 100%; margin-top: 18px; padding: 12px 16px; display: flex; gap: 12px; align-items: center; text-align: left;
  background: var(--htv-papier); color: var(--htv-encre); border: 2px solid var(--htv-encre); border-radius: 6px;
}
.bandeau p { margin: 0; }
.bandeau__titre { font-weight: 600; }
.bandeau__texte { font-size: .9rem; color: var(--htv-texte-2); }
.sortie__conseil { margin: 16px 0 0; font-size: .9rem; color: var(--soir-texte-2); }
.sortie__conseil [class^="ton-"] { font-weight: 700; }
.sortie__details { width: 100%; margin-top: 18px; text-align: left; }
.sortie__actions { width: 100%; margin-top: auto; padding-top: 22px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- Bắt thanh (js/jeux/bat-thanh.js) ---------- */
.bt { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.bt__tete { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-right: 52px; }
.bt__nom { margin: 0; font: 700 1.15rem var(--htv-titre); }
.bt__numero { margin: 0; font-size: .8rem; color: var(--soir-texte-3); }
.bt__compteurs { display: flex; align-items: center; gap: 12px; }
.bt__points { margin: 0; text-align: right; font: 700 1.6rem/1 var(--htv-titre); color: var(--soir-lumiere); }
.bt__points small { display: block; font: 600 .65rem var(--htv-texte); letter-spacing: .08em; color: var(--soir-texte-3); }
.combo {
  min-width: 3.2em; padding: 2px 10px; text-align: center; transform: rotate(-6deg);
  border: 3px solid var(--soir-rouge); border-radius: 6px; font: 700 1.6rem var(--htv-titre); color: var(--soir-rouge-clair);
}
.combo[data-niveau="4"] { background: var(--soir-rouge); color: var(--htv-papier-clair); }
/* La mèche de lanterne qui se consume (chrono) */
.meche { display: block; width: 100%; height: 28px; overflow: visible; }
.meche__boucle { fill: none; stroke: var(--htv-bois); stroke-width: 2; }
.meche__corde { fill: var(--soir-lumiere); transform-box: fill-box; transform-origin: left center; }
.meche__flamme { fill: var(--soir-lumiere); }
.meche__coeur { fill: var(--soir-rouge-clair); }
.meche__vacille { transform-box: fill-box; transform-origin: center bottom; animation: vacille .35s ease-in-out infinite alternate; }
@keyframes vacille { from { transform: scale(1, 1); } to { transform: scale(.85, 1.15); } }
.meche[data-etat="eteinte"] .meche__flamme, .meche[data-etat="eteinte"] .meche__coeur { opacity: 0; }
.bt__suite { display: flex; gap: 6px; justify-content: center; margin: 0; padding: 0; list-style: none; }
.bt__suite li { flex: 1 1 0; max-width: 26px; height: 6px; border-radius: 3px; background: var(--soir-trait); }
.bt__suite li[data-etat="bon"] { background: var(--soir-bon); }
.bt__suite li[data-etat="faux"] { background: var(--soir-rouge-clair); }
.bt__suite li[data-etat="courant"] { background: var(--soir-lumiere); }
.bt__ecoute { position: relative; width: 124px; height: 124px; margin: 4px auto 0; flex-shrink: 0; }
.bt__onde { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--soir-lumiere); animation: onde 1.6s ease-out infinite; }
@keyframes onde { 0% { transform: scale(.8); opacity: .6; } 100% { transform: scale(1.5); opacity: 0; } }
.bt__ecouter {
  position: absolute; inset: 0; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: var(--soir-fond-2); color: var(--soir-texte); border: 3px solid var(--soir-texte);
}
.bt__ecouter svg { width: 50px; height: 50px; }
.bt__consigne { margin: 0; text-align: center; font: 400 1.25rem var(--htv-main); color: var(--soir-texte-2); }
.bt__tons { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 520px) { .bt__tons { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.bouton-ton {
  min-height: 72px; padding: 8px; cursor: pointer; font: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--soir-carte); border: 2px solid currentColor; border-radius: 8px;
}
.bouton-ton__mot { font: 700 1.6rem/1 var(--htv-titre); }
.bouton-ton__nom { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.bouton-ton__touche { font-size: .7rem; color: var(--soir-texte-3); }
.bouton-ton:not(:disabled):hover { background: var(--soir-fond-2); }
.bouton-ton:disabled { cursor: default; }
.bouton-ton[data-etat="bon"] { background: currentColor; }
.bouton-ton[data-etat="bon"] > * { color: var(--soir-fond); }
.bouton-ton[data-etat="faux"] { border-style: dashed; opacity: .6; }
.bouton-ton[data-etat="eteint"] { color: var(--soir-texte-3); border-color: var(--soir-trait); }
.bt__retour { min-height: 56px; margin: 0; text-align: center; line-height: 1.5; }
.bt__retour--bon { font: 400 1.6rem var(--htv-main); color: var(--soir-bon); }
.bt__retour--faux { color: var(--soir-texte-2); }
.bt__retour--info { font-size: .85rem; color: var(--soir-texte-3); }
.bt__syllabe { font: 700 1.35rem var(--htv-titre); }
.bt__retour .bouton-audio { width: 40px; height: 40px; margin-left: 6px; vertical-align: middle; border-color: var(--soir-texte-2); }

/* ---------- Xếp câu, phrase en désordre (js/jeux/phrase.js) ---------- */
.xc__sens { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.xc__qui { margin: 0; font-size: .8rem; font-weight: 600; letter-spacing: .04em; color: var(--soir-texte-3); }
.xc__fr { margin: 0; font: 400 1.35rem/1.3 var(--htv-main); color: var(--soir-texte-2); }
/* La phrase en construction : une ligne d'écriture, comme sur un cahier */
.xc__ligne {
  position: relative; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 10px; min-height: 80px; padding: 10px 8px 14px;
  border-bottom: 2px solid var(--soir-lumiere); background: var(--soir-fond-2); border-radius: 6px 6px 0 0;
}
.xc__ligne[data-vide="true"]::before {
  content: "Touche ou glisse les mots ici"; align-self: center; width: 100%; text-align: center;
  font: 400 1.2rem var(--htv-main); color: var(--soir-texte-3);
}
.xc__reserve { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 64px; padding: 6px 0; }
.xc__mot {
  min-height: 56px; min-width: 56px; padding: 6px 14px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  font: 700 1.4rem/1 var(--htv-titre); background: var(--soir-carte); color: var(--soir-texte);
  border: 2px solid var(--soir-trait); border-radius: 8px; box-shadow: 3px 3px 0 var(--soir-ombre);
}
.xc__mot:not(:disabled):hover { border-color: var(--soir-lumiere); }
.xc__mot:focus-visible { outline: 3px solid var(--soir-lumiere); outline-offset: 2px; }
.xc__mot[data-glisse] { position: relative; z-index: 3; cursor: grabbing; border-color: var(--soir-lumiere); box-shadow: 6px 6px 0 var(--soir-ombre); }
.xc__mot[data-etat="bien"] { border-color: var(--soir-bon); }
.xc__mot[data-etat="faux"] { border-style: dashed; border-color: var(--soir-rouge-clair); }
.xc__mot[data-etat="bon"] { border-color: var(--soir-bon); box-shadow: 3px 3px 0 var(--soir-bon); }
.xc__mot[data-etat="corrige"] { border-color: var(--soir-lumiere); }
.xc__mot:disabled { cursor: default; }
.xc__repere { width: 4px; align-self: stretch; min-height: 48px; border-radius: 2px; background: var(--soir-lumiere); }
.xc__correction { padding: 12px 14px; background: var(--soir-carte); border: 2px solid var(--soir-trait); border-radius: 8px; }
.xc__correction[hidden] { display: none; }
.xc__phrase { display: flex; align-items: center; gap: 10px; }
.xc__vi { flex: 1; margin: 0; font: 700 1.3rem/1.45 var(--htv-titre); }
.xc__traduction { margin: 4px 0 0; color: var(--soir-texte-2); }
.xc__phrase .bouton-audio { flex-shrink: 0; border-color: var(--soir-texte-2); color: var(--soir-texte); }
.xc .bt__retour { min-height: 0; }
.xc .bt__retour--bon { font-size: 1.4rem; }

/* Statistiques par ton (fin de partie, page des jeux) */
.stats-tons { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.stats-tons li { display: grid; grid-template-columns: 4.6em 1fr auto; align-items: center; gap: 10px; font-size: .85rem; }
.stats-tons__nom { font: 700 1rem var(--htv-titre); }
.stats-tons__barre { height: 10px; border-radius: 5px; background: var(--soir-trait); overflow: hidden; }
.stats-tons__barre span { display: block; height: 100%; background: currentColor; }
.stats-tons__chiffre { color: var(--soir-texte-2); white-space: nowrap; }
.stats-tons__confusion { grid-column: 2 / -1; margin-top: -4px; color: var(--soir-texte-3); font-size: .8rem; }

/* ---------- En-tête : tem phiếu et bouton son (js/recompenses.js) ---------- */
.entete__outils { display: flex; align-items: center; gap: 10px; }
.compteur-tem {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; text-decoration: none;
  background: var(--htv-papier); color: var(--htv-encre);
  border: 2px dashed var(--htv-pointille); outline: 2px solid var(--htv-encre);
  font: 700 .7rem var(--htv-titre); letter-spacing: .08em;
}
.compteur-tem:hover { color: var(--htv-encre); background: var(--htv-papier-clair); }
.compteur-tem__solde { font-size: 1.15rem; letter-spacing: 0; color: var(--htv-rouge); }
.bouton-son {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--htv-craie); border: 2px solid var(--htv-craie);
}
.bouton-son:hover { background: var(--htv-olive-fonce); }
.bouton-son[aria-pressed="false"] { border-style: dashed; opacity: .75; }
.mode-soiree .bouton-son { color: var(--soir-texte-2); border-color: var(--soir-trait); }
.mode-soiree .bouton-son:hover { background: var(--soir-carte); }

/* ---------- Mode « mot à mot » (HTV.motAMot dans js/commun.js) ---------- */
.bouton-mots {
  flex-shrink: 0; min-height: 44px; padding: 0 14px; border-radius: 22px; cursor: pointer;
  background: transparent; color: var(--htv-craie); border: 2px dashed var(--htv-craie); opacity: .75;
  font: 700 .75rem var(--htv-titre); letter-spacing: .08em; text-transform: uppercase;
}
.bouton-mots:hover { background: var(--htv-olive-fonce); }
.bouton-mots[aria-pressed="true"] { border-style: solid; opacity: 1; background: var(--htv-craie); color: var(--htv-encre); }
.mode-soiree .bouton-mots { color: var(--soir-texte-2); border-color: var(--soir-trait); }
.mode-soiree .bouton-mots[aria-pressed="true"] { background: var(--soir-carte); color: var(--soir-texte-2); }
.mot {
  display: inline; margin: 0; padding: 0 1px; font: inherit; line-height: inherit; letter-spacing: inherit;
  color: inherit; background: none; border: 0; border-bottom: 2px dotted var(--htv-pointille); border-radius: 2px;
  cursor: pointer; transition: background-color var(--htv-duree-rapide) var(--htv-sortie);
}
.mot:hover, .mot:focus-visible { background: var(--htv-papier); border-bottom-style: solid; }
.mot:focus-visible { outline: 2px solid var(--htv-encre); outline-offset: 1px; }
.mot[data-etat="lecture"] { background: var(--htv-craie); border-bottom-color: var(--htv-rouge); }
.mot[data-etat="indispo"] { border-bottom-style: dashed; }
.mode-soiree .mot { border-bottom-color: var(--soir-trait); }
.mode-soiree .mot:hover, .mode-soiree .mot:focus-visible { background: var(--soir-carte); }
.mode-soiree .mot:focus-visible { outline-color: var(--soir-lumiere); }
.mode-soiree .mot[data-etat="lecture"] { background: var(--soir-carte); border-bottom-color: var(--soir-lumiere); }

/* Bulle de traduction du mode mot à mot (une seule, posée en position fixe par commun.js) */
.bulle-mot {
  position: fixed; z-index: 950; left: 0; top: 0; max-width: 320px; padding: 8px 12px 9px;
  display: flex; flex-direction: column; gap: 2px; pointer-events: none;
  background: var(--htv-papier-clair); color: var(--htv-encre);
  border: 2px solid var(--htv-encre); border-radius: 4px; box-shadow: 4px 4px 0 var(--htv-encre);
  font: 400 .95rem/1.35 var(--htv-texte); text-align: left;
  animation: bulle-mot-entree var(--htv-duree-rapide) var(--htv-sortie);
}
.bulle-mot[hidden] { display: none; }
.bulle-mot::after { /* petite pointe vers le mot */
  content: ""; position: absolute; left: var(--fleche, 50%); width: 10px; height: 10px; margin-left: -5px;
  background: inherit; border: 2px solid var(--htv-encre); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.bulle-mot[data-cote="dessus"]::after { bottom: -7px; }
.bulle-mot[data-cote="dessous"]::after { top: -7px; transform: rotate(225deg); }
.bulle-mot__vi { font: 700 1rem var(--htv-titre); }
.bulle-mot__fr { font-weight: 600; }
.bulle-mot__note { font: 400 1rem/1.25 var(--htv-main); color: var(--htv-bois); }
.bulle-mot.mode-soiree { background: var(--soir-carte); color: var(--soir-texte); border-color: var(--soir-lumiere); box-shadow: 4px 4px 0 var(--soir-ombre); }
.bulle-mot.mode-soiree::after { border-color: var(--soir-lumiere); }
.bulle-mot.mode-soiree .bulle-mot__note { color: var(--soir-texte-3); }
@keyframes bulle-mot-entree { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .bulle-mot { animation: none; } }

/* ---------- Page des jeux (jeux.html) ---------- */
body[data-page="jeux"] { background: var(--htv-nuit); }
.salle { position: relative; padding: 190px 0 72px; overflow: hidden; }
.salle__tete { position: relative; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.salle__tete .manuscrit { color: var(--soir-lumiere); margin: 0; }
.salle__tete .titre-geant { font-size: clamp(3.2rem, 10vw, 6rem); }
.salle__intro { margin: 0; max-width: 34em; color: var(--soir-texte-2); }
.salle__tem { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.salle__titre-joueur { margin: 0; font: 400 1.3rem var(--htv-main); color: var(--soir-texte-2); }
.jeux { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin: 44px 0 0; padding: 0; list-style: none; }
.carte-jeu {
  display: flex; flex-direction: column; gap: 10px; padding: 22px;
  background: var(--soir-carte); border: 2px solid var(--soir-trait); border-radius: 6px; box-shadow: 5px 5px 0 var(--soir-ombre);
}
.carte-jeu--actif { border-color: var(--soir-lumiere); }
.carte-jeu--bientot { border-style: dashed; box-shadow: none; opacity: .7; }
.carte-jeu__nom { margin: 0; font: 800 1.9rem/1 var(--htv-titre); }
.carte-jeu__fr { margin: 0; font: 400 1.2rem var(--htv-main); color: var(--soir-lumiere); }
.carte-jeu__texte { margin: 0; color: var(--soir-texte-2); font-size: .95rem; }
.carte-jeu__record { margin: 0; font-size: .85rem; color: var(--soir-texte-3); }
.carte-jeu .bouton-soir { margin-top: auto; align-self: flex-start; }
.carte-jeu__bientot { margin-top: auto; font: 700 .75rem var(--htv-titre); letter-spacing: .12em; color: var(--soir-texte-3); }
.salle__stats { margin-top: 44px; padding: 22px; border: 2px solid var(--soir-trait); border-radius: 6px; }
.salle__stats h2 { font-size: 1.5rem; margin-bottom: 4px; }
.salle__stats > p { margin: 0 0 16px; color: var(--soir-texte-3); font-size: .9rem; }
@media (max-width: 600px) {
  .salle { padding-top: 180px; }
  .entete__outils { margin-left: auto; }
}

/* ---------- Constellation des mots (constellation.html, js/jeux/constellation.js) ---------- */
/* Le ciel fait toute la page (sous l'en-tête) ; titre, réglages, légende et fiche flottent par-dessus.
   Couleurs lues par le canvas : les changer ici, jamais dans le JS */
.constellation {
  --const-appris: var(--soir-lumiere);       /* étoile allumée */
  --const-encours: var(--soir-rouge-clair);  /* en cours */
  --const-decouvrir: var(--soir-texte-3);    /* à découvrir : petit point pâle */
  --const-trait: var(--soir-texte-2);        /* trait entre deux mots qui partagent une syllabe */
  --const-trait-fort: var(--soir-lumiere);   /* traits du mot choisi */
  --const-fond-etoile: var(--soir-texte);    /* étoiles de décor */
  --const-voile: color-mix(in srgb, var(--htv-nuit) 82%, transparent); /* fond des éléments flottants */
  padding-bottom: 72px;
}
body[data-page="constellation"] { background: var(--htv-nuit); }
.constellation__ciel {
  position: relative; overflow: hidden; background: var(--htv-nuit);
  height: calc(100vh - var(--haut-entete, 120px)); height: calc(100dvh - var(--haut-entete, 120px)); min-height: 420px;
  border-bottom: 2px solid var(--soir-trait);
}
.constellation__ciel canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.constellation__ciel canvas:active { cursor: grabbing; }
.constellation__ciel canvas:focus-visible { outline: 3px solid var(--soir-lumiere); outline-offset: -3px; }

/* Éléments flottants : ils laissent passer le doigt sauf sur leurs boutons */
.constellation__tete, .constellation__reglages, .constellation__legende, .constellation__aide { position: absolute; z-index: 1; pointer-events: none; }
.constellation__reglages > *, .constellation__fiche { pointer-events: auto; }
.constellation__tete { left: 24px; top: 18px; margin: 0; }
.constellation__titre { margin: 0; font: 800 clamp(2.2rem, 5vw, 3.4rem)/1 var(--htv-titre); text-shadow: 0 2px 12px var(--htv-nuit); }
.constellation__compte { margin: 6px 0 0; color: var(--soir-texte-2); font-size: .95rem; text-shadow: 0 1px 6px var(--htv-nuit); }
.constellation__compte strong { color: var(--soir-lumiere); font: 700 1.1rem var(--htv-titre); }
.constellation__reglages { right: 24px; top: 20px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.mode-soiree .pastilles button { color: var(--soir-texte); background: var(--const-voile); border-color: var(--soir-trait); }
.mode-soiree .pastilles button:hover { background: var(--soir-carte); }
.mode-soiree .pastilles button[aria-pressed="true"] { background: var(--soir-lumiere); color: var(--htv-nuit); border-color: var(--soir-lumiere); }
.constellation__recentrer { min-height: 44px; padding: 8px 16px; background: var(--const-voile); }
.constellation__legende {
  left: 24px; bottom: 20px; display: flex; gap: 6px 16px; flex-wrap: wrap; margin: 0; padding: 8px 14px; list-style: none;
  font-size: .95rem; color: var(--soir-texte-2); background: var(--const-voile); border-radius: 999px;
}
.constellation__legende li { display: inline-flex; align-items: center; gap: 7px; }
.constellation__aide { right: 24px; bottom: 26px; margin: 0; font-size: .85rem; color: var(--soir-texte-3); }
.constellation__puce { display: inline-block; flex-shrink: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--const-encours); }
.constellation__puce--appris { background: var(--const-appris); box-shadow: 0 0 0 3px color-mix(in srgb, var(--const-appris) 25%, transparent); }
.constellation__puce--decouvrir { width: 7px; height: 7px; margin: 2px; background: var(--const-decouvrir); }

/* Fiche du mot choisi : carte flottante (à droite ; en bas sur téléphone), absente tant qu'aucun mot n'est choisi */
.constellation__fiche {
  position: absolute; z-index: 2; right: 24px; top: 84px; width: min(380px, calc(100% - 48px)); max-height: calc(100% - 108px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px; padding: 22px 22px 20px;
  background: var(--soir-carte); border: 2px solid var(--soir-lumiere); border-radius: 6px;
  box-shadow: 6px 6px 0 var(--soir-ombre);
}
.constellation__fiche[hidden] { display: none; }
.constellation__fermer {
  position: absolute; right: 8px; top: 8px; width: 44px; height: 44px; cursor: pointer;
  font: 700 1.4rem/1 var(--htv-texte); color: var(--soir-texte-2); background: transparent; border: 0; border-radius: 50%;
}
.constellation__fermer:hover { background: var(--soir-trait); color: var(--soir-texte); }
.constellation__fiche .discret { margin: 0; color: var(--soir-texte-3); font-size: .95rem; }
.constellation__etat { display: flex; align-items: center; gap: 8px; margin: 0; padding-right: 40px; font-size: .9rem; color: var(--soir-texte-2); }
.constellation__mot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.constellation__vi { margin: 0; font: 800 clamp(2.4rem, 5vw, 3.2rem)/1.05 var(--htv-titre); }
.mode-soiree .bouton-audio { border-color: var(--soir-texte); color: var(--soir-texte); }
.mode-soiree .bouton-audio:hover { background: var(--soir-trait); }
.constellation__fr { margin: 0; font: 400 clamp(1.5rem, 3vw, 1.8rem)/1.2 var(--htv-main); color: var(--soir-lumiere); }
.constellation__note { margin: 0; font-size: .95rem; color: var(--soir-texte-2); }
.constellation__ton { margin: 0; font-size: .95rem; color: var(--soir-texte-3); }
.constellation__ton span { font-weight: 700; }
.constellation__lecon {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; text-decoration: none;
  border: 1.5px dashed var(--soir-trait); border-radius: 4px;
}
.mode-soiree .constellation__lecon { color: var(--soir-texte); }
.constellation__lecon:hover { border-color: var(--soir-lumiere); }
.constellation__lecon span:nth-child(2) { font-weight: 700; }
.mode-soiree .etiquette { color: var(--soir-texte-3); }
.constellation__liens { display: flex; flex-direction: column; gap: 8px; }
.constellation__liens > .etiquette { margin: 0; }
.constellation__groupe { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0; }
.constellation__syllabe { font: 700 1rem var(--htv-titre); padding-right: 4px; }
.constellation__lien {
  min-height: 40px; padding: 4px 14px; cursor: pointer; font: 600 1rem var(--htv-texte);
  background: transparent; border: 1.5px solid var(--soir-trait); border-radius: 999px;
}
.constellation__lien:hover { border-color: var(--soir-lumiere); background: var(--htv-nuit); }

/* Sous le ciel : présentation et liste des mots */
.constellation__intro { max-width: 60ch; margin: 28px 0 0; color: var(--soir-texte-2); }
.constellation__liste { margin-top: 20px; border: 2px solid var(--soir-trait); border-radius: 6px; }
.constellation__liste > summary { min-height: 52px; display: flex; align-items: center; padding: 0 18px; cursor: pointer; font: 700 1.05rem var(--htv-titre); color: var(--soir-texte); }
.constellation__liste > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px 24px; padding: 4px 18px 20px; }
.constellation__liste-lecon h2 { margin: 0 0 6px; font-size: 1.05rem; }
.constellation__liste-lecon ul { margin: 0; padding: 0; list-style: none; }
.constellation__mot-liste {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 4px 6px; cursor: pointer; text-align: left;
  font: 600 .95rem var(--htv-texte); color: var(--soir-texte); background: transparent; border: 0; border-radius: 4px;
}
.constellation__mot-liste:hover, .constellation__mot-liste[aria-pressed="true"] { background: var(--soir-carte); }
.constellation__mot-liste .discret { font-weight: 400; font-size: .85rem; color: var(--soir-texte-3); }

@media (max-width: 760px) {
  .constellation__tete { left: 14px; top: 12px; }
  .constellation__compte { font-size: .85rem; max-width: 60vw; }
  .constellation__reglages { right: 12px; top: 12px; flex-direction: column; align-items: flex-end; gap: 8px; }
  .constellation__legende { left: 12px; bottom: 12px; right: 12px; justify-content: center; border-radius: 6px; font-size: .9rem; }
  .constellation__aide { display: none; }
  /* La fiche devient un panneau en bas de l'écran, par-dessus la légende */
  .constellation__fiche { left: 10px; right: 10px; top: auto; bottom: 10px; width: auto; max-height: 58%; padding: 18px 16px 16px; gap: 10px; }
  .constellation .conteneur { padding: 0 14px; }
}

/* ---------- Défi du jour (langues/<id>/index.html, js/jeux/defi.js) ---------- */
/* Tuile : une fiche de télégramme épinglée dans la grille ; réussie = tampon « ĐÃ XONG » */
.tuile--defi {
  position: relative; display: flex; flex-direction: column; gap: 10px; overflow: hidden;
  border-left: 8px solid var(--htv-rouge); box-shadow: var(--htv-ombre);
}
.defi__tete { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; }
.defi__etiquette { margin: 0; font: 700 .8rem var(--htv-titre); letter-spacing: .14em; text-transform: uppercase; color: var(--htv-rouge); }
.defi__date { font: 400 1.2rem var(--htv-main); color: var(--htv-texte-3); }
.defi__mission { margin: 0; font: 800 clamp(1.35rem, 2.2vw, 1.75rem)/1.15 var(--htv-titre); color: var(--htv-encre); }
.defi__precision { margin: 0; color: var(--htv-texte-2); font-size: .95rem; }
.defi__ligne { display: flex; align-items: center; gap: 12px; }
.defi__barre { flex: 1; }
.defi__compte { font: 700 1rem var(--htv-titre); white-space: nowrap; }
.defi__pied { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; margin-top: 4px; }
.defi__gain {
  padding: 4px 10px; font: 700 .8rem var(--htv-titre); letter-spacing: .08em; text-transform: uppercase;
  color: var(--htv-encre); background: var(--htv-craie); border: 1.5px dashed var(--htv-encre); border-radius: 2px;
}
.defi__bravo { margin: 0; font: 400 1.3rem var(--htv-main); color: var(--htv-rouge); }
.defi__relire {
  min-height: 44px; margin-left: auto; padding: 0 4px; cursor: pointer;
  font: 600 .9rem var(--htv-texte); color: var(--htv-texte-2); background: none; border: 0;
  text-decoration: underline; text-underline-offset: 3px;
}
.defi__relire:hover { color: var(--htv-rouge); }
.tuile--defi[data-reussi="oui"] { border-left-color: var(--htv-olive); }
.tuile--defi[data-reussi="oui"] .defi__tete, .tuile--defi[data-reussi="oui"] .defi__mission { padding-right: 92px; } /* place du tampon */
.tuile--defi[data-reussi="oui"] .progression--rouge > span { background: var(--htv-olive); }
.tuile--defi .tampon, .tuile--defi .tampon-onde { top: 16px; right: 16px; }

/* Télégramme (<dialog>) : feuille de la poste de Hà Nội, bandes de texte collées */
.telegramme {
  width: min(540px, calc(100% - 24px)); max-width: none; max-height: calc(100dvh - 24px);
  padding: 0; border: 0; background: transparent; overflow: visible; color: var(--htv-encre);
}
.telegramme::backdrop { background: color-mix(in srgb, var(--htv-encre) 62%, transparent); }
.telegramme__carte { position: relative; transform: rotate(-1.5deg); }
.telegramme__feuille {
  display: flex; flex-direction: column; gap: 16px; padding: 0 0 22px; max-height: calc(100dvh - 40px); overflow-y: auto;
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon); box-shadow: 8px 8px 0 var(--htv-encre);
}
.telegramme__tete {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 18px;
  background: var(--htv-rouge); color: var(--htv-craie);
  font: 700 .72rem var(--htv-titre); letter-spacing: .12em;
}
.telegramme__tete strong { font: 800 clamp(1.5rem, 5vw, 2rem)/1 var(--htv-titre); letter-spacing: .06em; }
.telegramme__champs { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 4px 24px; margin: 0; padding: 0 22px; }
.telegramme__champs div { display: flex; gap: 8px; align-items: baseline; border-bottom: 1.5px dotted var(--htv-pointille); padding-bottom: 2px; }
.telegramme__champs dt { font: 700 .7rem var(--htv-titre); letter-spacing: .12em; text-transform: uppercase; color: var(--htv-texte-3); }
.telegramme__champs dd { margin: 0; font: 400 1.2rem var(--htv-main); }
.telegramme__bandes { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 0 22px; }
.telegramme__bande {
  margin: 0; padding: 6px 12px; background: var(--htv-craie); border: 1px solid var(--htv-papier-fonce);
  box-shadow: 2px 2px 0 var(--htv-papier-fonce);
  font: 700 clamp(.95rem, 3.4vw, 1.15rem)/1.25 var(--htv-titre); letter-spacing: .06em;
}
.telegramme__bande:nth-child(even) { margin-left: 10px; transform: rotate(.6deg); }
.telegramme__bande:nth-child(odd) { transform: rotate(-.4deg); }
.telegramme__stop { color: var(--htv-rouge); }
.telegramme__suite { display: flex; flex-direction: column; gap: 10px; padding: 6px 22px 0; border-top: 1.5px dashed var(--htv-pointille); margin: 0 22px; padding-inline: 0; }
.telegramme__mission { margin: 10px 0 0; font: 800 clamp(1.25rem, 4vw, 1.5rem)/1.2 var(--htv-titre); }
.telegramme__precision { margin: 0; color: var(--htv-texte-2); }
.telegramme__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.telegramme__actions > * { min-height: 48px; }

/* Télégramme plié, à l'arrivée : un rabat qu'on ouvre */
.telegramme__pli {
  position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; text-align: center;
  background: var(--htv-papier); border: var(--htv-trait); border-radius: var(--htv-rayon); box-shadow: 8px 8px 0 var(--htv-encre);
}
.telegramme__pli::before {
  content: ""; position: absolute; inset: 12px; border: 2px dashed var(--htv-rouge); border-radius: 2px; pointer-events: none;
}
.telegramme__pli-titre { margin: 0; font: 800 clamp(2.6rem, 11vw, 4rem)/1 var(--htv-titre); letter-spacing: .04em; color: var(--htv-rouge); }
.telegramme__pli-texte { margin: 0; }
.telegramme__ouvrir { position: relative; min-height: 52px; }

@media (max-width: 640px) {
  .tuile--defi[data-reussi="oui"] .defi__tete, .tuile--defi[data-reussi="oui"] .defi__mission { padding-right: 78px; }
  .tuile--defi .tampon, .tuile--defi .tampon-onde { width: 64px; height: 64px; top: 12px; right: 12px; font-size: .75rem; }
  .telegramme__champs { grid-template-columns: 1fr; padding: 0 18px; }
  .telegramme__bandes { padding: 0 18px; }
  .telegramme__suite { margin: 0 18px; }
  .telegramme__tete { padding: 10px 14px; }
  .telegramme__tete > span:first-child { display: none; }
}
