.chess-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  width: 100%;
  gap: 15px;
  color: #fff;
  padding: 40px 20px;
  box-sizing: border-box;
  overflow-y: auto;
}
.chess-menu h3 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  color: #a29bfe;
  text-shadow: 0 5px 15px rgba(162, 155, 254, 0.4);
}
.chess-btn {
  background: #a29bfe;
  color: #fff;
  border: none;
  padding: 14px 28px;
  border-radius: 24px;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  min-width: 200px;
  box-shadow: 0 6px 0 #6c5ce7, 0 15px 20px rgba(0,0,0,0.2);
}
.chess-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #6c5ce7, 0 5px 10px rgba(0,0,0,0.2);
}
.chess-btn:hover {
  background: #b1aaff;
}
.chess-btn.danger {
  background: #ff7675;
  box-shadow: 0 6px 0 #d63031, 0 15px 20px rgba(0,0,0,0.2);
}
.chess-btn.danger:active {
  box-shadow: 0 2px 0 #d63031, 0 5px 10px rgba(0,0,0,0.2);
}
.chess-input {
  padding: 14px;
  font-size: 1.1rem;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  width: 100%;
  max-width: 300px;
  text-align: center;
}
.chess-controls {
  display: flex;
  gap: 15px;
  margin-top: 20px;
}
.chess-room-code {
  font-size: 2rem;
  color: #00b894;
  letter-spacing: 4px;
  font-weight: 900;
  background: rgba(0,0,0,0.5);
  padding: 10px 20px;
  border-radius: 12px;
  margin: 10px 0;
}

.chess-game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  overflow-y: auto;
}

.chess-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 600px;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.6);
  padding: 15px 20px;
  border-radius: 16px;
  box-sizing: border-box;
}

.chess-status {
  font-size: 1.5rem;
  font-weight: 900;
  color: #fdcb6e;
}
.game-over-glow {
  color: #ff7675;
  text-shadow: 0 0 15px rgba(255, 118, 117, 0.8);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.chess-board-wrapper {
  width: 100%;
  height: auto;
  max-height: min(100%, 75vh);
  max-width: min(100%, 500px);
  aspect-ratio: 1/1;
  background-image: url('../assets/chessboard.jpg');
  background-size: 100% 100%;
  background-position: center;
  padding: 0; /* Changed to 0 so exactly cropped images align perfectly */
  box-sizing: border-box;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  border-radius: 8px;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  container-type: inline-size;
}

.chess-board.flipped {
  transform: rotate(180deg);
}
.chess-board.flipped .chess-piece {
  transform: rotate(180deg);
}

.chess-square {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s, box-shadow 0.2s;
}

.chess-square.light {
  background: transparent;
}

.chess-square.dark {
  background: transparent;
}

.chess-square.selected {
  background: rgba(253, 203, 110, 0.6) !important;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.3);
}

.valid-move {
  cursor: pointer;
}

.move-indicator {
  position: absolute;
  width: 30%;
  height: 30%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 50%;
}

.valid-move:hover .move-indicator {
  background: rgba(0, 0, 0, 0.4);
}

.chess-piece {
  font-size: 10cqw;
  line-height: 1;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4));
  transition: transform 0.2s;
  z-index: 2;
}

.chess-square:hover .chess-piece {
  transform: scale(1.15) translateY(-5px);
  filter: drop-shadow(0 10px 10px rgba(0,0,0,0.5));
}
.chess-board.flipped .chess-square:hover .chess-piece {
  transform: rotate(180deg) scale(1.15) translateY(5px);
}

.white-piece {
  color: #ffffff;
  text-shadow: 0 0 5px rgba(255,255,255,0.5);
}

.black-piece {
  color: #000000;
  text-shadow: 0 0 5px rgba(255,255,255,0.5);
}
