/* Fazenda do Gemalino: estilos. Sem fontes externas: usa as fontes do aparelho. */
:root {
  --azul-ceu: #7cc4f5;
  --azul-claro: #cbeafd;
  --verde: #7cc95a;
  --verde-escuro: #4f9f3a;
  --amarelo: #ffd23f;
  --amarelo-escuro: #e9b400;
  --azul-marinho: #1f2f6b;
  --laranja: #ff9f43;
  --branco: #ffffff;
  --sombra: 0 6px 0 rgba(0, 0, 0, 0.18), 0 10px 24px rgba(0, 0, 0, 0.18);
  --alvo: 90px;            /* tamanho mínimo de toque */
  --btn: clamp(90px, 11vmin, 112px);
  --topo: calc(var(--btn) + 16px);
  --barra: calc(var(--btn) + 16px + env(safe-area-inset-left, 0px)); /* a coluna da criança, com a folga do notch */
  --alvo-baixo: max(48px, min(var(--btn), calc((100vh - 28px) / 5))); /* cinco botões em tela baixa */
  --fonte: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--azul-ceu);
  font-family: var(--fonte);
  color: var(--azul-marinho);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

img { -webkit-user-drag: none; user-select: none; pointer-events: none; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible { outline: 5px solid var(--azul-marinho); outline-offset: 4px; }

/* o jogo ocupa a área à direita da barra da criança (na tela de início a barra não aparece) */
/* z-index 30: as janelas (ajuda, adultos, pausa) ficam por cima da barra da criança */
#app { position: fixed; inset: 0 0 0 var(--barra); overflow: hidden; z-index: 30; container-type: size; } /* cqw/cqh/cqmin medem o palco, não a janela */
body.no-inicio #app { left: 0; }

/* ---------- Telas ---------- */
.tela {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}
.tela.ativa { display: block; animation: aparecer 0.35s ease-out; }

@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }

.ceu {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 60% at 20% 105%, var(--verde) 0 45%, transparent 46%),
    radial-gradient(120% 55% at 85% 108%, #8fd66b 0 45%, transparent 46%),
    radial-gradient(40% 18% at 18% 18%, rgba(255, 255, 255, 0.9) 0 50%, transparent 52%),
    radial-gradient(30% 14% at 78% 12%, rgba(255, 255, 255, 0.85) 0 50%, transparent 52%),
    linear-gradient(#5db6f2, var(--azul-claro) 75%);
}

/* Elementos fixos ficam escondidos na tela inicial */
body.no-inicio .barra,
body.no-inicio .estrelas,
body.no-inicio .balao { display: none; }

/* ---------- Tela de início ---------- */
.btn-comecar {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(70cqmin, 420px);
  height: min(70cqmin, 420px);
  border-radius: 50%;
  background: var(--amarelo);
  box-shadow: var(--sombra), inset 0 -10px 0 var(--amarelo-escuro);
  animation: respirar 2s ease-in-out infinite;
}
.gemalino-inicio {
  position: absolute;
  left: 50%;
  bottom: 8%;
  height: 82%;
  transform: translateX(-50%);
}
.btn-comecar .play {
  position: absolute;
  right: -2%;
  bottom: -2%;
  width: 38%;
  height: 38%;
  border-radius: 50%;
  background: var(--verde-escuro);
  color: var(--branco);
  display: grid;
  place-items: center;
  font-size: min(13cqmin, 80px);
  padding-left: 4%;
  box-shadow: var(--sombra);
}
@keyframes respirar {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.05); }
}

