/* Composants partagés : boutons, puces, tuiles des stands, scène de jeu, résultat, carte de question, toast, modale, confettis. */

/* ---------- Boutons : contour épais, ombre dure, ils s'écrasent sous le doigt ---------- */
.primary, .secondary, .chip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--e2);
  border: var(--trait-fort) solid var(--encre);
  box-shadow: var(--ombre);
  transition: transform .12s var(--sortie), box-shadow .12s var(--sortie), background-color .15s;
}
.primary {
  min-height: 60px;
  padding: 10px 28px;
  border-radius: 999px;
  background: var(--soleil);
  font: 400 24px/1 var(--titre);
  letter-spacing: .02em;
}
.secondary {
  min-height: 56px;
  padding: 8px 22px;
  border-radius: 999px;
  background: var(--papier);
  font: 400 20px/1 var(--titre);
}
.chip-button {
  min-width: var(--tactile);
  min-height: var(--tactile);
  padding: 0 12px;
  border-width: var(--trait);
  border-radius: 999px;
  background: var(--papier);
  box-shadow: 3px 3px 0 var(--encre);
  font-weight: 800;
  font-size: 15px;
}
.chip-button svg { width: 22px; height: 22px; flex: none; }
@media (hover: hover) and (pointer: fine) {
  .primary:not(:disabled):hover, .secondary:not(:disabled):hover, .chip-button:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--encre); }
  .chip-button:hover { box-shadow: 4px 4px 0 var(--encre); }
}
.primary:active, .secondary:active, .chip-button:active,
.primary:disabled, .secondary:disabled { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--encre); }
.primary:disabled, .secondary:disabled { cursor: default; opacity: .75; }
.button-row { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--e3); width: 100%; }

/* Bouton son : l'icône suit l'état */
#soundBtn .son-on, #soundBtn[aria-pressed="true"] .son-off { display: none; }
#soundBtn[aria-pressed="true"] .son-on { display: block; }

/* ---------- Tuiles des stands ---------- */
.game {
  --tilt: -1.4deg;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 168px;
  padding: 14px;
  text-align: left;
  background: var(--card-accent);
  border: var(--trait) solid var(--encre);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  transform: rotate(var(--tilt));
  transition: transform .15s var(--sortie), box-shadow .15s var(--sortie);
}
.game:nth-child(2n) { --tilt: 1.2deg; }
.game:nth-child(3n) { --tilt: -.6deg; }
.game-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin-bottom: 4px;
  background: var(--papier);
  border: var(--trait) solid var(--encre);
  border-radius: 50%;
}
.game-icon img { width: 42px; height: 42px; }
.game-title { font: 400 23px/1 var(--titre); }
.game-sub { font-size: 14px; font-weight: 700; line-height: 1.3; }
.game.random { background: repeating-linear-gradient(-45deg, var(--papier) 0 12px, var(--creme) 12px 24px); }
@media (hover: hover) and (pointer: fine) {
  .game:hover { transform: rotate(0deg) translate(-2px, -2px); box-shadow: var(--ombre-forte); }
}
.game:active { transform: rotate(var(--tilt)) translate(3px, 3px); box-shadow: 1px 1px 0 var(--encre); }
.stands.entree .game { animation: pose .5s var(--rebond) both; animation-delay: calc(var(--i) * 45ms); }

/* ---------- Scène de jeu : chaque stand a sa couleur (--stand) ---------- */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--stand);
  background-image: radial-gradient(rgb(255 255 255 / .32) 2px, transparent 2.5px);
  background-size: 22px 22px;
}
.stage.entree { animation: monte .38s var(--sortie) both; }
.auvent {
  height: 38px;
  flex: none;
  background:
    linear-gradient(var(--encre), var(--encre)) 0 20px / 100% 3px no-repeat,
    radial-gradient(circle at 14px 0, var(--papier) 12px, var(--encre) 12.5px 15px, transparent 15.5px) 0 20px / 28px 18px repeat-x,
    repeating-linear-gradient(90deg, var(--stand) 0 28px, var(--papier) 28px 56px) 0 0 / 100% 21px no-repeat;
}
.stage-header { display: grid; gap: 6px; justify-items: start; width: 100%; max-width: 760px; margin: 0 auto; padding: 4px var(--gouttiere) var(--e2); }
.stage-header h2 { margin: 6px 0 0; font: 400 clamp(38px, 11vw, 60px)/.95 var(--titre); outline: none; }
.stage-rules { margin: 0; max-width: 46ch; font-weight: 700; font-size: 15px; }
.stage-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--e4);
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: var(--e3) var(--gouttiere) calc(var(--bas-sur) + 20px);
}
.subline { margin: 0; text-align: center; font-size: 15px; }

/* ---------- Résultat ---------- */
.result {
  width: 100%;
  max-width: 520px;
  padding: 14px 18px;
  text-align: center;
  background: var(--papier);
  border: var(--trait) solid var(--encre);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  font-weight: 700;
  line-height: 1.4;
}
.result.success { background: var(--menthe); }
.result.fail { background: var(--rose); }

