:root {
  --noir: #000; --ivoire: #F4F1EA; --citron: #F5E663; --gris: #2a2a2a; --gris2: #8a8780;
  --vert: #3ecf7a; --rouge: #ff4d4d; --orange: #ffb547;
  --haut: env(safe-area-inset-top, 0px); --bas-s: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--noir); color: var(--ivoire);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.ecran { display: none; position: fixed; inset: 0; padding: calc(var(--haut) + 12px) 18px calc(var(--bas-s) + 18px);
  flex-direction: column; max-width: 560px; margin: 0 auto; }
.ecran.visible { display: flex; }
.ecran.defile { overflow-y: auto; display: none; }
.ecran.defile.visible { display: block; }
.centre { margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; }
.logo { font-size: 54px; font-weight: 800; color: var(--citron); letter-spacing: -1px; }
.sous { color: var(--gris2); text-align: center; }
.grand { font-size: 64px; font-weight: 800; color: var(--citron); }
.erreur { color: var(--rouge); min-height: 1.2em; }
.lien { color: var(--gris2); padding: 8px; }
.principal { background: var(--citron); color: #000; font-weight: 700; border-radius: 16px; padding: 18px; flex: 1; font-size: 19px; }
.secondaire { background: var(--gris); border-radius: 16px; padding: 18px; flex: 1; font-size: 17px; }
.large { width: 100%; margin-top: 20px; }
.bas { display: flex; gap: 12px; margin-top: auto; width: 100%; }

/* PIN */
.pin { display: flex; gap: 16px; }
.pin i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gris2); }
.pin i.plein { background: var(--citron); border-color: var(--citron); }
.clavier { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; }
.clavier button { height: 76px; border-radius: 50%; background: var(--gris); font-size: 28px; }
.clavier button:disabled { visibility: hidden; }

