/* Meu Amigo Gemalino — visual próprio (prefixo est-). Nada pisca. As animações só usam transform
   (subir, balançar, inclinar até 10°, achatar um pouco): NUNCA espelhar o Gemalino.
   Regra das animações: o estilo normal já é o estado final; a animação só faz o caminho até ele.
   Assim, com "menos movimento" (sem animação), tudo aparece certo de uma vez. */
:root {
  --ceu: #ffe9dc;
  --ceu-2: #fff6ef;
  --tema: #ffcdb2;
  --tema-escuro: #3a80c8;
  --est-item: var(--alvo);
  --est-linhas: 3;
  --est-madeira: #d9a066;
  --est-madeira-escura: #a86b3c;
}
@media (min-height: 640px) {
  :root { --est-item: calc(var(--alvo) * 1.3); }
}
@media (max-height: 460px) {
  :root { --est-linhas: 2; }
}

/* dentro da casinha o fundo é a parede pêssego (o morro e o galinheiro da base ficam só na capa) */
body[data-tela="tela-jogo"] .fundo { display: none; }
.est-prateleira-banheiro, .est-prateleira-quintal { --est-linhas: 2; }

/* com a pausa aberta, nada anda */
.est-pausado *, .est-pausado *::before, .est-pausado *::after { animation-play-state: paused !important; }

/* ---------- o Gemalino (o recorte, sempre inteiro e sem espelhar) ---------- */
.est-gema {
  position: relative; height: 100%; aspect-ratio: 900 / 1090; flex: 0 0 auto;
  touch-action: none; cursor: pointer; border-radius: 30px;
}
.est-gema:focus-visible { outline: 4px solid var(--azul); outline-offset: 4px; }
.est-gema-corpo { position: absolute; inset: 0; transform-origin: 50% 100%; }
.est-gema-img { width: 100%; height: 100%; pointer-events: none; }
.est-gema-bone { position: absolute; pointer-events: none; }
.est-gema-bone[hidden] { display: none; }
.est-camada { position: absolute; inset: 0; pointer-events: none; }

/* reações (só transform; inclinação máxima 10°) */
.est-r-pulinho { animation: est-pulinho 0.55s ease-out; }
.est-r-pulinhos { animation: est-pulinho 0.4s ease-out 3; }
.est-r-balanca { animation: est-balanca 1.2s ease-in-out; }
.est-r-ri { animation: est-ri 0.9s ease-in-out; }
.est-r-encolhe { animation: est-encolhe 0.8s ease-in-out; }
.est-r-treme { animation: est-treme 0.7s linear; }
.est-r-espreguica { animation: est-espreguica 1.3s ease-in-out; }
.est-r-boceja { animation: est-boceja 1.8s ease-in-out; }
.est-r-escorrega { animation: est-escorrega 1.5s ease-in-out; }
.est-r-cabeceia { animation: est-cabeceia 0.6s ease-out; }

