* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
}

/* Sélecteur de langue */
.language-selector {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 5px;
  z-index: 1000;
}

.lang-btn {
  background: white;
  border: 2px solid #667eea;
  color: #667eea;
  padding: 8px 15px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.9em;
  transition: all 0.3s;
}

.lang-btn:hover {
  background: #667eea;
  color: white;
}

.lang-btn.active {
  background: #667eea;
  color: white;
}

/* Bouton de don */
.donation-button {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
}

.donate-btn {
  background: #ff5e5e;
  color: white;
  padding: 12px 20px;
  border-radius: 25px;
  text-decoration: none;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(255, 94, 94, 0.3);
  transition: all 0.3s;
  font-size: 0.9em;
}

.donate-btn:hover {
  background: #ff4444;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 94, 94, 0.4);
}

.donate-btn span {
  font-size: 1.2em;
}

/* Publicités */
.ad-container {
  margin-top: 30px;
  padding: 15px;
  background: #f9f9f9;
  border-radius: 10px;
  text-align: center;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-container-bottom {
  display: none;
  width: 100%;
  max-width: 728px;
  margin: 20px auto;
  padding: 15px;
  background: #f9f9f9;
  border-radius: 10px;
  text-align: center;
  min-height: 90px;
}

@media (max-width: 1000px) {
  .ad-container {
    display: none;
  }

  .ad-container-bottom {
    display: block;
  }

  .donation-button {
    bottom: 10px;
    left: 10px;
  }

  .donate-btn {
    padding: 10px 16px;
    font-size: 0.85em;
  }
}

/* Écran de menu */
.menu-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}

.menu-container {
  background: white;
  border-radius: 20px;
  padding: 60px 80px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.menu-container h1 {
  font-size: 4em;
  color: #667eea;
  margin-bottom: 40px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.menu-options {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.menu-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 20px 40px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.3em;
  font-weight: bold;
  transition: all 0.3s;
  min-width: 200px;
}

.menu-btn:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.menu-btn:active {
  transform: translateY(0);
}

.multiplayer-options {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.multiplayer-options .btn-secondary {
  background: #9e9e9e;
}

.multiplayer-options .btn-secondary:hover {
  background: #757575;
}

.code-display {
  font-size: 3em;
  font-weight: bold;
  color: #667eea;
  letter-spacing: 10px;
  margin: 20px 0;
  padding: 20px;
  background: #f5f5f5;
  border-radius: 10px;
  text-align: center;
}

.code-input {
  font-size: 2em;
  font-weight: bold;
  text-align: center;
  padding: 15px;
  border: 3px solid #667eea;
  border-radius: 10px;
  width: 100%;
  max-width: 300px;
  margin: 20px 0;
  letter-spacing: 5px;
}

.info-text {
  color: #666;
  margin: 10px 0;
  font-size: 1.1em;
}

.error-text {
  color: #d32f2f;
  margin-top: 10px;
  font-weight: bold;
}

/* Lobby */
#lobby-players {
  margin: 20px 0;
  padding: 15px;
  background: #f9f9f9;
  border-radius: 10px;
}

#lobby-players h4 {
  color: #667eea;
  margin-bottom: 15px;
  text-align: center;
}

#players-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-item {
  padding: 12px 15px;
  background: white;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s;
}

.player-item.current-player {
  border-color: #667eea;
  background: #f0f4ff;
}

.player-name {
  font-weight: bold;
  color: #333;
}

.host-badge {
  background: #ffd700;
  color: #333;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: bold;
}

#all-players-info {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
}

.opponent-container {
  padding: 15px;
  background: #f9f9f9;
  border-radius: 10px;
  border: 2px solid #e0e0e0;
}

.opponent-header {
  font-size: 1.1em;
  margin-bottom: 10px;
  color: #667eea;
  text-align: center;
}

.opponent-stats {
  display: flex;
  gap: 15px;
  margin: 10px 0;
  padding: 10px;
  background: #f5f5f5;
  border-radius: 8px;
  justify-content: center;
}

.opponent-stat {
  display: flex;
  gap: 5px;
  align-items: center;
  font-size: 0.9em;
}

.stat-label {
  color: #666;
  font-weight: bold;
}

.opponent-progress {
  margin: 10px 0;
}

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

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  transition: width 0.3s ease;
  width: 0%;
}

.opponent-board {
  margin-top: 15px;
}

.opponent-level-container {
  margin-bottom: 20px;
  padding: 10px;
  background: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.opponent-level-title {
  font-weight: bold;
  color: #667eea;
  margin-bottom: 10px;
  font-size: 0.9em;
  text-align: center;
}

.opponent-attempt {
  display: flex;
  gap: 5px;
  margin-bottom: 8px;
  justify-content: center;
}

.opponent-cell {
  width: 25px;
  height: 25px;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.opponent-cell.correct {
  background: #4caf50;
  border-color: #4caf50;
}

.opponent-cell.present {
  background: #ff9800;
  border-color: #ff9800;
}

.opponent-cell.absent {
  background: #9e9e9e;
  border-color: #9e9e9e;
}

/* Leaderboard */
#sidebar-leaderboard {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 2px solid #e0e0e0;
}

#sidebar-leaderboard h3 {
  color: #667eea;
  margin-bottom: 15px;
  text-align: center;
  font-size: 1.2em;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 15px 0;
  max-height: 300px;
  overflow-y: auto;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px 15px;
  background: #f5f5f5;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  transition: all 0.3s;
}

