@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;700;800&display=swap');

:root {
  --laranja: #ff9800;
  --btn-vermelho: #ff7675;
  --btn-verde: #2ecc71;
  --btn-roxo: #a29bfe;
  --escuro: #1a252f;
  /* Temas de Fundo */
  --ceu-dia: #3498db;
  --ceu-tarde: #e67e22;
  --ceu-noite: #1c2833;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ceu-dia);
  font-family: 'Fredoka', sans-serif;
  overflow: hidden;
  transition: background 2s ease-in-out; 
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  touch-action: manipulation;
}

body.tema-tarde { background: var(--ceu-tarde); }
body.tema-noite { background: var(--ceu-noite); }

@supports (height: 100dvh) { body { height: 100dvh; } }

/* Tremida na tela ao errar */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-2deg); }
  40% { transform: translateX(10px) rotate(2deg); }
  60% { transform: translateX(-10px) rotate(-2deg); }
  80% { transform: translateX(10px) rotate(2deg); }
}
.shake-ativo { animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both; }

/* EFEITO DE CONGELAMENTO */
#efeito-gelo {
  position: absolute;
  inset: 0;
  background: rgba(0, 168, 255, 0.25); 
  box-shadow: inset 0 0 80px rgba(255,255,255,0.7); 
  pointer-events: none; 
  z-index: 45; 
  opacity: 0;
  transition: opacity 0.3s ease;
}
#efeito-gelo.ativo {
  opacity: 1;
}

/* --- NUVENS --- */
.nuvens-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}
.nuvem {
  position: absolute;
  background: white;
  width: 120px;
  height: 40px;
  border-radius: 50px;
  opacity: 0.5;
  animation: moverNuvens linear infinite;
}
.nuvem::after {
  content: '';
  position: absolute;
  background: white;
  width: 60px;
  height: 60px;
  top: -25px;
  left: 20px;
  border-radius: 50%;
}
@keyframes moverNuvens {
  from { left: -250px; }
  to { left: 110%; }
}

/* HEADER OTIMIZADO PARA CENTRALIZAÇÃO */
header {
  background: rgba(255, 255, 255, 0.95);
  width: 100%;
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 50;
  box-shadow: 0 3px 10px rgba(0,0,0,0.28);
}
.header-esq {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: flex-start;
  flex-wrap: wrap; /* Permite quebrar linha no mobile se não couber */
}
.header-dir {
  flex: 1;
}

.btn-sair, .btn-sobre, .btn-modos {
  color: white;
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 50px;
  font-weight: bold;
  font-size: 0.88rem;
  font-family: 'Fredoka', sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  transition: transform 0.1s;
}
.btn-sair:active, .btn-sobre:active, .btn-modos:active { transform: scale(0.95); }