/* ---------- Tampon : un résultat imprimé par-dessus le jeu (roue, chronos) ---------- */
.result.tampon {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  display: grid;
  gap: 4px;
  width: min(92%, 360px);
  padding: 16px 14px;
  background: var(--papier);
  border: var(--trait-fort) solid var(--encre);
  border-radius: 20px;
  box-shadow: 0 0 0 5px var(--papier), 0 0 0 9px var(--pomme), 9px 11px 0 9px var(--encre);
  transform: translate(-50%, -50%) rotate(-6deg);
  cursor: pointer;
  animation: tamponne .5s var(--sortie) both;
}
.tampon-titre { font-weight: 800; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.tampon-nom { font: 400 clamp(34px, 11vw, 52px)/1 var(--titre); color: var(--rouge-tampon); overflow-wrap: anywhere; }
.tampon-defi { font-size: 17px; font-weight: 800; line-height: 1.3; }
.tampon small { font-size: 13px; font-weight: 600; color: var(--encre-douce); }
@keyframes tamponne {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.3) rotate(-16deg); }
  55% { opacity: 1; transform: translate(-50%, -50%) scale(.94) rotate(-5deg); }
  100% { transform: translate(-50%, -50%) scale(1) rotate(-6deg); }
}

/* ---------- Carte de question (jeux de cartes à texte) ---------- */
/* La carte se centre dans l'espace libre ; compteur et bouton restent en bas, sous le pouce. */
.prompt-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--e4); width: 100%; }
.prompt-wrap > .prompt-card { margin-block: auto; }
.prompt-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 230px;
  padding: 28px 20px;
  text-align: center;
  background: var(--papier);
  border: var(--trait-fort) solid var(--encre);
  border-radius: 24px;
  box-shadow: var(--ombre-forte);
}
.prompt-card small { font-weight: 800; font-size: 13px; letter-spacing: .08em; }
.prompt-card .question { margin: 14px 0; font: 400 clamp(27px, 7.4vw, 40px)/1.12 var(--titre); }
.prompt-card .prompt-foot { font-size: 14px; font-weight: 700; }
.prompt-card.reveal { animation: pose .45s var(--rebond) both; }
.counter { margin: 0; padding: 2px 12px; background: var(--papier); border: 2px solid var(--encre); border-radius: 999px; font-size: 14px; font-weight: 800; }
.deco { position: absolute; pointer-events: none; }
#nextQuestion { width: min(100%, 420px); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  z-index: 30;
  top: calc(var(--haut-sur) + 10px);
  left: 50%;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  background: var(--encre);
  color: var(--papier);
  border-radius: 999px;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -180%);
  transition: transform .35s var(--rebond);
}
.toast.show { transform: translate(-50%, 0); }

/* ---------- Modale des joueurs : en haut de l'écran pour rester visible clavier ouvert ---------- */
.modal-bg {
  position: fixed;
  z-index: 21;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(var(--haut-sur) + 16px) 16px calc(var(--bas-sur) + 16px);
  overflow-y: auto;
  background: rgb(27 19 64 / .6);
}
.modal {
  width: min(480px, 100%);
  padding: 20px;
  background: var(--papier);
  border: var(--trait-fort) solid var(--encre);
  border-radius: 24px;
  box-shadow: var(--ombre-forte);
  animation: pose .35s var(--rebond) both;
}
.modal h2 { margin: 0 0 4px; font: 400 34px/1 var(--titre); }
.modal p { margin: 0 0 var(--e4); font-size: 15px; color: var(--encre-douce); }
.input-row { display: flex; gap: var(--e2); }
.input-row input {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  padding: 0 14px;
  font-size: 17px;
  font-weight: 700;
  background: #fff;
  border: var(--trait) solid var(--encre);
  border-radius: 14px;
}
.input-row .primary { min-height: 56px; padding: 6px 18px; font-size: 20px; }
.names { display: flex; flex-wrap: wrap; gap: var(--e2); margin: var(--e4) 0; }
.name-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 2px 2px 14px;
  background: var(--soleil);
  border: var(--trait) solid var(--encre);
  border-radius: 999px;
  font-weight: 800;
  font-size: 16px;
}
.name-pill:nth-child(4n+2) { background: var(--rose); }
.name-pill:nth-child(4n+3) { background: var(--piscine); }
.name-pill:nth-child(4n+4) { background: var(--menthe); }
.name-pill button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  background: transparent;
  border: 0;
  border-radius: 50%;
}
.name-pill button:active { background: rgb(27 19 64 / .12); }
.modal-actions { display: flex; justify-content: flex-end; }

/* ---------- Dé de « Surprends-moi » ---------- */
.de-scene { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; background: rgb(255 244 224 / .75); }
.de {
  width: 128px;
  height: 128px;
  padding: 18px;
  background: var(--papier);
  border: 5px solid var(--encre);
  border-radius: 26px;
  box-shadow: var(--ombre-forte);
  animation: roule 1.1s cubic-bezier(.2, .7, .3, 1) both;
}
.de-face { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; height: 100%; }
.de-face i { border-radius: 50%; }
.de-face i.on { background: var(--encre); }
@keyframes roule {
  0% { transform: translate(-70vw, -30vh) rotate(-540deg) scale(.6); }
  45% { transform: translate(14vw, 6vh) rotate(-80deg); }
  65% { transform: translate(-4vw, -5vh) rotate(25deg); }
  82% { transform: translate(2vw, 0) rotate(-8deg); }
  100% { transform: none; }
}

/* ---------- Confettis ---------- */
.confetti {
  position: fixed;
  top: 0;
  z-index: 45;
  width: 10px;
  height: 15px;
  border: 2px solid var(--encre);
  pointer-events: none;
  animation: confettiFall var(--d, 2s) cubic-bezier(.3, .6, .5, 1) both;
}

@keyframes pose { from { opacity: 0; transform: translateY(18px) scale(.9) rotate(-2deg); } }
@keyframes monte { from { opacity: 0; transform: translateY(28px); } }
@keyframes confettiFall {
  from { transform: translate3d(0, -20px, 0) rotate(0); }
  85% { opacity: 1; }
  to { opacity: 0; transform: translate3d(var(--dx), 105vh, 0) rotate(var(--rot)); }
}
