* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  overflow-x: hidden;
}

.board-container {
  width: min(80vw, 600px);
  height: min(80vw, 600px);
  max-width: 600px;
  max-height: 600px;
  position: relative;
  transition: transform 0.3s ease;
}

.chess-board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 3px solid #1e293b;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
}

.chess-square {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.chess-square.light {
  background-color: #E8D7B8;
}

.chess-square.dark {
  background-color: #B58863;
}

.chess-square:hover {
  opacity: 0.8;
}

.chess-square.selected {
  background-color: #FFD700 !important;
  box-shadow: inset 0 0 0 3px #FFA500;
}

.chess-square.valid::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  background-color: rgba(34, 197, 94, 0.5);
  border-radius: 50%;
  pointer-events: none;
}

.chess-square.last-move {
  background-color: rgba(59, 130, 246, 0.3) !important;
}

.chess-piece {
  font-size: clamp(2rem, 8vw, 4rem);
  user-select: none;
  transition: transform 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.chess-piece.selected {
  animation: wobble 0.5s ease-in-out infinite;
}

@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

.shatter-container {
  position: absolute;
  pointer-events: none;
  z-index: 1000;
}

.shatter-particle {
  position: absolute;
  font-size: clamp(1.5rem, 6vw, 3rem);
  pointer-events: none;
  will-change: transform, opacity;
}

.control-panel {
  background-color: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 1rem;
}

.control-btn {
  padding: 0.5rem 1rem;
  background-color: #334155;
  border: 1px solid #475569;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
}

.control-btn:hover:not(:disabled) {
  background-color: #475569;
  transform: translateY(-1px);
}

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

.control-btn.active {
  background-color: #FFD700;
  color: #1e293b;
  border-color: #FFA500;
}

.control-btn-primary {
  padding: 0.75rem 1.5rem;
  background-color: #FFD700;
  border: none;
  border-radius: 6px;
  color: #1e293b;
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.control-btn-primary:hover {
  background-color: #FFA500;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.move-history {
  max-height: 200px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.move-history::-webkit-scrollbar {
  width: 6px;
}

.move-history::-webkit-scrollbar-track {
  background: #0f172a;
  border-radius: 3px;
}

.move-history::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 3px;
}

.move-history::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

@media (max-width: 1024px) {
  .board-container {
    width: min(90vw, 500px);
    height: min(90vw, 500px);
  }
}

@media (max-width: 640px) {
  .chess-piece {
    font-size: clamp(1.5rem, 10vw, 3rem);
  }
  
  .board-container {
    width: 95vw;
    height: 95vw;
  }
}