/* CSS pour LesPitous.com */

body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  background-color: #f0f0f0;
  overflow-x: hidden;
}

.banner {
  background-color: #333;
  color: white;
  padding: 15px;
  text-align: center;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
}

.download-button {
  background-color: #ff6600;
  color: white;
  padding: 10px 20px;
  margin-left: 20px;
  margin-right: 20px;
  text-decoration: none;
  border-radius: 5px;
  font-weight: bold;
}

.main-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  padding-top: 60px;
  box-sizing: border-box;
  flex-wrap: nowrap;
}

.side-image {
  width: 15vw;
  height: auto;
  max-height: 80%;
  animation: mirrorFlip 2s infinite steps(1);
}

.side-image.left {
  transform: rotate(15deg) scaleX(1);
  animation-delay: 0s;
}

.side-image.right {
  transform: rotate(15deg) scaleX(1);
  animation-delay: 1s;
}

.center-image {
  width: 50vw;
  height: auto;
  max-height: 80%;
  margin: 0 2vw;
}

@keyframes mirrorFlip {
  0% { transform: rotate(15deg) scaleX(1); }
  50% { transform: rotate(-15deg) scaleX(-1); }
  100% { transform: rotate(15deg) scaleX(1); }
}

@media (max-width: 1024px) {
  .side-image {
    width: 20vw;
  }
  .center-image {
    width: 60vw;
  }
}

@media (max-width: 768px) {
  .main-container {
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 80px;
    flex-wrap: nowrap;
  }

  .side-image {
    width: 40vw;
    margin: 10px auto;
    animation: mirrorFlip 2s infinite steps(1);
    transform: rotate(15deg);
  }

  .side-image.left {
    animation-delay: 0s;
  }

  .side-image.right {
    animation-delay: 1s;
  }

  .center-image {
    width: 80vw;
    margin: 20px auto;
  }

  .download-button {
    display: inline-block;
    margin-top: 10px;
  }
}

.footer {
  display: flex;
  max-height: 50px;
  background-color: #333;
}

.conteneur-copyright {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#copyright {
  color: white;
}

#playSnake {
  align-items: right;
  padding-top: 5px;
  padding-right: 10px;
  height: 40px;
  width: auto;
}

/* --- Accessibilité : screen-reader only --- */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* --- Overlay + Modale --- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;              /* caché par défaut */
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.open { display: flex; }

.modal-dialog {
  position: relative;
  background: #fff;
  width: min(92vw, 640px);
  max-height: 90svh;   /* svh = plus fiable sur mobile que vh */
  overflow: auto;      /* permet de scroller si le contenu est trop haut */
  border-radius: 16px;
  padding: 16px 16px 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  display: grid;
  gap: 12px;
}


.modal-close {
  position: absolute;
  right: 12px; top: 10px;
  background: #ff4d4f; color: #fff;
  border: none; border-radius: 50%;
  width: 36px; height: 36px; font-size: 20px;
  cursor: pointer;
}

#snakeTitle {
  margin: 0 36px 8px 0; /* place pour le bouton X */
  font-size: 1.4rem;
}

.scorebar {
  display: flex; gap: 16px; font-size: 1.1rem;
}

#snakeCanvas {
  width: 100%;
  aspect-ratio: 1 / 1; /* Rend carré et responsive */
  background: #f6fff0;
  border: 3px solid #98d47a;
  border-radius: 12px;
}

/* Contrôles tactiles (affichés surtout sur mobile) */
.controls-mobile { display: none; }
@media (max-width: 768px) {
.controls-mobile {
    display: block;
    margin-top: 8px;              /* un peu d’air sous le canvas */
  }

  .dpad { 
    display: grid; 
    place-items: center; 
    gap: 8px; 
  }

  .dpad .middle { 
    display: flex; 
    gap: 24px; 
  }

  .dpad button {
    font-size: 1.2rem; 
    padding: 12px 16px;
    min-width: 56px;              /* + grande zone cliquable */
    min-height: 56px;
    border-radius: 10px; 
    border: 2px solid #98d47a;
    background: #eaffd4; 
    cursor: pointer;

    /* Améliorations tactiles */
    touch-action: manipulation;           /* enlève les délais ~300ms */
    -webkit-tap-highlight-color: transparent;
    user-select: none;                    /* évite la sélection accidentelle */
  }

  .dpad button:active {
    transform: scale(0.98);               /* petit feedback au tap */
  }
}

/* Mobile: ne jamais dépasser l'écran en hauteur */
@media (max-width: 768px) {
  #snakeCanvas {
    /* carré, borné par la largeur ET ~70% de la hauteur visible */
    width: min(90svw, 70svh);
    height: auto;          /* aspect-ratio s'applique */
    aspect-ratio: 1 / 1;
    display: block;
    margin-inline: auto;   /* centré */
  }

  /* un peu plus compact pour gagner de l'espace vertical */
  .modal-dialog { padding: 12px; }
  .scorebar { font-size: 1rem; }
}


.actions {
  display: flex; justify-content: center; gap: 12px;
}

.actions #btnRestart {
  padding: 10px 16px; font-size: 1rem;
  border-radius: 10px; border: 2px solid #6cc04a;
  background: #ccffd6; cursor: pointer;
}

/* Body scroll lock quand la modale est ouverte */
body.modal-open { overflow: hidden; }

