/* Letreiro: o usuário escolhe as letras na ordem certa para completar "SUMMIT" na frase. */

.jogo {
  position: absolute;
  inset: 0;
  background:
    var(--montanhas) bottom / 100% 46px no-repeat,
    radial-gradient(circle at 50% 30%, var(--floresta-clara), var(--floresta) 70%);
  transition:
    opacity 0.5s ease,
    transform 0.5s ease;
}

.fim .jogo {
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
}

.topo {
  position: absolute;
  left: 10px;
  top: 7px;
  animation: surgir 0.5s ease 0.1s backwards;
}

.topo-dica {
  position: absolute;
  right: 10px;
  top: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--floresta);
  background: var(--verde);
  animation: surgir 0.5s ease 0.2s backwards;
}

.letreiro {
  position: absolute;
  left: 0;
  right: 0;
  top: 38px;
  width: fit-content;
  margin: 0 auto;
  padding: 6px;
  border: 2px solid #2f6b5d;
  border-radius: 8px;
  background: linear-gradient(#173d3f, #0d2729);
  box-shadow:
    0 0 0 2px #081a1b,
    0 10px 22px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  animation: entrar-letreiro 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s backwards;
}

.letreiro-grade {
  display: grid;
  grid-template-columns: repeat(10, 24px);
  grid-auto-rows: 26px;
  gap: 3px;
  perspective: 240px;
}

.casa {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 1px;
  border-radius: 3px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  color: var(--floresta);
  background: linear-gradient(#fff, #e6eae3);
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.12),
    0 1px 0 rgba(0, 0, 0, 0.35);
}

/* Entrada só até o jogo começar (.pronto); depois as casas só animam ao acertar/errar */
.anuncio:not(.pronto) .casa {
  animation: virar 0.4s ease-out backwards;
  animation-delay: calc(0.45s + var(--i) * 30ms);
}

.casa.vazia {
  background: linear-gradient(#143537, #0f2b2d);
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(120, 220, 140, 0.06);
}

.casa.alvo {
  background: linear-gradient(#eef9ef, #cdebd0);
}

/* Casa da vez: contorno verde pulsando e um cursor piscando */
.casa.ativa {
  box-shadow: 0 0 0 2px var(--verde);
  animation: pulsar 1.1s ease-in-out infinite;
}

.casa.ativa::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 4px;
  height: 2px;
  border-radius: 1px;
  background: var(--verde);
  animation: cursor 1s steps(1) infinite;
}

.casa.ativa.errou {
  box-shadow: 0 0 0 2px var(--erro);
  animation: tremer 0.4s ease;
}

.casa.revelada {
  animation: revelar 0.45s cubic-bezier(0.2, 0.8, 0.3, 1.3);
}

.acertou .casa.alvo {
  color: var(--floresta);
  background: linear-gradient(#a6f0ad, var(--verde));
  animation: pular 0.5s ease backwards;
  animation-delay: calc(var(--n) * 70ms);
}

/* Confete que sai do letreiro quando a frase é completada */
.confete {
  position: absolute;
  left: 50%;
  top: 70%;
  pointer-events: none;
}

.confete span {
  position: absolute;
  width: 5px;
  height: 8px;
  border-radius: 1px;
  background: var(--cor);
  opacity: 0;
  animation: confete 1.2s cubic-bezier(0.15, 0.7, 0.4, 1) var(--atraso) forwards;
}

.instrucao {
  position: absolute;
  left: 0;
  right: 0;
  top: 173px;
  font-size: 10.5px;
  font-weight: 600;
  text-align: center;
  color: var(--verde-claro);
  animation: surgir 0.5s ease 0.8s backwards;
}

.teclas {
  position: absolute;
  left: 0;
  right: 0;
  top: 190px;
  display: flex;
  justify-content: center;
  gap: 7px;
}

.tecla {
  position: relative;
  width: 40px;
  height: 34px;
  padding-top: 1px;
  border: 0;
  border-radius: 7px;
  font-family: var(--texto);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  color: var(--floresta);
  background: linear-gradient(#fff, #e3e8df);
  box-shadow:
    0 3px 0 #8fa59b,
    0 5px 10px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
}

.anuncio:not(.pronto) .tecla {
  animation: aparecer 0.4s cubic-bezier(0.3, 1.5, 0.5, 1) backwards;
  animation-delay: calc(0.85s + var(--i) * 60ms);
}

.tecla:hover {
  transform: translateY(-2px);
  box-shadow:
    0 5px 0 #8fa59b,
    0 7px 12px rgba(0, 0, 0, 0.35);
}

.tecla:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 #8fa59b,
    0 2px 5px rgba(0, 0, 0, 0.35);
}

.tecla:focus-visible {
  outline: 2px solid var(--verde);
  outline-offset: 2px;
}

.tecla.certa {
  animation: acerto 0.45s ease;
}

.tecla.errada {
  color: var(--branco);
  background: linear-gradient(#ff9a9a, var(--erro));
  animation: tremer 0.4s ease;
}

/* Dica: anel pulsando na próxima letra certa */
.tecla.dica-letra::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid var(--verde);
  border-radius: 10px;
  animation: anel 1.2s ease-out infinite;
}

.aviso {
  position: absolute;
  left: 0;
  right: 0;
  top: 231px;
  font-size: 10.5px;
  font-weight: 600;
  text-align: center;
  color: var(--verde-claro);
}

.aviso.erro {
  color: #ffb1b1;
}

/* ---------- Animações ---------- */

@keyframes entrar-letreiro {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
  }
}

@keyframes virar {
  from {
    transform: rotateX(-90deg);
    opacity: 0;
  }
}

@keyframes revelar {
  from {
    transform: rotateX(-90deg);
  }
}

@keyframes aparecer {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
}

@keyframes pulsar {
  0%,
  100% {
    box-shadow:
      0 0 0 2px var(--verde),
      0 0 4px 1px rgba(82, 181, 90, 0.5);
  }
  50% {
    box-shadow:
      0 0 0 2px var(--verde),
      0 0 12px 3px rgba(82, 181, 90, 0.9);
  }
}

@keyframes cursor {
  50% {
    opacity: 0;
  }
}

@keyframes acerto {
  0% {
    color: var(--floresta);
    background: var(--verde);
    transform: translateY(2px);
  }
  60% {
    color: var(--floresta);
    background: var(--verde);
  }
}

@keyframes anel {
  from {
    opacity: 1;
    transform: scale(0.9);
  }
  to {
    opacity: 0;
    transform: scale(1.25);
  }
}

@keyframes pular {
  40% {
    transform: translateY(-6px);
    box-shadow: 0 0 14px 3px rgba(82, 181, 90, 0.85);
  }
}

@keyframes confete {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0);
  }
  100% {
    opacity: 0;
    transform: translate(var(--x), var(--y)) rotate(var(--r));
  }
}
