/* Compatibilité visée : Chrome et WebView Android à partir de la version 70, Safari iOS 12.
   Deux règles en découlent dans tout ce fichier :
   - les espacements des conteneurs flex passent par des marges (« gap » n'y est compris
     qu'à partir de Chrome 84 et iOS 14.5) ; « gap » reste utilisé dans les grilles ;
   - les dégradés répètent chaque couleur avec une seule position par arrêt. */

:root {
  --terre: #b4532a;
  --terre-fonce: #8a3d1d;
  --ocre: #e3a72f;
  --ocre-fonce: #b07f1a;
  --sable: #f6e7c8;
  --creme: #fff8ea;
  --indigo: #2b3a67;
  --vert: #3e7c4f;
  --vert-fonce: #2a5937;
  --rouge: #b93226;
  --encre: #2a1f17;
  --encre-douce: #6b5a4a;
  --bois: #c58b52;
  --bois-fonce: #9a6634;
  --rayon: 18px;
  --ombre: 0 4px 0 rgba(0, 0, 0, 0.14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* overscroll-behavior : sur Chrome Android, glisser le doigt vers le bas rechargerait la page et perdrait la partie. */
html, body { margin: 0; min-height: 100%; overscroll-behavior-y: contain; }

body {
  font-family: ui-rounded, "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif;
  color: var(--encre);
  background: var(--indigo);
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible { outline: 3px solid var(--indigo); outline-offset: 2px; }

h1, h2, h3, p { margin: 0; }

#app {
  max-width: 520px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--sable);
  display: flex;
  flex-direction: column;
}

.ecran { display: none; flex: 1; flex-direction: column; padding: 12px 14px 16px; }
.ecran.actif { display: flex; }
.ecran > * + * { margin-top: 12px; }

/* ---------- Éléments communs ---------- */

.dessin { display: block; width: 42px; height: 42px; flex: none; }

.auvent {
  height: 20px;
  background: repeating-linear-gradient(90deg, var(--terre) 0, var(--terre) 28px, var(--creme) 28px, var(--creme) 56px);
  position: relative;
}

.auvent::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 12px;
  background:
    radial-gradient(circle at 14px 0, var(--terre) 12px, transparent 13px) 0 0 / 56px 12px repeat-x,
    radial-gradient(circle at 14px 0, var(--creme) 12px, transparent 13px) 28px 0 / 56px 12px repeat-x;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.12));
}

.carte { background: var(--creme); border-radius: var(--rayon); padding: 16px; box-shadow: var(--ombre); }
.carte.centre { text-align: center; }
.carte h3 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--terre-fonce); margin-bottom: 8px; }
.carte p + p { margin-top: 8px; }

.rond {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: var(--creme);
  font-size: 20px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
}

.rond.petit { font-size: 18px; background: var(--sable); }
.rond:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); }
.rond:disabled { opacity: 0.35; box-shadow: none; cursor: default; }

.valider {
  background: var(--vert);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 4px 0 var(--vert-fonce);
}

.valider:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--vert-fonce); }
.valider:disabled { background: #a9c3b1; box-shadow: none; cursor: default; }

.secondaire {
  background: var(--creme);
  font-weight: 800;
  font-size: 18px;
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--ombre);
}

.message { min-height: 1.3em; color: var(--rouge); font-weight: 700; }
.vide { color: var(--encre-douce); font-size: 15px; }

.etoiles { color: var(--ocre); font-size: 40px; letter-spacing: 6px; line-height: 1; }
.etoiles.grandes { font-size: 56px; margin: 10px 0; }
.etoiles .vide, .record .vide { color: rgba(0, 0, 0, 0.16); font-size: inherit; }

/* ---------- Accueil ---------- */

/* Bascule de la langue de l'interface, au-dessus de l'enseigne. */
.haut { display: flex; justify-content: flex-end; }
.bascule-interface {
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--creme);
  color: var(--indigo);
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}
.bascule-interface::before { content: "🌐 "; }
.ecran > .haut + .enseigne { margin-top: 8px; }

.enseigne { background: var(--creme); border-radius: var(--rayon); overflow: hidden; text-align: center; padding-bottom: 16px; box-shadow: var(--ombre); }
.enseigne h1 { font-size: 42px; color: var(--terre); margin: 24px 0 4px; letter-spacing: -0.5px; }
.accroche { margin: 0 18px; font-size: 16px; }

