/* Style global */
body {
  font-family: monospace;
  background-color: #f4f4f4;
  color: #333;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  margin: 0;
  padding: 10px;
}

h1 {
  margin-bottom: 20px;
  font-size: 24px;
  text-align: center;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

/* Table de jeu */
table {
  border-collapse: collapse;
  margin-top: 20px;
  max-width: 100%; /* Limiter la largeur */
}

td {
  width: 50px; /* Taille fixe pour éviter l'étirement */
  height: 50px;
  text-align: center;
  vertical-align: middle;
  border: 1px solid #ccc;
  font-size: 24px;
  max-width: 60px; /* Taille max pour écrans larges */
  max-height: 60px;
}

/* Éléments de jeu */
.wall {
  background-color: #333;
}

.box {
  background-color: #f90;
}

.target {
  background-color: #0f0;
}

.player {
  background-color: #00f;
  color: white;
}

.box-on-target {
  background-color: #f72929; /* Couleur pour boîte sur cible */
}

/* Carte d'alerte */
#alertCard {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#alertCard.hidden {
  display: none;
}

.card {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  text-align: center;
  width: 90%;
  max-width: 300px;
}

.card p {
  margin: 0 0 20px;
  font-size: 16px;
}

.card button {
  background-color: #007bff;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
}

.card button:hover {
  background-color: #0056b3;
}

/* Boutons */
.redirect-btn,
.restart-btn,
.level-select {
  margin: 10px 5px;
  padding: 10px 15px;
  font-size: 14px;
  border-radius: 5px;
  border: 1px solid #ccc;
  cursor: pointer;
}

.redirect-btn {
  background-color: #007bff;
  color: white;
}

.restart-btn {
  background-color: #dc3545;
  color: white;
}

.level-select {
  background-color: #ffffff;
  color: #333;
}

.redirect-btn:hover {
  background-color: #0056b3;
}

.restart-btn:hover {
  background-color: #c82333;
}

/* Conteneur des boutons */
h1 {
  flex-wrap: wrap; /* Permet aux boutons de passer à la ligne si nécessaire */
}

/* Responsivité */
@media (max-width: 768px) {
  td {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .card {
    padding: 15px;
    font-size: 14px;
  }

  .redirect-btn,
  .restart-btn,
  .level-select {
    font-size: 12px;
    padding: 8px 12px;
  }
}

@media (max-width: 480px) {
  td {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .redirect-btn,
  .restart-btn,
  .level-select {
    font-size: 12px;
    padding: 8px 10px;
  }
}

/* Styles pour les boutons de flèches directionnelles */
.mobile-controls {
  display: none; /* Masqué par défaut */
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}

.arrow-row {
  display: flex;
  gap: 10px;
}

.arrow-btn {
  background-color: #007bff;
  color: white;
  border: none;
  padding: 15px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
}

.arrow-btn:hover {
  background-color: #0056b3;
}

/* Afficher les boutons de flèches en mode mobile */
@media (max-width: 768px) {
  .mobile-controls {
    display: flex;
  }
}