.credito-inicio {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  font-size: clamp(14px, 2.4cqmin, 20px);
  font-weight: 700;
  color: var(--azul-marinho);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* ---------- Menu na fazenda ---------- */
/* Fundo: parte do banner sem personagens; a turma recortada fica por cima. */
.fundo-menu {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 88%;
}
.turma {
  position: absolute;
  left: 8px;
  bottom: 0;
  width: min(50cqw, 108cqh);
  height: 86cqh;
}
.amigo {
  position: absolute;
  bottom: 0;
  min-width: var(--alvo);
  min-height: var(--alvo);
  padding: 0;
  background: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transform-origin: 50% 100%;
}
.amigo img { height: 100%; width: auto; max-width: none; }
.galinha-menu { left: 0; height: 46%; bottom: 3%; z-index: 1; }
.gemalino-menu { left: 22%; height: 88%; bottom: 4%; z-index: 2; }
.saltitao-menu { left: 14%; height: 30%; z-index: 3; }
.tobias-menu { left: 62%; height: 32%; bottom: 2%; z-index: 3; }
.bia-menu { left: 80%; height: 15%; bottom: 30%; z-index: 3; animation: voar 3s ease-in-out infinite; }

.gemalino-menu.acenando { animation: acenar 2.4s ease-in-out infinite; }
.amigo.pulando { animation: pulo 0.8s ease-out; }
.gemalino-menu.pulando { animation: pulo-grande 0.9s ease-out; }

@keyframes acenar {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}
@keyframes pulo-grande {
  0% { transform: none; }
  15% { transform: scale(1.06, 0.92); }
  45% { transform: translateY(-16%) scale(0.96, 1.06); }
  70% { transform: translateY(0) scale(1.06, 0.94); }
  85% { transform: translateY(-4%); }
  100% { transform: none; }
}
@keyframes voar {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-12%) rotate(4deg); }
}

/* 7 botões: 4 em cima e 3 embaixo (no celular em pé, 3 por fileira) */
.menu-botoes {
  --bj: clamp(var(--alvo), 16cqmin, 150px);
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, var(--bj));
  justify-content: end;
  gap: clamp(10px, 2cqmin, 20px);
  z-index: 5; /* sempre na frente da turma */
}
.btn-jogo {
  position: relative;
  width: var(--bj);
  height: var(--bj);
  border-radius: 28px;
  background: var(--branco);
  box-shadow: var(--sombra), inset 0 -8px 0 #dfe8f0;
  display: grid;
  grid-template: 100% / 100%;
  place-items: center;
  padding: 10px;
  overflow: hidden;
  animation: balancar 3s ease-in-out infinite;
}
.btn-jogo:nth-child(2n) { animation-delay: 0.4s; }
.btn-jogo:nth-child(3n) { animation-delay: 0.8s; }
.btn-jogo:nth-child(5) { grid-column-start: 2; }
.btn-jogo:active { transform: scale(0.94); }

