.titulo {
  text-align: center;
  text-decoration: underline;
  margin-top: 20px;
}

body {
  background-color: rgb(255, 245, 56);
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
}

header {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 55vh;
  background-color: #f0f0f0;
}

.game-container {
  display: grid;
  grid-template-columns: repeat(4, 80px);
  grid-gap: 10px;
  background-color: #000;
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.card {
  width: 80px;
  height: 80px;
  perspective: 1000px;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.card.volteada .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.card-front {
  background-color: #ccc;
}

.card-back {
  background-color: #fff;
  transform: rotateY(180deg);
}

#mensaje-ganaste {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  font-size: 36px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  text-align: center;
  padding: 20px;
}

#mensaje-ganaste button {
  margin-top: 20px;
  padding: 15px 30px;
  font-size: 18px;
  border: none;
  border-radius: 8px;
  background-color: #00c853;
  color: white;
  cursor: pointer;
}

#temporizador,
#movimientos,
#mejor-resultado {
  font-size: 1.2rem;
  margin: 10px auto;
  color: #000;
  text-align: center;
  font-weight: bold;
}

@media (max-width: 768px) {
  .game-container {
    grid-template-columns: repeat(4, 70px);
    grid-gap: 8px;
    padding: 12px;
  }

  .card {
    width: 70px;
    height: 70px;
  }

  .card-front,
  .card-back {
    font-size: 1.8rem;
  }

  h1 {
    font-size: 1.8rem;
  }

  #mensaje-ganaste {
    font-size: 28px;
  }

  #mensaje-ganaste button {
    font-size: 16px;
    padding: 10px 20px;
  }
}

@media (max-width: 480px) {
  .game-container {
    grid-template-columns: repeat(2, 80px);
    grid-gap: 10px;
    padding: 10px;
    margin: 0 auto;
  }

  .card {
    width: 80px;
    height: 80px;
  }

  .card-front,
  .card-back {
    font-size: 1.5rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  #mensaje-ganaste {
    font-size: 24px;
  }

  #mensaje-ganaste button {
    font-size: 14px;
    padding: 8px 16px;
  }

  #temporizador,
  #movimientos,
  #mejor-resultado {
    font-size: 1rem;
  }
}

#campo-nombre {
  text-align: center;
}

#ranking {
  text-align: center;
}

.mensaje-bienvenida {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;

  opacity: 0;
  animation: fadeIn 0.8s forwards, fadeOut 0.8s 3s forwards;
}

.mensaje-contenido {
  background: linear-gradient(135deg, #4CAF50, #81C784);
  color: white;
  padding: 40px 60px;
  border-radius: 20px;
  font-size: 2.2rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  max-width: 90%;
  line-height: 1.3;
  letter-spacing: 1.2px;
  user-select: none;
  transform: scale(0.8);
  animation: scaleUp 0.8s forwards, scaleDown 0.8s 3s forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
  }
}

@keyframes scaleUp {
  to {
    transform: scale(1);
  }
}

@keyframes scaleDown {
  to {
    transform: scale(0.8);
  }
}

@media (max-width: 480px) {
  .mensaje-contenido {
    font-size: 1.5rem;
    padding: 30px 20px;
    border-radius: 15px;
  }
}