/* Body & font */
body { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  margin: 0;
  font-family: 'Poppins', sans-serif; 
  background: linear-gradient(135deg, #89f7fe, #66a6ff);
  min-height: 100vh;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

/* Visually hidden for accessibility */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Turn indicator */
#turnIndicator {
  margin-bottom: 10px;
  font-size: 26px;
  font-weight: bold;
  text-shadow: 2px 2px 5px rgba(0,0,0,0.3);
}

/* Piece count display */
.game-info {
  display: flex;
  gap: 30px;
  margin-bottom: 20px;
  font-size: 18px;
  font-weight: 600;
}

.game-info span {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

#blackCount {
  color: #222;
}

#redCount {
  color: #ff4c4c;
}

/* Board */
.board { 
  display: grid; 
  grid-template-columns: repeat(8, minmax(35px, 70px)); 
  grid-template-rows: repeat(8, auto); 
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  position: relative;
  width: min(560px, 95vw);
}

/* Squares */
.cell { 
  aspect-ratio: 1;
  position: relative;
  transition: background-color 0.3s ease;
}

.black { background-color: #4a8f4a; }
.white { background-color: #f0e9d2; }

/* Pieces */
.piece { 
  width: 85%; 
  aspect-ratio: 1;
  border-radius: 50%; 
  margin: 7.5% auto; 
  cursor: pointer;
  position: relative;
  transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  --inset-shadow: none; /* Default */
}

/* Red Piece Styling - 3D with concentric rings */
.red { 
  --inset-shadow: inset 0 4px 6px rgba(255, 255, 255, 0.3), inset 0 -4px 6px rgba(0, 0, 0, 0.4);
  background: radial-gradient(circle at 35% 35%, 
    #ff7070 0%, 
    #ff4c4c 35%, 
    #d43f3f 40%, 
    #ff4c4c 45%, 
    #d43f3f 60%, 
    #ff4c4c 65%, 
    #b03030 100%);
  box-shadow: 
    var(--inset-shadow),
    0 4px 8px rgba(0, 0, 0, 0.5);
}

/* Black Piece Styling - 3D with concentric rings */
.black-piece { 
  --inset-shadow: inset 0 3px 4px rgba(255, 255, 255, 0.2), inset 0 -3px 5px rgba(0, 0, 0, 0.8);
  background: radial-gradient(circle at 35% 35%, 
    #666 0%, 
    #222 30%, 
    #555 38%, 
    #222 42%, 
    #555 58%, 
    #222 62%, 
    #111 100%);
  box-shadow: 
    var(--inset-shadow),
    0 4px 8px rgba(0, 0, 0, 0.7);
}

/* Selected piece indicator - Yellow highlight while keeping 3D depth */
.piece.selected {
  transform: scale(1.1);
  box-shadow: 
    0 0 20px 8px rgba(255, 215, 0, 0.9),
    var(--inset-shadow),
    0 4px 12px rgba(0, 0, 0, 0.6);
}

/* Highlight legal moves on cells */
.cell.highlight {
  position: relative;
}

.cell.highlight::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  background-color: rgba(255, 255, 0, 0.7);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.7; }
}

/* Capture move highlight (mandatory jumps) - red/orange indicator */
.cell.capture-highlight {
  position: relative;
}

.cell.capture-highlight::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 35px;
  height: 35px;
  background-color: rgba(255, 100, 0, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 15px rgba(255, 100, 0, 0.7);
  animation: capture-pulse 0.8s infinite;
}

@keyframes capture-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.3); opacity: 0.8; }
}

/* Must-capture indicator - highlight pieces that have mandatory captures */
.piece.must-capture {
  animation: must-capture-glow 0.6s infinite alternate;
}

.red.must-capture {
  box-shadow: 
    0 0 18px 8px rgba(255, 165, 0, 0.9),
    var(--inset-shadow),
    0 4px 8px rgba(0, 0, 0, 0.5);
}

.black-piece.must-capture {
  box-shadow: 
    0 0 18px 8px rgba(255, 165, 0, 0.9),
    var(--inset-shadow),
    0 4px 8px rgba(0, 0, 0, 0.7);
}

@keyframes must-capture-glow {
  0% { 
    box-shadow: 
      0 0 12px 6px rgba(255, 165, 0, 0.7),
      var(--inset-shadow);
  }
  100% { 
    box-shadow: 
      0 0 22px 10px rgba(255, 165, 0, 1),
      var(--inset-shadow);
  }
}

/* King crown - Centered perfectly with shadow */
.piece.king::after {
  content: '👑';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Glow for current player's pieces */
.red.current-turn { 
  box-shadow: 
    0 0 14px 6px rgba(255, 0, 0, 0.7),
    var(--inset-shadow),
    0 4px 8px rgba(0, 0, 0, 0.5); 
}
.black-piece.current-turn { 
  box-shadow: 
    0 0 14px 6px rgba(0, 0, 0, 0.7),
    var(--inset-shadow),
    0 4px 8px rgba(0, 0, 0, 0.7); 
}

/* Reset button */
#resetBtn {
  margin-top: 25px;
  padding: 12px 24px;
  font-size: 18px;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #ff758c, #ff7eb3);
  color: white;
  font-weight: bold;
  box-shadow: 0 6px 15px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#resetBtn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.35);
}

/* Win celebration */
.win-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 44px;
  font-weight: bold;
  color: gold;
  text-shadow: 2px 2px 5px black, 0 0 20px rgba(0,0,0,0.8);
  background: rgba(0, 0, 0, 0.7);
  padding: 20px 40px;
  border-radius: 10px;
  z-index: 100;
  animation: pop 1s ease forwards;
  text-align: center;
  white-space: nowrap;
}

@keyframes pop {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Responsive design */
@media (max-width: 600px) {
  body {
    padding: 10px;
  }

  #turnIndicator {
    font-size: 20px;
    margin-bottom: 8px;
  }

  .game-info {
    gap: 15px;
    margin-bottom: 15px;
    font-size: 14px;
  }

  .game-info span {
    padding: 6px 12px;
  }

  .board {
    border-radius: 10px;
  }

  .piece.king::after {
    font-size: 14px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .cell.highlight::after {
    width: 18px;
    height: 18px;
  }

  .cell.capture-highlight::after {
    width: 20px;
    height: 20px;
  }

  .win-message {
    font-size: 28px;
    padding: 15px 25px;
    white-space: normal;
  }

  #resetBtn {
    margin-top: 15px;
    padding: 10px 20px;
    font-size: 16px;
  }
}

@media (max-width: 380px) {
  .piece.king::after {
    font-size: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .game-info {
    gap: 10px;
    font-size: 12px;
  }

  .win-message {
    font-size: 22px;
    padding: 10px 20px;
  }
}