.btn-sair { background: var(--btn-vermelho); box-shadow: 0 3px 0 #d63031; }
.btn-sobre { background: #0984e3; box-shadow: 0 3px 0 #076ebf; }
.btn-modos { background: var(--btn-roxo); box-shadow: 0 3px 0 #6c5ce7; }

#vidas-ui {
  font-size: clamp(1rem, 3vw, 1.2rem);
  letter-spacing: 2px;
  transition: transform 0.2s;
  text-align: center;
}

/* RANKING NO CANTO SUPERIOR DIREITO */
.status-topo {
  position: absolute;
  top: 12px;
  right: 15px;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  font-weight: 800;
  font-size: 0.9rem;
  color: #2d3436;
  user-select: none;
}
.status-topo span { color: var(--laranja); }

#campo-jogo {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  z-index: 5;
}

/* PALAVRAS DE ALTO CONTRASTE */
.palavra-viva {
  position: absolute;
  top: 0;
  font-size: clamp(1.2rem, 3.4vw, 1.8rem);
  font-weight: 800;
  padding: clamp(10px, 2.6vw, 15px) clamp(18px, 4.2vw, 30px);
  background: white;
  color: var(--escuro);
  border-radius: 25px;
  border: 4px solid var(--escuro);
  box-shadow: 0 6px 0 var(--escuro);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
  will-change: transform;
  user-select: none;
  pointer-events: none;
  transition: transform 0.1s;
}

/* POWER-UPS STYLES */
.power-freeze { border-color: #0984e3; box-shadow: 0 6px 0 #0984e3; color: #0984e3; }
.power-slow { border-color: #f1c40f; box-shadow: 0 6px 0 #f1c40f; color: #d35400; }
.power-life { border-color: #fd79a8; box-shadow: 0 6px 0 #fd79a8; color: #e84393; }
.power-lightning { border-color: #9b59b6; box-shadow: 0 6px 0 #9b59b6; color: #8e44ad; }

/* PARTÍCULAS DE EXPLOSÃO */
.particula {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--laranja);
  border-radius: 50%;
  pointer-events: none;
  z-index: 20;
  animation: particulaAnim 0.6s ease-out forwards;
}
@keyframes particulaAnim {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* ÁREA DE DIGITAÇÃO E BADGES */
#area-digito {
  width: 100%;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(8px);
  z-index: 60;
  padding: 10px;
  box-shadow: 0 -7px 18px rgba(0,0,0,0.22);
  border-top: 2px solid rgba(0,0,0,0.1);
}

.wrap-inferior {
  width: min(96vw, 720px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.badge-inferior {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border-radius: 12px;
  background: white;
  border: 3px solid var(--btn-roxo);
  color: var(--escuro);
  font-weight: 800;
  font-size: clamp(0.9rem, 3.5vw, 1.2rem);
  box-shadow: 0 4px 0 rgba(0,0,0,0.08);
}
.badge-inferior span { color: var(--laranja); }

#input-palavra {
  flex: 1;
  max-width: 300px;
  font-size: clamp(1.2rem, 4.2vw, 1.6rem);
  padding: 10px;
  border-radius: 14px;
  border: 4px solid var(--btn-roxo);
  text-align: center;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  outline: none;
  background: white;
  box-shadow: 0 5px 0 rgba(0,0,0,0.10);
  color: var(--escuro);
  text-transform: uppercase;
}

/* BOTÕES LATERAIS EMPILHADOS */
.controles-lateral {
  position: absolute;
  right: 15px;
  bottom: 140px; 
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 80;
}

.btn-circular {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid white;
  background: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  font-size: 1.3rem;
  transition: transform 0.1s;
  padding: 0;
}
.btn-circular:active { transform: scale(0.9); }
.btn-circular.ativo { background: var(--btn-verde) !important; color: white; }

/* TECLADO VIRTUAL (Mobile) */
#teclado-virtual {
  display: none;
  background: #dfe6e9;
  padding: 8px 4px;
  width: 100%;
  flex-direction: column;
  gap: 6px;
  z-index: 100;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
.linha-teclado { display: flex; justify-content: center; gap: 4px; width: 100%; }
.tecla {
  flex: 1;
  max-width: 40px;
  height: 48px;
  border-radius: 8px;
  border: none;
  background: white;
  font-size: 1.2rem;
  font-family: 'Fredoka';
  font-weight: 700;
  color: var(--escuro);
  box-shadow: 0 4px 0 #b2bec3;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tecla:active { transform: translateY(4px); box-shadow: 0 0 0 transparent; background: #e0e0e0; }
.tecla-larga { max-width: 60px; background: var(--btn-vermelho); color: white; box-shadow: 0 4px 0 #d63031; }

/* Telas Overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(44, 62, 80, 0.9);
  backdrop-filter: blur(15px); display: flex; justify-content: center;
  align-items: center; z-index: 1000; padding: 18px;
}
.menu-caixa {
  background: white; padding: 32px; border-radius: 40px;
  border: 8px solid var(--laranja); width: min(92vw, 420px); text-align: center;
}
.caixa-sobre {
  max-height: 85vh; 
  overflow-y: auto; 
  width: min(92vw, 550px);
}
.btn-grande {
  color: white; border: none; padding: 16px; border-radius: 20px;
  font-size: 1.3rem; font-weight: bold; cursor: pointer;
  font-family: 'Fredoka'; width: 100%; margin-bottom: 10px; transition: transform 0.1s;
}
.btn-grande:active { transform: scale(0.95); }
.btn-aprendiz { background: var(--btn-verde); box-shadow: 0 6px 0 #27ae60; }
.btn-mestre { background: var(--btn-roxo); box-shadow: 0 6px 0 #6c5ce7; }

/* Responsividade */
@media (max-width: 768px) {
  #teclado-virtual { display: flex; }
  #input-palavra { pointer-events: none; }
  .controles-lateral { bottom: 250px; right: 10px; }
  .btn-circular { width: 38px; height: 38px; font-size: 1.1rem; }
  .header-esq { flex-wrap: wrap; }
}
@media (max-width: 420px) {
  .wrap-inferior { flex-wrap: wrap; }
  #input-palavra { order: -1; min-width: 100%; margin-bottom: 5px; }
  .badge-inferior { flex: 1; justify-content: center; }
}