.bloc h2, .titre-ecran { font-size: 15px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--terre-fonce); }
.bloc h2 { margin: 4px 2px 8px; }

/* Autant de colonnes que de boutons : deux pour le client, trois langues de famille aujourd'hui. */
.choix-langue { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }

.choix-langue button {
  background: var(--creme);
  border-radius: 16px;
  padding: 12px;
  font-weight: 800;
  font-size: 18px;
  box-shadow: var(--ombre);
}

.choix-langue button[aria-pressed="true"] { background: var(--indigo); color: #fff; }
@media (max-width: 380px) {
  .choix-langue { gap: 8px; }
  .choix-langue button { padding: 12px 4px; font-size: 16px; }
}

.note-voix { margin-top: 10px; background: var(--creme); border-radius: 12px; padding: 8px 12px; font-size: 14px; color: var(--terre-fonce); }

.niveaux { display: grid; gap: 10px; }

.niveau {
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--creme);
  border-radius: 16px;
  padding: 12px 14px;
  text-align: left;
  box-shadow: var(--ombre);
}

.niveau > * + * { margin-left: 12px; }
.niveau:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.14); }
.niveau .numero { width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--ocre); display: grid; place-items: center; font-weight: 800; font-size: 22px; }
.niveau .texte { flex: 1; }
.niveau .titre { display: block; font-weight: 800; font-size: 18px; }
.niveau .detail { font-size: 14px; color: var(--encre-douce); }
.niveau .record { color: var(--ocre); font-size: 18px; letter-spacing: 2px; white-space: nowrap; }

.ecran > .pied { margin-top: auto; padding-top: 12px; text-align: center; }
.lien-parents { background: none; padding: 12px; color: var(--indigo); font-weight: 700; text-decoration: underline; }
.apropos { font-size: 14px; color: var(--encre-douce); text-align: left; }
.apropos summary { padding: 10px; text-align: center; font-weight: 700; color: var(--indigo); cursor: pointer; }
.apropos p { margin: 0 4px 8px; }

/* ---------- Jeu ---------- */

.barre { display: flex; align-items: center; }
.barre > * + * { margin-left: 10px; }
.avancement { flex: 1; display: flex; justify-content: center; }
.pastille { width: 14px; height: 14px; border-radius: 50%; background: rgba(0, 0, 0, 0.15); }
.pastille + .pastille { margin-left: 6px; }
.pastille.fait { background: var(--vert); }
.pastille.courant { background: var(--ocre); box-shadow: 0 0 0 2px var(--terre); }
.recette { text-align: right; font-weight: 800; line-height: 1.1; white-space: nowrap; }
.recette-titre { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--terre-fonce); }

.scene { display: flex; align-items: flex-start; }
.scene > * + * { margin-left: 14px; }
.client { width: 88px; flex: none; text-align: center; }
.visage { width: 88px; height: 88px; border-radius: 50%; background: var(--creme); display: grid; place-items: center; font-size: 58px; line-height: 1; box-shadow: var(--ombre); }
.prenom { margin-top: 6px; font-weight: 800; }

.bulle {
  flex: 1;
  min-height: 118px;
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--rayon);
  padding: 12px 14px 10px;
  box-shadow: var(--ombre);
}

.bulle > * + * { margin-top: 6px; }

.bulle::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 32px;
  border: 10px solid transparent;
  border-left: 0;
  border-right-color: #fff;
}

.bulle-texte { font-size: 20px; font-weight: 800; line-height: 1.25; }
.bulle-texte.argent { flex: 1; display: grid; place-items: center; }
.bulle-texte.argent .piece { transform: scale(1.3); }
.bulle-aide { font-size: 15px; font-style: italic; color: var(--indigo); }
.bulle-indice { display: flex; flex-wrap: wrap; align-items: center; }
.bulle-indice .dessin { width: 28px; height: 28px; margin: 0 2px 2px 0; }
.bulle-indice .plus { margin: 0 6px; font-weight: 800; }
.bulle > .bulle-actions { margin-top: auto; padding-top: 6px; display: flex; justify-content: flex-end; }
.bulle-actions > * + * { margin-left: 8px; }

