/* =========================================
   STYLE : PUZZLES TACTIQUES (THEME GRAND MASTER)
   ========================================= */

:root {
  --bg-main: #050505;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #121212;
  --accent-gold: #d4af37;
  --accent-gold-dim: rgba(212, 175, 55, 0.5);
  --text-primary: #ffffff;
  --text-secondary: #888888;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --font-heading: "Playfair Display", serif;
  --font-body: "Inter", sans-serif;
  --glass-bg: rgba(20, 20, 20, 0.6);
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-body);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =========================================
   FOND D'AMBIANCE
   ========================================= */
.grand-master-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: -1;
  background-image: radial-gradient(
    circle at 50% 0%,
    #1a1500 0%,
    var(--bg-main) 60%
  );
  pointer-events: none;
}

/* =========================================
   1. LAYOUT PRINCIPAL
   ========================================= */
.game-main {
  flex: 1;
  padding: 120px 2rem 4rem 2rem; /* Espace pour le header */
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.game-area {
  display: flex;
  gap: 3rem;
  width: 100%;
  max-width: 1200px;
  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-radius: 4px;
  box-shadow:
    0 30px 60px -10px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
  cursor: pointer;
  position: relative; /* CRITIQUE POUR LES FLÈCHES */
}

/* Effet de lueur derrière le plateau */
.board-glow-effect {
  position: absolute;
  top: -20px;
  left: -20px;
  right: -20px;
  bottom: -20px;
  background: radial-gradient(
    circle,
    rgba(212, 175, 55, 0.08) 0%,
    transparent 70%
  );
  z-index: -1;
  filter: blur(20px);
  pointer-events: none !important; /* CRITIQUE */
}

.player-info {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px 20px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.03), transparent);
  border-left: 2px solid var(--accent-gold);
  border-radius: 0 4px 4px 0;
}

.avatar {
  width: 44px;
  height: 44px;
  background-color: #1a1a1a;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.details .name {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: #fff;
  display: block;
}

.rank-label {
  font-size: 0.75rem;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* =========================================
   3. SIDEBAR & CONTROLES
   ========================================= */
.game-sidebar {
  flex: 1;
  background: var(--bg-secondary);
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 100px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  min-width: 300px;
}

/* Thème */
.theme-container {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.theme-label {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--accent-gold);
  font-size: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.theme-display {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: #fff;
  margin-bottom: 0;
  flex: 1;
  text-align: right;
  text-transform: capitalize;
}

/* Header Sidebar */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.5rem;
}

.streak-container {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: #fff;
}
.text-gold {
  color: var(--accent-gold);
  margin-right: 5px;
}

/* Badges Difficulté (Restylés) */
.difficulty-badge {
  padding: 4px 12px;
  border-radius: 2px;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 1px;
  font-family: var(--font-body);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #aaa;
}

.difficulty-badge.easy {
  color: #2ecc71;
  border-color: rgba(46, 204, 113, 0.3);
}
.difficulty-badge.medium {
  color: #d4af37;
  border-color: rgba(212, 175, 55, 0.3);
}
.difficulty-badge.hard {
  color: #e67e22;
  border-color: rgba(230, 126, 34, 0.3);
}
.difficulty-badge.expert {
  color: #9b59b6;
  border-color: rgba(155, 89, 182, 0.3);
}

/* Indicateur de tour */
.turn-indicator {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 15px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.turn-icon {
  width: 14px;
  height: 14px;
  border-radius: 2px; /* Carré arrondi style échiquier */
}

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

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

/* =========================================
   5. RESULTAT (SIDEBAR) - FINAL (DESSIN)
   ========================================= */

.sidebar-result-box {
  /* Design compact et sombre */
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;

  /* Layout global : Ligne horizontale unique */
  padding: 8px 12px;
  margin-bottom: 1rem;

  display: none; /* Activé par le JS via style="display: flex" */
  flex-direction: row;
  align-items: center;
  gap: 10px;

  /* Bordure indicative fine à gauche */
  border-left: 3px solid transparent;
}

/* --- ICONE (GAUCHE) --- */
.result-icon {
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
}

/* --- CONTENEUR TEXTE + BOUTON --- */
.result-content {
  display: flex;
  flex-direction: row; /* Force l'alignement horizontal */
  align-items: center;
  justify-content: space-between; /* Ecarte le titre du bouton */
  width: 100%; /* Occupe tout l'espace restant */
}

/* --- TITRE (COLLÉ À L'ICONE) --- */
.result-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  margin: 0;
  white-space: nowrap;
}

/* --- BOUTON (TOUT À DROITE) --- */
#btn-result-action {
  /* Couleur TOUJOURS JAUNE (Or) */
  background-color: var(--accent-gold) !important;
  color: #000 !important;

  /* Style du bouton */
  border: none;
  border-radius: 2px;
  padding: 6px 12px;
  margin-left: auto; /* Pousse le bouton vers la droite au maximum */

  font-family: var(--font-body);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

#btn-result-action:hover {
  opacity: 0.9;
}

/* =========================================
   ETATS (COULEURS & ICONES)
   ========================================= */

