* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --light-sq: #ececd7; 
  --dark-sq: #739552;
  --bg-dark: #302e2b;
  --card-bg: #262421;
  --valid-move-dot: rgba(0, 0, 0, 0.12);
  --capture-ring: rgba(0, 0, 0, 0.15);
}

body {
  min-height: 100vh;
  font-family: 'Poppins', sans-serif;
  background: #1c1a17;
  color: #fff;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(115, 149, 82, 0.05) 0%, transparent 70%);
  top: -300px;
  left: -200px;
  z-index: 0;
  pointer-events: none;
}
.bg-glow2 {
  position: fixed;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.01) 0%, transparent 70%);
  bottom: -200px;
  right: -100px;
  z-index: 0;
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  padding: 40px;
  max-width: 1300px;
  margin: 0 auto;
  min-height: 100vh;
}

/* BARRE D'ÉVALUATION */
.board-section {
  display: flex;
  justify-content: center;
  align-items: center;
}
.game-container {
  display: flex;
  align-items: center;
  gap: 20px;
}
.eval-bar-container {
  width: 12px;
  height: 600px;
  background-color: #312e2b;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.eval-bar {
  background-color: #ffffff;
  width: 100%;
  height: 50%;
  transition: height 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
.eval-text {
  position: absolute;
  width: 100%;
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  z-index: 5;
  pointer-events: none;
}
.eval-text.white-adv { bottom: 8px; color: #1c1a17; }
.eval-text.black-adv { top: 8px; color: #ffffff; }

/* ÉCHIQUIER */
.board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.board-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.board {
  width: 600px;
  height: 600px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.square {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
}
.square.light { background: var(--light-sq); }
.square.dark { background: var(--dark-sq); }

.square.light.last-from, .square.light.last-to { background: #f7f785; }
.square.dark.last-from, .square.dark.last-to { background: #b9ca43; }
.square.selected { background-color: #dac343 !important; }

.square.in-check::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(231, 76, 60, 0.7) 0%, rgba(231, 76, 60, 0.1) 80%);
  z-index: 1;
}
.square.valid::after {
  content: '';
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: var(--valid-move-dot);
  position: absolute;
  z-index: 4;
}
.square.capture::after {
  content: '';
  width: 82%;
  height: 82%;
  border-radius: 50%;
  border: 4px solid var(--capture-ring);
  position: absolute;
  z-index: 4;
}

.piece {
  width: 90%;
  height: 90%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  position: relative;
  z-index: 5;
  transition: transform 0.1s ease;
}
.piece:active {
  transform: scale(0.95);
}
.piece svg {
  width: 100%;
  height: 100%;
}

/* COORDONNÉES */
.coordinates { display: grid; color: #757472; font-weight: 600; font-size: 0.7rem; }
.coordinates.top, .coordinates.bottom { grid-template-columns: repeat(8, 1fr); width: 600px; height: 14px; }
.coordinates span { text-align: center; }
.coordinates.vertical { width: 12px; height: 600px; grid-template-rows: repeat(8, 1fr); align-items: center; }

/* PANNEAU LATÉRAL */
.right-panel {
  width: 350px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 630px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(45deg, #fff, #989795);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.card {
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.02);
  padding: 14px;
  border-radius: 6px;
}
.card h2 {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #757472;
  margin-bottom: 8px;
}
.turn-indicator { display: flex; align-items: center; gap: 8px; }
.turn-dot { width: 10px; height: 10px; border-radius: 50%; }
.turn-dot.white { background: #fff; box-shadow: 0 0 6px #fff; }
.turn-dot.black { background: #312e2b; border: 1px solid #fff; }
#turn-text { font-weight: 600; font-size: 0.85rem; }

.status-badge { display: none; margin-top: 8px; padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; text-align: center; }
.status-badge.check { background: rgba(231, 76, 60, 0.15); color: #e74c3c; display: block; }
.status-badge.draw { background: rgba(149, 165, 166, 0.15); color: #bdc3c7; display: block; }

.captured-container { display: flex; flex-direction: column; gap: 8px; }
.captured-block { display: flex; align-items: center; gap: 10px; }
.captured-label { font-size: 0.6rem; color: #757472; text-transform: uppercase; width: 60px; }
.captured-row { display: flex; flex-wrap: wrap; gap: 2px; min-height: 24px; align-items: center; }
.cap-piece { width: 18px; height: 18px; display: inline-block; }
.cap-piece svg { width: 100%; height: 100%; }

.history-card { flex-grow: 1; display: flex; flex-direction: column; min-height: 150px; }
.move-history { flex-grow: 1; overflow-y: auto; font-size: 0.8rem; color: #dad9d7; }
.move-history::-webkit-scrollbar { width: 4px; }
.move-history::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.05); border-radius: 2px; }
.move-pair { display: grid; grid-template-columns: 35px 1fr 1fr; padding: 4px 6px; }
.move-pair:nth-child(odd) { background: rgba(255, 255, 255, 0.01); }
.move-num { color: #757472; font-weight: 600; }

#restartBtn {
  width: 100%; border: none; background: #312e2b; border-bottom: 2px solid #1f1d1b;
  color: #fff; padding: 10px; border-radius: 4px; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: background 0.1s;
}
#restartBtn:hover { background: #3d3a35; }

/* MODALES */
.game-overlay {
  position: absolute; inset: 0; z-index: 50; display: none; justify-content: center; align-items: center;
  background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(2px);
}
.game-overlay.show { display: flex; }
.overlay-box { background: #22201e; border: 1px solid #3d3a35; border-radius: 6px; padding: 24px; text-align: center; max-width: 280px; }
.overlay-icon { width: 45px; height: 45px; margin: 0 auto 10px; }
.overlay-icon svg { width: 100%; height: 100%; }
.overlay-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.overlay-subtitle { font-size: 0.8rem; color: #989795; margin-bottom: 16px; }
.overlay-btn { background: #769656; border: none; border-bottom: 2px solid #55703b; color: white; padding: 8px 20px; border-radius: 4px; font-weight: 600; cursor: pointer; }
.overlay-btn:hover { background: #86a666; }

.promo-modal { position: fixed; inset: 0; z-index: 200; display: none; justify-content: center; align-items: center; background: rgba(0,0,0,0.6); }
.promo-modal.show { display: flex; }
.promo-box { background: #262421; padding: 20px; border-radius: 6px; text-align: center; border: 1px solid #403d39; }
.promo-box h3 { font-size: 0.85rem; margin-bottom: 12px; color: #dad9d7; }
.promo-choices { display: flex; gap: 10px; }
.promo-choice { width: 56px; height: 56px; background: #312e2b; border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 1px solid rgba(255,255,255,0.03); }
.promo-choice:hover { background: #45423e; }
.promo-choice svg { width: 85%; height: 85%; }

@media(max-width: 1100px) {
  .app { flex-direction: column; padding: 20px; gap: 20px; }
  .right-panel { width: 100%; max-width: 600px; height: auto; }
}

.piece {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.1s ease;
}