/* ==========================
    VARIABLES
  =========================== */

/* Définition des couleurs utilisées pour la personnalisation */
:root {
  --cream : #FEF2BF;
  --gold : #FFD700;
  --cyan : #4DD0E1;
  --red-light : #ff4d4d;
  --red-dark : #b30000;
  --green-light : #00b712;
  --green-dark : #00770b;
  --blue-dark : #011F3F;
}

/* ==========================
    BODY
  =========================== */

body {
  text-align: center;
  background: radial-gradient(circle at center, #022c57 0%, #000 100%);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
}

/* Personnalisation de la classe qui sera appliquée au body lors d'une erreur du joueur */
.game-over {
  background-color: red;
  background-image: none;
  opacity: 0.8;
}

/* ==========================
    HEADER
  =========================== */

/* Personnalisation du header contenant le bouton d'ouverture de la modale "Règles du Jeu" */
header {
  text-align: end;
}

/* ==========================
    MAIN
  =========================== */

/* Personnalisation du message afficher en titre */
#level-title {
  font-family: 'Press Start 2P', cursive;
  font-size: 3rem;
  margin:  5%;
  margin-top: 0;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(77, 208, 225, 0.5);
  letter-spacing: 3px;
}

/* Animation sur le titre */
#level-title.anim-title {
  background: linear-gradient(to right,rgba(0, 183, 18, 1) 0%, rgba(218, 65, 65, 1) 25%, rgba(255, 234, 0, 1) 50%, rgba(41, 121, 255, 1) 75%, rgba(0, 183, 18, 1) 100%);
  background-size: 50%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: 1s linear infinite color-title;
}

@keyframes color-title {
  0% {background-position: 0%;}
  100% {background-position: 100%;}
}

/* Personnalisation de l'écran de record */
.score-board {
  margin-bottom: 20px;
}

#best-score {
  font-family: 'Press Start 2P', cursive;
  font-size: 1.2rem;
  letter-spacing: 3px;
  color: var(--gold);
  margin-top: -20px;
  margin-bottom: 30px;
  text-shadow: 3px 3px 0px #000;
}

/* ==========================
    BOUTONS DU JEU
  =========================== */

/* Personnalisation de la boite contenant les boutons */
.container {
  display: block;
  width: 50%;
  max-width: 500px;
  margin: auto;
}

/* Personnalisation de l'aspect global des boutons */
.btn {
  margin: 20px;
  display: inline-block;
  height: 180px;
  width: 180px;
  border: none;
  border-radius: 20%;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.5), 0 10px 20px rgba(0, 0, 0, 0.4);
  transition: all 0.1s ease;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Personnalisation de la couleur des boutons */
