/* =========================================
   STYLE : JEU EN LIGNE (VERSION FINALE AJUSTÉE)
   ========================================= */

:root {
  --bg-dark: #121212;
  --bg-secondary: #1e1e1e;
  --bg-tertiary: #2a2a2a;
  --accent-gold: #d4af37;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --border-subtle: rgba(255, 255, 255, 0.1);
}

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  overflow-x: hidden;
}

/* --- LAYOUT PRINCIPAL --- */
.game-main {
  min-height: 100vh;
  padding-top: 100px;
  padding-bottom: 50px;
  display: flex;
  justify-content: center;
}

.game-area {
  display: flex;
  flex-direction: row;
  gap: 25px;
  width: 100%;
  max-width: 1200px;
  padding: 0 20px;
}

/* --- COLONNE GAUCHE (PLATEAU) --- */
.board-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px; /* Espacement équilibré */
  max-width: 650px;
  margin: 0 auto;
}

.board-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  background-color: #333;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#board {
  width: 100% !important;
  height: 100% !important;
}

/* --- CARTES JOUEURS (AJUSTÉ) --- */
.player-info {
  display: flex;
  align-items: center; /* Centre verticalement */
  justify-content: flex-start; /* ALIGNE TOUT À GAUCHE (Horizontalement) */
  gap: 12px; /* Espace un peu plus serré */
  padding: 6px 12px; /* Plus fin (était 10px 15px) */
  background: var(--bg-secondary);
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  width: 100%;
  box-sizing: border-box;
  min-height: 54px; /* Hauteur réduite (était 68px) pour affiner */
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.avatar {
  width: 38px; /* Taille réduite pour aller avec la barre plus fine (était 46px) */
  height: 38px;
  border-radius: 5px;
  background-color: #444;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.details {
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* FORCE LE TEXTE (Nom + Elo) À GAUCHE */
  justify-content: center;
  gap: 2px; /* Espace réduit entre le nom et le grade */
}

/* Le reste ne change pas, mais assurez-vous que ceci est présent pour le texte */
.details .name {
  font-weight: 700;
  font-size: 0.95rem; /* Légèrement ajusté */
  color: var(--text-primary);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.details .rating {
  font-size: 0.75rem;
  color: var(--accent-gold);
  font-weight: 600;
  background: rgba(212, 175, 55, 0.1); /* Petit badge doré subtil */
  padding: 2px 6px;
  border-radius: 3px;
  line-height: 1;
}

/* Puce de connexion tout à droite */
.connection-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: auto; /* Pousse la puce à l'extrême droite */
}
.connection-status.online {
  background: #2ecc71;
  box-shadow: 0 0 6px rgba(46, 204, 113, 0.4);
}
.connection-status.offline {
  background: #555;
}

/* --- INDICATEURS VISUELS --- */
.selected-square {
  background-color: rgba(255, 235, 59, 0.5) !important;
}
.highlight-last-move {
  background-color: rgba(155, 200, 50, 0.5) !important;
}
.move-hint {
  background: radial-gradient(rgba(0, 0, 0, 0.3) 19%, transparent 20%);
}
.capture-hint {
  background: radial-gradient(
    transparent 0%,
    transparent 40%,
    rgba(200, 0, 0, 0.4) 41%,
    rgba(200, 0, 0, 0.4) 55%,
    transparent 56%
  );
}
.square-55d63 {
  transition: background-color 0.1s ease-in-out;
}

/* --- COLONNE DROITE (SIDEBAR) --- */
.game-sidebar {
  width: 360px;
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  height: fit-content;
  border: 1px solid var(--border-subtle);
}

.sidebar-header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-controls {
  background: var(--bg-tertiary);
  padding: 15px;
  border-radius: 6px;
}

.time-selector-container {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
}

.btn-time-select {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}
.btn-time-select:hover {
  background: rgba(255, 255, 255, 0.05);
}
.btn-time-select.active {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(212, 175, 55, 0.08);
}

.btn-game.primary {
  width: 100%;
  padding: 14px;
  background: var(--accent-gold);
  color: #000;
  border: none;
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn-game.primary:hover {
  background: #f0c43d;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
}

.btn-game.danger {
  width: 100%;
  padding: 12px;
  background: rgba(192, 57, 43, 0.15);
  color: #e74c3c;
  border: 1px solid rgba(192, 57, 43, 0.3);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.2s;
}
.btn-game.danger:hover {
  background: rgba(192, 57, 43, 0.25);
  border-color: #e74c3c;
}

/* --- HORLOGES & HISTORIQUE --- */
.timers-container {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.clock {
  background: #0a0a0a;
  color: #fff;
  font-family: "Courier New", monospace;
  font-size: 1.6rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 4px;
  width: 100%;
  text-align: center;
  border: 1px solid #333;
  letter-spacing: 1px;
}

.history-container {
  background: var(--bg-tertiary);
  border-radius: 4px;
  padding: 10px;
  flex-grow: 1;
  min-height: 180px;
  border: 1px solid var(--border-subtle);
}

.move-history-content {
  font-family: "Roboto Mono", monospace;
  color: var(--text-secondary);
  line-height: 1.7;
  max-height: 180px;
  overflow-y: auto;
  font-size: 0.9rem;
}

/* --- MODALES --- */
#promotion-overlay,
#game-over-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
  backdrop-filter: blur(2px);
}

.promotion-modal,
.game-over-modal {
  background: #252525;
  padding: 25px;
  border-radius: 8px;
  text-align: center;
  color: #e0e0e0;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-subtle);
}
.promo-piece {
  width: 60px;
  cursor: pointer;
  transition: 0.2s;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  margin: 0 5px;
}
.promo-piece:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.2);
}

/* --- SVG FLÈCHES --- */
.arrow-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 500;
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 950px) {
  .game-area {
    flex-direction: column;
    align-items: center;
    padding: 0 10px;
    gap: 15px;
  }
  .game-sidebar {
    width: 100%;
    order: 2;
  }
  .board-wrapper {
    order: 1;
    width: 100%;
    max-width: 500px;
  }
  /* Sur mobile, on garde les infos lisibles */
  .player-info {
    padding: 8px 12px;
    min-height: 60px;
  }
  .avatar {
    width: 40px;
    height: 40px;
  }
}
