html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
}

#pulse-game-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #000010 50%, #000000 100%);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pulseCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: none;
  touch-action: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#hud-top {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  max-width: 1200px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 50;
}

#pulse-ui {
  color: #fff;
  font-family: 'Orbitron', sans-serif;
  text-align: left;
  letter-spacing: 1px;
}


#pulse-ui p {
  margin: 3px 0;
}

.hint {
  opacity: 0.7;
  font-size: 0.9rem;
}

/* Bloc droit : lecteur + engrenage */
#hud-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 0 30px rgba(255,255,255,0.15);
  border-radius: 16px;
  text-align: center;
  padding: 40px 60px;
  color: #fff;
  z-index: 100;
  backdrop-filter: blur(10px);
  display: none;
}

.popup.visible {
  display: block;
}

.popup h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 2rem;
  margin-bottom: 20px;
  letter-spacing: 2px;
}

.popup-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 20px;
}

#leaderboard-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.85);
  border: 2px solid #00ffffaa;
  border-radius: 15px;
  padding: 30px 50px;
  color: #fff;
  font-family: Orbitron, sans-serif;
  text-align: center;
  z-index: 9999;
  box-shadow: 0 0 30px #00ffff55;
  display: none;
}

#leaderboard-popup.visible {
  display: block;
}

#open-leaderboard {
  background: linear-gradient(90deg, #ff4df0, #00ffff);
  border: none;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: Orbitron, sans-serif;
  cursor: pointer;
  transition: transform 0.2s ease;
}

#open-leaderboard:hover {
  transform: scale(1.1);
}

#leaderboard-popup .close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  background: transparent;
  border: none;
  color: #00ffff;
  font-size: 22px;
  cursor: pointer;
  transition: transform 0.2s;
}
#leaderboard-popup .close-btn:hover {
  transform: scale(1.2);
  color: #ff4df0;
}


.popup button {
    background: linear-gradient(90deg, #00ffff, #ff4df0);
    border: none;
    color: #fff;
    padding: 12px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: transform 0.2s, opacity 0.2s;
}

.popup button:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

#leaderboard-section {
  margin-top: 30px;
  text-align: center;
}

#leaderboard-section h3 {
  color: #00ffff;
  font-family: Orbitron, sans-serif;
  margin-bottom: 10px;
  text-shadow: 0 0 10px #00ffffaa;
}

#leaderboard-list {
  max-height: 250px;
  overflow-y: auto;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 0 20px rgba(0,255,255,0.15);
}

#leaderboard-list p {
  margin: 5px 0;
  font-size: 0.9rem;
  color: #fff;
}

#leaderboard-list .rank {
  color: #00ffff;
  font-weight: bold;
  margin-right: 5px;
}
#leaderboard-list .name {
  color: #fff;
}
#leaderboard-list .score {
  color: #ff4df0;
  float: right;
}

.player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 6px 12px;
  margin-bottom: 6px;
  transition: background 0.2s;
}
.player-row:hover {
  background: rgba(0,255,255,0.1);
}
.player-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.player-info img {
  border-radius: 50%;
  width: 28px;
  height: 28px;
}
.player-score {
  color: #00ffff;
  font-family: Orbitron, sans-serif;
}


/* Bouton engrenage au-dessus du lecteur */
#open-settings {
  background: rgba(0,0,0,0.4);
  border: 1px solid #00ffffaa;
  border-radius: 50%;
  font-size: 20px;
  color: #00ffff;
  cursor: pointer;
  padding: 8px 10px;
  transition: all 0.3s ease;
}

#open-settings:hover {
  background: #00ffff22;
  transform: rotate(60deg);
}

/* Pop-up paramètres */
#settings-popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#settings-popup.visible {
  opacity: 1;
  pointer-events: all;
}

.popup-content {
  background: #111;
  border: 2px solid #00ffffaa;
  border-radius: 15px;
  padding: 25px 40px;
  color: #fff;
  font-family: Orbitron, sans-serif;
  width: 320px;
  box-shadow: 0 0 30px #00ffff55;
  text-align: center;
}

.popup-content h2 {
  color: #00ffff;
  margin-bottom: 15px;
}