/* --- SUCCÈS --- */
.sidebar-result-box.success {
  border-left-color: var(--accent-gold);
  background-color: rgba(212, 175, 55, 0.05); /* Fond or très subtil */
}
.sidebar-result-box.success .result-title {
  color: var(--accent-gold);
}
.sidebar-result-box.success .result-icon {
  color: var(--accent-gold);
}
.sidebar-result-box.success .result-icon::before {
  content: "\f091"; /* Icône Trophée (Coupe) */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
}

/* --- ECHEC --- */
.sidebar-result-box.failure {
  border-left-color: var(--accent-gold);
  background-color: rgba(212, 175, 55, 0.05); /* Fond or très subtil */
}
.sidebar-result-box.failure .result-title {
  color: var(--accent-gold);
}
.sidebar-result-box.failure .result-icon {
  color: var(--accent-gold);
}
.sidebar-result-box.failure .result-icon::before {
  content: "\f00d"; /* Une SEULE croix (X) */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
}
/* =========================================
   6. HISTORIQUE
   ========================================= */
.history-container {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  padding: 10px 15px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 100px;
}

.history-header {
  font-family: var(--font-body);
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

.move-history-content {
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  color: #ddd;
  line-height: 1.6;
  overflow-y: auto;
  word-spacing: 8px;
}

.placeholder-text {
  font-style: italic;
  color: #555;
}

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

.btn-game {
  width: 100%;
  padding: 14px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: var(--font-body);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.btn-game.small {
  padding: 6px 12px;
  font-size: 0.7rem;
  width: auto;
  margin-top: 5px;
}

/* Bouton Secondaire (Indice) */
.btn-game.secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.btn-game.secondary:hover {
  border-color: #fff;
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

/* Bouton Danger (Réessayer) */
.btn-game.danger {
  background: rgba(212, 175, 55, 0.1);
  color: var(--accent-gold);
  border: 1px solid rgba(212, 175, 55, 0.3);
}
.btn-game.danger:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--accent-gold);
}

/* =========================================
   8. CRITIQUE : INDICATEURS & FLÈCHES (NE PAS TOUCHER)
   ========================================= */

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

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

/* --- POINTS DE DEPLACEMENT --- */
.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%;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.8;
}

/* --- CLICK-THROUGH (IMPORTANT JS) --- */
.board-glow-effect,
.highlight1-32417,
.highlight2-9c5d2 {
  pointer-events: none !important;
}

.chessboard-moving-piece {
  z-index: 9999 !important;
  opacity: 1 !important;
  pointer-events: none;
}
.square-55d63 img {
  opacity: 1 !important;
  transition: none !important;
}

/* =========================================
   9. INTERFACE DE PROMOTION (MODALE)
   ========================================= */
#promotion-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 2000;
  display: none;
  justify-content: center;
  align-items: center;
}

.promotion-modal {
  background: #1a1a1a;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
  text-align: center;
  border: 1px solid var(--accent-gold);
}

.promotion-title {
  margin: 0 0 15px 0;
  font-family: var(--font-heading);
  color: var(--accent-gold);
  font-size: 1.1rem;
}

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

.promo-piece {
  width: 50px;
  height: 50px;
  cursor: pointer;
  border-radius: 4px;
  transition:
    transform 0.2s,
    background 0.2s;
  background-color: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.promo-piece:hover {
  transform: scale(1.1);
  background-color: var(--accent-gold);
}

/* =========================================
   10. FOOTER & RESPONSIVE
   ========================================= */
footer {
  border-top: 1px solid var(--border-subtle);
  padding: 4rem 2rem;
  background: var(--bg-main);
  margin-top: auto;
  z-index: 1;
  position: relative;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 3rem;
}

.footer-brand h4 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: #fff;
  margin-bottom: 0.5rem;
}
.footer-brand .dot {
  color: var(--accent-gold);
}
.footer-brand p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-style: italic;
}

.footer-nav-group {
  display: flex;
  gap: 4rem;
}
.footer-col h5 {
  color: var(--accent-gold);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 1.2rem;
}
.footer-col a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-decoration: none;
  transition: color 0.2s;
}
.footer-col a:hover {
  color: #fff;
}

.footer-copy {
  width: 100%;
  border-top: 1px solid var(--border-subtle);
  padding-top: 2rem;
  margin-top: 1rem;
  color: #444;
  font-size: 0.8rem;
  text-align: center;
}
.timer-box {
  background: var(--bg-tertiary);
  padding: 4px 10px; /* Réduit un peu le padding */
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  font-family: var(--font-heading);
  font-size: 1.1rem; /* Taille de police plus cohérente avec le reste */
  font-weight: bold;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  margin: 0 5px; /* Petit espacement horizontal */
}

/* Le reste (.timer-box.urgent et @keyframes) ne change pas */
.timer-box.urgent {
  background: rgba(231, 76, 60, 0.2);
  border-color: #e74c3c;
  color: #e74c3c;
  animation: pulseTimer 1s infinite;
}
@media (max-width: 900px) {
  .game-area {
    flex-direction: column;
    align-items: center;
  }
  .board-wrapper,
  .game-sidebar {
    width: 100%;
    max-width: 600px;
    flex: none;
  }
  .game-sidebar {
    position: static;
  }
  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
  .footer-nav-group {
    justify-content: center;
  }
}
