/* =========================================
   STYLE : PUZZLES TACTIQUES (FINAL)
   ========================================= */

/* --- 1. LAYOUT PRINCIPAL --- */
.game-main {
  min-height: 100vh;
  padding: 120px 2rem 4rem 2rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: transparent;
}

.game-area {
  display: flex;
  gap: 3rem;
  width: 100%;
  max-width: 1100px;
  position: relative;
}

/* =========================================
   2. LE PLATEAU (BOARD)
   ========================================= */
.board-wrapper {
  flex: 1.5;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.board-container {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background-color: var(--bg-secondary);
  border: 3px solid var(--border-subtle);
  border-radius: 4px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  cursor: pointer;
  position: relative; /* IMPORTANT pour le positionnement des flèches SVG */
}

.player-info {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: var(--bg-secondary);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.avatar {
  width: 40px;
  height: 40px;
  background-color: var(--bg-tertiary);
  border-radius: 50%;
  border: 1px solid var(--accent-gold);
}

.details .name {
  font-family: var(--font-body);
  font-weight: 600;
  display: block;
  color: var(--text-primary);
}

.details .rating {
  font-family: var(--font-heading);
  font-weight: bold;
  font-size: 0.9rem;
  color: var(--accent-gold);
  background: rgba(212, 175, 55, 0.1);
  padding: 2px 8px;
  border-radius: 2px;
  margin-top: 4px;
  display: inline-block;
  border: 1px solid rgba(212, 175, 55, 0.2);
}

/* =========================================
   3. SIDEBAR & CONTROLES
   ========================================= */
.game-sidebar {
  flex: 1;
  background: var(--bg-secondary);
  padding: 2rem;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 120px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1rem;
  flex-wrap: wrap;
  gap: 10px;
}

.streak-container {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--text-primary);
}

/* --- STYLE DES SELECTS (Inspiré du Dropdown Nav) --- */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1rem;
}

.control-group label {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-left: 2px;
}

.game-select {
  /* 1. Base Structure & Reset */
  width: 100%;
  appearance: none; /* Supprime le style natif */
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  outline: none;

  /* 2. Style visuel (Copie de nav.css .dropdown-menu) */
  background-color: rgba(15, 15, 15, 0.95);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);

  color: #bbb; /* Couleur texte repos */
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 12px 15px;

  /* 3. Bordures & Ombres */
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top: 2px solid var(--accent-gold); /* La touche dorée du menu */
  border-radius: 0 0 4px 4px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);

  /* 4. Flèche personnalisée (SVG encodé en Gold) */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d4af37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 14px;

  transition: all 0.3s ease;
}

/* Effet au survol */
.game-select:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--accent-gold); /* Le texte devient doré */
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* Effet au focus */
.game-select:focus {
  border-color: rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-gold);
  color: var(--text-primary);
}

/* Style des options internes */
.game-select option {
  background-color: #151515;
  color: #ddd;
  padding: 10px;
}

/* --- INDICATEUR DE TOUR --- */
.turn-indicator {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-tertiary);
  padding: 10px 15px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.turn-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transition: 0.3s ease;
}

.turn-indicator.white-turn .turn-icon {
  background-color: #eee;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}
.turn-indicator.black-turn .turn-icon {
  background-color: #111;
  border: 2px solid #555;
}

#status-text {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--text-primary);
}

/* =========================================
   4. ANALYSE & FEEDBACK
   ========================================= */
.engine-feedback-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-gold);
  border-radius: 2px;
  padding: 15px;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 15px;
  min-height: 70px;
}

.engine-icon {
  font-size: 1.4rem;
  opacity: 0.8;
}

#engine-text {
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.analysis-blunder {
  color: #e74c3c !important;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 1px;
}

.analysis-best {
  color: #2ecc71 !important;
  font-weight: 600;
}

.refutation-move {
  background: rgba(212, 175, 55, 0.1);
  padding: 2px 6px;
  border-radius: 2px;
  font-family: "Courier New", monospace;
  color: var(--accent-gold);
  border: 1px solid rgba(212, 175, 55, 0.2);
}

.feedback {
  padding: 1rem;
  border-radius: 2px;
  text-align: center;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  letter-spacing: 1px;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  display: none;
}

.feedback.visible {
  opacity: 1;
  transform: translateY(0);
  display: block;
}

.feedback.success {
  background: rgba(46, 204, 113, 0.1);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.feedback.error {
  background: rgba(231, 76, 60, 0.1);
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.3);
}

/* =========================================
   5. HISTORIQUE & BOUTON COPIER
   ========================================= */
