/* --- Définition de la palette "Fun" --- */
:root {
  --primary: #6A3B99; /* Violet principal */
  --secondary: #00C853; /* Vert vif (pour les boutons "suivant") */
  --accent: #FF4081; /* Rose/Rouge pour le vote */
  --bg: #F0E8FF; /* Fond violet très clair */
  --card-bg: #ffffff;
  --text: #333;
  --text-light: #555;
  --border-light: #eee;
  --shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* --- Général --- */
body {
  font-family: 'Lilita One', cursive;
  background-color: var(--bg);
  color: var(--text);
  display: grid;
  place-items: center;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
}

main {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.card {
  background-color: var(--card-bg);
  border-radius: 16px;
  padding: 24px 32px;
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--border-light);
}

input[type="text"] {
  width: calc(100% - 24px);
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  text-align: center;
  text-transform: uppercase;
  transition: all 0.2s ease-in-out;
}
input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(106, 17, 203, 0.2);
  outline: none;
}

button {
  width: 100%;
  padding: 14px;
  margin-top: 10px;
  font-family: 'Lilita One', cursive; /* On utilise la police fun */
  font-size: 1.3rem; /* Police plus grosse */
  letter-spacing: 1px;
  color: #fff;
  background-color: var(--primary); /* Fond violet simple */
  border: none;
  border-bottom: 5px solid rgba(0,0,0,0.2); /* Effet 3D simple */
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

/* REMPLACER TOUTE LA RÈGLE "button:hover" */
button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* REMPLACER TOUTE LA RÈGLE "button:active" */
button:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
  box-shadow: none;
}

button:disabled {
  background: #aaa;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

hr {
  border: 0;
  height: 1px;
  background-color: var(--border-light);
  margin: 20px 0;
}

h2 { 
  margin-top: 0; 
  color: var(--primary); 
  font-size: 2.5rem; /* Plus gros */
  letter-spacing: 1px;
}
h3 { 
  margin-top: 0; 
  color: var(--text); 
  font-size: 1.5rem;
  letter-spacing: 1px;
}


/* --- Gestion des Écrans (Transition) --- */
.screen {
  display: none; 
  animation: 0.4s ease-out 0s 1 fadeIn;
}
.screen.active {
  display: block; 
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Accueil : Sélection Joueur --- */
#playerSelectionContainer {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 15px;
  margin-top: 15px;
}
.player-choice {
  cursor: pointer;
  text-align: center;
  padding: 5px;
  border-radius: 8px;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}
.player-choice img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.player-choice span {
  display: block;
  font-size: 14px;
  margin-top: 5px;
  font-weight: 500;
}
.player-choice:hover {
  background-color: #f0f0ff;
}
.player-choice.selected {
  border-color: var(--primary);
  background-color: #f0f0ff;
  transform: scale(1.05);
}
/* --- Accueil : Sélection Joueur --- */
/* Modifie la règle .player-choice */
.player-choice {
  cursor: pointer;
  text-align: center;
  padding: 5px;
  border-radius: 12px; /* Plus arrondi */
  border: 4px solid transparent; /* Bordure plus épaisse */
  transition: all 0.2s ease;
  background-color: #fff;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Fait tourner les éléments ! */
.player-choice:nth-child(even) {
  transform: rotate(4deg);
}
.player-choice:nth-child(odd) {
  transform: rotate(-4deg);
}

/* Au survol, on remet droit et on zoome */
.player-choice:hover {
  transform: rotate(0deg) scale(1.1);
  border-color: var(--primary);
  z-index: 10;
}
.player-choice.selected {
  border-color: var(--primary);
  background-color: #f0f0ff;
  transform: scale(1.1) rotate(0deg);
  z-index: 5;
}

/* ... */

/* --- Jeu (Vote) --- */
/* Modifie la règle .vote-button */
.vote-button {
  background: var(--card-bg);
  color: var(--text);
  border: 4px solid #ddd;
  padding: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  border-radius: 12px; /* Plus arrondi */
  font-family: 'Lilita One', cursive;
  font-size: 1.1rem;
}

/* Fait tourner les boutons de vote */
.vote-button:nth-child(even) {
  transform: rotate(3deg);
}
.vote-button:nth-child(odd) {
  transform: rotate(-3deg);
}

/* Au survol, on grossit */
.vote-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 8px 20px rgba(255, 64, 129, 0.3);
  transform: translateY(-3px) scale(1.1) rotate(0deg);
  z-index: 10;
}

/* --- Lobby : Liste Joueurs --- */
#playersList {
  list-style: none;
  padding: 0;
  margin: 20px 0;
  max-height: 200px;
  overflow-y: auto;
}
#playersList li {
  font-size: 18px;
  padding: 10px;
  background-color: #f9f9f9;
  border-radius: 6px;
  margin-bottom: 8px;
  text-align: left;
  padding-left: 15px;
  transition: all 0.2s ease-in-out;
  display: flex;
  align-items: center;
}
#playersList li:hover {
  transform: translateX(5px);
  background-color: #f0f0ff;
}
#playersList li img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 15px;
}
#playersList li.host {
  font-weight: bold;
  color: var(--primary);
  border-left: 4px solid var(--primary);
}
.host-only { display: none; }

/* --- Jeu (Vote) --- */
#voteOptions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}
.vote-button {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid #ddd;
  padding: 10px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.vote-button img {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
}
.vote-button span {
  display: block;
  margin-top: 8px;
  font-weight: bold;
}
.vote-button:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 8px 20px rgba(106, 17, 203, 0.3);
  transform: translateY(-3px);
}
.waiting { margin-top: 20px; font-style: italic; color: var(--text-light); }