.section {
  margin-bottom: 25px;
}

#save-settings {
  background: linear-gradient(90deg,#00ffff,#ff4df0);
  border: none;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: Orbitron, sans-serif;
  cursor: pointer;
  transition: transform 0.2s ease;
}

#save-settings:hover {
  transform: scale(1.1);
}

/* Lecteur musical (côté droit) */
#music-player {
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  padding: 10px 12px;
  width: 170px;
  color: #fff;
  font-family: Orbitron, sans-serif;
  text-align: center;
  transition: box-shadow 0.4s ease;
}

#track-title {
  font-size: 0.8rem;
  color: #00ffff;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Boutons du lecteur */
#music-player .controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 5px;
}

#music-player .controls button {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease, background 0.3s;
}

/* Taille standard pour précédent/suivant */
#prev-track, #next-track {
  font-size: 20px;
}

/* 🔥 Bouton Play/Pause central plus grand et stylé */
#play-pause {
  font-size: 28px;
  background: linear-gradient(135deg, #00ffff44, #ff4df044);
  border-radius: 8px;
  padding: 4px 10px;
  box-shadow: 0 0 8px #00ffff88;
  transition: all 0.3s ease;
}

#play-pause:hover {
  transform: scale(1.2);
  background: linear-gradient(135deg, #00ffffaa, #ff4df0aa);
  box-shadow: 0 0 15px #00ffffcc, 0 0 25px #ff4df0aa;
}

.pause-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  vertical-align: middle;
}

.pause-icon::before,
.pause-icon::after {
  content: '';
  display: block;
  width: 4px;   /* épaisseur des barres */
  height: 14px; /* hauteur des barres */
  background: linear-gradient(180deg, #00ffff, #ff4df0);
  border-radius: 2px;
  box-shadow: 0 0 6px #00ffff88, 0 0 10px #ff4df088;
}



#music-player .controls button:hover {
  transform: scale(1.2);
  color: #00ffff;
}

#music-player.playing {
  box-shadow: 0 0 20px #00ffff66, 0 0 40px #ff4df055;
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 20px #00ffff55, 0 0 40px #ff4df033;
  }
  50% {
    box-shadow: 0 0 35px #00ffffaa, 0 0 60px #ff4df0aa;
  }
}

#sound-controls {
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  top: 0;
  left: 0;
  transform: none;
  z-index: 10;
}

#sound-controls::before {
  content: "";
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #00ffffaa, transparent);
  margin-bottom: 8px;
}

/* État hover : contour subtil et effet glow léger */
#sound-controls button:hover,
#toggle-music button:hover {
  border: 1px solid rgba(200, 200, 200, 0.3);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.15);
}

#toggle-sound {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 22px;
  cursor: pointer;
  transition: opacity 0.3s;
}

#toggle-sound:hover {
  opacity: 0.7;
}

/* Rendu propre du slider (neon bleu Pulse) */
/* === SLIDER PULSE === */
#volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  background: transparent; /* ✅ enlève le fond natif */
  border-radius: 10px;
  outline: none;
  cursor: pointer;
  --percent: 80%;
}

/* Piste (Chrome, Edge) */
#volume-slider::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, #00ffff 0%, #00ffff var(--percent), #333 var(--percent), #333 100%);
  border-radius: 10px;
  height: 8px;
}

/* Bouton (Chrome, Edge) */
#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #00ffff;
  border-radius: 50%;
  box-shadow: 0 0 8px #00ffffaa;
  margin-top: -4px;
  cursor: pointer;
}

/* Piste (Firefox) */
#volume-slider::-moz-range-track {
  background: linear-gradient(90deg, #00ffff 0%, #00ffff var(--percent), #333 var(--percent), #333 100%);
  border-radius: 10px;
  height: 8px;
}

/* Bouton (Firefox) */
#volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #00ffff;
  border-radius: 50%;
  box-shadow: 0 0 8px #00ffffaa;
  cursor: pointer;
}

/* Effet pulse quand tu glisses */
#volume-slider:active::-webkit-slider-thumb {
  box-shadow: 0 0 15px #00ffff, 0 0 25px #ff4df0;
}

