/* Escolinha do Gemalino: estilos comuns (vindos do jogo Fazenda do Gemalino).
   Sem fontes externas: usa as fontes do aparelho. Os módulos têm o seu CSS em estilo-modulos.css. */
: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); }
}

/* ---------- 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; }
/* o voltar das brincadeiras: no canto de cima à direita da tela, só quando há para onde voltar */
.btn-voltar {
  position: absolute; z-index: 20; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right));
}
.btn-voltar[hidden] { display: none; }
@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; }

/* 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; }

/* ---------- 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); }
}


/* ---------- 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; }
}

/* 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-fechar {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--azul-claro);
  color: var(--azul-marinho);
  font-size: 24px;
}
@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 chega a cinco botões (com a setinha). 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é: cinco botões de 90 px não cabem numa linha só (o jogo pede para virar o
   aparelho, mas os botões continuam inteiros). A barra passa para duas linhas e o resto da
   tela desce junto, porque todo mundo se apoia em --topo. */
@media (orientation: portrait) {
  #app { --topo: calc(var(--btn) * 2 + 24px); }
}

/* ---------- 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; }
}

/* nome escrito em cada quadrinho do menu (qualidade: toda escolha mostra o nome) */
.lugar { position: relative; }
.lugar .rotulo-lugar { 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; }
