:root {
  --bg-main: #050505;
  --bg-panel: #0a0a0a;
  --accent-gold: #d4af37;
  --accent-gold-hover: #b4932a;
  --text-primary: #ffffff;
  --text-secondary: #888888;
  --font-heading: "Playfair Display", serif;
  --font-body: "Inter", sans-serif;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --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;
}

.grand-master-bg::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse 80% 45% at 50% 0%,
    rgba(212, 175, 55, 0.1) 0%,
    transparent 70%
  );
}

/* =========================================
   2. HERO SECTION (TITRE)
   ========================================= */
.game-hero {
  position: relative;
  /* Espacement: 10rem haut (header), 2rem bas */
  padding: 10rem 2rem 2rem;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  z-index: 1;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
}

.badge-pro {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--accent-gold);
  border: 1px solid rgba(212, 175, 55, 0.3);
  padding: 6px 18px;
  margin-bottom: 1.5rem;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(212, 175, 55, 0.05),
    transparent
  );
}

.game-hero h1 {
  font-family: var(--font-heading);
  font-size: 4rem;
  line-height: 1.1;
  margin: 0 0 1rem 0;
  color: #fff;
  letter-spacing: -1px;
}

.text-gradient-gold {
  background: linear-gradient(to bottom, #fcf6ba, #d4af37, #aa8a29);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-style: italic;
  filter: drop-shadow(0 0 15px rgba(212, 175, 55, 0.2));
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1.6;
  font-weight: 300;
  max-width: 600px;
  margin: 0 auto;
}

/* =========================================
   3. LAYOUT PRINCIPAL (MAIN)
   ========================================= */
.game-main {
  flex: 1;
  display: flex;
  justify-content: center;
  width: 100%;
  padding-bottom: 4rem;
}

.game-area {
  display: flex;
  gap: 2rem;
  width: 100%;
  max-width: 1300px;
  padding: 0 2rem;
  align-items: flex-start;
}

/* =========================================
   4. PLATEAU (BOARD) & JOUEUR
   ========================================= */
.board-wrapper {
  flex: 1.5;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0; /* Empêche l'overflow flex */
}

.board-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  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);
}

.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);
}

#board {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  overflow: hidden;
}

/* Panneau Info Joueur */
.player-panel {
  display: flex;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 15px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.03), transparent);
  border-left: 2px solid var(--accent-gold);
  padding: 10px 20px;
  min-width: 200px;
  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);
  background-size: cover;
  background-position: center;
}

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

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

/* =========================================
   5. SIDEBAR (TABLEAU DE BORD)
   ========================================= */
.game-sidebar {
  flex: 1;
  max-width: 450px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 600px;
  height: auto;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.sidebar-header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1rem;
}

.streak-container {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: #fff;
  display: flex;
  align-items: center;
}

.gold-icon {
  color: var(--accent-gold);
  margin-right: 8px;
}

/* Zone Moteur */
.engine-feedback-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-left: 2px solid var(--accent-gold-dim);
  border-radius: 2px;
  padding: 1rem;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.engine-pulse {
  width: 6px;
  height: 6px;
  background: var(--accent-gold);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
  animation: pulse 2.5s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.35);
  }
  70% {
    opacity: 0.6;
    box-shadow: 0 0 0 7px rgba(212, 175, 55, 0);
  }
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
  }
}

#engine-text {
  font-family: "Courier New", monospace;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Historique */
