/* ===================== */
/* RESET */
/* ===================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Arial, sans-serif;
}

/* ===================== */
/* CONTENEUR PRINCIPAL */
/* ===================== */
.Fondindex {
  position: relative;
  width: 100vw;
  height: 100dvh;
}

/* ===================== */
/* FOND */
/* ===================== */
.fondindex {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

/* ===================== */
/* INTRO MODAL */
/* ===================== */

#introOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity 0.4s ease;
}

.intro-box {
  max-width: 680px;
  padding: 50px 40px;
  border-radius: 22px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: white;
  text-align: center;
  line-height: 1.7;
  font-size: 1.05rem;
  box-shadow: 0 0 50px rgba(0,0,0,0.6);
  animation: fadeInIntro 0.8s ease;
}

.intro-logo {
  width: 90px;
  margin-bottom: 25px;
}

.intro-text {
  margin-bottom: 35px;
}

#startFormation {
  padding: 14px 35px;
  border-radius: 30px;
  border: none;
  background: gold;
  color: black;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

#startFormation:hover {
  transform: scale(1.07);
  box-shadow: 0 0 20px gold;
}

@keyframes fadeInIntro {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ===================== */
/* COFFRE */
/* ===================== */
.tresor-button {
  position: absolute;
  left: 50%;
  top: 78%;
  transform: translate(-50%, -50%);
  width: clamp(230px, 31vw, 400px);
  aspect-ratio: 1;
  cursor: pointer;
  z-index: 10;
}

.tresor-button.hide {
  display: none;
}

.tresor-img {
  position: absolute;
  inset: 0;
  width: 100%;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.coffre-ferme { opacity: 1; }
.coffre-ouvert { opacity: 0; transform: scale(0.95); }

.tresor-button:hover .coffre-ferme { opacity: 0; }
.tresor-button:hover .coffre-ouvert {
  opacity: 1;
  transform: scale(1.05);
}

/* ===================== */
/* LOADER */
/* ===================== */
#loaderScreen {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#loaderText {
  color: gold;
  font-size: 1.2rem;
  text-align: center;
  text-shadow: 0 0 12px gold;
  animation: blink 1.2s infinite;
}

/* ===================== */
/* 🧭 MINI-JEU */
/* ===================== */
#mapGame {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding-top: 180px;
  gap: 25px;
  background: rgba(0,0,0,0.7);
  z-index: 200;
}

#gameInstruction {
  color: white;
  font-size: 1.4rem;
  text-align: center;
  text-shadow: 0 0 15px gold;
  margin-bottom: 5px;
}

/* 🔢 compteur tentatives */
#attemptCounter {
  color: white;
  font-size: 1.1rem;
  text-shadow: 0 0 10px black;
  margin-bottom: 10px;
}

/* 🔴 message d'erreur clignotant */
#errorMessage {
  color: red;
  font-size: 1.2rem;
  font-weight: bold;
  display: none;
  text-shadow: 0 0 12px red;
  animation: errorBlink 0.6s infinite;
}

#mapPieces {
  display: flex;
  gap: 30px;
}

.map-piece-wrapper {
  position: relative;
  cursor: pointer;
}

/* image carte */
.map-piece {
  width: 160px;
  transition: all 0.3s ease;
}

/* sombre tant que pas cliqué */
.map-piece.inactive {
  filter: brightness(0.4) grayscale(100%);
}

/* ⭐ sélection */
.map-piece-wrapper.active .map-piece {
  filter: brightness(1.2) drop-shadow(0 0 15px gold);
}

/* 🌀 TREMBLEMENT */
.shake {
  animation: shakeAnim 0.5s ease;
}

/* n° ordre */
.order-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: white;
  text-shadow: 0 0 20px gold, 0 0 40px gold;
  animation: flash 0.8s ease;
  pointer-events: none;
}

/* ===================== */
/* VICTOIRE */
/* ===================== */
#victoryScreen {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 25px;
  z-index: 300;
}

#victoryScreen h1 {
  color: white;
  text-align: center;
  text-shadow: 0 0 20px gold;
  font-size: 1.6rem;
}

/* CARTE FINALE */
.full-map {
  max-width: 420px;
  width: auto;
  animation: mapFlash 1.5s ease;
  filter: drop-shadow(0 0 25px gold);
}

/* ===================== */
/* VIDÉO */
/* ===================== */
#videoContainer {
  position: fixed;
  inset: 0;
  background: black;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 400;
}

#videoContainer video {
  width: 80%;
  max-width: 900px;
  border-radius: 16px;
}

/* BOUTON X */
#closeVideo {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: white;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* SON 🔉 */
#soundToggle {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: white;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 25px gold;
}

#soundToggle.muted::after {
  content: "";
  position: absolute;
  width: 36px;
  height: 3px;
  background: red;
  transform: rotate(-45deg);
  border-radius: 2px;
}

/* ===================== */
/* FADE */
/* ===================== */
#cinematicFade {
  position: fixed;
  inset: 0;
  background: black;
  opacity: 0;
  pointer-events: none;
  z-index: 500;
  transition: opacity 1.2s ease;
}

#cinematicFade.active {
  opacity: 1;
}

/* ===================== */
/* GEMS */
/* ===================== */
#gemCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
}

/* ===================== */
/* 📱 VERSION MOBILE */
/* ===================== */

@media (max-width: 768px) {

  .fondindex {
    content: url("images/mobile/Fondmobiledebut.png");
    object-fit: cover;
  }

}

/* ===================== */
/* ANIMATIONS */
/* ===================== */
@keyframes blink {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* 🔴 erreur clignote */
@keyframes errorBlink {
  0%,100% { opacity: 1; }
  50% { opacity: 0.1; }
}

/* 🌀 tremblement */
@keyframes shakeAnim {
  0% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-6px); }
  100% { transform: translateX(0); }
}

@keyframes flash {
  0% { opacity: 0; transform: scale(0.3); }
  60% { opacity: 1; transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes mapFlash {
  0% { opacity: 0; transform: scale(0.6); filter: brightness(0); }
  50% { opacity: 1; transform: scale(1.1); filter: brightness(2); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* ===================== */
/* 📱 VERSION MOBILE */
/* ===================== */

@media (max-width: 768px) {

  /* pièces mini-jeu plus petites */
  #mapPieces {
    gap: 12px;
  }

  .map-piece {
    width: 80px;
  }

  #gameInstruction {
    font-size: 1.1rem;
  }

  #attemptCounter {
    font-size: 1rem;
  }

  /* coffre */
  .tresor-button {
    position: absolute;
    left: 65px;
    top: 479px;
    width: 328px;
    height: 269px;
    transform: none;
  }

  .tresor-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  /* conteneur vidéo */
  #videoContainer {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  /* vidéo */
  #videoContainer video {
    position: relative;
    width: 92vw;
    max-width: 420px;
    height: auto;
    border-radius: 12px;
    object-fit: contain;
  }

  /* bouton fermer vidéo (au-dessus de la vidéo) */
  #closeVideo {
    position: absolute;
    top: calc(50% - 150px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
  }

  /* bouton son */
  #soundToggle {
    position: absolute;
    bottom: 40px;
    right: 20px;
  }

}
}
