/* Resetando margens e preenchimentos para todos os elementos */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Estilo para o corpo da página, ocupando toda a tela */
body {
  height: 100vh;
  display: flex;
  justify-content: center;
  background-color: #87CEEB; /* Cor de fundo azul céu */
  overflow: hidden; /* Evita barras de rolagem */
}

/* Estilo para a tela principal do jogo */
.tela {
  position: relative;
  width: 100%;
  max-width: 1200px; /* Limita a largura máxima para telas grandes */
  height: 100vh;
  border-bottom: 15px solid rgb(35, 160, 35);
  margin: 0 auto;
  overflow: hidden; /* Esconde elementos que saem da tela */
  background: linear-gradient(#87CEEB, #E0F6FF); /* Gradiente para o céu */
}

/* Estilo para o contador de pontuação */
.score-container {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 24px;
  font-family: 'Arial', sans-serif;
  font-weight: bold;
  color: #333;
  background-color: rgba(255, 255, 255, 0.7);
  padding: 5px 10px;
  border-radius: 5px;
  z-index: 10;
}

/* Estilo para o cano (obstáculo) */
.pipe {
  position: absolute;
  bottom: 0;
  width: 80px;
  right: -80px; /* Começa fora da tela */
  animation: pipe-animation 1.5s infinite linear;
}

/* Animação do cano se movendo da direita para a esquerda */
@keyframes pipe-animation {
  from {
    right: -80px;
  }
  to {
    right: 100%;
  }
}

/* Estilo para o personagem Mario */
.mario {
  position: absolute;
  bottom: 0;
  width: 150px;
  left: 10%;
}

/* Classe para animação de pulo do Mario */
.jump {
  animation: jump 500ms ease-out;
}

/* Animação de pulo */
@keyframes jump {
  0% {
    bottom: 0;
  }
  40% {
    bottom: 180px;
  }
  50% {
    bottom: 180px;
  }
  60% {
    bottom: 180px;
  }
  100% {
    bottom: 0;
  }
}

/* Estilo para as nuvens de fundo */
.clouds {
  position: absolute;
  width: 550px;
  animation: clouds-animation 20s infinite linear;
  top: 20%;
}

/* Animação das nuvens se movendo */
@keyframes clouds-animation {
  from {
    right: -550px;
  }
  to {
    right: 100%;
  }
}

/* Estilo para a tela de Game Over */
.game-over {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(255, 255, 255, 0.9);
  padding: 30px;
  border-radius: 10px;
  text-align: center;
  display: none; /* Escondido inicialmente */
  z-index: 100;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  width: 80%;
  max-width: 400px;
}

.game-over h2 {
  font-size: 36px;
  color: #e74c3c;
  margin-bottom: 20px;
}

.game-over p {
  font-size: 24px;
  margin-bottom: 30px;
}

/* Estilo para o botão de reiniciar */
.restart-button {
  background-color: #2ecc71;
  color: white;
  border: none;
  padding: 15px 30px;
  font-size: 18px;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.restart-button:hover {
  background-color: #27ae60;
}

/* Media queries para responsividade - TABLETS */
@media (max-width: 768px) {
  .mario {
    width: 100px; /* Mario menor em tablets */
    left: 10%;
  }
  
  .pipe {
    width: 60px; /* Cano menor em tablets */
  }
  
  .clouds {
    width: 400px; /* Nuvens menores em tablets */
    top: 15%;
  }
  
  .score-container {
    font-size: 20px;
    top: 15px;
    right: 15px;
  }
  
  /* Ajuste na animação de pulo para tablets */
  @keyframes jump {
    0% {
      bottom: 0;
    }
    40% {
      bottom: 140px; /* Altura de pulo ajustada para tablets */
    }
    50% {
      bottom: 140px;
    }
    60% {
      bottom: 140px;
    }
    100% {
      bottom: 0;
    }
  }
  
  /* Ajuste na velocidade do cano para tablets */
  .pipe {
    animation: pipe-animation 1.3s infinite linear; /* Um pouco mais rápido */
  }
  
  .game-over h2 {
    font-size: 30px;
  }
  
  .game-over p {
    font-size: 20px;
  }
  
  .restart-button {
    padding: 12px 24px;
    font-size: 16px;
  }
}

/* Media queries para responsividade - CELULARES */
@media (max-width: 480px) {
  .mario {
    width: 70px; /* Mario ainda menor em celulares */
    left: 10%;
  }
  
  .pipe {
    width: 40px; /* Cano ainda menor em celulares */
  }
  
  .clouds {
    width: 250px; /* Nuvens ainda menores em celulares */
    top: 10%;
  }
  
  .score-container {
    font-size: 16px;
    top: 10px;
    right: 10px;
    padding: 3px 8px;
  }
  
  /* Ajuste na animação de pulo para celulares */
  @keyframes jump {
    0% {
      bottom: 0;
    }
    40% {
      bottom: 100px; /* Altura de pulo ajustada para celulares */
    }
    50% {
      bottom: 100px;
    }
    60% {
      bottom: 100px;
    }
    100% {
      bottom: 0;
    }
  }
  
  /* Ajuste na velocidade do cano para celulares */
  .pipe {
    animation: pipe-animation 1.2s infinite linear; /* Ainda mais rápido */
  }
  
  .game-over {
    padding: 20px;
    width: 90%;
  }
  
  .game-over h2 {
    font-size: 24px;
    margin-bottom: 15px;
  }
  
  .game-over p {
    font-size: 18px;
    margin-bottom: 20px;
  }
  
  .restart-button {
    padding: 10px 20px;
    font-size: 14px;
  }
}

/* Media queries para telas muito pequenas */
@media (max-width: 320px) {
  .mario {
    width: 50px; /* Mario muito pequeno para telas muito pequenas */
  }
  
  .pipe {
    width: 30px; /* Cano muito pequeno para telas muito pequenas */
  }
  
  /* Ajuste na animação de pulo para telas muito pequenas */
  @keyframes jump {
    0% {
      bottom: 0;
    }
    40% {
      bottom: 80px; /* Altura de pulo ajustada para telas muito pequenas */
    }
    50% {
      bottom: 80px;
    }
    60% {
      bottom: 80px;
    }
    100% {
      bottom: 0;
    }
  }
}

/* Ajuste para altura da tela em dispositivos com tela baixa */
@media (max-height: 500px) {
  .mario {
    width: 60px;
  }
  
  .pipe {
    width: 35px;
  }
  
  @keyframes jump {
    0% {
      bottom: 0;
    }
    40% {
      bottom: 70px; /* Pulo menor para telas com altura reduzida */
    }
    50% {
      bottom: 70px;
    }
    60% {
      bottom: 70px;
    }
    100% {
      bottom: 0;
    }
  }
  
  .clouds {
    top: 5%;
  }
}

/* Estilo para o botão de som */
.sound-button {
  position: absolute;
  top: 20px;
  left: 20px;
  background-color: rgba(255, 255, 255, 0.7);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 20px;
  cursor: pointer;
  z-index: 10;
  transition: background-color 0.3s;
}

.sound-button:hover {
  background-color: rgba(255, 255, 255, 0.9);
}

/* Ajuste para telas menores */
@media (max-width: 480px) {
  .sound-button {
    width: 30px;
    height: 30px;
    font-size: 16px;
    top: 10px;
    left: 10px;
  }
}