@keyframes est-pulinho { 40% { transform: translateY(-10%); } 70% { transform: translateY(0) scale(1.03, 0.96); } }
@keyframes est-balanca { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes est-ri {
  15% { transform: translateX(-2%) rotate(-3deg); } 30% { transform: translateX(2%) rotate(3deg); }
  45% { transform: translateX(-2%) rotate(-3deg); } 60% { transform: translateX(2%) rotate(3deg); } 80% { transform: translateY(-3%); }
}
@keyframes est-encolhe { 30% { transform: scale(1.03, 0.93); } 60% { transform: scale(0.98, 1.03); } }
@keyframes est-treme {
  10%, 50%, 90% { transform: translateX(-1.5%); } 30%, 70% { transform: translateX(1.5%); }
}
@keyframes est-espreguica { 40% { transform: scale(0.98, 1.05) rotate(-3deg); } 70% { transform: scale(0.99, 1.03) rotate(3deg); } }
@keyframes est-boceja { 40%, 60% { transform: scale(1.02, 1.05) rotate(-4deg); } }
@keyframes est-escorrega {
  25% { transform: translateY(4%) rotate(10deg); } 60% { transform: translateY(6%) rotate(10deg) scale(1, 0.94); }
}
@keyframes est-cabeceia { 40% { transform: translateY(-9%) rotate(-5deg); } }

/* efeitos em volta da cabeça */
.est-efeito { position: absolute; font-size: clamp(22px, 4vh, 44px); line-height: 1; opacity: 0; animation: est-sobe 1.5s ease-out; }
.est-efeito-coracoes { color: #f06292; }
.est-efeito-estrelas { color: #ffb300; text-shadow: 0 0 2px #b8860b; }
.est-efeito-gotas { color: #4aa8e8; }
@keyframes est-sobe { from { opacity: 1; transform: translateY(20%); } 70% { opacity: 1; } to { opacity: 0; transform: translateY(-120%); } }

/* ---------- a casinha (menu) ---------- */
.est-casa {
  --porta: max(var(--alvo), min(calc((100vh - 150px) / 2), 24vw, 210px));
  align-items: stretch; justify-content: center; gap: 4vw;
}
.est-casa-gema { display: flex; align-items: flex-end; height: 100%; }
/* o Gemalino diminui quando falta largura (1090/900 = altura por largura do recorte) */
.est-casa .est-gema { height: min(100%, calc((100vw - var(--barra) - 60px - 2 * var(--porta) - 4vw) * 1.211)); }
.est-portas {
  display: grid; grid-template-columns: repeat(2, var(--porta)); grid-auto-rows: var(--porta);
  gap: 10px; align-content: center;
}
.est-porta {
  width: var(--porta); height: var(--porta); padding: 6px; border: 0; border-radius: 26px;
  background: var(--branco); box-shadow: var(--sombra);
}
.est-porta { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.est-porta svg { flex: 1 1 0; min-height: 0; }
.est-porta .rotulo-escolha { flex: 0 0 auto; }
.est-porta svg, .est-item svg { width: 100%; height: 100%; display: block; }
.est-porta:active, .est-item:active { transform: translateY(3px); }

/* ---------- um cômodo: a cena e a prateleira ---------- */
.est-sala { gap: 10px; }
.est-cena {
  position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; border-radius: var(--raio);
  display: flex; align-items: flex-end; justify-content: center; box-shadow: var(--sombra);
}
.est-fundo { position: absolute; inset: 0; }
.est-fundo svg { width: 100%; height: 100%; display: block; }
.est-cena .est-gema { height: 92%; max-height: 100%; margin-bottom: 1%; }
.est-prateleira {
  flex: 0 0 auto; align-self: center; display: grid; gap: 8px; padding: 8px;
  grid-template-rows: repeat(var(--est-linhas), var(--est-item)); grid-auto-flow: column; grid-auto-columns: var(--est-item);
  background: var(--est-madeira); border-radius: var(--raio); box-shadow: inset 0 -6px 0 var(--est-madeira-escura), var(--sombra);
}
.est-item {
  width: var(--est-item); height: var(--est-item); padding: 8px; border: 0; border-radius: 20px;
  background: var(--branco); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15); cursor: pointer; display: grid;
}
.est-item[aria-pressed="true"] { background: #fff2b3; outline: 5px solid var(--azul); outline-offset: -5px; }
.est-fruta { touch-action: none; }
.est-fruta.arrastando { z-index: 8; position: relative; box-shadow: 0 10px 18px rgba(0, 0, 0, 0.25); }

/* ---------- quarto: noite, cobertor e Zzz ---------- */
/* a noite fica atrás do Gemalino; ele só fica um pouco mais escuro (filtro no recorte, sem redesenhar) */
.est-dormindo .est-gema-img, .est-dormindo .est-gema-bone { filter: brightness(0.72); transition: filter 3s ease-in-out; }
.est-noite { position: absolute; inset: 0; background: rgba(18, 28, 80, 0.55); pointer-events: none; animation: est-escurece 3s ease-in-out; }
.est-noite.est-sai { opacity: 0; animation: est-clareia 1.2s ease-in-out; }
@keyframes est-escurece { from { opacity: 0; } }
@keyframes est-clareia { from { opacity: 1; } to { opacity: 0; } }
.est-cobertor { position: absolute; left: -8%; right: -8%; top: 55%; bottom: -1%; animation: est-cobre 1.6s ease-out; }
.est-cobertor svg { width: 100%; height: 100%; display: block; }
.est-cobertor.est-sai { transform: translateY(60%); opacity: 0; animation: est-descobre 1.2s ease-in; }
@keyframes est-cobre { from { transform: translateY(60%); opacity: 0; } }
@keyframes est-descobre { from { transform: none; opacity: 1; } }
.est-zzz { position: absolute; left: 70%; top: -2%; width: 30%; height: 30%; }
.est-zzz span {
  position: absolute; left: 0; bottom: 0; font-size: clamp(22px, 5vh, 46px); font-weight: bold; color: #fffdf7;
  text-shadow: 0 2px 0 #3a4a8a; opacity: 0.9; animation: est-z 2.7s ease-in-out infinite;
}
@keyframes est-z { from { transform: translate(0, 0); opacity: 0; } 30% { opacity: 1; } to { transform: translate(60%, -160%); opacity: 0; } }

/* ---------- banheiro: espuma, chuveiro, toalha e escova ---------- */
.est-bolha {
  position: absolute; width: var(--tam, 12%); aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #ffffff 0 30%, #eef9ff 55%, #cdeefc 100%);
  border: 2px solid rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 1px rgba(110, 190, 230, 0.5);
  animation: est-nasce 0.3s ease-out;
}
@keyframes est-nasce { from { transform: translate(-50%, -50%) scale(0.2); } }
.est-chuva { position: absolute; inset: 0; pointer-events: none; }
.est-chuva span { position: absolute; top: 2%; width: 5%; aspect-ratio: 1; animation: est-cai 0.8s linear infinite; }
.est-chuva svg, .est-gotinha svg, .est-toalha svg, .est-escova svg, .est-mao svg, .est-bola svg, .est-voando svg { width: 100%; height: 100%; display: block; }
@keyframes est-cai { from { transform: translateY(-20%); opacity: 0; } 20% { opacity: 1; } to { transform: translateY(1600%); opacity: 0.6; } }
.est-gotinha { position: absolute; width: 6%; aspect-ratio: 1; transform: translate(-50%, -50%); opacity: 0.85; }
.est-toalha { position: absolute; left: 18%; top: 22%; width: 64%; aspect-ratio: 1; animation: est-esfrega 0.4s ease-in-out 4; }
@keyframes est-esfrega { 50% { transform: translateX(10%); } }
.est-escova { position: absolute; left: 24%; top: 25%; width: 42%; aspect-ratio: 1; }
/* a escova muda de lugar a cada parte (em cima, embaixo, os de trás); inclinação pequena, sem espelhar */
.est-escova[data-etapa="baixo"] { top: 29%; }
.est-escova[data-etapa="tras"] { top: 27%; left: 31%; rotate: -8deg; }
.est-escova.est-vaivem { animation: est-vaivem 0.35s ease-in-out; }
@keyframes est-vaivem { 25% { transform: translateX(-7%); } 75% { transform: translateX(7%); } }
.est-espuminha { position: absolute; width: 4%; aspect-ratio: 1; border-radius: 50%; background: #ffffff; box-shadow: 0 0 0 1px #cfe8f5; transform: translate(-50%, -50%); }
.est-brilho {
  position: absolute; left: 55%; top: 42%; font-size: clamp(28px, 7vh, 64px); line-height: 1; color: #fffdf7;
  text-shadow: 0 0 6px #ffd54f, 0 0 2px #b8860b; transform: translate(-50%, -50%); animation: est-plim 1.4s ease-out;
}
@keyframes est-plim { from { transform: translate(-50%, -50%) scale(0.3); opacity: 0; } 50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; } }

/* ---------- cozinha: a fruta voando até a boca ---------- */
.est-voando {
  position: absolute; z-index: 7; pointer-events: none;
  transform: translate(var(--dx), var(--dy)) scale(0.3); opacity: 0; animation: est-voa 0.55s ease-in;
}
@keyframes est-voa { from { transform: none; opacity: 1; } 85% { opacity: 1; } }

/* ---------- quintal: bola e mão de carinho ---------- */
.est-bola { position: absolute; transform: translate(var(--dx), var(--dy)); animation: est-bola-ida 0.7s ease-out; }
@keyframes est-bola-ida { from { transform: none; } }
.est-bola.est-bola-volta { transform: translate(calc(var(--dx) + 160%), calc(var(--dy) - 40%)); opacity: 0; animation: est-bola-volta 0.8s ease-out; }
@keyframes est-bola-volta { from { transform: translate(var(--dx), var(--dy)); opacity: 1; } 70% { opacity: 1; } }
.est-bola.est-bola-cai { transform: translate(calc(var(--dx) + 120%), calc(var(--dy) + 180%)); opacity: 0; animation: est-bola-cai 0.8s ease-in; }
@keyframes est-bola-cai { from { transform: translate(var(--dx), var(--dy)); opacity: 1; } 70% { opacity: 1; } }
.est-mao { position: absolute; left: 34%; top: -8%; width: 32%; aspect-ratio: 1; animation: est-afaga 0.5s ease-in-out 3; }
@keyframes est-afaga { 50% { transform: translateY(14%); } }

/* ---------- aviso da figurinha (só quando o álbum existe) ---------- */
.est-figurinha {
  position: absolute; z-index: 8; right: 8px; bottom: 8px; display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; background: var(--branco); border-radius: 999px; box-shadow: var(--sombra);
  font-size: 18px; font-weight: bold; color: var(--azul); pointer-events: none; animation: est-aparece 0.6s ease-out;
}
.est-figurinha-estrela { font-size: 28px; color: #ffb300; }
@keyframes est-aparece { from { opacity: 0; transform: translateY(20%); } }

/* nome escrito em cada cartão de escolha (qualidade: toda escolha mostra o nome; o adulto lê, a criança ouve) */
.rotulo-escolha { display: block; max-width: 100%; font-weight: 700; font-size: clamp(12px, 1.5vw, 16px); line-height: 1.15;
  color: #1f3b57; text-align: center; pointer-events: none; overflow-wrap: anywhere; }