.leaderboard-item.current-player-leaderboard {
  border-color: #667eea;
  background: #f0f4ff;
  font-weight: bold;
}

.leaderboard-position {
  font-size: 1.2em;
  font-weight: bold;
  min-width: 40px;
  text-align: center;
}

.leaderboard-name {
  flex: 1;
  font-weight: 500;
  color: #333;
}

.leaderboard-time {
  font-weight: bold;
  color: #667eea;
  font-family: monospace;
}

.main-wrapper {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  margin: 0 auto;
}

.container {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 600px;
  flex-shrink: 0;
}

.sidebar {
  background: white;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 300px;
  flex-shrink: 0;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  position: sticky;
  top: 20px;
}

.sidebar h3 {
  color: #667eea;
  margin-bottom: 20px;
  font-size: 1.5em;
  text-align: center;
}

#history-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.history-item {
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  padding: 15px;
  background: #f9f9f9;
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: bold;
  color: #667eea;
}

.history-item-time {
  font-size: 0.9em;
  color: #666;
}

.history-attempts {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.history-attempt-row {
  display: flex;
  gap: 3px;
  justify-content: center;
}

.history-cell {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.history-cell.correct {
  background: #4caf50;
  border-color: #4caf50;
}

.history-cell.present {
  background: #ff9800;
  border-color: #ff9800;
}

.history-cell.absent {
  background: #9e9e9e;
  border-color: #9e9e9e;
}

header {
  text-align: center;
  margin-bottom: 30px;
}

header h1 {
  font-size: 3em;
  color: #667eea;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
  color: #666;
  font-size: 1.1em;
}

.game-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 15px;
  background: #f5f5f5;
  border-radius: 10px;
  flex-wrap: wrap;
  gap: 10px;
}

.game-buttons {
  display: flex;
  gap: 10px;
}

.info-item {
  font-size: 1.1em;
  font-weight: bold;
}

.label {
  color: #666;
  margin-right: 10px;
}

.btn-secondary {
  background: #667eea;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  font-weight: bold;
  transition: background 0.3s;
}

.btn-secondary:hover {
  background: #5568d3;
}

.game-board {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 30px;
}

.row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.cell {
  width: 50px;
  height: 50px;
  border: 3px solid #ddd;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8em;
  font-weight: bold;
  text-transform: uppercase;
  background: white;
  transition: all 0.3s;
}

.cell.filled {
  border-color: #999;
  animation: pop 0.2s;
}

.cell.correct {
  background: #4caf50;
  color: white;
  border-color: #4caf50;
}

.cell.present {
  background: #ff9800;
  color: white;
  border-color: #ff9800;
}

.cell.absent {
  background: #9e9e9e;
  color: white;
  border-color: #9e9e9e;
}

.cell.current {
  border-color: #667eea;
  border-width: 4px;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.keyboard-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.key {
  min-width: 40px;
  height: 50px;
  border: none;
  border-radius: 6px;
  background: #e0e0e0;
  color: #333;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.key:hover {
  background: #d0d0d0;
  transform: translateY(-2px);
}

.key:active {
  transform: translateY(0);
}

.key.correct {
  background: #4caf50;
  color: white;
}

.key.present {
  background: #ff9800;
  color: white;
}

.key.absent {
  background: #9e9e9e;
  color: white;
}

.key.wide {
  min-width: 80px;
  font-size: 0.9em;
}

.message {
  text-align: center;
  min-height: 30px;
  font-weight: bold;
  color: #d32f2f;
  margin-bottom: 10px;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  animation: slideIn 0.3s;
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content h2 {
  color: #667eea;
  margin-bottom: 20px;
  font-size: 2em;
}

.modal-content p {
  margin-bottom: 30px;
  font-size: 1.2em;
  color: #666;
}

.btn-primary {
  background: #667eea;
  color: white;
  border: none;
  padding: 15px 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1em;
  font-weight: bold;
  transition: background 0.3s;
}

.btn-primary:hover {
  background: #5568d3;
}

@media (max-width: 1000px) {
  .main-wrapper {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-width: 600px;
    position: relative;
    top: 0;
  }
}

@media (max-width: 600px) {
  .cell {
    width: 40px;
    height: 40px;
    font-size: 1.5em;
  }

  .key {
    min-width: 30px;
    height: 45px;
    font-size: 0.9em;
  }

  header h1 {
    font-size: 2em;
  }

  .history-cell {
    width: 15px;
    height: 15px;
  }
}

/* Publicités AdSense */
.ad-container {
  margin: 20px 0;
  text-align: center;
  overflow: hidden;
}

.ad-sidebar {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 2px solid #e0e0e0;
}

.ad-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px;
  z-index: 100;
  display: none; /* Caché par défaut, affiché sur mobile */
}

/* Afficher la pub bottom sur mobile uniquement */
@media (max-width: 768px) {
  .ad-sidebar {
    display: none;
  }

  .ad-bottom {
    display: block;
  }

  body {
    padding-bottom: 100px; /* Espace pour la pub en bas */
  }
}

/* Cacher la pub bottom sur desktop */
@media (min-width: 769px) {
  .ad-bottom {
    display: none;
  }

  .ad-sidebar {
    display: block;
  }
}
