/* Chess Game Styles */

.chess-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.chess-info {
  display: flex;
  justify-content: space-between;
  width: min(90vw, 480px);
  gap: 1rem;
}

.captured-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-size: 1.25rem;
  min-height: 1.5rem;
  padding: 0.25rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  flex: 1;
}

.captured-pieces.white {
  justify-content: flex-start;
}

.captured-pieces.black {
  justify-content: flex-end;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0;
  width: min(90vw, 480px);
  aspect-ratio: 1;
  border: 4px solid rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.chess-square {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background-color 0.15s;
}

.chess-square.light {
  background: #f0d9b5;
}

.chess-square.dark {
  background: #b58863;
}

.chess-square.selected {
  background: #829769 !important;
}

.chess-square.last-move {
  background: rgba(255, 255, 0, 0.4) !important;
}

.chess-square.last-move.light {
  background: #cdd26a !important;
}

.chess-square.last-move.dark {
  background: #aaa23a !important;
}

.chess-square.legal-move::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  pointer-events: none;
}

.chess-square.legal-move.has-piece::after {
  width: 100%;
  height: 100%;
  background: transparent;
  border: 4px solid rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  box-sizing: border-box;
}

.chess-square.in-check {
  background: rgba(255, 0, 0, 0.5) !important;
}

.chess-square.game-over {
  cursor: default;
}

.chess-piece {
  font-size: calc(min(90vw, 480px) / 10);
  user-select: none;
  cursor: pointer;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.chess-square.game-over .chess-piece {
  cursor: default;
}

.move-history {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  width: min(90vw, 480px);
  max-height: 60px;
  overflow-y: auto;
  font-family: monospace;
  color: #ccc;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.move-history-content {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.move-pair {
  white-space: nowrap;
}

.move-number {
  color: #888;
  margin-right: 0.25rem;
}

.game-controls {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.btn-resign {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
  padding: 0.5rem 1rem;
  border: 2px solid rgba(231, 76, 60, 0.4);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn-resign:hover {
  background: rgba(231, 76, 60, 0.3);
  border-color: #e74c3c;
}

.btn-resign:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Promotion modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #2d3748;
  padding: 2rem;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
  margin: 0 0 1rem 0;
  color: white;
}

.promotion-options {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.promotion-options button {
  width: 60px;
  height: 60px;
  font-size: 2.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  cursor: pointer;
  color: white;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.promotion-options button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}

/* Turn indicator */
.turn-indicator {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-weight: bold;
  text-align: center;
  width: min(90vw, 480px);
  box-sizing: border-box;
}

.turn-indicator.your-turn {
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.4);
}

.turn-indicator.opponent-turn {
  background: rgba(241, 196, 15, 0.2);
  color: #f1c40f;
  border: 1px solid rgba(241, 196, 15, 0.4);
}

.turn-indicator.in-check {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.4);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Responsive adjustments */
@media (max-width: 500px) {
  .chess-board {
    width: 95vw;
  }

  .chess-piece {
    font-size: calc(95vw / 10);
  }

  .chess-info,
  .move-history,
  .turn-indicator {
    width: 95vw;
  }

  .promotion-options button {
    width: 50px;
    height: 50px;
    font-size: 2rem;
  }
}

@media (max-width: 350px) {
  .promotion-options {
    flex-wrap: wrap;
  }

  .promotion-options button {
    width: 45px;
    height: 45px;
    font-size: 1.75rem;
  }
}