@keyframes balancar {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

.mini-cartas { position: relative; width: 100%; height: 100%; }
.mini-carta {
  position: absolute;
  width: 56%;
  height: 78%;
  border-radius: 12px;
  background: var(--azul-claro);
  border: 4px solid var(--amarelo);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.mini-carta img { width: 90%; height: 90%; object-fit: contain; }
.mini-carta:first-child { left: 0; top: 2%; transform: rotate(-10deg); }
.mini-carta:last-child { right: 0; bottom: 2%; transform: rotate(8deg); }

.btn-galinha { position: absolute; left: 6%; top: 4%; height: 70%; }
.mini-ninho {
  position: absolute;
  right: 4%;
  bottom: 8%;
  width: 56%;
  height: 34%;
  border-radius: 50%;
  background: repeating-linear-gradient(35deg, #b07a3b 0 5px, #8a5a2b 5px 9px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 4%;
  padding-top: 0;
}
.mini-ninho .ovo-css { width: 30%; margin-top: -22%; }

.maos { display: flex; gap: 4px; font-size: clamp(28px, 5.2cqmin, 52px); line-height: 1; }

/* ---------- Barra do topo e botões redondos ---------- */
/* a barra da criança é SEMPRE a mesma coluna à esquerda, em qualquer aparelho; só o tamanho muda */
.barra {
  position: fixed; z-index: 20; top: 0; bottom: 0; left: 0; width: var(--barra);
  display: flex; flex-direction: column; justify-content: center; gap: 10px;
  padding: 8px 8px 8px max(8px, env(safe-area-inset-left));
}
.botao-barra {
  position: relative; width: var(--btn); height: var(--btn); min-width: 0; min-height: 0; border-radius: 50%; border: 0;
  background: var(--branco); color: var(--azul-marinho); box-shadow: var(--sombra); overflow: hidden;
}
.trava-progresso { position: absolute; left: 0; bottom: 0; height: 8px; width: 0; background: var(--amarelo-escuro); }
.botao-trava.segurando .trava-progresso { width: calc(var(--toques, 0) * 100%); transition: width 0.15s ease-out; }
@media (max-height: 460px) {
  :root { --barra: calc(var(--alvo-baixo) + 16px + env(safe-area-inset-left, 0px)); }
}
.btn-redondo {
  width: var(--btn);
  height: var(--btn);
  min-width: var(--alvo);
  min-height: var(--alvo);
  border-radius: 50%;
  background: var(--branco);
  box-shadow: var(--sombra);
  font-size: calc(var(--btn) * 0.46);
  display: grid;
  place-items: center;
  line-height: 1;
}
.btn-redondo:active { transform: scale(0.92); }
.btn-redondo.desligado { opacity: 0.55; filter: grayscale(1); }
body.no-menu #botao-casa { display: none; }

/* área dos adultos: a conta antes do conteúdo */
.pais-conta p { font-size: 22px; }
.conta-opcoes { display: flex; gap: 12px; margin: 12px 0 16px; }
.conta-opcao {
  flex: 1; min-height: 64px; border-radius: 14px; background: var(--azul-claro); font-size: 26px; font-weight: 900;
}
.pais-cancelar { min-height: 52px; border-radius: 14px; background: #eee; padding: 0 16px; font-weight: 700; }
.pais-conteudo[hidden], .pais-conta[hidden] { display: none; }

/* Estrelinhas (só somam, nunca tiram) */
.estrelas {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 30cqw;
  gap: 2px;
  font-size: clamp(26px, 5cqmin, 44px);
  z-index: 20;
  pointer-events: none;
}
.estrelas span { animation: estrela-nova 0.6s ease-out; }
@keyframes estrela-nova {
  0% { transform: scale(0) rotate(-90deg); }
  70% { transform: scale(1.4) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}

/* Balão da fala */
.balao {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: calc(50% + var(--btn) * 0.8);
  transform: translateX(-50%);
  max-width: min(calc(100cqw - var(--btn) * 3.4 - 26cqw), 560px);
  padding: 12px 20px;
  border-radius: 24px;
  background: var(--branco);
  box-shadow: var(--sombra);
  font-size: clamp(17px, 2.8cqmin, 26px);
  font-weight: 700;
  text-align: center;
  z-index: 19;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.balao.visivel { opacity: 1; }

/* Porta dos pais: segurar 3 segundos (o cadeado fica na barra da criança) */

.painel-pais {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 60, 0.6);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}
.painel-pais[hidden] { display: none; }
.painel-caixa {
  width: min(520px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--branco);
  border-radius: 24px;
  padding: 20px 24px;
  box-shadow: var(--sombra);
  font-size: 18px;
}
.painel-caixa h2 { margin: 0 0 12px; font-size: 24px; }
.painel-caixa label { display: block; margin: 10px 0; font-weight: 700; }
.painel-caixa label.linha { display: flex; align-items: center; gap: 10px; }
.painel-caixa input[type="range"] { width: 100%; height: 36px; }
.painel-caixa input[type="checkbox"] { width: 30px; height: 30px; }
.painel-acoes { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.painel-acoes button {
  flex: 1 1 140px;
  min-height: 56px;
  border-radius: 14px;
  background: var(--azul-claro);
  font-weight: 700;
  font-size: 18px;
}
.painel-acoes button.destaque { background: var(--amarelo); }
.painel-nota { font-size: 14px; color: #4a5680; margin: 14px 0 0; }
.painel-caixa h3 { margin: 16px 0 6px; font-size: 18px; }
.creditos p { margin: 4px 0; font-size: 14px; line-height: 1.35; }
.creditos p:first-child { font-weight: 700; font-size: 16px; }

/* ---------- Área de jogo comum ---------- */
.tela-jogo > :not(.ceu) { position: absolute; }

/* ---------- Minijogo 1: Memória ---------- */
.cartas {
  inset: calc(var(--topo) + 4px) 16px calc(var(--alvo) + 16px) 16px;
  display: grid;
  justify-content: center;
  align-content: center;
  gap: var(--gap, 14px);
  grid-template-columns: repeat(var(--cols, 3), var(--carta-w, 120px));
  perspective: 1000px;
}
.carta {
  width: var(--carta-w, 120px);
  height: calc(var(--carta-w, 120px) * 1.3);
  min-width: var(--alvo);
  padding: 0;
  background: none;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s;
}
.carta.virada, .carta.par { transform: rotateY(180deg); }
.carta .face {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--sombra);
  display: grid;
  place-items: center;
}
.carta .verso {
  background: var(--amarelo);
  border: 5px solid var(--branco);
  color: var(--azul-marinho);
  font-weight: 900;
  font-size: calc(var(--carta-w, 120px) * 0.5);
}
.carta .frente {
  background: var(--azul-claro);
  border: 5px solid var(--branco);
  transform: rotateY(180deg);
  overflow: hidden;
}
.carta .frente img { width: 86%; height: 86%; object-fit: contain; }
.carta.par .frente { border-color: var(--amarelo); }
.carta.par.pulando .frente img { animation: pulo 0.7s ease-out 2; }

@keyframes pulo {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-18%) scale(1.05, 0.95); }
  55% { transform: translateY(0) scale(1.08, 0.92); }
  75% { transform: translateY(-6%); }
}

/* ---------- Minijogo 2: Ovinhos ---------- */
.ovinhos-area {
  left: 16px;
  right: 40%;
  top: var(--topo);
  bottom: calc(var(--alvo) + 6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2cqw;
}
.galinha { height: min(92%, 52cqh); max-width: 45%; object-fit: contain; transform-origin: 50% 100%; }
.galinha.feliz { animation: pulo 0.7s ease-out 2; }

.ninho {
  position: relative;
  width: min(62cqh, 34cqw, 440px);
  aspect-ratio: 2 / 1;
  margin-bottom: 4%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 35%, #6b4220 0 38%, transparent 40%),
    repeating-linear-gradient(30deg, #c08945 0 7px, #8f5c2a 7px 12px),
    #a06a33;
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.2), 0 8px 0 rgba(0, 0, 0, 0.12);
}
.ninho-vagas {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 42%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2%;
}
.vaga {
  width: 18%;
  aspect-ratio: 1 / 1.28;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  border: 4px dashed rgba(255, 255, 255, 0.85);
}
.vaga .ovo-css { width: 100%; margin: -4px; animation: cair 0.35s ease-out; }
@keyframes cair { from { transform: translateY(-40%) scale(1.2); } to { transform: none; } }

.cesta {
  right: 16px;
  top: var(--topo);
  bottom: 16px;
  width: 38%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 28px;
  background: repeating-linear-gradient(45deg, #e8c27e 0 10px, #d9ad62 10px 20px);
  border: 6px solid #b8843d;
}

/* Ovo comum: branco, sem rosto e sem roupa (regra da série) */
.ovo-css {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1.28;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 36% 30%, #ffffff 0 18%, #f6f1e7 45%, #e2d6c0 100%);
  box-shadow: inset -6px -8px 12px rgba(150, 120, 80, 0.25), 0 4px 6px rgba(0, 0, 0, 0.15);
}
.ovo {
  width: clamp(var(--alvo), 12cqmin, 120px);
  min-height: var(--alvo);
  padding: 0;
  background: none;
  touch-action: none;
  transition: transform 0.15s;
}
.ovo:active { transform: scale(1.08); }
.arrastando { position: fixed !important; z-index: 30; pointer-events: none; transform: scale(1.12); transition: none; }
.ovo.arrastando { position: fixed; z-index: 30; pointer-events: none; transform: scale(1.12); transition: none; }
.ovo.usado { visibility: hidden; }

/* ---------- Minijogo 3: Pode ou não pode ---------- */
.pode-area {
  left: 16px;
  right: 16px;
  top: var(--topo);
  bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3cqw;
  padding-left: var(--alvo);
}
.sit-img {
  max-width: min(64cqw, 900px);
  max-height: 100%;
  border-radius: 24px;
  border: 6px solid var(--branco);
  box-shadow: var(--sombra);
  object-fit: contain;
  min-width: 0;
}
.sit-img.troca { animation: aparecer 0.4s ease-out; }
.pode-botoes { display: flex; flex-direction: column; gap: 18px; }
.btn-mao {
  width: clamp(var(--alvo), 17cqmin, 150px);
  height: clamp(var(--alvo), 17cqmin, 150px);
  border-radius: 50%;
  font-size: clamp(48px, 10cqmin, 90px);
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: var(--sombra);
}
.btn-mao.sim { background: #c9f2b0; }
.btn-mao.nao { background: #ffe2b8; }
.btn-mao:active { transform: scale(0.92); }
.btn-mao.certo { animation: pulo 0.7s ease-out; }

/* ---------- Recompensas ---------- */
.gemalino-danca {
  position: absolute;
  left: 8px;
  bottom: 0;
  height: 0;
  z-index: 25;
  transform-origin: 50% 100%;
  opacity: 0;
}
.gemalino-danca.dancando {
  height: min(60cqh, 420px);
  opacity: 1;
  animation: danca 0.6s ease-in-out infinite;
}
.gemalino-danca.explicando {
  height: min(42cqh, 300px);
  opacity: 1;
  animation: carinho 2.4s ease-in-out infinite;
}
@keyframes carinho {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}
@keyframes danca {
  0%, 100% { transform: rotate(-8deg) translateY(0); }
  25% { transform: rotate(0) translateY(-10%); }
  50% { transform: rotate(8deg) translateY(0); }
  75% { transform: rotate(0) translateY(-10%); }
}

.festa {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2cqw;
  z-index: 24;
  pointer-events: none;
}
.festa img { height: min(26cqh, 170px); animation: pulo 0.6s ease-out infinite; }
.festa img:nth-child(2) { animation-delay: 0.1s; }
.festa img:nth-child(3) { animation-delay: 0.2s; }
.festa img:nth-child(4) { animation-delay: 0.3s; }
.festa img:nth-child(5) { animation-delay: 0.15s; }

.confete { position: absolute; inset: 0; pointer-events: none; z-index: 26; overflow: hidden; }
.confete i {
  position: absolute;
  top: -5%;
  width: 14px;
  height: 20px;
  border-radius: 3px;
  animation: confete-cai linear forwards;
}
@keyframes confete-cai {
  to { transform: translateY(115cqh) rotate(720deg); }
}

/* ---------- Celular em pé (retrato): a tela se rearruma ---------- */
@media (orientation: portrait) {
  .turma { left: 0; width: 100cqw; height: 44cqh; }
  .galinha-menu { left: 2%; height: 40%; }
  .gemalino-menu { left: 10%; height: 68%; }
  .saltitao-menu { left: 26%; height: 26%; }
  .tobias-menu { left: 60%; height: 28%; }
  .bia-menu { left: 67%; bottom: 46%; height: 12%; }
  .menu-botoes {
    top: calc(var(--topo) + 4px);
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }
  .menu-botoes { --bj: clamp(var(--alvo), 25cqw, 150px); grid-template-columns: repeat(3, var(--bj)); gap: 10px; }
  .btn-jogo:nth-child(5) { grid-column-start: auto; }
  .btn-jogo:nth-child(7) { grid-column-start: 2; }

  /* balão logo abaixo da barra (no menu, abaixo dos botões) */
  .balao {
    top: calc(var(--topo) + 4px);
    left: 12px;
    right: 12px;
    transform: none;
    max-width: none;
  }
  body.no-menu .balao { top: calc(var(--topo) + 3 * clamp(var(--alvo), 25cqw, 150px) + 40px); }
  .estrelas { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); max-width: 60cqw; font-size: 30px; }

  .cartas { top: calc(var(--topo) + 96px); bottom: calc(var(--alvo) + 24px); }

  .ovinhos-area { left: 16px; right: 16px; top: calc(var(--topo) + 96px); bottom: 50%; }
  .galinha { height: 100%; }
  .ninho { width: min(50cqw, 300px); }
  .cesta { left: 16px; right: 16px; width: auto; top: 52%; bottom: calc(var(--alvo) + 24px); }

  .pode-area {
    flex-direction: column;
    padding-left: 0;
    top: calc(var(--topo) + 96px);
    bottom: calc(var(--alvo) + 24px);
  }
  .sit-img { max-width: 100%; max-height: 58%; }
  .pode-botoes { flex-direction: row; gap: 28px; }
  .gemalino-danca.explicando { left: auto; right: 8px; height: 24cqh; }
  .gemalino-danca.dancando { left: 50%; margin-left: -18cqh; height: 44cqh; }
}

/* Telas bem baixas (celular deitado) */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --btn: 90px; --topo: 100px; }
  .balao { max-width: 40cqw; font-size: 16px; padding: 8px 14px; }
  .estrelas { max-width: 22cqw; font-size: 24px; }
  .menu-botoes { --bj: 90px; gap: 8px; bottom: 8px; }
  .turma { width: 40cqw; }
  .cesta { gap: 6px; padding: 6px; top: 100px; }
  .ovo { width: 90px; }
  .ovinhos-area { bottom: 8px; left: calc(var(--alvo) + 20px); }
  .galinha { height: 88%; }
  .pode-area { top: 100px; bottom: 8px; }
}

/* Quem prefere menos movimento */
@media (prefers-reduced-motion: reduce) {
  .gemalino-danca.dancando { animation: danca 1.2s ease-in-out infinite !important; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- Balão do Gemalino (revisão de design) ----------
   O rostinho do Gemalino fica ao lado do texto: a criança sabe quem está falando.
   A instrução da tarefa fica sempre à vista (borda amarela); elogios aparecem e somem. */
.balao {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px 8px 8px;
  font-size: clamp(18px, 3.1cqmin, 30px);
  line-height: 1.2;
  text-align: left;
  border: 4px solid var(--branco);
}
.balao::before {
  content: "";
  flex: 0 0 auto;
  width: 2.4em;
  height: 2.4em;
  border-radius: 50%;
  background: #fff4c2 url("assets/img/gemalino.webp") 50% 4% / 150% auto no-repeat;
  box-shadow: inset 0 0 0 3px var(--amarelo);
}
.balao.instrucao { border-color: var(--amarelo); }
.balao.explicando { border-color: var(--laranja); }
.balao.explicando::before { animation: carinho 1.2s ease-in-out infinite; }
/* o Gemalino de corpo inteiro não aparece mais por cima da brincadeira ao explicar */
.gemalino-danca.explicando { height: 0; opacity: 0; }
@media (orientation: landscape) and (max-height: 500px) {
  .balao { font-size: 16px; padding: 4px 12px 4px 4px; gap: 8px; }
}

/* ---------- Menu (revisão de design): botões maiores, em 3 colunas, centrados à direita ---------- */
@media (orientation: landscape) and (min-height: 501px) {
  .menu-botoes {
    --bj: clamp(var(--alvo), min(20cqmin, 13cqw), 180px);
    top: var(--topo);
    bottom: max(16px, env(safe-area-inset-bottom));
    grid-template-columns: repeat(3, var(--bj));
    align-content: center;
  }
  .btn-jogo:nth-child(5) { grid-column-start: auto; }
  .btn-jogo:nth-child(7) { grid-column-start: 2; }
}

/* Ajuda do botão ?: cada linha é um botão e, ao tocar nela, a Mamãe Galinha lê de novo.
   As linhas podem ser menores que o alvo de 90 px: elas só repetem a fala, não são a brincadeira. */
.ajuda .painel-caixa { position: relative; width: min(560px, 100%); }
.ajuda h3 { margin: 14px 0 6px; color: var(--azul-marinho); font-size: 20px; }
.ajuda h3:first-of-type { margin-top: 0; }
.ajuda-linha {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 6px 0;
  padding: 10px 14px;
  min-height: 56px;
  border: 0;
  border-radius: 14px;
  background: var(--azul-claro);
  color: var(--azul-marinho);
  font-family: var(--fonte);
  font-size: 19px;
  line-height: 1.3;
  text-align: left;
}
.ajuda-linha:active { transform: scale(0.98); }
.ajuda-icone {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--branco);
  box-shadow: var(--sombra);
  font-size: 24px;
}
.ajuda .painel-caixa h2 { padding-right: calc(var(--alvo) + 8px); }
#ajuda-voltar { min-height: var(--alvo); font-size: 22px; }
.ajuda-fechar {
  position: absolute;
  top: 10px;
  right: 10px;
  width: var(--alvo);
  height: var(--alvo);
  border: 0;
  border-radius: 50%;
  background: var(--azul-claro);
  color: var(--azul-marinho);
  font-size: 30px;
}
@media (max-height: 460px) {
  .ajuda h3 { margin: 8px 0 4px; font-size: 18px; }
  .ajuda-linha { margin: 4px 0; padding: 7px 12px; min-height: 48px; font-size: 17px; }
  .ajuda-icone { width: 38px; height: 38px; font-size: 21px; }
}

/* Com o botão da ajuda, a barra do topo tem quatro botões. Em tela estreita só o espaço
   entre eles diminui: o botão nunca fica menor que o alvo de 90 px. */


/* ---------- celular em pé (retrato): só o aviso para virar o aparelho ---------- */
.aviso-retrato { display: none; }
@media (orientation: portrait) and (max-width: 900px) {
  .aviso-retrato {
    position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--azul-claro); color: var(--azul-marinho); text-align: center; padding: 24px; font-size: 24px; font-weight: bold;
  }
  .aviso-retrato span { font-size: 80px; }
}

/* ===== DIRETIVA DO GEMALINO: nenhum objeto passa das laterais, do topo nem do rodapé =====
   Celular deitado e baixo (cerca de 750 x 350 px de tela útil): o que antes dependia de % da tela
   agora usa o tamanho real dos objetos (alvo de 90 px) e cabe inteiro. Conferir com
   ferramentas/conferir_bordas.py (falha se algum objeto passar da borda, em vários tamanhos). */
@media (orientation: landscape) and (max-height: 500px) {
  /* Memória: a caixa das cartas usa a tela toda abaixo do balão; o JS escolhe colunas e linhas para caberem */
  .cartas { inset: 70px 8px 8px 8px; }
  .carta { min-width: 0; }
  /* Balão: sempre no topo, à esquerda e com no máximo 2 linhas, para nunca cobrir cartas, roupas, pasta ou músicas */
  body:is([data-tela="memoria"], [data-tela="ovinhos"], [data-tela="pode"], [data-tela="cozinha"], [data-tela="vestir"], [data-tela="escovar"], [data-tela="cante"]) .balao {
    top: 8px; left: 12px; transform: none; max-width: min(62cqw, 460px);
  }
  /* Ovinhos: a cesta tem 3 ovos de 90 px inteiros, do topo ao rodapé; o balão e as estrelas saem da frente */
  .cesta {
    top: 8px; bottom: 8px; right: max(8px, env(safe-area-inset-right)); width: auto;
    grid-template-columns: repeat(3, var(--alvo)); gap: 8px; padding: 8px; border-width: 4px;
  }
  .ovo { width: var(--alvo); }
  body[data-tela="ovinhos"] .balao { max-width: calc(100cqw - 3 * var(--alvo) - 84px); }
  body[data-tela="ovinhos"] .estrelas { top: auto; bottom: 8px; right: auto; left: 12px; max-width: 24cqw; font-size: 24px; }
  .ovinhos-area { left: 8px; right: calc(3 * var(--alvo) + 56px); top: 76px; bottom: 8px; }
  .ninho { width: min(44cqh, 22cqw); }
}

/* Dançarinos do Cante: o balanço gira em torno dos pés; a folga de baixo impede que o canto passe do rodapé */
.palco { bottom: max(16px, 3cqh); }

/* Fala longa (ex.: a da figurinha): letra menor e balão mais largo, para não passar de 2 linhas e não cobrir nada */
.balao.longo { font-size: clamp(13px, 2cqmin, 20px); }
@media (orientation: landscape) and (max-height: 500px) {
  body:is([data-tela="memoria"], [data-tela="pode"], [data-tela="cozinha"], [data-tela="vestir"], [data-tela="escovar"]) .balao.longo {
    font-size: 13px; max-width: min(calc(100cqw - 190px), 560px);
  }
  body[data-tela="cante"] .balao { max-width: calc(100cqw - 360px); }
}
/* Dançarinos: folga maior embaixo (o balanço gira em torno dos pés) */
.palco { bottom: max(24px, 6cqh); }

/* nome escrito em cada quadrinho do menu (qualidade: toda escolha mostra o nome; o adulto lê, a criança ouve) */
.btn-jogo .rotulo-jogo { position: absolute; left: 6px; right: 6px; bottom: 8px; z-index: 2; padding: 2px 4px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.92); color: #1f3b57; font-weight: 700; font-size: clamp(11px, 1.4vw, 15px); line-height: 1.15; text-align: center; pointer-events: none; }