.history-container {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.history-header {
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 15px;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

/* Nouveau style pour le bouton d'outils (Coller) */
.btn-tool {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 3px;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-tool:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

.move-history-content {
  padding: 10px 15px;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #ddd;
  overflow-y: auto;
  height: 200px;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

/* Texte d'aide quand c'est vide */
.placeholder-text {
  color: #555;
  font-style: italic;
  font-size: 0.8rem;
  font-family: var(--font-body);
}

/* Contrôles */
.controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: auto;
}

.analysis-nav-row {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.analysis-nav-row button {
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  color: #fff;
  padding: 12px 0;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}
.analysis-nav-row button:last-child {
  border-right: none;
}
.analysis-nav-row button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-gold);
}

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

.btn-game.primary {
  background: linear-gradient(
    135deg,
    var(--accent-gold),
    var(--accent-gold-hover)
  );
  color: #000;
  border: none;
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.2);
}
.btn-game.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

.btn-game.secondary {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}
.btn-game.secondary:hover {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.info-box-minimal {
  font-size: 0.75rem;
  color: #555;
  text-align: center;
  margin-top: 0.5rem;
}

/* =========================================
   6. MODALES (OVERLAYS)
   ========================================= */
#promotion-overlay,
#game-over-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  border-radius: 4px; /* Suit le board */
}

.promotion-modal {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  color: #000;
}

.game-over-modal {
  background: linear-gradient(145deg, #151515, #0a0a0a);
  border: 1px solid var(--accent-gold);
  padding: 2.5rem;
  text-align: center;
  box-shadow: 0 0 50px rgba(212, 175, 55, 0.1);
  border-radius: 8px;
  max-width: 350px;
  width: 90%;
}

.game-over-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

#game-over-title {
  color: var(--accent-gold);
  font-family: var(--font-heading);
  font-size: 1.8rem;
  margin: 0.5rem 0;
}

#game-over-reason {
  color: #aaa;
  margin-bottom: 2rem;
}

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

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

.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;
  margin-bottom: 0.5rem;
  color: #fff;
}
.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 ul {
  padding: 0;
  list-style: none;
}
.footer-col li {
  margin-bottom: 0.8rem;
}
.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;
}

/* =========================================
   8. RESPONSIVE
   ========================================= */
@media (max-width: 1024px) {
  .game-area {
    flex-direction: column;
    align-items: center;
    padding: 0 1rem;
  }
  .board-wrapper,
  .game-sidebar {
    width: 100%;
    max-width: 600px;
    flex: none;
  }
  .game-hero {
    padding-top: 8rem;
  }
  .game-hero h1 {
    font-size: 3rem;
  }
}

@media (max-width: 768px) {
  .game-hero h1 {
    font-size: 2.5rem;
  }
  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
  .footer-nav-group {
    justify-content: center;
    gap: 2rem;
    width: 100%;
  }
}
/* --- AMÉLIORATION DE L'HISTORIQUE --- */
#engine-feedback-box {
  border-left: 4px solid var(--accent-gold);
  padding: 15px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  margin-bottom: 20px;
}

.move-history-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.move-row {
  display: flex;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
  align-items: center;
}

.move-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

.move-number {
  color: #666;
  width: 35px;
  font-weight: bold;
  flex-shrink: 0;
}

.move-san {
  flex: 1;
  display: flex;
  align-items: center;
  color: #ddd;
}

/* =========================================
   9. TOAST NOTIFICATIONS
   ========================================= */
.toast-notification {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  backdrop-filter: blur(12px);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  transition:
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  white-space: normal;
  text-align: center;
}

.toast-notification.toast-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-error {
  background: linear-gradient(
    135deg,
    rgba(20, 10, 10, 0.92),
    rgba(15, 8, 8, 0.95)
  );
  border: 1px solid rgba(180, 50, 50, 0.4);
  border-left: 3px solid #c0392b;
  color: #e8c4c4;
}

.toast-success {
  background: linear-gradient(
    135deg,
    rgba(10, 15, 10, 0.92),
    rgba(8, 12, 8, 0.95)
  );
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-left: 3px solid var(--accent-gold);
  color: #c8d8c4;
}

.toast-icon {
  font-size: 0.75rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
}

.toast-error .toast-icon {
  background: rgba(192, 57, 43, 0.2);
  color: #e74c3c;
  border: 1px solid rgba(192, 57, 43, 0.3);
}

.toast-success .toast-icon {
  background: rgba(212, 175, 55, 0.1);
  color: var(--accent-gold);
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.toast-message {
  line-height: 1.4;
}
