/* =====================================================================
   Le Hangar — styles propres au jeu (préfixe hg-)
   La barre, le plein écran et les infobulles sont dans css/games.css.
   ===================================================================== */

.hg-jeu {
  --mg-jeu-largeur: 1204px; /* barre de 1180 px + marges de 12 px : ne pas changer */
  --mgb-fond: linear-gradient(120deg, #23272f, #3d3a35 55%, #5b4321);
  --mgb-accent: #ffc233;
  --mgb-titre: linear-gradient(100deg, #ffffff, #ffc233);
  --mg-stat-largeur: 4.6em;
  --mg-fs-fond: #1b1e25;
  --mg-bulle-fond: #23272f;
}

.hg-jeu [hidden] {
  display: none !important;
}

.hg-zone {
  position: relative;
  box-sizing: border-box;
  align-self: center;
  width: min(var(--mg-barre-largeur, 1180px), calc(100vw - 24px));
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 194, 51, 0.07), transparent 65%),
    repeating-linear-gradient(135deg, #22262e 0 14px, #20242b 14px 28px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  touch-action: none;
  user-select: none;
}

.hg-jeu.mg-fs .hg-zone {
  align-self: stretch;
  width: auto;
  flex: 1;
  min-height: 0;
}

.hg-canvas {
  position: absolute;
  display: block;
  cursor: pointer;
}

/* ---------- Fenêtres dans la zone ---------- */
.hg-voile {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(14, 16, 20, 0.6);
  backdrop-filter: blur(2px);
  z-index: 5;
}

.hg-panneau {
  box-sizing: border-box;
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
  background: #fbf8f1;
  color: #2a2a2a;
  border-radius: 14px;
  border-top: 6px solid #ffc233;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  padding: 18px 22px 20px;
  animation: hg-entree 0.22s ease-out;
}

@keyframes hg-entree {
  from {
    transform: translateY(12px) scale(0.97);
    opacity: 0;
  }
}

.hg-panneau h2 {
  margin: 0;
  font-size: 1.35em;
  color: #2b2f38;
}

.hg-panneau-tete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.hg-fermer {
  border: 0;
  background: transparent;
  font-size: 1.3em;
  line-height: 1;
  color: #666;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.hg-fermer:hover {
  background: #eee6d4;
  color: #222;
}

.hg-panneau-niveaux {
  width: 560px;
}

.hg-grille {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.hg-niv {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  font-size: 1.15em;
  color: #4a3a22;
  cursor: pointer;
  background: linear-gradient(#e2c08a, #c9975a);
  box-shadow:
    inset 0 0 0 3px #a8733a,
    inset 0 -4px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.1s;
}

.hg-niv:hover {
  transform: translateY(-2px);
}

.hg-niv:focus-visible {
  outline: 3px solid #4d3fa8;
  outline-offset: 2px;
}

.hg-niv.fait {
  background: linear-gradient(#bfe0a8, #86bd6a);
  color: #24461a;
  box-shadow:
    inset 0 0 0 3px #5e9a46,
    inset 0 -4px 0 rgba(0, 0, 0, 0.15);
}

.hg-niv.courant {
  outline: 3px solid #2b2f38;
  outline-offset: 2px;
}

/* étoiles obtenues sous le numéro du niveau */
.hg-niv-etoiles {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  font-size: 0.8em;
  letter-spacing: 1px;
  line-height: 1;
  color: rgba(36, 70, 26, 0.3);
}

.hg-niv-etoiles b {
  color: #e09b00;
  text-shadow: 0 1px 0 #fff8;
}

.hg-legende {
  margin: 14px 0 0;
  font-size: 0.9em;
  color: #666;
  text-align: center;
}

.hg-l-fait {
  color: #3f7a2c;
  font-weight: 700;
}

.hg-l-etoile {
  color: #e09b00;
}

.hg-panneau-bravo {
  width: 380px;
  text-align: center;
}

.hg-panneau-bravo p {
  margin: 10px 0 0;
  line-height: 1.4;
}

.hg-bravo-etoile {
  font-size: 2.8em;
  line-height: 1;
  color: #d8d2c4;
  margin-bottom: 6px;
  letter-spacing: 4px;
}

.hg-bravo-etoile span {
  display: inline-block;
}

/* l'étoile du milieu un peu plus haute, comme un podium */
.hg-bravo-etoile span:nth-child(2) {
  font-size: 1.2em;
  transform: translateY(-6px);
}

.hg-bravo-etoile .gagnee {
  color: #ffb300;
  text-shadow: 0 2px 10px rgba(255, 179, 0, 0.5);
  animation: hg-etoile 0.6s ease-out backwards;
}

@keyframes hg-etoile {
  0% {
    transform: scale(0.2) rotate(-90deg);
  }
  70% {
    transform: scale(1.25) rotate(8deg);
  }
}

.hg-bravo-optimal {
  font-size: 0.95em;
  color: #666;
}

.hg-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

@media (max-width: 600px) {
  .hg-grille {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }
  .hg-panneau {
    padding: 14px;
  }
}

/* Écran étroit : cinq infos sur une ligne */
@media (max-width: 600px) {
  .hg-jeu {
    --mg-stat-largeur: 0;
  }
}

/* Démonstration de la solution (ampoule) */
.hg-demo {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  max-width: calc(100% - 24px);
  box-sizing: border-box;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(20, 22, 28, 0.88);
  color: #ffc233;
  font-weight: 600;
  font-size: 0.95em;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  animation: hg-entree 0.2s ease-out;
}

.hg-demo small {
  color: #c9c3b6;
  font-weight: 400;
}

.hg-jeu .mg-barre-btn.hg-actif {
  background: #ffc233;
  color: #23272f;
}
