/* ============================================
   CORRIDA MALUCA — estilos principais
   ============================================ */

:root {
  --laranja: #ff6b35;
  --laranja-escuro: #d94e1d;
  --amarelo: #ffd23f;
  --verde: #4caf50;
  --verde-escuro: #2e7d32;
  --azul: #2196f3;
  --rosa: #ec407a;
  --branco: #ffffff;
  --preto-suave: #1a1a1a;
  --sombra-cartoon: 0 6px 0 rgba(0, 0, 0, 0.18);
  --sombra-cartoon-pressed: 0 2px 0 rgba(0, 0, 0, 0.18);
  --raio: 24px;

  --fonte-display: 'Baloo 2', system-ui, sans-serif;
  --fonte-corpo: 'Fredoka', system-ui, sans-serif;
}

body {
  font-family: var(--fonte-corpo);
  font-weight: 500;
  color: var(--preto-suave);
  background: #87CEEB;
}

/* ============================================
   APP — container que segura todas as telas
   ============================================ */
.app {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  /* Safari iOS — evita bounce */
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   TELAS — sistema de troca
   ============================================ */
.tela {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.tela--ativa { display: flex; }

.tela--jogo.tela--ativa { display: block; }

/* ============================================
   AVISO ROTAÇÃO (aparece em portrait no celular)
   ============================================ */
.aviso-rotacao {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(180deg, var(--laranja) 0%, var(--laranja-escuro) 100%);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--branco);
  font-family: var(--fonte-display);
  font-size: 28px;
  text-align: center;
  padding: 2rem;
}
.aviso-rotacao__icone {
  font-size: 100px;
  animation: girar-icone 1.5s ease-in-out infinite;
  margin-bottom: 1rem;
}
@media (orientation: portrait) and (max-width: 900px) {
  .aviso-rotacao { display: flex; }
}

/* ============================================
   TELA HOME
   ============================================ */
.tela--home {
  background: linear-gradient(180deg, #87CEEB 0%, #FFD23F 60%, #ff6b35 100%);
  padding: 2rem;
  gap: 2rem;
}

.logo {
  text-align: center;
  animation: bounce-suave 2s ease-in-out infinite;
}
.logo__titulo {
  font-family: var(--fonte-display);
  font-weight: 800;
  font-size: clamp(48px, 12vw, 96px);
  color: var(--branco);
  text-shadow:
    -3px -3px 0 var(--preto-suave),
     3px -3px 0 var(--preto-suave),
    -3px  3px 0 var(--preto-suave),
     3px  3px 0 var(--preto-suave),
     0 8px 0 rgba(0,0,0,0.25);
  line-height: 0.95;
  letter-spacing: -2px;
}
.logo__titulo--2 {
  color: var(--amarelo);
  transform: rotate(-3deg) translateY(-8px);
}

.rodape {
  position: absolute;
  bottom: 1.5rem;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.5px;
}

/* ============================================
   BOTÕES — estilo "cartoon" (chunky, com sombra)
   ============================================ */
.btn {
  font-family: var(--fonte-display);
  font-weight: 800;
  letter-spacing: 0.5px;
  border-radius: var(--raio);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: var(--sombra-cartoon-pressed);
}

.btn--gigante {
  padding: 24px 60px;
  font-size: 32px;
  background: var(--laranja);
  color: var(--branco);
  box-shadow: var(--sombra-cartoon);
  border: 4px solid var(--preto-suave);
  text-shadow: 0 2px 0 rgba(0,0,0,0.25);
}
.btn__icone { font-size: 28px; }

.btn--primario {
  padding: 16px 32px;
  font-size: 20px;
  background: var(--verde);
  color: var(--branco);
  box-shadow: var(--sombra-cartoon);
  border: 3px solid var(--preto-suave);
}

.btn--secundario {
  padding: 16px 32px;
  font-size: 20px;
  background: var(--branco);
  color: var(--preto-suave);
  box-shadow: var(--sombra-cartoon);
  border: 3px solid var(--preto-suave);
}

.btn--icone {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--branco);
  color: var(--preto-suave);
  font-size: 28px;
  font-weight: 700;
  border: 3px solid var(--preto-suave);
  box-shadow: var(--sombra-cartoon);
}

.btn--sair {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: var(--branco);
  font-size: 20px;
  font-weight: 700;
  z-index: 10;
}

/* ============================================
   TELA FASES
   ============================================ */
.tela--fases {
  background: linear-gradient(180deg, #87CEEB 0%, #B5E2F5 100%);
  padding: 1rem;
  gap: 1rem;
  justify-content: flex-start;
}

.cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 900px;
  padding: 0.5rem 0;
}
.cabecalho h2 {
  font-family: var(--fonte-display);
  font-weight: 800;
  font-size: 28px;
  color: var(--preto-suave);
  text-shadow: 0 3px 0 rgba(255,255,255,0.6);
}
.placeholder-direita { width: 52px; }

.grid-fases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 900px;
  overflow-y: auto;
  padding-bottom: 1rem;
}

.fase-card {
  background: var(--branco);
  border: 3px solid var(--preto-suave);
  border-radius: var(--raio);
  box-shadow: var(--sombra-cartoon);
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease;
  position: relative;
}
.fase-card:active:not(.fase-card--bloqueada) {
  transform: translateY(4px);
  box-shadow: var(--sombra-cartoon-pressed);
}
.fase-card__emoji { font-size: 48px; line-height: 1; }
.fase-card__nome {
  font-family: var(--fonte-display);
  font-weight: 600;
  font-size: 14px;
  margin-top: 6px;
  color: var(--preto-suave);
}
.fase-card__estrela {
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 28px;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.3));
}
.fase-card--bloqueada {
  opacity: 0.5;
  cursor: not-allowed;
  background: #d0d0d0;
}

