/* === POPUP OVERLAY === */
.popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.7);
  z-index: 10000;
}

/* === POPUP CONTENT WITH ANIMATED BACKGROUND === */
.popup-content {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #1a2a6c, #b21f1f, #f36d1f, #ffcc00, #1a2a6c);
  background-size: 400% 400%;
  animation: lavaFlow 12s ease infinite;
  margin: 5% auto;
  padding: 20px;
  border-radius: 15px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  color: white;
}

.popup-content::after {
  content: '';
  position: absolute;
  top: 0;
  left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0.1) 100%
  );
  transform: skewX(-20deg);
  animation: lightSweep 4s infinite;
  pointer-events: none;
  z-index: 1;
}

/* === POPUP ANIMATIONS === */
@keyframes lavaFlow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes lightSweep {
  0%   { left: -75%; }
  100% { left: 125%; }
}

.player-info {
  display: flex;
  align-items: center;
  gap: 8px; /* espace entre l'avatar et le nom */
  font-weight: bold;
}

/* === CLOSE BUTTON === */
.close-button,
.close-button-legend,
.close-button-score {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: #ffcc00;
  transition: color 0.2s ease, transform 0.2s ease;
}

.close-button:hover,
.close-button-legend:hover,
.close-button-score:hover {
  color: #ffffff;
  transform: scale(1.15) rotate(8deg);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* === LEADERBOARD STRUCTURE === */
.leaderboard-container {
  background: rgba(0, 0, 0, 0.6);
  border-radius: 15px;
  overflow: hidden;
  margin-top: 20px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.leaderboard-header {
  display: grid;
  grid-template-columns: 1fr 3fr 2fr;
  padding: 15px 20px;
  background: rgba(255, 204, 0, 0.2);
  font-weight: bold;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-list {
  max-height: 50vh;
  overflow-y: auto;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 1fr 3fr 2fr;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.3s ease;
}

.leaderboard-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* === RANKING DECORATIONS === */
.leaderboard-rank {
  display: flex;
  align-items: center;
}

.top-rank {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: bold;
  margin-right: 10px;
}

.rank-1 .top-rank {
  background: linear-gradient(to right, #ffcc00, #ff9900);
  color: #1a1a1a;
  box-shadow: 0 0 15px rgba(255, 204, 0, 0.5);
}

.rank-2 .top-rank {
  background: linear-gradient(to right, #c0c0c0, #a0a0a0);
  color: #1a1a1a;
  box-shadow: 0 0 10px rgba(192, 192, 192, 0.5);
}

.rank-3 .top-rank {
  background: linear-gradient(to right, #cd7f32, #a56a28);
  color: #1a1a1a;
  box-shadow: 0 0 10px rgba(205, 127, 50, 0.5);
}

/* === AVATAR & SCORE DISPLAY === */
.player-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(to right, #1a2a6c, #b21f1f);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  font-weight: bold;
  font-size: 12px;
}

.score-value {
  font-weight: bold;
  color: #ffcc00;
  text-align: right;
}


/* === SCORE DETAILS === */
#score-details-popup.popup .popup-content {
  background: linear-gradient(135deg, #004d40, #00695c, #00796b, #26a69a, #004d40);
  background-size: 400% 400%;
  animation: lavaFlow 10s ease infinite;
  color: white;
  font-family: 'Segoe UI', sans-serif;
}

#score-details-popup h3 {
  text-align: center;
  font-size: clamp(20px, 4vw, 28px);
  margin: 0 0 15px 0;
  color: #ffe066;
  text-shadow: 0 0 3px rgba(0,0,0,0.7);
}

#score-breakdown ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

#score-breakdown li {
  margin-bottom: 10px;
  font-size: clamp(14px, 2vw, 18px);
  line-height: 1.6;
}

#score-breakdown h4 {
  margin: 20px 0 10px;
  font-size: clamp(16px, 2.5vw, 22px);
  border-bottom: 1px solid rgba(255,255,255,0.3);
  padding-bottom: 5px;
  color: #ffd54f;
}

.score-summary {
  text-align: center;
  margin-top: 20px;
}

.score-summary strong {
  font-size: clamp(18px, 3vw, 26px);
  color: #ffff8d;
}

#restart-button {
  margin: 25px auto 0;
  padding: 10px 20px;
  font-size: clamp(14px, 2vw, 18px);
  cursor: pointer;
  background-color: #43a047;
  color: white;
  border: none;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}

#restart-button:hover {
  background-color: #388e3c;
}

/* === SAVE SCORE FORM === */
#save-score-form input {
  padding: 8px;
  width: 100%;
  margin-bottom: 8px;
  border: none;
  border-radius: 4px;
  background-color: #eeeeee;
  color: #333;
}

#save-score-button {
  padding: 8px 15px;
  background-color: #0288d1;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#save-score-button:hover {
  background-color: #0277bd;
}

#save-score-message {
  margin-top: 10px;
  font-weight: bold;
}

.positive-score { color: #80e27e; font-weight: bold; }
.negative-score { color: #ff5252; font-weight: bold; }
.neutral-score  { color: #b0bec5; }

.animal-legend .animal {
  width: 20px;
  height: 20px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 3px;
  position: static;
}

@keyframes scoreFloatFade {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  10% {
    opacity: 1;
    transform: translate(-50%, -80%) scale(1);
  }
  90% {
    opacity: 1;
    transform: translate(-50%, -120%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -140%) scale(0.8);
  }
}

.score-animation {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  font-size: 1.4em;
  font-weight: bold;
  pointer-events: none;
  animation: scoreFloatFade 1.5s ease-out forwards;
}