#volume-slider:focus {
  outline: none !important;
  box-shadow: none !important;
}

#volume-slider::-webkit-slider-thumb:focus {
  outline: none !important;
  box-shadow: none !important;
}

#orientation-popup {
  display: none;
  background: rgba(0,0,0,0.9);
  border: 2px solid #00ffffaa;
  box-shadow: 0 0 30px #ff4df066;
  z-index: 999;
  text-align: center;
  padding: 40px 60px;
  border-radius: 20px;
}

#orientation-popup.visible {
  display: block;
}

#orientation-popup h2 {
  font-family: 'Orbitron', sans-serif;
  color: #00ffff;
  font-size: 1.8rem;
  margin-bottom: 10px;
}

#orientation-popup p {
  color: #fff;
  font-size: 1rem;
  opacity: 0.85;
}

/* === 🔄 LANDSCAPE RESPONSIVE === */
@media screen and (orientation: landscape) {
  html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #000;
    touch-action: none;
  }

  #pulse-game-wrapper {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #000010 50%, #000000 100%);
  }

  #pulseCanvas {
    width: 100vw;
    height: 100vh;
    display: block;
    touch-action: none;
  }


  canvas, #pulse-game-wrapper {
    max-width: none !important;
    max-height: none !important;
    overflow: hidden;
  }


  /* HUD au-dessus du canvas, en overlay */
  #hud-top {
    position: absolute;
    top: 2vh;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: none;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
    font-size: 1rem;
  }

  #pulse-ui {
    font-size: clamp(0.8rem, 2vw, 1rem);
    text-align: left;
  }

  .hint {
    font-size: clamp(0.7rem, 1.8vw, 0.9rem);
    opacity: 0.8;
  }

  #hud-right {
    flex-direction: row;
    gap: 1vw;
  }

  /* Popups adaptatives */
  .popup {
    width: 80vw;
    max-width: 700px;
    padding: 4vh 6vw;
    border-radius: 2vh;
    font-size: clamp(0.8rem, 2vw, 1rem);
  }

  .popup h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 1.5vh;
  }

  #leaderboard-popup {
    width: 80vw;
    max-height: 80vh;
    overflow-y: auto;
    padding: 4vh 5vw;
    border-radius: 2vh;
  }

  .player-row {
    font-size: clamp(0.8rem, 1.6vw, 1rem);
    padding: 0.5vh 1vw;
  }
  
  /* === POPUP PARAMÈTRES (MOBILE LANDSCAPE OPTIMISÉ) === */
  #settings-popup {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: opacity 0.25s ease;
  }

  #settings-popup.hidden {
    opacity: 0;
    pointer-events: none;
  }

  /* --- Contenu compact pour écrans horizontaux --- */
  #settings-popup .popup-content {
    background: #141414;
    color: #fff;
    width: 75%;
    max-width: 320px;
    max-height: 70vh;
    overflow-y: auto;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.6);
    animation: popupFade 0.25s ease;
    border: 1px solid rgba(255,255,255,0.1);
  }

  #settings-popup h2 {
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 10px;
    color: #00b4ff;
  }

  #settings-popup h3 {
    font-size: 0.95rem;
    margin: 8px 0 4px;
    color: #ffd700;
  }

  #settings-popup .section {
    margin-bottom: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 8px;
  }

  #settings-popup input[type="range"] {
    width: 100%;
    accent-color: #00b4ff;
    margin-top: 4px;
  }

  #settings-popup .popup-content::-webkit-scrollbar {
    width: 4px;
  }

  #settings-popup .popup-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
  }

  /* Quand la modale est visible */
  #settings-popup.visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* Effet d’ouverture fluide */
  #settings-popup.visible .popup-content {
    transform: scale(1);
    opacity: 1;
    transition: all 0.25s ease;
  }

  /* État caché (fade + léger zoom out) */
  #settings-popup.hidden .popup-content {
    transform: scale(0.9);
  }


  @keyframes popupFade {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }

}

@supports (env(safe-area-inset-left: 0)) {
  #pulse-game-wrapper {
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
             env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
}