/* ============================================
   TELA COUNTDOWN
   ============================================ */
.tela--countdown {
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
}
.countdown-num {
  font-family: var(--fonte-display);
  font-weight: 800;
  font-size: clamp(120px, 30vw, 240px);
  color: var(--laranja);
  text-shadow:
    -4px -4px 0 var(--branco),
     4px -4px 0 var(--branco),
    -4px  4px 0 var(--branco),
     4px  4px 0 var(--branco);
}

/* ============================================
   TELA JOGO
   ============================================ */
.tela--jogo {
  display: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #87CEEB;
}

.cenario {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.cenario__ceu {
  position: absolute;
  inset: 0;
  /* default — sobrescrito por temas */
  background: linear-gradient(180deg, #87CEEB 0%, #C5E5F0 60%, #d4d09a 75%, #8fa856 85%);
}
.cenario__sol {
  position: absolute;
  top: 12%;
  right: 18%;
  font-size: 60px;
  opacity: 0.85;
  animation: pulsar-sol 4s ease-in-out infinite;
}
.cenario__chao {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 38%;
  background: linear-gradient(180deg, #8fa856 0%, #5a8a3a 30%, #4a7c2e 100%);
  clip-path: polygon(0 18%, 100% 18%, 100% 100%, 0 100%);
}
.cenario__trilha {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 32%;
  background: linear-gradient(180deg, transparent 0%, rgba(120, 90, 50, 0.3) 30%, rgba(140, 100, 60, 0.6) 70%, rgba(160, 115, 70, 0.85) 100%);
  clip-path: polygon(46% 0, 54% 0, 100% 100%, 0 100%);
}

/* Camadas de parallax — cada uma é dois divs lado a lado pra fazer loop infinito */
.camada {
  position: absolute;
  display: flex;
  white-space: nowrap;
}
.camada__conteudo {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  flex-shrink: 0;
  width: 50%;
}
.camada--fundo {
  top: 38%;
  left: 0;
  width: 200%;
  height: 22%;
  opacity: 0.65;
  filter: blur(0.5px);
}
.camada--fundo .camada__conteudo { font-size: 50px; }

.camada--meio {
  top: 48%;
  left: 0;
  width: 200%;
  height: 18%;
  opacity: 0.75;
}
.camada--meio .camada__conteudo { font-size: 32px; }

.camada--frente {
  bottom: 8%;
  left: 0;
  width: 200%;
  height: 32%;
}
.camada--frente .camada__conteudo { font-size: 80px; }

.camada--flores {
  bottom: 2%;
  left: 0;
  width: 200%;
  height: 10%;
}
.camada--flores .camada__conteudo { font-size: 26px; align-items: center; }

/* ============================================
   COMANDO (ícone + texto que aparece no centro)
   ============================================ */
.comando {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: rgba(255, 255, 255, 0.95);
  border: 4px solid var(--preto-suave);
  border-radius: var(--raio);
  padding: 24px 40px;
  text-align: center;
  min-width: 220px;
  z-index: 20;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.comando--visivel {
  transform: translate(-50%, -50%) scale(1);
  animation: comando-pulsar 0.6s ease-in-out infinite;
}
.comando__emoji {
  font-size: clamp(80px, 14vw, 140px);
  line-height: 1;
}
.comando__texto {
  font-family: var(--fonte-display);
  font-weight: 800;
  font-size: clamp(28px, 5vw, 44px);
  color: var(--preto-suave);
  margin-top: 8px;
  text-shadow: 0 3px 0 rgba(0,0,0,0.1);
}

/* ============================================
   HUD (barra de tempo + sair)
   ============================================ */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  pointer-events: none;
}
.hud__barra {
  margin: 16px 70px 0 16px;
  height: 16px;
  background: rgba(0, 0, 0, 0.35);
  border: 3px solid var(--preto-suave);
  border-radius: 12px;
  overflow: hidden;
}
.hud__barra-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #ffd23f 0%, var(--laranja) 100%);
  transition: width 0.1s linear;
}
.hud .btn { pointer-events: auto; }

/* ============================================
   TELA FIM
   ============================================ */
.tela--fim {
  background: linear-gradient(180deg, #FFD23F 0%, #FF8C00 100%);
  padding: 2rem;
  gap: 1rem;
  position: relative;
  overflow: hidden;
}
.fim__estrela {
  font-size: clamp(100px, 20vw, 180px);
  animation: pular-estrela 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.fim__titulo {
  font-family: var(--fonte-display);
  font-weight: 800;
  font-size: clamp(40px, 9vw, 72px);
  color: var(--branco);
  text-shadow:
    -3px -3px 0 var(--preto-suave),
     3px -3px 0 var(--preto-suave),
    -3px  3px 0 var(--preto-suave),
     3px  3px 0 var(--preto-suave),
     0 8px 0 rgba(0,0,0,0.25);
  letter-spacing: -1px;
}
.fim__subtitulo {
  font-family: var(--fonte-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--branco);
  text-shadow: 0 3px 0 rgba(0,0,0,0.2);
}
.fim__botoes {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1rem;
}
.confete-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.confete {
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
}