.history-container {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  padding: 10px 15px;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.history-header {
  font-family: var(--font-body);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 5px;
  margin-bottom: 5px;

  /* Flex pour le bouton */
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* STYLE DU BOUTON DE COPIE */
.btn-copy {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-copy:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.btn-copy.copied {
  border-color: #2ecc71;
  color: #2ecc71;
}

.move-history-content {
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.6;
  max-height: 80px;
  overflow-y: auto;
  word-spacing: 5px;
}

.move-history-content span {
  display: inline-block;
}

.move-history-content::-webkit-scrollbar {
  width: 4px;
}
.move-history-content::-webkit-scrollbar-thumb {
  background: var(--accent-gold);
  border-radius: 2px;
}

/* =========================================
   6. BOUTONS
   ========================================= */
.controls {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.btn-game {
  width: 100%;
  padding: 1rem;
  border-radius: 2px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: var(--font-body);
}

.btn-game.primary {
  background: var(--accent-gold);
  color: #000;
  border: 1px solid var(--accent-gold);
}

.btn-game.primary:hover {
  background: transparent;
  color: var(--accent-gold);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.2);
}

.btn-game.secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-game.secondary:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.btn-game.danger {
  background: rgba(231, 76, 60, 0.1);
  color: #ffffff;
  border: 1px solid #ffffff;
  transition: all 0.2s ease;
}

.btn-game.danger:hover {
  background: #554a4a;
  color: #fff;
  border-color: #ffffff;
  box-shadow: none;
  transform: translateY(-2px);
}

/* =========================================
   7. INDICATEURS & FLÈCHES
   ========================================= */

.selected-square {
  box-shadow: inset 0 0 0 4px #ffd700 !important;
}

.hint-square {
  box-shadow: inset 0 0 0 4px #ffd700 !important;
}

/* --- HIGHLIGHT LAST MOVE (Style identique à la sélection) --- */
.highlight-last-move {
  box-shadow: inset 0 0 0 4px #ffd700 !important;
}

/* --- POINTS DE DEPLACEMENT (Utilisation de background-image) --- */
.move-hint {
  background-image: radial-gradient(rgba(0, 0, 0, 0.2) 19%, transparent 20%);
}

.capture-hint {
  background-image: radial-gradient(
    transparent 0%,
    transparent 40%,
    rgba(0, 0, 0, 0.2) 41%,
    rgba(0, 0, 0, 0.2) 55%,
    transparent 56%
  );
}

/* --- CANVAS DES FLÈCHES (SVG) --- */
.arrow-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* CRUCIAL : Laisse passer les clics GAUCHE vers les pièces */
  pointer-events: none;
  /* Z-Index élevé pour être visible, mais on gère le clic droit en JS */
  z-index: 1000;
  opacity: 0.8;
}

/* --- CLICK-THROUGH --- */
/* Important : ces éléments ne doivent pas bloquer le clic sur la case */
.board-glow-effect,
.highlight1-32417,
.highlight2-9c5d2 {
  pointer-events: none !important;
}

/* Fix responsive */
@media (max-width: 900px) {
  .game-area {
    flex-direction: column;
    align-items: center;
  }
  .board-wrapper,
  .game-sidebar {
    width: 100%;
    max-width: 500px;
    flex: none;
  }
  .game-sidebar {
    position: static;
  }
}

.chessboard-moving-piece {
  z-index: 9999 !important;
  opacity: 1 !important;
  pointer-events: none;
}
.square-55d63 img {
  opacity: 1 !important;
  transition: none !important;
}
.board-container {
  cursor: pointer;
}
/* =========================================
   8. INTERFACE DE PROMOTION (MODALE)
   ========================================= */
#promotion-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000; /* Au-dessus des pièces et flèches */
  display: none; /* Caché par défaut */
  justify-content: center;
  align-items: center;
}

.promotion-modal {
  background: white;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  text-align: center;
  animation: popIn 0.2s ease-out;
}

.promotion-title {
  margin: 0 0 10px 0;
  font-family: var(--font-body);
  font-weight: 600;
  color: #333;
  font-size: 0.9rem;
}

.promotion-pieces {
  display: flex;
  gap: 10px;
}

.promo-piece {
  width: 50px;
  height: 50px;
  cursor: pointer;
  border-radius: 4px;
  transition:
    transform 0.1s,
    background 0.1s;
  background-color: #f0f0f0;
}

.promo-piece:hover {
  transform: scale(1.1);
  background-color: #e0e0e0;
}

@keyframes popIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* =========================================
   9. MODALE FIN DE PARTIE (GAME OVER)
   ========================================= */
#game-over-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85); /* Fond très sombre pour focus */
  z-index: 2100; /* Au-dessus de tout */
  display: none; /* Caché par défaut */
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(5px); /* Effet flou pro */
}

.game-over-modal {
  background: var(--bg-secondary); /* Couleur de fond du thème */
  border: 2px solid var(--accent-gold); /* Bordure dorée */
  padding: 2.5rem;
  border-radius: 8px;
  text-align: center;
  max-width: 90%;
  width: 400px;
  box-shadow: 0 0 50px rgba(212, 175, 55, 0.2); /* Lueur dorée */
  animation: slideUpFade 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.game-over-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  display: inline-block;
  animation: bounceSlow 2s infinite ease-in-out;
}

#game-over-title {
  font-family: var(--font-heading);
  color: var(--accent-gold);
  font-size: 1.8rem;
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

#game-over-reason {
  color: var(--text-primary);
  font-size: 1.1rem;
  margin-bottom: 2rem;
  font-family: var(--font-body);
  line-height: 1.4;
}

.game-over-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Animations */
@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bounceSlow {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}