.red {
  background: linear-gradient(145deg,#da4141, #b30000);
}

.green {
  background: linear-gradient(145deg,#00b712, #00770b);
}

.blue {
  background: linear-gradient(145deg,#2979ff, #0d47a1);
}

.yellow {
  background: linear-gradient(145deg,#ffea00, #ffb300);
}

/* Personnalisation de la classe qui sera appliquée lors de la pression d'un bouton par le joueur */
.pressed {
  box-shadow: 0 0 10px white;
  transform: translateY(8px);
  filter: brightness(1.3);
}

/* ==========================
    FOOTER
  =========================== */

footer {
  margin-top: auto;
  width: 100%;
  font-family: 'Press Start 2P', cursive ;
  font-size: 0.6rem;
  padding: 20px 0;
  color: var(--cream);
  text-shadow: 3px 3px 1px black;
}

footer a {
  color: var(--cyan);
  text-decoration: none;
  transition: color 0.2s ease;
  border-radius: 5px;
}

footer a:hover {
  color: var(--gold);
}

/* ==========================
    FENETRES MODALES
  =========================== */

/* Personnalisations générales */

/* Le fond sombre qui va courir tout l'écran */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 1000;
/* Important pour centrer la boite au milieu de l'écran */
  display: none;
  justify-content: center;
  align-items: center;
}

/* La boite de dialogue */
.modal-box {
  background-color: var(--blue-dark);
  border: 4px solid var(--cream);
  border-radius: 15px;
  padding: 30px;
  text-align: center;
  font-family: 'Press Start 2P', cursive;
  color: var(--cream);
  box-shadow: 0 0 20px var(--gold);
  max-width: 80%;
}

/* Les paragraphes dans la boite de dialogue */
.modal-box p {
  line-height: 1.5;
  font-size: 0.8rem;
  margin-bottom: 20px;
  text-shadow: 3px 3px 1px black;
}

/* Les boutons dans la boite de dialogue */
.modal-btn {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.7rem;
  color: white;
  padding: 10px 20px;
  width: 80px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.modal-btn:active {
  transform: scale(0.95);
}

/* Personnalisation du bouton d'ouverture de la modale affichant les règles du jeu */
#rules-btn {
  margin-top: 30px;
  margin-right: 5%;
  font-family: 'Press Start 2P', cursive;
  font-size: 1.3rem;
  color: var(--cream);
  width: 50px;
  height: 50px;
  border: 2px solid var(--cream);
  border-radius: 50%;
  background-color: transparent;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

#rules-btn:hover {
  transform: scale(1.2);
  background-color: var(--cyan);
  color: white;
  border-color: white;
}

/* Personnalisation de la fenêtre contenant les règles du jeu */
.box-rules {
  max-height: 80vh;
  overflow-y: auto;
  width: 40%;
  display: flex;
  flex-direction: column;
}

/* Personnalisation des boutons de la fenêtre des règles du jeu */
#btn-close-top {
  font-size: 0.9rem;
  align-self: flex-end;
  width: auto;
}

#btn-close-bottom {
  width: auto;
  align-self: center;
}

/* Personnalisation du texte des règles du jeu */
.rules-title {
  margin-top: 20px;
  color: var(--gold);
  text-shadow: 3px 3px 1px black;
}

.rules-txt {
  width: 80%;
  margin: 50px auto;
  text-align: start;
  display: flex;
  flex-direction: column;
  gap: 10px;
  letter-spacing: 1.8px;
  line-height: 1.5;
  font-size: 0.8rem;
  text-shadow: 3px 3px 1px black;
}

.rules-txt p {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
}

.rules-txt span {
  font-family: 'Press Start 2P', cursive;
  color: var(--gold);
  font-size: 1rem;
}

.rules-txt ul {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
  list-style-type: square;
}

.rules-txt ul li {
  margin-top: 20px;
}

/* Personnalisation du bouton de reset du record */
#reset-btn {
  background: transparent;
  border: 2px solid var(--cream);
  color: var(--cream);
  font-family: 'Press Start 2P', cursive;
  font-size: 0.8rem;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

#reset-btn:hover {
  background-color: var(--red-light);
  border-color: var(--red-light);
  color: white;
}

/* Personnalisation de la fenêtre modale de confirmation du Reset */

/* Le conteneur des boutons YES et NO de la boite */
.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.yes {
  background-color: var(--red-light);
  box-shadow: 0 5px 0 var(--red-dark);
}

.no {
  background-color: var(--green-light);
  box-shadow: 0 5px 0 var(--green-dark);
}

/* ==========================
    ACCESSIBILITE
  =========================== */

/* Effet qui s'applique sur les boutons et le lien lors de la sélection au clavier */
button:focus-visible, a:focus-visible {
	outline: 4px solid var(--gold);
	outline-offset: 2px
}


/* ==========================
    FORMAT MOBILE
  =========================== */

/* Ajustement de personnalisation selon la taille de l'écran */
@media screen and (max-width : 1024px) {

  .container {
    width: 100%;
  }

  .reset {
    width: 220px;
  }

  #rules-btn {
    font-size: 0.7rem;
    width: 30px;
    height: 30px;
    margin-bottom: 20px;
  }
    
  .box-rules {
    width: 90%;
    padding: 30px 10px;
  }

  #btn-close-top {
    display: none;
  }

  .rules-title {
    font-size: 1.2rem;
  }

  .rules-txt {
    margin: 30px auto;
  }

  .rules-txt span{
    font-size: 0.8rem;
  }

  .rules-txt ul {
    list-style-position: inside;
    padding: 0;
  }

  #level-title {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  #best-score {
    font-size: 0.7rem;
    margin-top: 5px;
  }

  #reset-btn {
    font-size: 0.6rem;
    padding: 5px 12px;
  }

  .btn {
    height: 100px;
    width: 100px;
    margin: 15px;
  }
}