/* Frimousses : style « carnet de dessin moderne ».
   Fond crème, formes rondes, traits d'encre, ombres décalées. Aucune couleur d'émotion sur les cartes visages.
   Police Andika embarquée (assets/css/police.css), avec une pile de polices de secours. */

:root {
  --creme: #fbf6ec;
  --papier: #fffdf7;
  --encre: #2b2b2b;
  --lavande: #dcd3f5;
  --lavande2: #b3a5e6;
  --sable: #e3c27e;
  --rayon: 22px;
  --ombre: 3px 4px 0 rgba(43, 43, 43, 0.22);
  font-family: Andika, 'Comic Neue', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--creme);
  color: var(--encre);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

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

.icone {
  width: 40px;
  height: 40px;
  display: block;
}

/* ---------- boutons ---------- */
.bouton {
  min-width: 64px;
  min-height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--papier);
  border: 4px solid var(--encre);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.bouton:active {
  transform: translate(2px, 3px);
  box-shadow: 1px 1px 0 rgba(43, 43, 43, 0.22);
}
.bouton[aria-pressed='true'] {
  background: var(--lavande);
  outline: 4px solid var(--lavande2);
  outline-offset: 2px;
}
.bouton:disabled {
  opacity: 0.4;
  cursor: default;
}
.bouton.rond {
  width: 68px;
  height: 68px;
  padding: 8px;
  border-radius: 50%;
}
.bouton.gros {
  min-width: 120px;
  min-height: 120px;
  border-radius: 34px;
}
.bouton.gros .icone {
  width: 64px;
  height: 64px;
}

