/* La Cabane à jeux — styles */
:root {
  --fond: #fff6e0;
  --encre: #3b2a20;
  --accent: #ff7043;
  --carte: #ffffff;
  --ombre: rgba(59, 42, 32, .18);
  --rayon: 28px;
}

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

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--fond); color: var(--encre);
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation; overscroll-behavior: none;
}
body {
  background-color: var(--fond);
  background-image: radial-gradient(rgba(255, 183, 77, .25) 3px, transparent 4px);
  background-size: 38px 38px;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
svg { display: block; }

#app { position: fixed; inset: 0; }
.ecran {
  position: absolute; inset: 0; display: none; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 14px)
           calc(env(safe-area-inset-bottom) + 14px) calc(env(safe-area-inset-left) + 14px);
}
.ecran.actif { display: flex; }

/* ---------- Accueil ---------- */
.entete-accueil { display: flex; align-items: center; gap: 14px; padding: 4px 4px 14px; }
.logo { width: clamp(48px, 9vmin, 84px); height: auto; flex: none; }
.entete-accueil h1 { flex: 1; margin: 0; font-size: clamp(24px, 5vmin, 46px); letter-spacing: .5px; color: #8a4b2a; }

.btn-son {
  width: 64px; height: 64px; flex: none; border-radius: 50%;
  background: #fff; color: #8a4b2a; box-shadow: 0 5px 0 var(--ombre);
  display: grid; place-items: center;
}
.btn-son svg { width: 60%; height: 60%; }
.btn-son.petit { width: 50px; height: 50px; opacity: .8; }
.btn-son .ico-son-off { display: none; }
body.muet .btn-son .ico-son-on { display: none; }
body.muet .btn-son .ico-son-off { display: block; }
body.muet .btn-son { color: #b0a49a; }

.tuiles {
  flex: 1; display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(14px, 3vmin, 30px);
  width: 100%; max-width: 980px; margin: 0 auto; min-height: 0;
}
@media (orientation: landscape) and (max-height: 560px) { .tuiles { grid-template-columns: repeat(4, 1fr); } }

.tuile {
  border-radius: var(--rayon); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; min-height: 0; padding: 12px; position: relative;
  box-shadow: 0 10px 0 var(--bord), 0 14px 24px var(--ombre);
  background: var(--fond-tuile); transition: transform .08s;
}
.tuile:active { transform: translateY(7px); box-shadow: 0 3px 0 var(--bord), 0 6px 12px var(--ombre); }
.tuile svg { width: min(80%, 26vh); height: auto; flex: 1 1 auto; min-height: 0; max-height: 72%; }
.tuile span { font-size: clamp(18px, 3.4vmin, 32px); font-weight: bold; color: rgba(59, 42, 32, .75); }
.t-coloriage { --fond-tuile: #ffd1dc; --bord: #e89aac; }
.t-memory    { --fond-tuile: #d9ccff; --bord: #a593e0; }
.t-chiffres  { --fond-tuile: #fff0a8; --bord: #e0c35a; }
.t-attrape   { --fond-tuile: #c8efc9; --bord: #8fcf92; }

/* ---------- Barre de jeu ---------- */
.barre-jeu { display: flex; align-items: center; justify-content: space-between; height: 54px; flex: none; position: relative; }
.btn-maison {
  --progres: 0;
  width: 50px; height: 50px; border-radius: 50%; position: relative; color: #8a4b2a;
  background: rgba(255, 255, 255, .75); opacity: .75; display: grid; place-items: center;
  box-shadow: 0 3px 0 var(--ombre);
}
.btn-maison::before {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--progres) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 27px, #000 28px);
          mask: radial-gradient(circle, transparent 27px, #000 28px);
}
.btn-maison svg { width: 60%; height: 60%; position: relative; }
.btn-maison.appui { opacity: 1; transform: scale(1.08); }
.btn-maison.indice { animation: hoche .5s; }
.astuce-maison {
  position: absolute; left: 62px; top: 50%; transform: translateY(-50%);
  background: #fff; padding: 6px 12px; border-radius: 12px; font-size: 15px; box-shadow: 0 3px 8px var(--ombre);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.btn-maison.indice + .astuce-maison { opacity: 1; }
@keyframes hoche { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }

.zone-jeu { flex: 1; position: relative; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Confettis ---------- */
.confettis { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confettis i {
  position: absolute; top: -20px; width: 14px; height: 18px; border-radius: 3px;
  animation: tombe 2.4s ease-in forwards;
}
@keyframes tombe {
  to { transform: translate(var(--derive), 110vh) rotate(var(--tour)); }
}

/* ---------- Boutons communs ---------- */
.btn-rond {
  width: 96px; height: 96px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; box-shadow: 0 7px 0 #c9502a;
}
.btn-rond.secondaire { background: #8e7cc3; box-shadow: 0 7px 0 #65569a; }
.btn-rond:active { transform: translateY(5px); box-shadow: 0 2px 0 #c9502a; }
.btn-rond svg { width: 52%; height: 52%; }

/* =================== COLORIAGE =================== */
.galerie {
  flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr;
  gap: clamp(12px, 2.4vmin, 24px); min-height: 0; padding: 6px;
}
@media (orientation: portrait) { .galerie { grid-template-columns: repeat(2, 1fr); } }
.vignette {
  background: #fff; border-radius: 22px; padding: 10px; box-shadow: 0 7px 0 #e8d8bf;
  display: grid; place-items: center; min-height: 0; position: relative; overflow: hidden;
}
.vignette:active { transform: translateY(5px); box-shadow: 0 2px 0 #e8d8bf; }
.vignette svg { width: 100%; height: 100%; }
.pastille-crayon {
  position: absolute; width: 40%; aspect-ratio: 1; display: grid; place-items: center;
  background: #e3f2fd; border-radius: 50%; color: #1e4fbf;
}
.pastille-crayon svg { width: 70%; height: 70%; }
.pastille-crayon .mine { fill: #1e4fbf; }

.page-coloriage .zone { fill: #fff; stroke: #2b2b2b; stroke-width: 3.5; stroke-linejoin: round; }
.page-coloriage .sans-trait { stroke: none; }

.atelier {
  flex: 1; min-height: 0; display: grid; gap: 12px;
  grid-template-columns: auto 1fr auto; grid-template-areas: "outils support palette";
}
.outils { grid-area: outils; display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.support { grid-area: support; min-width: 0; min-height: 0; display: grid; place-items: center; }
.palette {
  grid-area: palette; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  align-content: center;
}
@media (orientation: portrait) {
  .atelier { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; grid-template-areas: "outils" "support" "palette"; }
  .outils { flex-direction: row; }
  .palette { grid-template-columns: repeat(6, auto); justify-content: center; }
}
.outils { --couleur: #ef5350; }
.outil {
  width: clamp(54px, 9vmin, 76px); aspect-ratio: 1; border-radius: 20px; background: #fff;
  color: #5d4037; display: grid; place-items: center; box-shadow: 0 5px 0 #e8d8bf;
}
.outil svg { width: 70%; height: 70%; }
.outil svg rect { fill: currentColor; }
.outil.choisi { background: #ffe0b2; box-shadow: 0 0 0 4px var(--accent), 0 5px 0 #e8d8bf; }
.outils .goutte, .outils .mine { fill: var(--couleur); stroke: currentColor; stroke-width: 2; }
.outil-corbeille { --progres: 0; position: relative; color: #b0473a; }
.outil-corbeille::after {
  content: ""; position: absolute; left: 10%; bottom: 6px; height: 6px; border-radius: 3px;
  width: calc(var(--progres) * 80%); background: #e53935;
}
.outil-corbeille.indice { animation: hoche .5s; }

.feuille {
  position: relative; background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: 0 6px 18px var(--ombre); width: 400px; height: 300px;
}
.feuille svg, .feuille canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.feuille canvas { touch-action: none; }
.pastille {
  width: clamp(44px, 7.5vmin, 62px); aspect-ratio: 1; border-radius: 50%; background: var(--c);
  border: 4px solid #fff; box-shadow: 0 3px 0 var(--ombre), inset 0 0 0 1px rgba(0,0,0,.15);
  transition: transform .1s;
}
.pastille.choisie { transform: scale(1.18); box-shadow: 0 0 0 4px var(--accent), 0 3px 0 var(--ombre); }

/* =================== MEMORY =================== */
.choix-niveau { flex: 1; display: flex; align-items: center; justify-content: center; gap: clamp(16px, 4vmin, 40px); flex-wrap: wrap; }
.btn-niveau {
  background: #fff; border-radius: 26px; padding: clamp(16px, 3vmin, 28px);
  box-shadow: 0 8px 0 #c9bdf0; width: clamp(150px, 26vmin, 240px); aspect-ratio: 1;
  display: grid; place-items: center;
}
.btn-niveau:active { transform: translateY(6px); box-shadow: 0 2px 0 #c9bdf0; }
.mini-grille { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 6px; width: 100%; }
.mini-grille i { display: block; aspect-ratio: 3/4; border-radius: 6px; background: #7e57c2; }

.plateau-zone { flex: 1; min-height: 0; display: grid; place-items: center; }
.plateau { --cols: 4; --l: 120px; --h: 120px; display: grid; grid-template-columns: repeat(var(--cols), var(--l)); gap: 12px; }
.carte { width: var(--l); height: var(--h); position: relative; perspective: 800px; }
.carte .face {
  position: absolute; inset: 0; border-radius: 18px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform .4s ease; display: grid; place-items: center;
}
.carte .dos {
  background: #7e57c2 radial-gradient(circle at 50% 50%, #b39ddb 0 18%, transparent 19%);
  border: 5px solid #fff; box-shadow: 0 5px 0 #5e3fa3;
}
.carte .recto { background: #fff; transform: rotateY(180deg); box-shadow: 0 5px 0 #d6cde8; }
.carte .recto svg { width: 78%; height: 78%; max-width: 78%; }
.carte.retournee .dos { transform: rotateY(-180deg); }
.carte.retournee .recto { transform: rotateY(0); }
.carte.trouvee .recto { box-shadow: 0 0 0 5px #66bb6a, 0 5px 0 #d6cde8; animation: saute .45s; }
@keyframes saute { 50% { transform: scale(1.1); } }

.bravo-fin {
  position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255, 246, 224, .72);
  animation: apparait .3s;
}
.bravo-carte {
  background: #fff; border-radius: 32px; padding: 26px 34px; box-shadow: 0 12px 30px var(--ombre);
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.grande-etoile { width: 150px; height: 150px; animation: tourne 2s ease-in-out infinite; }
.bravo-boutons { display: flex; gap: 22px; }
@keyframes apparait { from { opacity: 0; } }
@keyframes tourne { 50% { transform: rotate(12deg) scale(1.08); } }

/* =================== CHIFFRES =================== */
.menu-chiffres { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; }
.modes { display: flex; gap: clamp(16px, 4vmin, 40px); flex-wrap: wrap; justify-content: center; }
.mode {
  background: #fff; border-radius: 28px; box-shadow: 0 8px 0 #e0c35a; padding: 22px 26px;
  display: flex; align-items: center; gap: 12px; min-width: clamp(240px, 38vmin, 380px); justify-content: center;
}
.mode:active { transform: translateY(6px); box-shadow: 0 2px 0 #e0c35a; }
.mode-dessins { display: flex; gap: 2px; }
.mode-dessins svg { width: clamp(40px, 7vmin, 64px); height: auto; }
.mode-fleche { font-size: 34px; color: #b89a2e; font-weight: bold; }
.gros-chiffre { font-size: clamp(56px, 11vmin, 100px); font-weight: bold; color: #e65100; line-height: 1; }
.choix-max { display: flex; gap: 14px; }
.pilule { background: #fff; border-radius: 999px; padding: 12px 26px; font-size: 24px; font-weight: bold; box-shadow: 0 4px 0 #e8d8bf; color: #8a6d3b; }
.pilule.choisie { background: #ffca28; color: #5a3b00; box-shadow: 0 0 0 3px #e65100, 0 4px 0 #e8d8bf; }

.jeu-compter, .jeu-trouver { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.consigne { display: flex; align-items: center; gap: 16px; justify-content: space-between; flex: none; }
.haut-parleur {
  width: 66px; height: 66px; border-radius: 50%; background: #4fc3f7; color: #fff; display: grid; place-items: center;
  box-shadow: 0 5px 0 #0288d1; flex: none;
}
.haut-parleur svg { width: 58%; height: 58%; }
.cible { display: flex; align-items: center; gap: 8px; }
.cible svg { width: clamp(64px, 12vmin, 110px); height: auto; }
.point-interrogation { font-size: clamp(48px, 9vmin, 80px); font-weight: bold; color: #e65100; }
.progres { display: flex; gap: 4px; }
.progres svg { width: clamp(28px, 5vmin, 42px); height: auto; filter: grayscale(1) opacity(.3); transition: filter .3s; }
.progres .gagnee svg { filter: none; }
.progres .nouvelle svg { animation: saute .6s; }

.tas {
  flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(var(--par-ligne), minmax(0, 1fr));
  gap: 10px; align-content: center; justify-items: center; max-width: 900px; width: 100%; margin: 0 auto;
}
.objet { position: relative; width: min(100%, 22vmin, 190px); aspect-ratio: 1; border-radius: 50%; transition: transform .15s; }
.objet svg { width: 100%; height: 100%; }
.objet.compte { transform: scale(.92); }
.objet .numero {
  position: absolute; right: -2px; top: -2px; width: 38px; height: 38px; border-radius: 50%;
  background: #1e4fbf; color: #fff; font-weight: bold; font-size: 22px; display: grid; place-items: center;
  animation: saute .3s;
}
.reponses { display: flex; justify-content: center; gap: clamp(14px, 4vmin, 40px); flex: none; padding-bottom: 6px; }
.reponse {
  width: clamp(92px, 16vmin, 140px); aspect-ratio: 1; border-radius: 28px; background: #fff;
  font-size: clamp(52px, 10vmin, 86px); font-weight: bold; color: #1e4fbf; box-shadow: 0 8px 0 #c5cae9;
}
.reponse:active, .groupe:active { transform: translateY(5px); }
.reponse.essaye, .groupe.essaye { opacity: .45; }
.reponse.juste, .groupe.juste { background: #c8e6c9; box-shadow: 0 0 0 5px #43a047, 0 8px 0 #a5d6a7; opacity: 1; }
.secoue { animation: secoue .45s; }
@keyframes secoue { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

.groupes { flex: 1; min-height: 0; display: flex; gap: clamp(12px, 3vmin, 30px); align-items: stretch; justify-content: center; }
@media (orientation: portrait) { .groupes { flex-direction: column; } }
.groupe {
  flex: 1; max-width: 360px; background: #fff; border-radius: 26px; box-shadow: 0 8px 0 #e0c35a; padding: 14px;
  display: grid; grid-template-columns: repeat(var(--par-ligne), minmax(0, 1fr)); gap: 6px;
  align-content: center; justify-items: center; min-height: 0;
}
@media (orientation: portrait) { .groupe { max-width: none; } }
.groupe svg { width: 100%; max-width: 110px; height: auto; }
@media (orientation: portrait) { .groupe svg { max-height: 8vh; } }

/* =================== ATTRAPE =================== */
.attrape { flex: 1; min-height: 0; position: relative; border-radius: 22px; overflow: hidden; box-shadow: 0 6px 18px var(--ombre); }
.attrape canvas { position: absolute; inset: 0; touch-action: none; display: block; }
.score {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, .85);
  padding: 6px 18px 6px 10px; border-radius: 999px; font-size: 32px; font-weight: bold; color: #8a4b2a;
  pointer-events: none;
}
.score svg { width: 40px; height: 40px; }

@media (prefers-reduced-motion: reduce) {
  .carte .face { transition-duration: .01s; }
  .grande-etoile { animation: none; }
}