.etal { background: var(--bois); border-radius: var(--rayon); overflow: hidden; box-shadow: inset 0 -8px 0 var(--bois-fonce), var(--ombre); }
.produits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 22px 12px 18px; }
.produits.inactif { opacity: 0.5; pointer-events: none; }

.produit {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--creme);
  border-radius: 16px;
  padding: 8px 4px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}

.produit:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2); }
.etiquette { margin-top: 4px; background: var(--ocre); border-radius: 999px; padding: 1px 10px; font-weight: 800; font-size: 14px; }

/* Hauteur fixe : le panneau ne saute pas d'une phase à l'autre et le bouton reste près du contenu. */
.bas { min-height: 326px; display: flex; flex-direction: column; background: var(--creme); border-radius: var(--rayon); padding: 12px; box-shadow: var(--ombre); }
.bas > * + * { margin-top: 10px; }
.bas:focus { outline: none; }
/* Pas de bouton collant : quand la place manque, il recouvrirait le panier et capterait
   les touchers destinés aux articles. Les paliers plus bas font tenir l'écran à la place. */
.bas > .valider { margin-top: auto; }
/* La marge automatique du bouton vaut zéro quand la place manque : l'espace vient du message. */
.bas > .message:not(:last-child) { padding-bottom: 10px; }
.consigne { font-weight: 800; font-size: 18px; color: var(--terre-fonce); }
.recap { font-size: 18px; font-weight: 700; }
.recap .dessin { display: inline-block; width: 26px; height: 26px; vertical-align: -7px; }
.recap small { font-size: 13px; font-weight: 600; color: var(--encre-douce); }

.panier, .rendu {
  min-height: 58px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  background: #fff;
  border: 2px dashed var(--bois);
  border-radius: 14px;
  padding: 4px;
}

.panier > *, .rendu > * { margin: 4px; }

.article { display: inline-flex; align-items: center; background: var(--sable); border-radius: 12px; padding: 4px 12px; font-size: 20px; font-weight: 800; }
.article .dessin { width: 28px; height: 28px; margin-right: 6px; }

.choix-total { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choix { background: var(--ocre); border-radius: 16px; padding: 14px 4px; font-size: 21px; font-weight: 800; box-shadow: 0 4px 0 var(--ocre-fonce); }
.choix:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ocre-fonce); }
.choix:disabled { opacity: 0.35; box-shadow: none; text-decoration: line-through; cursor: default; }

.caisse { display: flex; align-items: center; justify-content: space-between; background: var(--bois); border-radius: 14px; padding: 10px; box-shadow: inset 0 -5px 0 var(--bois-fonce); }
.rendu > .somme { margin-left: auto; font-weight: 800; font-size: 18px; }

.piece {
  display: inline-grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  font-weight: 800;
  color: var(--encre);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.28), inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}

button.piece:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28); }

