/* Statistics Modal Styles */
#statisticsModal, #statsModal, #settingsModal, #leaderboardModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-overlay, .quiz-overlay {
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  box-sizing: border-box;
}

.stats-modal, .stats-container, .settings-container, .leaderboard-container {
  background: white;
  border-radius: 20px;
  max-width: 90vw;
  max-height: 90vh;
  width: 100%;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  margin: 1rem;
}

.stats-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2rem;
  border-radius: 20px 20px 0 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.stats-title {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stats-title h2 {
  margin: 0;
  font-size: 1.8rem;
}

.stats-icon {
  font-size: 2rem;
}

.stats-nav-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1rem;
}

.stats-nav-btn {
  padding: 0.6rem 1.2rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s;
  backdrop-filter: blur(10px);
}

.stats-nav-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.stats-nav-btn.active {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 2rem;
}

.stat-card {
  background: white;
  border-radius: 15px;
  padding: 1.5rem;
  border-left: 5px solid;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card.color-0 { border-left-color: #e74c3c; }
.stat-card.color-1 { border-left-color: #27ae60; }
.stat-card.color-2 { border-left-color: #f39c12; }
.stat-card.color-3 { border-left-color: #3498db; }
.stat-card.color-4 { border-left-color: #9b59b6; }

.stat-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-icon {
  font-size: 2.5rem;
}

.stat-info h3 {
  margin: 0;
  color: #333;
  font-size: 1.2rem;
}

.stat-percentage {
  font-size: 1.5rem;
  font-weight: bold;
  color: #333;
}

.stat-played {
  font-size: 0.9rem;
  color: #000;
}

.stat-details {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
  color: #333;
}

.stat-score {
  font-weight: bold;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e9ecef;
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #28a745, #20c997);
  border-radius: 10px;
  transition: width 0.3s;
}

.recommendations {
  background: #f8f9fa;
  padding: 2rem;
  border-radius: 0 0 20px 20px;
}

.recommendations-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.recommendations-header h3 {
  margin: 0;
  color: #333;
}

.lightbulb-icon {
  font-size: 1.5rem;
}

.recommendation-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
  color: #000;
}

.rec-icon {
  font-size: 1rem;
}

.close-modal {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.close-modal:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Settings Modal Styles */
#settingsModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.settings-overlay {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.settings-modal {
  background: white;
  border-radius: 20px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.settings-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1.5rem 2rem;
  border-radius: 20px 20px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-header h3 {
  margin: 0;
  font-size: 1.5rem;
}

.close-settings {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.5rem;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.close-settings:hover {
  background: rgba(255, 255, 255, 0.3);
}

.settings-content {
  padding: 2rem;
}

.setting-group {
  margin-bottom: 2rem;
}

.setting-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
  color: #333;
}

.volume-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.volume-slider {
  flex: 1;
  min-width: 150px;
}

.mute-btn {
  padding: 0.5rem 1rem;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s;
}

.mute-btn:hover {
  background: #5a6268;
}

.toggle-switch {
  position: relative;
  width: 60px;
  height: 30px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 30px;
}

.toggle-switch .slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

.toggle-switch input:checked + .slider {
  background-color: #2196F3;
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(30px);
}

.timer-select {
  width: 100%;
  padding: 0.5rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
}

.settings-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.reset-btn, .save-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s;
}

.reset-btn {
  background: #6c757d;
  color: white;
}

.reset-btn:hover {
  background: #5a6268;
}

.save-btn {
  background: #007bff;
  color: white;
}

.save-btn:hover {
  background: #0056b3;
}

@media (max-width: 768px) {
  .stats-header {
    flex-direction: column;
    text-align: center;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .volume-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-footer {
    flex-direction: column;
  }
}

/* Styles pour les statistiques améliorées */
.best-score {
  font-size: 0.8rem;
  color: #ffd700;
  margin: 0.2rem 0;
  font-weight: bold;
}

.last-played {
  font-size: 0.75rem;
  opacity: 0.8;
  margin: 0.2rem 0;
}

.global-summary {
  background: rgba(0, 0, 0, 0.1);
  margin: 2rem;
  border-radius: 15px;
  padding: 1.5rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.global-summary h3 {
  margin-bottom: 1rem;
  color: #333;
  font-weight: bold;
}

.global-stats {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 1rem;
}

.global-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

.global-stat-number {
  font-size: 2rem;
  font-weight: bold;
  color: #2c5aa0;
  margin-bottom: 0.5rem;
}

.global-stat-label {
  font-size: 0.9rem;
  color: #000;
  text-align: center;
  font-weight: 500;
}

/* Stats Tabs */
.stats-tab {
  animation: fadeIn 0.3s ease-in-out;
}

.stats-tab.active {
  display: block !important;
}

.quiz-header {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 15px;
}

.quiz-header h3 {
  margin: 0;
  font-size: 1.5rem;
  color: #333;
}

/* Enhanced stat cards */
.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #ffeaa7);
  background-size: 300% 100%;
  animation: gradientMove 3s ease-in-out infinite;
}

@keyframes gradientMove {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.category-stat {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  border-left: 4px solid #3498db;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s;
}

.category-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.category-stat h4 {
  margin: 0 0 1rem 0;
  color: #2c3e50;
  font-size: 1.2rem;
}

.stat-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
  color: #000;
  font-size: 0.9rem;
}

.detailed-stats {
  margin-top: 2rem;
}

.detailed-stats h3 {
  color: #2c3e50;
  border-bottom: 2px solid #ecf0f1;
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

/* Additional Modal Fixes */
.stats-content, .settings-content, .leaderboard-content {
  max-height: calc(90vh - 180px);
  overflow-y: auto;
  padding: 1rem;
}

.stats-header, .settings-header, .leaderboard-header {
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Global Leaderboard Modal Styles */
.leaderboard-modal {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  padding: 2rem;
  max-width: 800px;
  width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  color: white;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 1rem;
}

.leaderboard-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.leaderboard-title h2 {
  margin: 0;
  font-size: 1.8rem;
}

.leaderboard-icon {
  font-size: 2rem;
}

.close-modal {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s;
}

.close-modal:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.no-scores {
  text-align: center;
  padding: 3rem;
  color: rgba(255, 255, 255, 0.8);
}

.no-scores-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.leaderboard-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.leaderboard-entry {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 15px;
  align-items: center;
  transition: all 0.3s;
  border: 2px solid transparent;
}

.leaderboard-entry:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.leaderboard-entry.rank-1 {
  background: linear-gradient(135deg, #ffd700, #ffed4a);
  color: #333;
  border: 2px solid #ffd700;
  box-shadow: 0 8px 25px rgba(255, 215, 0, 0.3);
}

.leaderboard-entry.rank-2 {
  background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
  color: #333;
  border: 2px solid #c0c0c0;
  box-shadow: 0 6px 20px rgba(192, 192, 192, 0.3);
}

.leaderboard-entry.rank-3 {
  background: linear-gradient(135deg, #cd7f32, #deb887);
  color: #333;
  border: 2px solid #cd7f32;
  box-shadow: 0 4px 15px rgba(205, 127, 50, 0.3);
}

.rank-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: bold;
}

.rank-number {
  font-size: 1.5rem;
  min-width: 30px;
  text-align: center;
}

.crown, .medal {
  font-size: 1.2rem;
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.player-name {
  font-weight: bold;
  font-size: 1.1rem;
}

.quiz-type {
  font-size: 0.9rem;
  opacity: 0.7;
  font-style: italic;
}

.score-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
}

.score {
  font-size: 1.3rem;
  font-weight: bold;
  color: #4ade80;
}

.rank-1 .score, .rank-2 .score, .rank-3 .score {
  color: #333;
}

.date {
  font-size: 0.8rem;
  opacity: 0.7;
}

.leaderboard-footer {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.8);
}

@media (max-width: 768px) {
  .leaderboard-modal {
    width: 95vw;
    padding: 1rem;
  }

  .leaderboard-entry {
    grid-template-columns: 60px 1fr auto;
    gap: 0.5rem;
    padding: 0.8rem;
  }

  .rank-number {
    font-size: 1.2rem;
  }

  .player-name {
    font-size: 1rem;
  }

  .score {
    font-size: 1.1rem;
  }
}

/* Navigation styles */