/* =============================================================================
   Truffe — dessin animé chaleureux. Fond crème, contours brun encre épais
   comme une BD, ombres « autocollant » décalées, boutons bonbon. Truffe, la
   mascotte, réagit à chaque tour (voir « Mascotte » plus bas).
   Polices servies depuis /fonts : Fredoka (titres, mots, nombres) et
   Atkinson Hyperlegible (texte courant, conçue pour la lisibilité).
   Contrastes sur la crème : encre 13:1, texte secondaire 6,6:1, tomate foncé
   5:1, vert foncé 5,1:1, bleu foncé 5,1:1 ; encre sur boutons colorés ≥ 5:1.
   ============================================================================= */
@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka-500.woff2") format("woff2");
  font-weight: 500; font-display: swap; }
@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka-600.woff2") format("woff2");
  font-weight: 600; font-display: swap; }
@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka-700.woff2") format("woff2");
  font-weight: 700; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/fonts/atkinson-400.woff2") format("woff2");
  font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/fonts/atkinson-700.woff2") format("woff2");
  font-weight: 700; font-display: swap; }

:root {
  --creme: #fff6e8;         /* fond */
  --papier: #fffdf8;        /* cartes, panneaux */
  --sable: #f7e6cc;         /* creux, champs */
  --ink: #3b2416;           /* encre : texte et contours */
  --muted: #6e5242;
  --tomate: #ff6b4a;  --tomate-f: #c2371b;
  --soleil: #ffc93c;  --miel: #ffa62b;
  --vert: #45c97a;    --vert-f: #1d7a45;
  --bleu: #5bb8ff;    --bleu-f: #1c6fb0;
  --caramel: #f2b25c; --brun: #8a4b2a;
  --trait: 3px solid var(--ink);
  --ombre: 0 4px 0 var(--ink);
  --r: 18px;
  --disp: "Fredoka", "Baloo 2", ui-rounded, "Segoe UI", sans-serif;
  --txt: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button, input { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--bleu-f); outline-offset: 3px; }
a { color: var(--bleu-f); text-underline-offset: 3px; }

/* Fond : crème, deux taches de couleur douces et des empreintes de pattes.
   Posé sur un calque fixe (body::before) plutôt qu'avec background-attachment:
   fixed, qui force le navigateur à repeindre tout le fond à chaque défilement
   sur mobile. Les écrans superposés, déjà fixes, le reprennent tel quel. */