/* Les vraies pièces : 25 F dorée, 50 et 100 F argentées, 200 et 500 F bicolores. */
.piece.v25 { width: 40px; height: 40px; font-size: 14px; background: radial-gradient(circle at 35% 30%, #f6dc8a, #c9952a); }
.piece.v50 { width: 44px; height: 44px; font-size: 15px; background: radial-gradient(circle at 35% 30%, #f6f6f6, #a9adb3); }
.piece.v100 { width: 48px; height: 48px; font-size: 15px; background: radial-gradient(circle at 35% 30%, #f6f6f6, #a9adb3); }
.piece.v200 { width: 52px; height: 52px; font-size: 15px; background: radial-gradient(circle, #ececec 0, #ececec 54%, #d2a13a 56%); }
.piece.v500 { width: 56px; height: 56px; font-size: 16px; background: radial-gradient(circle, #ecc766 0, #ecc766 54%, #b3b7bd 56%); }
.rendu .piece { width: 38px; height: 38px; font-size: 13px; }

.billet {
  display: inline-grid;
  place-items: center;
  min-width: 110px;
  height: 52px;
  padding: 0 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2f7d6b, #1f5a4d);
  color: #fff;
  font-size: 18px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25), inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.bravo { flex: 1; display: grid; place-content: center; text-align: center; gap: 6px; }
.gain { font-size: 24px; font-weight: 800; color: var(--vert); }

/* Écrans de téléphone : l'adresse et les barres du navigateur prennent 80 à 110 px de la hauteur
   de l'appareil. En dessous de 840 px visibles, mise en page serrée et étal effacé quand on ne sert plus. */
@media (max-height: 840px) {
  .client, .visage { width: 72px; }
  .visage { height: 72px; font-size: 46px; }
  .bulle { min-height: 96px; }
  .bulle-texte { font-size: 18px; }
  .produits { gap: 8px; padding: 18px 10px 14px; }
  .produit { padding: 6px 4px; }
  .produit .dessin { width: 34px; height: 34px; }
  .bas { min-height: 0; }
  .etal.replie { display: none; }
}

/* Petits écrans (téléphone 360 × 640 ou 320 × 568 une fois les barres déduites) :
   la mise en page serrée demande au plus 594 px, aide et indice ouverts. */
@media (max-height: 700px) {
  .ecran { padding: 8px 10px 10px; }
  .ecran > * + * { margin-top: 8px; }
  .client, .visage { width: 56px; }
  .visage { height: 56px; font-size: 36px; }
  .prenom { margin-top: 2px; font-size: 14px; }
  .scene > * + * { margin-left: 12px; }
  .bulle { min-height: 0; padding: 8px 10px; }
  .bulle::before { top: 18px; }
  .bulle-texte { font-size: 17px; }
  .auvent { height: 14px; }
  .produits { gap: 6px; padding: 16px 8px 12px; }
  .produit { padding: 4px; }
  .produit .dessin { width: 30px; height: 30px; }
  .etiquette { margin-top: 2px; }
  .bas { padding: 8px 10px; }
  .bas > * + * { margin-top: 6px; }
  .bas[data-phase="servir"] .consigne { display: none; }
  .panier, .rendu { min-height: 50px; }
  .valider { padding: 9px; font-size: 18px; }
}

/* Très petits écrans (iPhone SE de première génération sous Safari, environ 320 × 460) :
   l'étal passe sur une seule rangée de six. */
@media (max-height: 540px) {
  .etal .auvent { display: none; }
  .produits { grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 8px 6px; }
  .produit { padding: 4px 0; }
  .etiquette { padding: 1px 4px; font-size: 12px; }
  .caisse { padding: 6px; }
  .panier, .rendu { min-height: 46px; }
}

@media (max-width: 340px) {
  .caisse { padding-left: 4px; padding-right: 4px; }
}

/* ---------- Bilan ---------- */

.bilan { display: flex; flex-direction: column; flex: 1; }
.bilan > * + * { margin-top: 12px; }
.bilan h2 { font-size: 26px; color: var(--terre); }
.chiffres { font-size: 18px; line-height: 1.5; }
.mots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mots li { background: #fff; border-radius: 12px; padding: 6px 10px; }
.mots strong { display: block; font-size: 17px; }
.mots span { font-size: 14px; color: var(--encre-douce); }
.bilan > .actions { display: grid; gap: 10px; margin-top: auto; padding-top: 12px; }

/* ---------- Studio ---------- */

.titre-ecran { flex: 1; font-size: 18px; }
.note { font-size: 14px; color: var(--encre-douce); }
.avancement-studio { font-weight: 800; }
.studio-liste { list-style: none; margin-bottom: 0; padding: 0; display: grid; gap: 8px; }
.studio-liste li { display: flex; align-items: center; background: var(--creme); border-radius: 14px; padding: 10px 12px; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1); }
.studio-liste li > * + * { margin-left: 8px; }
.mot { flex: 1; min-width: 0; }
.mot strong { display: block; font-size: 18px; }
.mot span { font-size: 14px; color: var(--encre-douce); }
.btn { min-width: 44px; min-height: 44px; background: var(--sable); border-radius: 12px; padding: 9px 12px; font-weight: 800; flex: none; }
.btn.rec { background: var(--terre); color: #fff; }
.btn.rec.actif { background: var(--rouge); animation: pulse 1s infinite; }

/* ---------- Animations ---------- */

.arrive { animation: arrive 0.35s ease-out; }
.secoue { animation: secoue 0.35s; }
.pop { animation: pop 0.2s; }

@keyframes arrive { from { transform: translateX(-28px); opacity: 0; } }
@keyframes secoue { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes pop { 50% { transform: scale(1.12); } }
@keyframes pulse { 50% { opacity: 0.6; } }

@media (prefers-reduced-motion: reduce) {
  .arrive, .secoue, .pop, .btn.rec.actif { animation: none; }
}