/* ---------- menu ---------- */
.menu {
  height: 100%;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  grid-template-rows: auto 1fr;
  gap: 18px 28px;
  padding: 18px 28px 24px;
}
.menu-tete {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 22px;
}
.menu-leon {
  width: 150px;
}
.titre {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  letter-spacing: 0.08em;
}
.ruban {
  margin-left: auto;
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--papier);
  border: 3px dashed var(--encre);
  border-radius: 14px;
  transform: rotate(-1.5deg);
}
.menu-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 18px;
  min-height: 0;
}
.bouton.mode {
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}
.mode-cartes {
  display: flex;
  align-items: center;
  gap: 12px;
}
.mini-carte {
  width: clamp(70px, 11vh, 104px);
  height: clamp(70px, 11vh, 104px);
  border: 4px solid var(--encre);
  border-radius: 16px;
  background-size: cover;
  background-position: center;
  box-shadow: var(--ombre);
}
.mode-lien {
  font-size: 2rem;
  font-weight: 700;
}
.mode-nom {
  font-weight: 700;
  font-size: clamp(0.95rem, 2vh, 1.25rem);
  letter-spacing: 0.04em;
}
.menu-reglages {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}
.menu-niveaux {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.bouton.niveau {
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}
.niveau-grille {
  display: grid;
  grid-template-columns: repeat(var(--c), 1fr);
  gap: 4px;
  width: 80px;
}
.niveau-grille i {
  display: block;
  aspect-ratio: 1;
  border: 2.5px solid var(--encre);
  border-radius: 4px;
  background: var(--lavande);
}
.niveau-nom {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.niveau-sablier .icone {
  width: 22px;
  height: 22px;
}
.menu-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.bouton.option {
  min-width: 72px;
  min-height: 72px;
  padding: 8px;
  border-radius: 20px;
}
.bouton.option .abc {
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}
.quiz-icone {
  position: relative;
  display: block;
  width: 46px;
  height: 46px;
}
.quiz-icone svg {
  width: 100%;
  height: 100%;
}
.quiz-frequence {
  position: absolute;
  right: -12px;
  bottom: -10px;
  padding: 0 6px;
  font-size: 0.9rem;
  background: var(--papier);
  border: 2.5px solid var(--encre);
  border-radius: 10px;
}
.bouton.jouer {
  flex: 1;
  min-height: 110px;
  border-radius: 34px;
  background: var(--encre);
  color: var(--creme);
}
.bouton.jouer .icone {
  width: 70px;
  height: 70px;
}
.bouton.jouer:active {
  background: #444;
}

/* ---------- partie ---------- */
.jeu {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}
.barre {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
}
.sablier {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sablier-icone .icone {
  width: 44px;
  height: 44px;
}
.sablier-piste {
  flex: 1;
  height: 28px;
  background: var(--papier);
  border: 4px solid var(--encre);
  border-radius: 20px;
  overflow: hidden;
}
.sablier-sable {
  width: 100%;
  height: 100%;
  background: var(--sable);
  transform-origin: left center;
}
.points {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 2rem;
  font-weight: 700;
}
.points-etoile .icone {
  width: 38px;
  height: 38px;
  fill: #f4a81d;
  stroke: var(--encre);
}
.zone {
  display: grid;
  grid-template-columns: 1fr 190px;
  gap: 16px;
  padding: 0 18px 18px;
  min-height: 0;
}
.plateau-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}
.plateau {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(var(--cols, 3), var(--c, 100px));
  grid-auto-rows: var(--c, 100px);
}
.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 0;
}
.leon {
  width: 170px;
  flex: none;
}
.leon-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.leon-svg path,
.leon-svg ellipse,
.leon-svg circle,
.leon-svg rect {
  transition: fill 0.45s, stroke 0.45s;
}
.leon.saute {
  animation: saute 0.7s ease-out;
}
.leon.secoue {
  animation: secoue 0.7s ease-in-out;
}
.leon.salue {
  animation: saute 0.7s ease-out 2;
}
.leon-queue {
  transform-origin: 48px 112px;
  animation: queue 3.4s ease-in-out infinite;
}
.leon-pupille {
  animation: regard 5s ease-in-out infinite;
}
.pile {
  position: relative;
  width: 150px;
  height: 150px;
  flex: none;
  border: 4px dashed rgba(43, 43, 43, 0.35);
  border-radius: 24px;
  display: grid;
  place-items: center;
}
.pile > .icone {
  width: 70px;
  height: 70px;
  opacity: 0.25;
}
.pile-carte {
  position: absolute;
  inset: 22px;
  border: 3px solid var(--encre);
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  box-shadow: 2px 3px 0 rgba(43, 43, 43, 0.22);
}

@media (orientation: portrait) {
  .zone {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 150px;
  }
  .rail {
    flex-direction: row;
    justify-content: space-around;
  }
  .pile {
    width: 130px;
    height: 130px;
  }
  .leon {
    width: 150px;
  }
  .menu {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    overflow: auto;
  }
  .menu-modes {
    grid-auto-rows: auto;
  }
}

/* ---------- cartes ---------- */
.carte {
  width: var(--c);
  height: var(--c);
  padding: 0;
  border: 0;
  background: none;
  perspective: 800px;
  display: block;
}
.carte-in {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.3, 1);
}
.carte.retournee .carte-in {
  transform: rotateY(180deg);
}
.face {
  position: absolute;
  inset: 0;
  border: 4px solid var(--encre);
  border-radius: 18px;
  box-shadow: var(--ombre);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.dos {
  background-color: var(--lavande);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'><g fill='none' stroke='%23ffffff' stroke-width='3.2' stroke-linecap='round'><circle cx='14' cy='14' r='6'/><path d='M40 10 l9 9 m0 -9 l-9 9'/><path d='M8 44 q6 -9 12 0 t12 0'/><path d='M46 42 q8 4 8 12 q-8 0 -8 -12z'/></g></svg>");
  background-size: 64px 64px;
}
.recto {
  transform: rotateY(180deg);
  background-color: var(--papier);
  background-size: cover;
  background-position: center;
}
.carte.paire .face {
  box-shadow: 0 0 0 6px var(--papier), 0 0 0 10px var(--encre);
}
.carte.paire {
  animation: pulse 0.5s ease-out;
}
.carte.vide {
  visibility: hidden;
}

/* ---------- quiz, fin, sortie : voile par-dessus la partie ---------- */
.voile {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(251, 246, 236, 0.97);
  animation: apparait 0.25s ease-out;
}
.quiz {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 4vh, 34px);
  padding: 16px;
}
.quiz-cartes {
  display: flex;
  gap: 28px;
}
.carte-quiz {
  --cq: clamp(120px, 27vh, 230px);
  width: var(--cq);
  height: var(--cq);
  border: 5px solid var(--encre);
  border-radius: 24px;
  background-color: var(--papier);
  background-size: cover;
  background-position: center;
  box-shadow: var(--ombre);
  transition: box-shadow 0.35s, transform 0.35s, opacity 0.35s, filter 0.35s;
  animation: surgit 0.4s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.carte-quiz.grisee {
  filter: grayscale(1);
  opacity: 0.45;
  transform: scale(0.82);
}
.carte-quiz.revele {
  box-shadow: 0 0 0 12px var(--emo), var(--ombre);
}
.quiz-reponses {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(14px, 3vw, 28px);
}
.smiley-btn {
  width: clamp(96px, 17vh, 140px);
  height: clamp(96px, 17vh, 140px);
  padding: 0;
  background: none;
  border: 0;
  border-radius: 50%;
  filter: drop-shadow(3px 4px 0 rgba(43, 43, 43, 0.22));
  transition: transform 0.15s, opacity 0.3s;
}
.smiley-btn:active:not(:disabled) {
  transform: scale(0.94);
}
.smiley-btn svg {
  display: block;
  width: 100%;
  height: 100%;
}
.smiley-btn:disabled:not(.bon) {
  opacity: 0.3;
}
.smiley-btn.bon {
  animation: rebond 0.7s ease-out;
}
.quiz-mots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.mot-btn {
  min-width: min(40vw, 300px);
  min-height: 92px;
  padding: 8px 20px;
  font-size: clamp(1.8rem, 5vh, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #000;
  background: var(--papier);
  border: 4px solid var(--encre);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
}
.mot-btn.bon {
  box-shadow: 0 0 0 8px var(--emo);
  animation: rebond 0.7s ease-out;
}
.mot-btn.faux {
  opacity: 0.4;
}
.mot-btn:disabled:not(.bon):not(.faux) {
  opacity: 0.5;
}

.fin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2.5vh, 24px);
}
.fin-leon {
  width: clamp(150px, 26vh, 260px);
}
.fin-leon .leon {
  width: 100%;
}
.fin-etoiles {
  display: flex;
  gap: 16px;
}
.etoile .icone {
  width: clamp(70px, 13vh, 110px);
  height: clamp(70px, 13vh, 110px);
  fill: rgba(43, 43, 43, 0.12);
  stroke: rgba(43, 43, 43, 0.35);
}
.etoile.pleine .icone {
  fill: #f4a81d;
  stroke: var(--encre);
  animation: etoile 0.6s cubic-bezier(0.3, 1.6, 0.5, 1) both;
  animation-delay: calc(var(--i) * 0.35s);
}
.fin-points {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 2.2rem;
  font-weight: 700;
}
.fin-points .icone {
  width: 40px;
  height: 40px;
  fill: #f4a81d;
  stroke: var(--encre);
}
.fin-actions,
.sortie {
  display: flex;
  gap: 28px;
}
.confettis {
  position: absolute;
  inset: 0;
  z-index: 25;
  overflow: hidden;
  pointer-events: none;
}
.confetti {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  border: 2px solid var(--encre);
  border-radius: 3px;
  animation: chute 2s ease-in forwards;
}

