/* Les Dumplies — styles des jeux. 1em = 1 % de la largeur du cadre (voir #cadre) : tout grandit avec la fenêtre.
   Sur un petit écran (téléphone à l'horizontale), les textes et les boutons ne descendent pas sous une taille lisible
   et touchable au doigt : max(…em, …px), sans effet sur un ordinateur (le cadre y fait plus de 1000 px de large). */
:root { --fond: #FFF1E6; --encre: #4A4A6A; --doux: #8A8AA8; --carte: #FFFFFF; --bord: #F1E4EF;
  --rose: #F7AAC0; --rose-f: #D66E8B; --menthe: #A7DCD6; --jaune: #FCE192; --vert: #AAD680; --orange: #F9A64A; --violet: #D0ABE6; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: linear-gradient(#FDE7F0, #FFF4DC); color: var(--encre); font-family: Nunito, system-ui, sans-serif; overflow: hidden; touch-action: none; }
body { display: flex; align-items: center; justify-content: center; }
#cadre { position: relative; width: min(100vw, 177.78vh); height: min(56.25vw, 100vh); font-size: min(1vw, 1.7778vh); overflow: hidden; background: #C3E8F8; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
/* hauteur réellement visible (Safari sur iPhone : 100vh compte aussi la place sous les barres) */
@supports (height: 100dvh) { #cadre { width: min(100vw, 177.78dvh); height: min(56.25vw, 100dvh); font-size: min(1vw, 1.7778dvh); } }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.titre { font-family: Fredoka, Nunito, sans-serif; font-weight: 700; }

/* barre du haut */
#hud { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: .7em; padding: .7em .9em; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.pastille { display: inline-flex; align-items: center; gap: .35em; height: 2.7em; padding: 0 .95em; border: 0; border-radius: 1.35em; background: rgba(255, 255, 255, .92); color: var(--encre);
  font: 800 max(1.35em, 15px) Nunito, sans-serif; box-shadow: 0 .18em 0 rgba(120, 90, 140, .25); white-space: nowrap; text-decoration: none; }
button.pastille, a.pastille { cursor: pointer; }
@media (hover: hover) { button.pastille:hover, a.pastille:hover { transform: translateY(-.06em); } }
.pastille svg { width: 1.25em; height: 1.25em; display: block; }
.espace { flex: 1; }
#hud-titre { font: 700 max(1.6em, 13px) Fredoka, Nunito, sans-serif; color: #fff; text-shadow: 0 .08em 0 rgba(90, 70, 130, .55), 0 0 .4em rgba(90, 70, 130, .35); pointer-events: none; }
#vies { display: inline-flex; gap: .15em; }
#vies svg { width: 1.2em; height: 1.2em; }
.vide { opacity: .25; filter: grayscale(1); }

/* panneau central */
#panneau { position: absolute; inset: 0; z-index: 8; display: none; align-items: center; justify-content: center; background: rgba(70, 55, 110, .34); }
#panneau.on { display: flex; }
.carte { position: relative; width: max(50em, min(560px, 92%)); max-height: 94%; overflow: auto; background: var(--carte); border-radius: 2.2em; padding: 2em 2.6em 2.2em; text-align: center; box-shadow: 0 .6em 0 var(--bord), 0 1.6em 3em rgba(70, 50, 110, .3);
  animation: arrive .38s cubic-bezier(.2, 1.5, .4, 1); touch-action: pan-y; }
@keyframes arrive { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
.carte h1 { margin: 0 0 .25em; font: 700 max(3.2em, 22px) Fredoka, Nunito, sans-serif; color: var(--rose-f); line-height: 1.08; }
.carte .sous { margin: 0 0 .7em; font: 800 max(1.35em, 11px) Nunito, sans-serif; color: var(--doux); }
.carte p { margin: .45em 0; font-size: max(1.55em, 13px); line-height: 1.38; font-weight: 700; }
.carte ul { margin: .5em auto; padding: 0; list-style: none; text-align: left; display: inline-block; }
.carte li { font-size: max(1.45em, 12.5px); line-height: 1.4; font-weight: 700; margin: .28em 0; padding-left: 1.5em; position: relative; }
.carte li::before { content: ''; position: absolute; left: .25em; top: .32em; width: .75em; height: .75em; border-radius: 50%; background: var(--c, var(--rose)); }
kbd { font: 800 .86em Nunito, sans-serif; background: #F4EFFA; border-radius: .4em; padding: .05em .45em; box-shadow: 0 .12em 0 #D9D0E8; }
.boutons { display: flex; flex-wrap: wrap; gap: .9em; justify-content: center; margin-top: 1.1em; }
.btn { border: 0; cursor: pointer; font: 800 max(1.7em, 15px) Nunito, sans-serif; color: var(--encre); background: #F3EEF8; padding: .55em 1.25em; border-radius: 1.5em; box-shadow: 0 .2em 0 #D9D0E8; text-decoration: none; display: inline-block; }
.btn.primaire { background: #F7AAC0; color: #fff; text-shadow: 0 .06em 0 #C4587A; box-shadow: 0 .22em 0 #D66E8B; }
@media (hover: hover) { .btn:hover { transform: translateY(-.08em); } }
.btn:active { transform: translateY(.1em); box-shadow: 0 .08em 0 #D9D0E8; }
.etoiles-fin { display: flex; justify-content: center; gap: .6em; margin: .4em 0 .2em; }
.etoiles-fin svg { width: 6.5em; height: 6.5em; animation: pop .5s cubic-bezier(.2, 1.8, .4, 1) both; }
@keyframes pop { from { transform: scale(0) rotate(-60deg); } to { transform: none; } }
.record { color: var(--doux); font-size: max(1.3em, 11px) !important; }
.gain { display: inline-flex; align-items: center; gap: .6em; background: #FFF6D8; border-radius: 1.2em; padding: .3em .9em; margin-top: .4em; font: 800 max(1.35em, 12px) Nunito, sans-serif; }
.gain svg { width: 3em; height: 3em; }

/* bulles de dialogue */
#bulle { position: absolute; left: 50%; bottom: 3.2%; transform: translateX(-50%); max-width: 74%; z-index: 6; pointer-events: none; opacity: 0; transition: opacity .18s; }
#bulle.on { opacity: 1; }
#bulle span { display: block; background: rgba(255, 255, 255, .95); border-radius: 1.2em; padding: .42em 1em .5em; font: 800 max(1.75em, 14px) Nunito, sans-serif; text-align: center; box-shadow: 0 .16em 0 var(--t, #D9D0E8); }
#bulle b { color: var(--t, var(--rose-f)); font-family: Fredoka, Nunito, sans-serif; font-weight: 700; }
#grand { position: absolute; left: 0; right: 0; top: 30%; text-align: center; z-index: 6; pointer-events: none; font: 700 6em Fredoka, Nunito, sans-serif; color: #fff; text-shadow: 0 .05em 0 #6A4C93, .04em 0 0 #6A4C93, -.04em 0 0 #6A4C93, 0 -.04em 0 #6A4C93, .03em .03em 0 #6A4C93, -.03em .03em 0 #6A4C93, 0 .1em .2em rgba(60, 40, 90, .4); opacity: 0; }
#grand.on { animation: grand 1s ease-out; }
@keyframes grand { 0% { transform: scale(.5); opacity: 0; } 18% { transform: scale(1.12); opacity: 1; } 30% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-.3em); } }
#chargement { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; background: #FFF1E6; font: 700 3em Fredoka, Nunito, sans-serif; color: var(--rose-f); }

/* commandes à l'écran */
.ctrl { position: absolute; z-index: 5; }
.gros-btn { border: 0; cursor: pointer; width: 6.4em; height: 6.4em; border-radius: 50%; font: 700 1.5em Fredoka, Nunito, sans-serif; color: #fff; text-shadow: 0 .06em 0 rgba(0, 0, 0, .25); box-shadow: 0 .3em 0 rgba(0, 0, 0, .18); }
.gros-btn:active, .gros-btn.on { transform: translateY(.2em); box-shadow: 0 .1em 0 rgba(0, 0, 0, .18); }

/* accueil : barre des jeux */
#menu { position: absolute; left: 0; right: 0; bottom: .7em; display: flex; justify-content: center; gap: .5em; z-index: 5; pointer-events: none; }
/* font-size : sans lui, un <button> garde la taille de texte du navigateur (13 px) et l'icône ne suit plus l'écran */
.icone-jeu { font-size: inherit; pointer-events: auto; position: relative; width: max(6.6em, 44px); height: max(6.6em, 44px); border: .25em solid #fff; border-radius: 1.5em; background: var(--c, #fff); cursor: pointer; padding: 0; box-shadow: 0 .3em 0 rgba(90, 70, 130, .3); overflow: hidden; }
@media (hover: hover) { .icone-jeu:hover { transform: translateY(-.3em); } }
.icone-jeu.on { border-color: #FFD84A; transform: translateY(-.3em); }
.icone-jeu svg.visage { position: absolute; inset: 0; width: 100%; height: 100%; }
.icone-jeu .mini { position: absolute; left: 0; right: 0; bottom: .25em; display: flex; justify-content: center; gap: .05em; }
.icone-jeu .mini svg { width: 1.25em; height: 1.25em; }
.fleche { font-size: inherit; position: absolute; top: 44%; z-index: 5; width: max(4.2em, 44px); height: max(4.2em, 44px); border: 0; border-radius: 50%; background: rgba(255, 255, 255, .85); cursor: pointer; box-shadow: 0 .25em 0 rgba(90, 70, 130, .3); }
.fleche svg { width: 2.4em; height: 2.4em; display: block; margin: auto; }
@media (hover: hover) { .fleche:hover { background: #fff; } }
#fiche { position: absolute; left: 50%; top: 13%; transform: translateX(-50%); width: max(46em, min(520px, 90%)); z-index: 6; display: none; background: #fff; border-radius: 1.8em; padding: 1.1em 1.6em 1.3em; text-align: center; box-shadow: 0 .4em 0 var(--bord), 0 1em 2em rgba(70, 50, 110, .3); animation: arrive-fiche .3s cubic-bezier(.2, 1.5, .4, 1); }
/* la fiche est centrée par translateX(-50%) : son animation d'entrée doit le garder, sinon elle part collée à droite puis saute au milieu */
@keyframes arrive-fiche { from { transform: translateX(-50%) scale(.7); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
#fiche.on { display: block; }
#fiche h2 { margin: 0; font: 700 2.9em Fredoka, Nunito, sans-serif; color: var(--t, var(--rose-f)); }
#fiche .genre { font: 800 max(1.2em, 10px) Nunito, sans-serif; color: var(--doux); text-transform: uppercase; letter-spacing: .08em; }
#fiche p { margin: .35em 0 .6em; font-size: max(1.5em, 13px); font-weight: 700; line-height: 1.35; }
#fiche .fermer { position: absolute; right: .6em; top: .5em; border: 0; background: #F3EEF8; width: 2.2em; height: 2.2em; border-radius: 50%; font: 800 max(1.4em, 16px) Nunito, sans-serif; color: var(--doux); cursor: pointer; }
#fiche .etoiles { display: flex; justify-content: center; gap: .2em; margin-bottom: .3em; }
#fiche .etoiles svg { width: 2.4em; height: 2.4em; }

/* carnet d'autocollants */
.carnet { width: 84em; max-height: 92%; padding: 1.4em 1.8em 1.6em; }
.grille-carnet { display: grid; grid-template-columns: repeat(10, 1fr); gap: .5em; margin-top: .6em; }
.colle { position: relative; aspect-ratio: 1; border-radius: 1em; background: #F6F1FA; overflow: hidden; }
.colle.gagne { background: var(--c); box-shadow: 0 0 0 .22em #fff, 0 .3em .5em rgba(90, 70, 130, .3); transform: rotate(var(--r)); }
.colle svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.colle:not(.gagne) svg { filter: brightness(0) opacity(.09); }
.ligne-carnet { font: 800 max(1.15em, 10px) Nunito, sans-serif; color: var(--doux); text-align: center; padding-top: .3em; line-height: 1.1; }

/* atelier de Fabrique ton Dumply */
#atelier { position: absolute; right: 1.2em; top: max(5.2em, 52px); bottom: 1.2em; width: max(44em, min(430px, 61%)); z-index: 5; display: flex; flex-direction: column; gap: .7em; background: rgba(255, 255, 255, .95); border-radius: 1.8em; padding: 1.1em 1.3em; box-shadow: 0 .4em 0 var(--bord), 0 1em 2em rgba(70, 50, 110, .25); }
/* 16 px au moins : en dessous, Safari sur iPhone zoome toute la page quand on touche le champ */
#atelier input { width: 100%; border: .16em solid var(--bord); border-radius: 1em; padding: .35em .7em; font: 800 max(2em, 16px) Nunito, sans-serif; color: var(--encre); outline: 0; user-select: text; -webkit-user-select: text; }
#atelier input:focus { border-color: var(--rose); }
.onglets { display: flex; flex-wrap: wrap; gap: .3em; }
.onglet { border: 0; cursor: pointer; background: #F3EEF8; color: var(--encre); font: 800 max(1.2em, 12px) Nunito, sans-serif; padding: .36em .75em; border-radius: 1em; }
.onglet.on { background: var(--rose); color: #fff; }
.zone { flex: 1; min-height: 0; display: flex; flex-wrap: wrap; align-content: flex-start; gap: .55em; padding: .5em .2em; overflow: auto; touch-action: pan-y; }
.choix { border: .16em solid transparent; cursor: pointer; background: #F8F4FB; color: var(--encre); font: 800 max(1.5em, 13px) Nunito, sans-serif; padding: .45em .85em; border-radius: 1em; box-shadow: 0 .12em 0 #E2D9EC; }
.choix.on { border-color: var(--rose-f); background: #FDE0E8; }
.pastille-couleur { font-size: inherit; width: max(5em, 40px); height: max(5em, 40px); border-radius: 50%; border: .3em solid #fff; box-shadow: 0 0 0 .12em #D9D0E8; cursor: pointer; }
.pastille-couleur.on { box-shadow: 0 0 0 .3em var(--rose-f); }
.essais { display: flex; gap: .4em; }
.essais button { flex: 1; border: 0; cursor: pointer; background: #E7F5E0; color: #4F8A3A; font: 800 max(1.35em, 12px) Nunito, sans-serif; padding: .45em .2em; border-radius: 1em; box-shadow: 0 .14em 0 #C4E2B6; }
.fin { display: flex; gap: .6em; justify-content: center; }
.fin .btn { font-size: max(1.55em, 14px); }

/* logo (comme sur le sommaire de la série) */
.logo { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.logo-les { font: 600 1.3em Fredoka, Nunito, sans-serif; color: #fff; text-shadow: 0 .08em 0 rgba(90, 70, 130, .5); margin-left: .2em; }
.logo-nom { font: 700 3.4em Fredoka, Nunito, sans-serif; letter-spacing: .02em; }
.logo-nom span { color: var(--c); -webkit-text-stroke: .055em var(--t); paint-order: stroke fill; display: inline-block; }

/* petit écran : le titre du jeu (déjà dans ses règles) laisse la place aux boutons de la barre du haut */
@media (max-height: 500px), (max-width: 820px) { #hud-titre { display: none; } }

/* téléphone à la verticale : on demande de le tourner (le jeu attend, voir commun.js) ; tablette à la verticale : une phrase sous l'image */
#tourne { display: none; }
#tourne p { margin: 0; }
@media (orientation: portrait) and (max-width: 640px) {
  #tourne { display: flex; position: fixed; inset: 0; z-index: 50; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; background: linear-gradient(#FDE7F0, #FFF4DC); }
  #tourne svg { width: 130px; height: 130px; }
  #tourne .tel { transform-origin: 60px 60px; animation: tourne 2.4s ease-in-out infinite; }
  #tourne .tel-p { font: 700 26px Fredoka, Nunito, sans-serif; color: var(--rose-f); }
  #tourne .tab-p { display: none; }
}
@media (orientation: portrait) and (min-width: 641px) and (pointer: coarse) {
  #tourne { display: block; position: fixed; left: 0; right: 0; bottom: 5vh; text-align: center; pointer-events: none; }
  #tourne svg, #tourne .tel-p { display: none; }
  #tourne .tab-p { font: 800 20px Nunito, sans-serif; color: var(--doux); }
}
@keyframes tourne { 0%, 25% { transform: none; } 55%, 85% { transform: rotate(-90deg); } 100% { transform: none; } }