/* --- Résultats Round --- */
#roundResultHeader {
  color: var(--text);
  font-size: 2.2rem; /* Police fun plus grosse */
  font-weight: 500;
  letter-spacing: 1px;
}

#roundWinnerImageContainer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin: 25px 0;
  min-height: 160px; /* Pour éviter que tout saute */
}

.round-winner-image {
  width: 130px;
  height: 130px;
  border-radius: 50%; /* Cercle */
  object-fit: cover;
  border: 6px solid var(--primary);
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  animation: 0.3s ease-out 0.1s 1 scaleIn; /* <-- NOUVEAU NOM D'ANIM */
  transform: scale(0); /* <-- AJOUTER : état de départ */
  animation-fill-mode: forwards; /* <-- AJOUTER : applique l'état de départ */
}

/* Si un seul gagnant, on le grossit */
.round-winner-image:only-child {
   width: 160px;
   height: 160px;
}

#roundResultText {
  font-size: 2.8rem; /* Très gros */
  font-weight: bold;
  color: var(--accent);
  margin: 10px 0;
}

#roundVoteCounts { 
  font-size: 1rem; 
  color: var(--text-light); 
  font-family: sans-serif; /* Plus lisible pour les comptes */
}

/* --- Résultats Finaux (Axe) --- */
.axis-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  margin-top: 30px;
}
.axis-label { font-weight: bold; color: var(--text-light); font-size: 14px; }
.axis {
  flex-grow: 1;
  height: 12px;
  background: linear-gradient(to right, var(--secondary), var(--accent));
  margin: 0 15px;
  border-radius: 6px;
  position: relative;
}
#playerDotsContainer { position: relative; height: 100%; width: 100%; }

/* Point remplacé par une image */
.player-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40px; /* Plus grand pour la photo */
  height: 40px;
  background-color: var(--text);
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  animation: 0.5s ease-out 0.2s 1 popIn;
  animation-fill-mode: backwards;
  object-fit: cover; /* S'assure que l'image remplit le cercle */
}
.player-dot::after {
  content: attr(data-nickname);
  position: absolute;
  bottom: -30px; 
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
}
@keyframes popIn {
  from { transform: translate(-50%, -50%) scale(0); }
  to { transform: translate(-50%, -50%) scale(1); }
}

/* --- Résumé Final (Palmarès & Votes) --- */
#finalSummaryContainer, #finalFavoritesContainer {
  margin-top: 20px;
  text-align: left;
  max-height: 200px;
  overflow-y: auto;
  padding: 20px 10px 0 10px;
  border-top: 1px solid var(--border-light);
}
.summary-player h4 {
  margin: 0 0 5px 0;
  color: var(--primary);
  font-size: 18px;
}
.summary-player ul, #finalFavoritesContainer ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.summary-player li, #finalFavoritesContainer li {
  background-color: #f9f9f9;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 5px;
  font-size: 14px;
  color: var(--text-light);
}
@keyframes scaleIn {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}
/* --- Adaptation PC (Grands Écrans) --- */

@media (min-width: 768px) {
  
  /* On élargit le conteneur principal */
  main {
    max-width: 800px;
  }

  /* On passe les options de vote sur 3 colonnes */
  #voteOptions {
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
  }
  
  /* On grossit un peu les cartes de vote */
  .vote-button img {
    width: 100px;
    height: 100px;
  }

  /* On fait de la place pour plus de joueurs sur l'écran d'accueil */
  #playerSelectionContainer {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  /* On grossit l'image du gagnant du round */
  .round-winner-image:only-child {
    width: 220px;
    height: 220px;
  }
  .round-winner-image {
    width: 180px;
    height: 180px;
  }
}
/* --- Tooltip "Tu es qui ?" --- */

.tooltip-trigger {
  position: relative; /* Base de positionnement pour le popup */
  cursor: help; /* Change le curseur pour montrer qu'il y a une info */
  display: inline-block; /* S'assure qu'il est bien positionné */
}

/* Le popup lui-même (caché par défaut) */
.tooltip-trigger::after {
  content: attr(data-tooltip); /* Prend le texte de l'attribut HTML */
  position: absolute;
  
  /* Positionnement au-dessus */
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px; /* Espace entre le texte et le popup */
  
  /* Style du popup */
  background-color: var(--text, #333);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-family: sans-serif; /* Plus lisible en petit */
  font-size: 0.9rem;
  white-space: nowrap; /* Empêche le texte de se couper */
  
  /* Animation (caché) */
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(5px); /* Léger décalage pour l'anim */
  transition: all 0.2s ease-out;
}

/* Quand on survole le texte... */
.tooltip-trigger:hover::after {
  /* ... on affiche le popup */
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* --- Conteneur des mouches --- */
#flyContainer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none; /* Permet de cliquer à travers les mouches */
  overflow: hidden; /* Empêche les mouches de déborder */
}

.fly-emoji {
  position: absolute;
  opacity: 0.8;
  filter: grayscale(100%) brightness(0.7); /* Pour les rendre un peu plus discrètes */
  transition: opacity 1s ease-out;
}

/* Animation pour les mouches */
@keyframes flyAppear {
  0% {
    opacity: 0;
    transform: scale(0) rotate(var(--rotation, 0deg)); /* Utilise une variable CSS pour la rotation */
  }
  20% {
    opacity: 0.8;
    transform: scale(1) rotate(var(--rotation, 0deg));
  }
  80% {
    opacity: 0.8;
    transform: scale(1) rotate(var(--rotation, 0deg));
  }
  100% {
    opacity: 0;
    transform: scale(0.5) rotate(var(--rotation, 0deg)); /* Disparaît un peu en rétrécissant */
  }
}