/* ---------- démonstration animée ---------- */
.demo {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: var(--creme);
  animation: apparait 0.3s ease-out;
}
.demo-scene {
  display: grid;
  place-items: center;
}
.demo-grille {
  --c: clamp(120px, 24vh, 210px);
  display: grid;
  grid-template-columns: repeat(2, var(--c));
  grid-auto-rows: var(--c);
  gap: 22px;
}
.demo-leon {
  position: absolute;
  left: 28px;
  bottom: 24px;
  width: 170px;
}
.demo-passer {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 70;
}
.demo-coin {
  position: absolute;
  right: 120px;
  bottom: 90px;
  width: 10px;
  height: 10px;
}
.main-doigt {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 60;
  width: 88px;
  pointer-events: none;
  filter: drop-shadow(3px 5px 0 rgba(43, 43, 43, 0.25));
}
.main-svg {
  display: block;
  width: 100%;
  height: auto;
}
.onde {
  position: absolute;
  z-index: 55;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 4px solid var(--encre);
  border-radius: 50%;
  pointer-events: none;
  animation: onde 0.55s ease-out forwards;
}

/* ---------- animations ---------- */
@keyframes apparait {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes surgit {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
@keyframes rebond {
  0% { transform: scale(1); }
  30% { transform: scale(1.22) rotate(-4deg); }
  60% { transform: scale(0.95) rotate(3deg); }
  100% { transform: scale(1.08); }
}
@keyframes etoile {
  from { transform: scale(0) rotate(-40deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes saute {
  0%, 100% { transform: translateY(0) rotate(0); }
  35% { transform: translateY(-26px) rotate(-4deg); }
  65% { transform: translateY(-6px) rotate(3deg); }
}
@keyframes secoue {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-6deg); }
  50% { transform: rotate(5deg); }
  80% { transform: rotate(-3deg); }
}
@keyframes queue {
  0%, 100% { transform: rotate(0); }
  50% { transform: rotate(8deg); }
}
@keyframes regard {
  0%, 40%, 100% { transform: translateX(0); }
  50%, 80% { transform: translateX(-4px); }
}
@keyframes chute {
  to { transform: translateY(105vh) rotate(540deg); opacity: 0.9; }
}
@keyframes onde {
  to { transform: scale(3.2); opacity: 0; }
}

/* Réglage système « réduire les animations » : plus de rotation 3D, de confettis ni de mouvements. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .confettis {
    display: none;
  }
}