:root {
  --fond:
    radial-gradient(40rem 26rem at 105% -5%, rgba(255,201,60,.35), transparent 70%),
    radial-gradient(34rem 24rem at -10% 105%, rgba(91,184,255,.22), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='%238a4b2a' opacity='.07'%3E%3Cg transform='translate(24 30) rotate(-18)'%3E%3Cellipse cx='0' cy='8' rx='8' ry='7'/%3E%3Ccircle cx='-9' cy='-4' r='3.4'/%3E%3Ccircle cx='-3' cy='-9' r='3.4'/%3E%3Ccircle cx='4' cy='-9' r='3.4'/%3E%3Ccircle cx='10' cy='-4' r='3.4'/%3E%3C/g%3E%3Cg transform='translate(96 98) rotate(14)'%3E%3Cellipse cx='0' cy='8' rx='8' ry='7'/%3E%3Ccircle cx='-9' cy='-4' r='3.4'/%3E%3Ccircle cx='-3' cy='-9' r='3.4'/%3E%3Ccircle cx='4' cy='-9' r='3.4'/%3E%3Ccircle cx='10' cy='-4' r='3.4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") var(--creme);
}
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: var(--fond); pointer-events: none; }
body {
  background-color: var(--creme);
  color: var(--ink); font-family: var(--txt); font-size: 17px; line-height: 1.5;
  min-height: 100vh; min-height: 100dvh;
  display: flex; justify-content: center; align-items: flex-start; overflow-x: hidden;
}
h1, h2, .brand, .etiq, .btn, .word, .mc-word, .val, .final, .carte .mot { font-family: var(--disp); }
.etiq { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

#app { position: relative; width: min(680px, 100%); padding: 18px 20px 24px; margin: 0 auto; }

/* --- Mascotte ---------------------------------------------------------------- */
.mascotte { display: inline-block; flex: none; }
.mascotte.mini { width: 34px; height: 34px; }
.mascotte.moyen { width: 88px; height: 88px; }
.mascotte.grand { width: 132px; height: 132px; }
.mascotte.hero { width: 150px; height: 150px; }
.truffe { width: 100%; height: 100%; overflow: visible; }
.truffe .t-crane { fill: #f2b25c; stroke: var(--ink); stroke-width: 3; }
.truffe .t-oreille { fill: #8a4b2a; stroke: var(--ink); stroke-width: 3; stroke-linejoin: round;
  transform-box: fill-box; transition: transform .35s cubic-bezier(.3,1.6,.5,1); }
.truffe .t-og { transform-origin: 90% 10%; }
.truffe .t-od { transform-origin: 10% 10%; }
.truffe .t-tache { fill: #d98a3f; }
.truffe .t-museau { fill: #fff1d6; stroke: var(--ink); stroke-width: 2.5; }
.truffe .t-nez { fill: var(--ink); transform-box: fill-box; transform-origin: center; }
.truffe .t-reflet { fill: #fff; opacity: .7; }
.truffe .t-yeux circle { fill: var(--ink); }
.truffe .t-yeux .t-reflet { fill: #fff; opacity: 1; }
.truffe .t-yeux path, .truffe .t-bouche path { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.truffe .t-bouche .b-gorge { fill: #7a2a1a; stroke-linejoin: round; }
.truffe .t-bouche .b-langue { fill: #ff8a9a; stroke-width: 2; }
.truffe .t-odeur path { stroke: var(--ink); stroke-width: 3; opacity: 0; }
.truffe .t-doute { font: 700 30px var(--disp); fill: var(--bleu-f); opacity: 0; }
.truffe .t-etoiles path { fill: var(--soleil); stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; opacity: 0;
  transform-box: fill-box; transform-origin: center; }
.truffe .t-tete { transform-box: fill-box; transform-origin: 50% 90%; transition: transform .35s cubic-bezier(.3,1.6,.5,1); }
:where(.truffe .t-yeux > g, .truffe .t-bouche > *) { display: none; }
.truffe .t-yeux > g { transform-box: fill-box; transform-origin: center; }

/* Humeurs (data-h sur le conteneur .mascotte) */
[data-h] .y-ouverts, [data-h] .b-sourire { display: inline; }
[data-h="renifle"] .y-ouverts, [data-h="trouve"] .y-ouverts, [data-h="brule"] .y-ouverts,
[data-h="perdu"] .y-ouverts, [data-h="doute"] .y-ouverts, [data-h="content"] .y-ouverts,
[data-h="bougon"] .y-ouverts, [data-h="boude"] .y-ouverts, [data-h="reconcilie"] .y-ouverts { display: none; }
[data-h="renifle"] .y-fermes { display: inline; }
[data-h="trouve"] .y-joie, [data-h="content"] .y-joie { display: inline; }
[data-h="brule"] .y-ouverts { display: inline; }
[data-h="perdu"] .y-tristes { display: inline; }
[data-h="doute"] .y-doute { display: inline; }
[data-h="trouve"] .b-sourire, [data-h="brule"] .b-sourire, [data-h="perdu"] .b-sourire,
[data-h="bougon"] .b-sourire, [data-h="boude"] .b-sourire, [data-h="reconcilie"] .b-sourire { display: none; }
[data-h="trouve"] .b-ouverte, [data-h="brule"] .b-ouverte { display: inline; }
[data-h="perdu"] .b-triste { display: inline; }

[data-h="attend"] .y-ouverts { animation: cligne 4.5s infinite; }
@keyframes cligne { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
[data-h="attend"] .t-tete { animation: souffle 3s ease-in-out infinite; }
@keyframes souffle { 50% { transform: translateY(2px) rotate(-1deg); } }
[data-h="renifle"] .t-tete { transform: rotate(-6deg) translateY(4px); }
[data-h="renifle"] .t-nez { animation: renifle .26s ease-in-out infinite; }
@keyframes renifle { 50% { transform: scale(1.12, .9) translateY(-1px); } }
[data-h="renifle"] .t-odeur path { opacity: 1; animation: odeur .26s ease-in-out infinite alternate; }
@keyframes odeur { to { opacity: .2; } }
[data-h="doute"] .t-tete { transform: rotate(9deg); }
[data-h="doute"] .t-od { transform: rotate(-28deg); }
[data-h="doute"] .t-doute { opacity: 1; }
[data-h="content"] .t-tete { transform: rotate(-4deg); }
[data-h="content"] .t-og { transform: rotate(14deg); }
[data-h="content"] .t-od { transform: rotate(-14deg); }
[data-h="trouve"] .t-tete, [data-h="brule"] .t-tete { animation: saute .5s cubic-bezier(.3,1.6,.5,1) 2; }
@keyframes saute { 40% { transform: translateY(-10px) rotate(-4deg); } }
[data-h="trouve"] .t-og { transform: rotate(32deg); }
[data-h="trouve"] .t-od { transform: rotate(-32deg); }
[data-h="trouve"] .t-etoiles path, [data-h="brule"] .t-etoiles path { opacity: 1; animation: brille .9s ease-in-out infinite; }
@keyframes brille { 50% { transform: scale(1.35) rotate(20deg); } }
[data-h="perdu"] .t-tete { transform: translateY(6px) rotate(3deg); }
[data-h="perdu"] .t-og { transform: rotate(-18deg); }
[data-h="perdu"] .t-od { transform: rotate(18deg); }

/* Humeur au fil des ▼ (voir « Répliques » dans app.js) : bougon après 2 ▼
   d'affilée, boudeur après 3 ▼ dans la carte, réconcilié au ▲ suivant. */
.truffe .t-hmpf { font: 700 15px var(--disp); fill: var(--muted); opacity: 0; }
.truffe .t-coeurs path { fill: var(--tomate); stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; opacity: 0;
  transform-box: fill-box; transform-origin: center; }
[data-h="bougon"] .y-bougon, [data-h="bougon"] .b-moue { display: inline; }
[data-h="bougon"] .t-tete { transform: translateY(3px) rotate(-3deg); }
[data-h="bougon"] .t-og { transform: rotate(-12deg); }
[data-h="bougon"] .t-od { transform: rotate(12deg); }
[data-h="boude"] .y-fermes, [data-h="boude"] .b-moue { display: inline; }
[data-h="boude"] .t-tete { transform: translateX(-4px) rotate(-14deg); }
[data-h="boude"] .t-og { transform: rotate(-16deg); }
[data-h="boude"] .t-od { transform: rotate(16deg); }
[data-h="boude"] .t-hmpf { opacity: 1; }
[data-h="reconcilie"] .y-joie, [data-h="reconcilie"] .b-ouverte { display: inline; }
[data-h="reconcilie"] .t-tete { animation: saute .5s cubic-bezier(.3,1.6,.5,1) 2; }
[data-h="reconcilie"] .t-og { transform: rotate(26deg); }
[data-h="reconcilie"] .t-od { transform: rotate(-26deg); }
[data-h="reconcilie"] .t-coeurs path { opacity: 1; animation: brille .9s ease-in-out infinite; }

/* --- Logo « Snouff » : le mot est le bruit du reniflement ; trois traits de
   flair (les mêmes que l'humeur « renifle » de Truffe) frémissent après lui. */
.logo { white-space: nowrap; }
.logo::after { content: ""; display: inline-block; width: .38em; height: .56em; margin-left: .08em;
  vertical-align: .32em; transform-origin: left center;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 20'%3E%3Cg stroke='%233b2416' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M2 4.5 10 2'/%3E%3Cpath d='M2 10h10'/%3E%3Cpath d='M2 15.5 10 18'/%3E%3C/g%3E%3C/svg%3E") no-repeat left center / contain;
  animation: snouffe 2.4s ease-in-out infinite; }
@keyframes snouffe { 0%, 30%, 100% { transform: none; opacity: 1; } 8%, 22% { transform: translateX(2px) scaleX(1.3); } 15% { transform: none; opacity: .5; } }

/* --- Barre du haut ----------------------------------------------------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 26px; font-weight: 700;
  color: var(--ink); background: none; border: 0; padding: 2px 0; }
.brand:hover .mascotte { transform: rotate(-8deg); }
.brand .mascotte { transition: transform .2s; }
.topnav { display: flex; align-items: center; gap: 10px; }
.pastille { font-family: var(--disp); font-weight: 600; font-size: 14px; padding: 4px 12px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--papier); }
.record { font-family: var(--disp); font-weight: 600; font-size: 15px; color: var(--muted); }
.record b { color: var(--ink); font-size: 18px; }
body:has(.ecran.show) .topbar { visibility: hidden; }

/* --- HUD --------------------------------------------------------------------- */
.hud { display: grid; grid-template-columns: auto 1fr; gap: 12px; margin-bottom: 14px; }
.stat, .macarte { background: var(--papier); border: var(--trait); border-radius: var(--r);
  box-shadow: var(--ombre); padding: 10px 16px 12px; }
.stat .val { font-size: 36px; font-weight: 700; line-height: 1.1; color: var(--vert-f); }
.stat .niv { font-size: 15px; color: var(--muted); }
.stat .niv b { color: var(--ink); }
.macarte { text-align: right; min-width: 0; background: var(--soleil); }
.macarte .etiq { color: var(--ink); }
.mc-word { font-size: 30px; font-weight: 700; line-height: 1.1; overflow-wrap: anywhere; }
.mc-word.long { font-size: 24px; }
.mc-gain { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mc-gain b { font-family: var(--disp); font-size: 18px; background: var(--papier); border: 2px solid var(--ink);
  border-radius: 999px; padding: 0 8px; }

/* --- Gamelle : un os par mot, pour toute la partie ---------------------- */
.gamelle { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.bol { flex: none; width: 34px; height: 24px; overflow: visible; }
.bol .bol-os { fill: var(--papier); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.bol path { fill: var(--tomate); stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; }
/* 25 os sur deux rangées de 13 : assez grands pour se lire sur mobile. */
.rangee-os { flex: 1; min-width: 0; max-width: 560px; display: grid; grid-template-columns: repeat(13, 1fr);
  gap: 3px 4px; }
.rangee-os svg { width: 100%; height: 20px; min-width: 0; overflow: visible;
  transition: transform .3s cubic-bezier(.3,1.6,.5,1), opacity .3s; }
.rangee-os path { fill: var(--papier); stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; }
.rangee-os .used { opacity: .28; transform: scale(.8) rotate(-12deg); }
.rangee-os .used path { fill: var(--sable); }
.g-compte { flex: none; min-width: 2ch; text-align: right; font-family: var(--disp); font-size: 28px; line-height: 1;
  font-variant-numeric: tabular-nums; }
.gamelle.low .rangee-os svg:not(.used) path { fill: var(--tomate); }
.gamelle.low .rangee-os svg:not(.used) { animation: tremble .6s ease-in-out infinite; }
.gamelle.low .g-compte { color: var(--tomate-f); }
@keyframes tremble { 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }

/* --- Trace -------------------------------------------------------------------- */
/* Pas de limite de mots par carte : l'historique défile au-delà de 5 lignes
   (et, sur mobile, cède la place à Truffe et à la saisie). */
.trail { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; min-height: 32px; margin-bottom: 6px;
  max-height: 200px; overflow-y: auto; align-content: flex-start; overscroll-behavior: contain; padding: 2px 0; }
.trail li { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 12px; font-size: 16px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--papier); animation: pop .3s cubic-bezier(.3,1.6,.5,1); }
.trail .toi { font-weight: 700; }
.trail .ch { margin-left: 4px; font-size: 12px; }
.trail .ch.pres { color: var(--vert-f); }
.trail .ch.loin { color: var(--tomate-f); }
.trail .tr { color: var(--muted); }
.trail .tr::before { content: "→ "; }
.trail .tr.ok { color: var(--vert-f); font-weight: 700; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- Scène : Truffe et sa bulle ----------------------------------------------- */
.scene { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 10px 0 18px; min-height: 150px; }
.bulle { position: relative; flex: 0 1 auto; min-width: 150px; max-width: 64%; text-align: center;
  background: var(--papier); border: var(--trait); border-radius: 26px; box-shadow: var(--ombre);
  padding: 12px 20px 14px; }
.bulle::before { content: ""; position: absolute; left: -15px; top: 50%; width: 22px; height: 22px;
  background: var(--papier); border-left: var(--trait); border-bottom: var(--trait);
  transform: translateY(-50%) rotate(45deg) skew(12deg, 12deg); border-bottom-left-radius: 4px; }
.bulle-lbl { font-size: 14px; font-weight: 700; color: var(--muted); }
.word { font-size: clamp(34px, 8vw, 52px); font-weight: 700; line-height: 1.1; overflow-wrap: anywhere; }
.scene.sniff .word { color: var(--muted); font-weight: 500; }
.scene.stop .word { animation: pop .35s cubic-bezier(.3,1.6,.5,1); }
.scene.ok .bulle { background: var(--vert); }
.scene.ok .bulle::before { background: var(--vert); }
.scene.ok .bulle-lbl { color: var(--ink); }
.scene.brule .bulle { background: var(--soleil); }
.scene.brule .bulle::before { background: var(--soleil); }
.scene.brule .bulle-lbl { color: var(--ink); }
.confetti { position: absolute; left: 50%; top: 50%; width: 10px; height: 14px; border: 2px solid var(--ink);
  border-radius: 3px; pointer-events: none; animation: vole .9s cubic-bezier(.2,.7,.4,1) forwards; }
@keyframes vole { to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }
.secoue { animation: secoue .4s; }
@keyframes secoue { 20% { transform: translateX(-8px) rotate(-1deg); } 50% { transform: translateX(8px) rotate(1deg); } 80% { transform: translateX(-4px); } }

/* --- Saisie ------------------------------------------------------------------- */
.inrow { display: flex; gap: 10px; }
.inrow input { flex: 1; min-width: 0; background: var(--papier); border: var(--trait); border-radius: var(--r);
  box-shadow: inset 0 3px 0 var(--sable); font-family: var(--disp); font-size: 22px; font-weight: 600;
  padding: 12px 18px; outline: none; color: var(--ink); }
.inrow input::placeholder { color: var(--muted); opacity: .85; font-weight: 500; }
.inrow input:focus { box-shadow: inset 0 3px 0 var(--sable), 0 0 0 4px rgba(91,184,255,.5); }
.inrow input.bad { animation: secoue .35s; }
.enterbtn { flex: none; width: 60px; display: grid; place-items: center; color: var(--ink);
  background: var(--tomate); border: var(--trait); border-radius: var(--r); box-shadow: var(--ombre);
  transition: transform .08s, box-shadow .08s; }
.enterbtn svg { width: 28px; height: 28px; }
.enterbtn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.enterbtn[aria-disabled="true"] { opacity: .6; cursor: wait; }
.refus, .msg { min-height: 24px; margin-top: 10px; font-weight: 700; color: var(--tomate-f); }
.msg:empty { display: none; }

/* --- Toast -------------------------------------------------------------------- */
.toast { position: fixed; left: 50%; top: 26%; z-index: 40; pointer-events: none; text-align: center; opacity: 0;
  transform: translateX(-50%); }
.toast .big { font-family: var(--disp); font-size: 56px; font-weight: 700; color: var(--soleil); white-space: nowrap;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
.toast .sub { display: inline-block; margin-top: 6px; font-family: var(--disp); font-weight: 600; font-size: 16px;
  background: var(--papier); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 12px; }
.toast.chaud .big { color: var(--tomate); }
.toast.pop { animation: toast 1.2s ease-out forwards; }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 16px) scale(.5) rotate(-6deg); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.1) rotate(3deg); }
  30% { transform: translate(-50%, 0) scale(1) rotate(-2deg); }
  75% { opacity: 1; transform: translate(-50%, -6px) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -30px); }
}

/* --- Aide au premier lancement -------------------------------------------------- */
.coach { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: start;
  margin: 0 auto 14px; max-width: 540px; text-align: left; background: #e6f4ff;
  border: var(--trait); border-radius: var(--r); box-shadow: var(--ombre); padding: 12px 14px; animation: pop .3s ease-out; }
.coach .mascotte.mini { width: 40px; height: 40px; }
.coach-b { grid-column: 2; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.lien { background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
  min-height: 40px; font-size: 15px; }
.lien:hover { color: var(--ink); }

/* --- Boutons bonbon ------------------------------------------------------------ */
.btn { font-size: 20px; font-weight: 600; line-height: 1.2; color: var(--ink); background: var(--papier);
  border: var(--trait); border-radius: var(--r); box-shadow: var(--ombre); padding: 14px 26px; min-height: 56px;
  transition: transform .08s, box-shadow .08s, filter .12s; }
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.btn-tomate { background: var(--tomate); }
.btn-bleu { background: var(--bleu); }
.btn-vert { background: var(--vert); }
.btn-blanc { background: var(--papier); }
.btn.petit { font-size: 16px; padding: 8px 16px; min-height: 44px; }
.btn-ghost { font-size: 15px; font-weight: 700; color: var(--muted); background: none; border: 2px dashed var(--muted);
  border-radius: var(--r); padding: 10px 16px; margin-top: 6px; }
.btn-ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--ink); }
.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }

/* --- Modale de confirmation ---------------------------------------------------- */
.modale { margin: auto; width: min(420px, calc(100% - 32px)); padding: 18px 20px 20px; text-align: center;
  color: var(--ink); background: var(--papier); border: var(--trait); border-radius: 22px;
  box-shadow: 0 6px 0 var(--ink); }
.modale::backdrop { background: rgba(59,36,22,.45); backdrop-filter: blur(2px); }
.modale[open] { animation: pop .3s cubic-bezier(.3,1.6,.5,1); }
.modale[open]::backdrop { animation: entre .2s ease-out; }
.modale h2 { font-family: var(--disp); font-size: 24px; line-height: 1.2; margin: 4px 0 6px; }
.modale p { color: var(--muted); line-height: 1.5; }
.modale-b { display: flex; gap: 10px; margin-top: 18px; }
.modale-b .btn { flex: 1; font-size: 18px; padding: 12px 14px; min-height: 52px; }

/* --- Écrans superposés (accueil, choix, fin, classements) ---------------------- */
.ecran { position: fixed; inset: 0; z-index: 20; display: none; flex-direction: column; align-items: center;
  justify-content: safe center; gap: 10px; overflow-y: auto; overscroll-behavior: contain; text-align: center;
  padding: calc(22px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right))
           calc(26px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  background: var(--fond); }
.ecran.show { display: flex; animation: entre .25s ease-out; }
@keyframes entre { from { opacity: 0; transform: translateY(8px); } }
.ecran > * { flex: none; }
.ecran h2 { font-size: 28px; font-weight: 700; line-height: 1.2; max-width: 540px; }
.ecran h1:focus, .ecran h2:focus { outline: none; }
.recap { color: var(--muted); max-width: 470px; line-height: 1.6; }
.recap b { color: var(--ink); }
.final { font-size: clamp(56px, 16vw, 84px); font-weight: 700; line-height: 1; color: var(--vert);
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); margin: 4px 0 8px; }
.final.gain { color: var(--soleil); }
.final.perdu { color: var(--tomate); text-decoration: line-through; text-decoration-thickness: 6px; text-decoration-color: var(--ink); }
.final.nul { color: var(--sable); }
.endrecord { font-family: var(--disp); font-weight: 700; background: var(--soleil); border: var(--trait);
  border-radius: 999px; padding: 2px 14px; transform: rotate(-3deg); animation: pop .5s cubic-bezier(.3,1.6,.5,1); }
.endbtns { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
.carnet { width: 100%; max-width: 380px; background: var(--papier); border: var(--trait); border-radius: var(--r);
  box-shadow: var(--ombre); padding: 12px 16px; text-align: left; }

/* Accueil */
.start .mascotte.hero { margin-bottom: -6px; }
.start h1 { font-size: clamp(54px, 15vw, 88px); font-weight: 700; line-height: 1; color: var(--caramel);
  -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink);
  letter-spacing: .01em; transform: rotate(-2deg); }
.tagline { font-family: var(--disp); font-size: 20px; font-weight: 600; margin-top: 6px; }
.menu-play { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 380px; margin-top: 8px; }
.home-week { margin-top: 10px; }
.hw-head { display: flex; justify-content: space-between; align-items: center; }
.hw-all { font-family: var(--disp); font-weight: 600; color: var(--bleu-f); background: none; border: 0;
  padding: 8px 0 8px 12px; text-decoration: underline; text-underline-offset: 3px; }
.hw-rows { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.hw-empty { color: var(--muted); padding: 6px 0; text-align: center; }
/* Lignes grisées du podium, présentes dans le HTML : même hauteur que les vraies. */
.hw-skel { display: block; height: 16px; border-radius: 6px; background: var(--sable); animation: hwPulse 1.4s ease-in-out infinite; }
.hw-skel:nth-child(2) { width: 70%; }
.hw-skel:nth-child(3) { width: 40px; }
@keyframes hwPulse { 50% { opacity: .45; } }
/* Vainqueur de la semaine dernière, mis à l'honneur au-dessus du podium (comme Vocabulium). */
.hw-champ { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; margin: 6px 0 8px;
  background: #fff1c7; border: 2px solid var(--ink); border-radius: 12px; text-align: left; }
.hw-champ[hidden] { display: none; }
.hw-champ-icon { flex: none; color: var(--soleil); }
.hw-champ-info { flex: 1; min-width: 0; }
.hw-champ-lbl { font-family: var(--disp); font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); }
.hw-champ-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-champ-score { font-family: var(--disp); font-weight: 700; font-size: 18px; color: var(--vert-f); white-space: nowrap; }
/* Promo croisée discrète : Vocabulium (notre autre jeu). */
.cross-promo { display: flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%; margin: 14px auto 0;
  padding: 6px 14px; border: 2px solid var(--ink); border-radius: 999px; background: var(--papier);
  color: var(--muted); text-decoration: none; transition: background .2s ease; }
.cross-promo:hover { background: var(--sable); }
.cross-promo + .cross-promo { margin-top: 8px; }
.regles-plus { margin-top: 10px; font-weight: 700; }
.cross-promo .cp-icon { flex: none; font-size: 15px; line-height: 1; }
.cross-promo .cp-title { font-size: 13px; line-height: 1.25; }
.cross-promo .cp-title b { font-family: var(--disp); font-weight: 600; color: var(--ink); }
.cross-promo .cp-arrow { flex: none; transition: transform .2s ease, color .2s ease; }
.cross-promo:hover .cp-arrow { color: var(--tomate-f); transform: translateX(2px); }
.home-about { width: 100%; max-width: 470px; margin-top: 8px; text-align: left; }
.home-about > summary { font-family: var(--disp); font-size: 19px; font-weight: 600; cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.home-about > summary::-webkit-details-marker { display: none; }
.home-about > summary::after { content: ""; width: 9px; height: 9px; margin-left: auto;
  border-right: 3px solid currentColor; border-bottom: 3px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .2s; }
.home-about[open] > summary::after { transform: rotate(225deg); }
.regles { padding-left: 1.5em; display: flex; flex-direction: column; gap: 8px; line-height: 1.55; }
.regles li::marker { font-family: var(--disp); font-weight: 700; color: var(--tomate-f); }
.legal { max-width: 520px; margin-top: 2px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.legal a { color: var(--muted); }
.insecable { white-space: nowrap; }

/* Choix de la carte */
.choix-tete { display: flex; align-items: center; gap: 12px; text-align: left; }
.choix-q { font-family: var(--disp); font-size: 18px; font-weight: 500; color: var(--muted); }
.choix-score { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px;
  font-family: var(--disp); font-size: 17px; font-weight: 600; color: var(--muted); }
.choix-score b { color: var(--ink); font-size: 20px; }
.choix-score .c-gamelle { display: inline-flex; align-items: center; gap: 6px; }
.choix-score .bol { width: 28px; height: 20px; }
.choix-score .c-gain { font-size: 20px; font-weight: 700; color: var(--ink); background: var(--soleil);
  border: 2px solid var(--ink); border-radius: 999px; padding: 0 10px; animation: pop .4s cubic-bezier(.3,1.6,.5,1); }
.bandeau { max-width: 470px; font-weight: 700; background: var(--papier); border: 2px dashed var(--tomate-f);
  border-radius: var(--r); padding: 10px 14px; color: var(--tomate-f); }
.cartes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; width: 100%; max-width: 640px; margin-top: 6px; }
.carte { --c: var(--vert); position: relative; display: flex; flex-direction: column; align-items: center;
  justify-content: space-between; gap: 12px; min-height: 210px; padding: 0 12px 14px; overflow: hidden;
  background: var(--papier); border: var(--trait); border-radius: 22px; box-shadow: 0 6px 0 var(--ink);
  color: var(--ink); transform: rotate(var(--rot, 0deg));
  transition: transform .18s cubic-bezier(.3,1.6,.5,1), box-shadow .18s; animation: donne .45s cubic-bezier(.3,1.5,.5,1) both; }
.carte:nth-child(1) { --rot: -3deg; }
.carte:nth-child(2) { --rot: 1.5deg; animation-delay: 80ms; }
.carte:nth-child(3) { --rot: -1deg; animation-delay: 160ms; }
.carte:hover { transform: translateY(-8px) rotate(0deg); box-shadow: 0 10px 0 var(--ink); }
.carte:active { transform: translateY(2px) rotate(0deg); box-shadow: 0 2px 0 var(--ink); }
.carte.moyenne { --c: var(--soleil); }
.carte.risquée { --c: var(--tomate); }
.carte .type { align-self: stretch; margin: 0 -12px; padding: 8px 0 6px; background: var(--c); border-bottom: var(--trait);
  font-family: var(--disp); font-size: 15px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.carte .mot { font-size: 27px; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.carte .val { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: var(--soleil); border: var(--trait); box-shadow: inset 0 -5px 0 var(--miel);
  font-family: var(--disp); font-size: 22px; font-weight: 700; line-height: 1; }
.carte .val small { font-size: 11px; font-weight: 600; }
@keyframes donne { from { opacity: 0; transform: translateY(40px) rotate(12deg) scale(.8); } }

/* Pistes (défaite) */
.pistes { width: 100%; max-width: 420px; }
.pistes-mots { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.pistes-mots span { font-family: var(--disp); font-size: 20px; font-weight: 600; background: var(--bleu);
  border: var(--trait); border-radius: 999px; padding: 2px 14px; box-shadow: 0 3px 0 var(--ink); }

/* Rang en fin de partie */
.lbpos { margin-top: 6px; }
.lbpos-rank { font-size: 18px; margin-top: 2px; }
.lbpos-rank b { font-family: var(--disp); font-size: 24px; background: var(--soleil); border: 2px solid var(--ink);
  border-radius: 10px; padding: 0 8px; }
.lbpos-claim { margin-top: 10px; }
.lbpos-lbl { display: block; font-size: 15px; color: var(--muted); margin-bottom: 6px; }
.lbpos-inrow { display: flex; gap: 8px; }
.lbpos-field { flex: 1; min-width: 0; font-size: 17px; padding: 8px 12px; border: var(--trait); border-radius: 12px;
  background: var(--papier); color: var(--ink); }
.lbpos-field:focus { outline: none; box-shadow: 0 0 0 4px rgba(91,184,255,.5); }
.lbpos-msg { margin-top: 6px; font-weight: 700; color: var(--tomate-f); }
.lbpos-msg:empty { display: none; }

/* Classements */
.lb-modes { display: inline-flex; gap: 4px; padding: 4px; background: var(--sable); border: var(--trait); border-radius: 999px; }
.lb-mode { font-family: var(--disp); font-size: 16px; font-weight: 600; background: none; border: 0; border-radius: 999px;
  padding: 10px 18px; color: var(--muted); }
.lb-mode[aria-selected="true"] { background: var(--papier); color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.lb-week { color: var(--muted); }
.lb-board, #lbChamp { width: 100%; max-width: 480px; }
.lb-podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end; margin: 6px 0 4px; }
.lb-podium:empty { display: none; }
.lb-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; padding: 12px 6px;
  background: var(--papier); border: var(--trait); border-radius: var(--r); box-shadow: var(--ombre); }
.lb-slot-rank { font-family: var(--disp); font-weight: 700; font-size: 15px; border: 2px solid var(--ink);
  border-radius: 999px; padding: 0 10px; }
.lb-slot-name { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-slot-score { font-family: var(--disp); font-weight: 700; font-size: 20px; color: var(--vert-f); }
.lb-slot--1 { order: 2; padding-bottom: 26px; }
.lb-slot--1 .lb-slot-rank { background: var(--soleil); }
.lb-slot--2 { order: 1; }
.lb-slot--2 .lb-slot-rank { background: #dfe6ee; }
.lb-slot--3 { order: 3; }
.lb-slot--3 .lb-slot-rank { background: #f0b98a; }
.lb-slot.is-me { background: #e6f4ff; }
/* Liste (4e et suivants) : cadre à hauteur fixe qui défile, comme Vocabulium.
   7 lignes pile (42 px chacune) sous le podium, soit 10 joueurs visibles sans
   défiler et jamais de ligne coupée ; la page, elle, ne grandit pas. Ombres de
   défilement en CSS pur : elles n'apparaissent que s'il reste des joueurs
   cachés en haut ou en bas (les dégradés « local » couvrent l'ombre aux bouts). */
.lb-list { list-style: none; margin-top: 12px; padding: 6px; max-height: calc(7 * 42px + 12px + 6px);
  overflow-y: auto; overscroll-behavior: contain; border: var(--trait); border-radius: var(--r);
  scrollbar-width: thin; scrollbar-color: var(--muted) transparent;
  background:
    linear-gradient(var(--papier), rgba(255,253,248,0)) center top / 100% 20px no-repeat,
    linear-gradient(rgba(255,253,248,0), var(--papier)) center bottom / 100% 20px no-repeat,
    radial-gradient(farthest-side at 50% 0, rgba(59,36,22,.28), rgba(59,36,22,0)) center top / 100% 12px no-repeat,
    radial-gradient(farthest-side at 50% 100%, rgba(59,36,22,.28), rgba(59,36,22,0)) center bottom / 100% 12px no-repeat,
    var(--papier);
  background-attachment: local, local, scroll, scroll, scroll; }
.lb-list:empty { display: none; }
.lb-row { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; padding: 4px 12px;
  min-height: 42px; border-radius: 12px; text-align: left; }
.lb-row:nth-child(odd) { background: rgba(247,230,204,.6); }
.lb-rank { font-family: var(--disp); font-weight: 700; color: var(--muted); }
.lb-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name small { font-weight: 400; color: var(--muted); }
.lb-score { font-family: var(--disp); font-weight: 700; font-size: 18px; color: var(--vert-f); }
.lb-row.is-me { background: #e6f4ff; box-shadow: inset 0 0 0 2px var(--bleu-f); }
.lb-moi { font-weight: 700; min-height: 1em; }

/* --- Mobile -------------------------------------------------------------------- */
@media (max-width: 560px) {
  /* Hauteur = zone visible (clavier déduit, voir ajusteHauteur dans app.js) :
     l'écran de jeu tient toujours entier, la saisie reste collée en bas. */
  body { overflow: hidden; }
  #app { height: var(--hauteur, 100dvh); overflow: hidden; display: flex; flex-direction: column;
    padding: calc(10px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right))
             calc(12px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left)); }
  .brand { font-size: 22px; }
  .hud { gap: 10px; }
  .stat, .macarte { padding: 8px 12px 10px; }
  .stat .val { font-size: 28px; }
  .mc-word { font-size: 24px; }
  .mc-word.long { font-size: 18px; }
  .trail { flex: 0 1 auto; max-height: none; }
  .scene { flex: 1 0 auto; flex-direction: column; gap: 14px; margin: 8px 0 14px; }
  /* Carte longue (8 mots et plus) : Truffe passe à côté de sa bulle, comme
     clavier ouvert, pour laisser la place à l'historique. */
  #app:has(#histo li:nth-child(8)) .trail { flex: 1 1 0; }
  #app:has(#histo li:nth-child(8)) .scene { flex: none; min-height: 0; flex-direction: row; gap: 10px; margin: 6px 0 10px; }
  #app:has(#histo li:nth-child(8)) .mascotte.grand { width: 72px; height: 72px; }
  #app:has(#histo li:nth-child(8)) .bulle { max-width: 72%; min-width: 0; padding: 8px 16px 10px; }
  #app:has(#histo li:nth-child(8)) .bulle::before { left: -15px; top: 50%;
    transform: translateY(-50%) rotate(45deg) skew(12deg, 12deg); }
  #app:has(#histo li:nth-child(8)) .word { font-size: 32px; }
  .mascotte.grand { width: 112px; height: 112px; }
  .bulle { max-width: 100%; }
  .bulle::before { left: 50%; top: -15px; transform: translateX(-50%) rotate(135deg) skew(12deg, 12deg); }
  .inrow input { font-size: 20px; }
  .cartes { grid-template-columns: 1fr; gap: 14px; }
  .carte { min-height: 0; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "type type" "mot val";
    align-items: center; gap: 10px 12px; padding: 0 14px 12px; text-align: left; }
  .carte .type { grid-area: type; margin: 0 -14px; padding: 6px 14px 4px; }
  .carte .mot { grid-area: mot; font-size: 26px; }
  .carte .val { grid-area: val; width: 58px; height: 58px; font-size: 20px; }
  .endbtns { width: 100%; }
  .endbtns > * { flex: 1 1 40%; }
}

/* --- Écran serré (clavier ouvert, petit téléphone) ---------------------------
   Posé par app.js quand la zone visible fait moins de 640 px de haut : tout se
   resserre pour que score, carte, tours, mots, Truffe et saisie restent visibles. */
body.serre #app { padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 6px; }
body.serre .topbar { margin-bottom: 6px; }
body.serre .brand { font-size: 18px; gap: 6px; }
body.serre .brand .mascotte.mini { width: 24px; height: 24px; }
body.serre .pastille { font-size: 12px; padding: 1px 8px; }
body.serre .record { font-size: 13px; }
body.serre .record b { font-size: 15px; }
body.serre .hud { margin-bottom: 8px; gap: 8px; }
body.serre .stat, body.serre .macarte { padding: 4px 10px 6px; border-width: 2.5px; box-shadow: 0 3px 0 var(--ink); }
body.serre .etiq { font-size: 11px; }
body.serre .stat .val { font-size: 22px; }
body.serre .stat .niv, body.serre .mc-gain { font-size: 13px; }
body.serre .mc-gain b { font-size: 14px; }
body.serre .mc-word { font-size: 20px; }
body.serre .mc-word.long { font-size: 16px; }
body.serre .gamelle { margin-bottom: 6px; gap: 6px; }
body.serre .rangee-os { gap: 2px 3px; }
body.serre .rangee-os svg { height: 12px; }
body.serre .g-compte { font-size: 20px; }
/* Les mots donnés prennent toute la place libre ; Truffe descend juste
   au-dessus de la saisie. */
body.serre .trail { flex: 1 1 auto; min-height: 30px; overflow-y: auto; margin-bottom: 4px; gap: 4px;
  align-content: flex-start; align-items: flex-start; }
body.serre .trail li { font-size: 14px; padding: 1px 9px; }
body.serre .scene { flex: none; min-height: 0; overflow: hidden; flex-direction: row; gap: 10px; margin: 4px 0 8px; }
/* Pas la place pour l'aide ET Truffe au-dessus du clavier : l'aide prend sa
   place le temps d'être lue (la réponse reste lisible dans la trace). */
body.serre #app:has(#coachJeu .coach) .scene { display: none; }
body.serre #coachJeu:has(.coach) { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
body.serre .inrow { flex: none; }
body.serre .mascotte.grand { width: 64px; height: 64px; }
body.serre .bulle { padding: 6px 14px 8px; border-radius: 20px; max-width: 72%; min-width: 0; }
body.serre .bulle::before { left: -15px; top: 50%; transform: translateY(-50%) rotate(45deg) skew(12deg, 12deg); }
body.serre .bulle-lbl { font-size: 12px; }
body.serre .word { font-size: 28px; }
body.serre .coach { padding: 6px 10px; margin-bottom: 8px; gap: 4px 8px; font-size: 14px; flex: none; }
body.serre .coach .mascotte.mini { width: 28px; height: 28px; }
body.serre .coach .btn.petit { min-height: 36px; padding: 4px 12px; font-size: 14px; }
body.serre .coach .lien { min-height: 36px; }
body.serre .inrow input { font-size: 18px; padding: 8px 14px; }
body.serre .enterbtn { width: 50px; }
body.serre .refus { min-height: 0; margin-top: 4px; font-size: 14px; }
body.serre .refus:empty { display: none; }
body.serre .toast { top: 12%; }
body.serre .toast .big { font-size: 40px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; }
}

/* --- Page légale ---------------------------------------------------------------- */
.doc { width: min(720px, 100%); padding: 20px 16px 40px; margin: 0 auto; }
.doc .brand { text-decoration: none; gap: 0; }
.doc .retour { font-family: var(--disp); font-weight: 600; }
.doc article { background: var(--papier); border: var(--trait); border-radius: 22px; box-shadow: 0 6px 0 var(--ink);
  padding: 24px 22px; display: flex; flex-direction: column; gap: 12px; }
.doc h1 { font-size: 30px; line-height: 1.15; }
.doc h2 { font-size: 22px; margin-top: 14px; color: var(--tomate-f); }
.doc h3 { font-family: var(--disp); font-size: 18px; margin-top: 4px; }
.doc p, .doc li { line-height: 1.65; max-width: 68ch; }
.doc ul { padding-left: 1.2em; display: flex; flex-direction: column; gap: 4px; }
.doc .maj { color: var(--muted); font-size: 15px; }
.doc code { font-size: .9em; background: var(--sable); border-radius: 4px; padding: 0 4px; }
.doc h1, .doc h2 { font-family: var(--disp); }
.doc table { border-collapse: collapse; margin: 4px 0; }
.doc th, .doc td { text-align: left; padding: 4px 14px 4px 0; border-bottom: 1px solid var(--sable); }
.doc th { font-family: var(--disp); font-weight: 600; }