/* Accueil */
.barre { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.titre { font-weight: 700; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.joueurs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 24px 0; }
.joueur { background: #111; border-radius: 22px; padding: 18px 10px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-size: 18px; border: 2px solid transparent; transition: transform .15s; }
.joueur:last-child:nth-child(odd) { grid-column: span 2; }
.joueur.sel { border-color: var(--citron); background: #1a1a12; }
.joueur:active { transform: scale(.96); }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; background: var(--c); color: #000; font-weight: 800;
  width: 28px; height: 28px; font-size: 14px; }
.avatar.grand { width: 82px; height: 82px; font-size: 40px; }
.avatar.petit { width: 26px; height: 26px; font-size: 13px; margin-right: 6px; }
.resume-joueur .mode { color: var(--gris2); text-align: center; margin-bottom: 14px; }
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 10px; }
.chiffres div { background: #111; border-radius: 14px; padding: 12px 6px; text-align: center; }
.chiffres b { display: block; font-size: 22px; }
.chiffres small { color: var(--gris2); font-size: 12px; }

/* Jeu */
.jeu { padding-left: 14px; padding-right: 14px; }
.barre-jeu { display: flex; align-items: center; gap: 14px; font-size: 16px; }
.pastille { display: flex; align-items: center; font-weight: 700; margin-right: auto; }
.compteur b { font-size: 20px; }
.compteur.juste { color: var(--vert); } .compteur.faux { color: var(--rouge); } .compteur.info { color: var(--gris2); font-variant-numeric: tabular-nums; }
.compteur.bump { animation: bump .45s; }
@keyframes bump { 40% { transform: scale(1.45); } }
.pile { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: hidden; flex: 0 1 auto; max-height: 42vh; }
.pile li { display: flex; align-items: center; gap: 10px; background: #111; border-radius: 12px; padding: 9px 14px; font-size: 19px;
  transition: background .3s, opacity .3s; }
.pile li:nth-child(n+4) { opacity: .55; } .pile li:nth-child(n+6) { opacity: .3; }
.pile .op { font-weight: 700; font-variant-numeric: tabular-nums; }
.pile .dit { flex: 1; color: var(--gris2); font-size: 14px; }
.pile .etat { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; }
.pile li.attente .etat { border: 3px solid var(--gris); border-top-color: var(--citron); animation: tourne .8s linear infinite; }
.pile li.juste .etat { background: var(--vert); color: #000; animation: pop .35s; } .pile li.juste .etat::after { content: "✓"; }
.pile li.faux { background: #2a0e0e; } .pile li.faux .etat { background: var(--rouge); color: #000; animation: pop .35s; } .pile li.faux .etat::after { content: "✗"; }
.pile li.incompris .etat { background: var(--orange); color: #000; } .pile li.incompris .etat::after { content: "?"; }
.pile li.arrive { animation: monte .35s ease-out; }
@keyframes tourne { to { transform: rotate(360deg); } }
@keyframes pop { 0% { transform: scale(.2); } 70% { transform: scale(1.3); } }
@keyframes monte { from { transform: translateY(38vh) scale(1.8); opacity: 0; } }
.scene { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 160px; }
.operation { font-size: clamp(64px, 20vw, 120px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -2px; transition: color .15s, transform .15s; white-space: nowrap; }
.operation.entre { animation: entre .25s ease-out; }
.operation.ecoute { color: var(--citron); transform: scale(1.04); }
.operation.attente { color: var(--gris2); }
@keyframes entre { from { opacity: 0; transform: translateY(20px); } }
.aide { color: var(--gris2); min-height: 1.2em; margin-top: 10px; }
.pied-jeu { display: flex; align-items: center; justify-content: space-between; }
.micro { --niv: 0; width: 54px; height: 54px; border-radius: 50%; background: var(--gris); display: grid; place-items: center; position: relative; }
.micro span { width: 18px; height: 18px; border-radius: 50%; background: var(--gris2); transform: scale(calc(1 + var(--niv) * 1.6)); transition: transform .05s; }
.micro.voix span { background: var(--citron); }

/* Fin */
.recap { list-style: none; padding: 0; margin: 0; width: 100%; max-height: 40vh; overflow: auto; columns: 2; column-gap: 10px; }
.recap li { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 8px; margin-bottom: 5px; break-inside: avoid; background: #111; }
.recap li.juste span:last-child { color: var(--vert); } .recap li.faux { background: #2a0e0e; } .recap li.faux span:last-child { color: var(--rouge); }
.recap li.incompris span:last-child { color: var(--orange); }

/* Reglages */
.reglages h3 { margin: 26px 0 10px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.reglages h3 small { color: var(--gris2); font-weight: 400; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.puce input { display: none; }
.puce span { display: inline-block; padding: 10px 14px; border-radius: 999px; background: var(--gris); font-size: 15px; }
.puce input:checked + span { background: var(--citron); color: #000; font-weight: 700; }
.tables .puce span { min-width: 58px; text-align: center; }

/* Stats */
.onglets { display: flex; gap: 8px; overflow-x: auto; margin: 10px 0 16px; }
.onglets button { display: flex; align-items: center; background: #111; border-radius: 999px; padding: 6px 12px 6px 6px; white-space: nowrap; }
.onglets button.sel { outline: 2px solid var(--citron); }
.onglets small { color: var(--gris2); margin-left: 6px; }
.stats h3 { margin: 26px 0 10px; }
.note { color: var(--gris2); font-size: 13px; }
.jauge { height: 14px; background: var(--gris); border-radius: 7px; overflow: hidden; display: flex; }
.jauge i { background: var(--vert); } .jauge i.vu { background: var(--orange); opacity: .7; }
.conseils { padding-left: 18px; line-height: 1.45; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--gris2); font-weight: 500; padding: 6px 4px; }
td { padding: 7px 4px; border-top: 1px solid #1c1c1c; vertical-align: middle; }
tr.hors { opacity: .4; } tr[data-p] { cursor: pointer; }
tr.faux td:nth-child(2) { color: var(--rouge); } tr.juste td:nth-child(2) { color: var(--vert); } tr.incompris td:nth-child(2) { color: var(--orange); }
.barre-taux { display: inline-block; width: 40px; height: 6px; background: var(--gris); border-radius: 3px; margin-right: 6px; vertical-align: middle;
  background-image: linear-gradient(var(--c), var(--c)); background-size: calc(var(--t) * 100%) 100%; background-repeat: no-repeat; }
.grille { display: grid; grid-template-columns: 22px repeat(12, 1fr); gap: 3px; font-size: 11px; }
.grille b { color: var(--gris2); font-weight: 500; text-align: center; align-self: center; }
.grille span { aspect-ratio: 1; border-radius: 4px; }
.erreurs { padding-left: 20px; line-height: 1.6; }

.notions td:nth-child(4), .notions td:nth-child(5) { white-space: nowrap; }

.palier { background: #111; border-radius: 16px; padding: 14px; margin-bottom: 14px; }
.palier-haut { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.palier-haut b { color: var(--citron); }
.palier .jauge { height: 8px; margin-bottom: 8px; }
.fin-palier { display: none; background: var(--citron); color: #000; border-radius: 16px; padding: 14px 18px; text-align: center; animation: pop .5s; }
.fin-palier.visible { display: flex; flex-direction: column; gap: 4px; }
.paliers { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.paliers label { display: flex; gap: 10px; align-items: center; background: #111; border-radius: 12px; padding: 10px 12px; }
.paliers input { accent-color: var(--citron); width: 20px; height: 20px; }
.paliers input:checked + span { color: var(--citron); }
[hidden] { display: none !important; }
