@font-face {
  font-family: "Luckiest Guy";
  src: url("./assets/fonts/LuckiestGuy-Regular.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ── RESET ──────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

/* ── BODY ───────────────────────────────────────── */
body {
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: linear-gradient(to bottom, #f7edd8, #e8d3a5);
  font-family: Arial, Helvetica, sans-serif; /* fallback ajouté */
}

/* ── FOND ───────────────────────────────────────── */
.background-doodles {
  position: fixed;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.3), transparent 20%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,0.2), transparent 20%);
  z-index: -1;
}

/* ── CONTAINER ──────────────────────────────────── */
.container {
  min-height: 100vh; /* CORRIGÉ : était height:100vh — le contenu ne débordait plus */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* ── LOGO ───────────────────────────────────────── */
.logo {
  width: clamp(180px, 60vw, 500px); /* CORRIGÉ : était 500px fixe → débordement sur mobile */
  margin-bottom: 10px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-8px); }
}

/* ── TITRE ──────────────────────────────────────── */
h1 {
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(18px, 4vw, 34px); /* CORRIGÉ : était 34px fixe */
  margin: 0 0 5px;
  color: #3b2b1a;
  text-align: center;
  line-height: 1.2;
}

.subtitle {
  font-size: clamp(13px, 2vw, 16px);
  margin-bottom: 15px;
  color: #5c4630;
  text-align: center;
}

/* ── TOP BAR ────────────────────────────────────── */
.top-bar {
  display: flex;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;            /* évite le débordement sur mobile */
  justify-content: center;
}

.lives {
  font-size: clamp(20px, 4vw, 28px);
}

.score-box {
  background: white;
  padding: 10px 20px;
  border-radius: 15px;
  font-weight: bold;
  border: 3px solid #5f4322;
}

/* ── GALERIE ─────────────────────────────────────
   CORRIGÉ : flex+wrap → CSS Grid auto-fill
   Les colonnes se créent et se suppriment automatiquement
   selon l'espace disponible, sans media query manuelle.
──────────────────────────────────────────────────── */
.game {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: clamp(12px, 2vw, 30px);
  width: 100%;
  max-width: 1400px;
}

/* ── TABLEAU (carte) ────────────────────────────── */
.card {
  background: #d6b98c;
  padding: clamp(12px, 2vw, 30px); /* CORRIGÉ : était 30px fixe → gonflait la largeur réelle */
  border-radius: 10px;
  box-shadow:
    0 8px 20px rgba(0,0,0,0.2),
    inset 0 0 0 6px #8b6b3e,
    inset 0 0 0 12px #c7a16b;
  width: 100%;
  animation: fadeMuseum 0.8s ease forwards;
  opacity: 0;
  transform: translateY(30px);
  transition: transform 0.3s;
}

/* délais d'apparition */
.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }
.card:nth-child(5) { animation-delay: 0.5s; }
.card:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeMuseum {
  100% { opacity: 1; transform: translateY(0px); }
}

.card:hover {
  transform: translateY(-5px) scale(1.02);
}

/* ── IMAGE ──────────────────────────────────────── */
.card img {
  width: 90%;
  height: auto;
  object-fit: contain;
  border: 8px solid #f7e7c1;
  box-shadow: 0 0 0 4px #5f4322;
  display: block;
  margin: 0 auto;
  cursor: zoom-in;
}

/* ── LABEL ──────────────────────────────────────── */
.label {
  background: #f5e8c7;
  padding: 10px;
  margin-top: 10px;
  border-radius: 10px;
  border: 2px solid #5f4322;
}

.label p {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: bold;
  line-height: 1.4;
}

/* ── SELECT ─────────────────────────────────────── */
select {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 2px solid #5f4322;
  background: #fff9ea;
  font-weight: bold;
  cursor: pointer;
  outline: none;
}

/* ── BOUTONS ────────────────────────────────────── */
.buttons {
  display: flex;
  gap: 15px;
  margin-top: 20px;
  flex-wrap: wrap;           /* empêche le débordement sur mobile */
  justify-content: center;
}

.validate-btn,
.retry-btn {
  padding: 14px 25px;
  font-size: clamp(14px, 2vw, 18px);
  border: none;
  border-radius: 15px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
  min-height: 48px;           /* taille tactile minimum recommandée */
}

.validate-btn {
  background: #3b2b1a;
  color: white;
}

.retry-btn {
  background: #fff7d1;
  border: 3px solid #5f4322;
}

.validate-btn:hover,
.retry-btn:hover {
  transform: scale(1.05);
}

/* ── MESSAGE ────────────────────────────────────── */
#message {
  margin-top: 15px;
  padding: 18px;
  font-size: clamp(15px, 2.5vw, 20px);
  font-weight: bold;
  text-align: center;
  background: #fff7e6;
  border-radius: 15px;
  border: 3px solid #5f4322;
  display: none;
  width: 90%;
  max-width: min(700px, 90vw); /* CORRIGÉ : était max-width:700px, débordait sur mobile */
  animation: pop 0.5s ease;
}

@keyframes pop {
  0%   { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

/* ── RESPONSIVE ─────────────────────────────────── */

/* Grand écran : force 6 colonnes pour éviter les pistes vides d'auto-fill */
@media (min-width: 1320px) {
  .game {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* Tablette : 2–3 colonnes selon l'écran */
@media (max-width: 768px) {
  .label p {
    font-size: 13px;
  }
}

/* Mobile : 2 colonnes puis 1 sur très petit écran */
@media (max-width: 480px) {
  .game {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .card img {
    border-width: 4px;
  }

  .label p {
    font-size: 12px;
  }

  select {
    padding: 8px;
    font-size: 12px;
  }
}

@media (max-width: 340px) {
  .game {
    grid-template-columns: 1fr;
  }
}

/* ── MODALE IMAGE ───────────────────────────────── */
.img-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.80);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.img-modal.is-open {
  display: flex;
}

.img-modal__close {
  position: fixed;
  top: 16px;
  right: 20px;
  background: #3b2b1a;
  color: white;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 1001;
}

.img-modal__close:hover {
  transform: scale(1.15);
}

#img-modal__img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border: 8px solid #f7e7c1;
  box-shadow: 0 0 0 4px #5f4322, 0 20px 60px rgba(0,0,0,0.6);
  cursor: default;
  border-radius: 4px;
}

/* ── MODALE RÉSULTAT ────────────────────────────── */
.result-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.70);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.result-modal.is-open {
  display: flex;
}

.result-modal__box {
  background: #fff7e6;
  border: 3px solid #5f4322;
  border-radius: 15px;
  padding: 32px 28px;
  max-width: min(500px, 90vw);
  text-align: center;
  font-size: clamp(15px, 2.5vw, 20px);
  font-weight: bold;
  animation: pop 0.4s ease;
}

.result-modal__box p {
  margin: 0;
}

.result-modal__actions {
  margin-top: 20px;
}

/* Accessibilité : désactive les animations si l'utilisateur le préfère */
@media (prefers-reduced-motion: reduce) {
  .logo,
  .card {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
