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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #2c3e50, #34495e);
  color: white;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  max-width: 1200px;
  width: 100%;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 30px;
}

h1 {
  font-size: 2.5rem;
  color: #ecf0f1;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-info {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 20px;
}

.info-item {
  background: rgba(52, 73, 94, 0.8);
  padding: 10px 20px;
  border-radius: 8px;
  border: 2px solid #3498db;
}

.label {
  font-weight: bold;
  color: #3498db;
}

#game-state,
#current-player {
  color: #e74c3c;
  font-weight: bold;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.board-container {
  background: rgba(44, 62, 80, 0.9);
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  margin-bottom: 30px;
}

.column-labels,
.row-labels {
  display: flex;
  align-items: center;
  justify-content: center;
}

.column-labels {
  margin: 5px 0;
}

.column-labels .label,
.row-labels .label {
  width: 60px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #ecf0f1;
  font-size: 1.1rem;
}

.corner {
  width: 30px;
  height: 30px;
}

.board-row {
  display: flex;
  align-items: center;
}

.row-labels {
  flex-direction: column;
  width: 30px;
}

.row-labels .label {
  height: 60px;
  width: 30px;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 60px);
  grid-template-rows: repeat(8, 60px);
  gap: 1px;
  border: 3px solid #34495e;
  border-radius: 8px;
  overflow: hidden;
}

.square {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.square:hover {
  transform: scale(1.05);
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3);
}

.square.light {
  background-color: #f0d9b5;
  color: #333;
}

.square.dark {
  background-color: #b58863;
  color: #333;
}

.square.selected {
  background-color: #ffff99 !important;
  box-shadow: inset 0 0 15px rgba(255, 193, 7, 0.8);
  transform: scale(1.1);
}

.square.valid-move {
  background-color: #90ee90 !important;
  box-shadow: inset 0 0 10px rgba(144, 238, 144, 0.8);
}

.square.invalid-move {
  background-color: #ffb6c1 !important;
  box-shadow: inset 0 0 10px rgba(255, 182, 193, 0.8);
  animation: shake 0.5s ease-in-out;
}

.piece {
  user-select: none;
  pointer-events: none;
}

.controls {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.btn-success {
  background: linear-gradient(45deg, #27ae60, #2ecc71);
  color: white;
}

.btn-success:hover {
  background: linear-gradient(45deg, #229954, #27ae60);
}

.btn-info {
  background: linear-gradient(45deg, #2980b9, #3498db);
  color: white;
}

.btn-info:hover {
  background: linear-gradient(45deg, #21618c, #2980b9);
}

.status-message {
  min-height: 50px;
  padding: 15px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: bold;
  text-align: center;
  transition: all 0.3s ease;
  max-width: 500px;
}

.status-message.success {
  background: linear-gradient(45deg, #27ae60, rgba(46, 204, 113, 0.8));
  color: white;
}

.status-message.error {
  background: linear-gradient(45deg, #e74c3c, rgba(231, 76, 60, 0.8));
  color: white;
}

.status-message.info {
  background: linear-gradient(45deg, #3498db, rgba(52, 152, 219, 0.8));
  color: white;
}

footer {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

/* unvisited */
footer a:link {
  margin-top: 1rem;
  text-decoration: none;
  color: #71b5fc;
}

footer a:visited {
  text-decoration: none;
  color: #5a91ca;
}

footer a:hover {
  text-decoration: underline;
  color: #aad3fd;
}

/* modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
}

.modal-content {
  background: linear-gradient(135deg, #2c3e50, #34495e);
  margin: 5% auto;
  padding: 30px;
  border-radius: 15px;
  width: 80%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  position: relative;
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  position: absolute;
  top: 15px;
  right: 25px;
  transition: color 0.3s ease;
}

.close:hover {
  color: #e74c3c;
}

.rules-content h2 {
  color: #3498db;
  margin-bottom: 20px;
  text-align: center;
}

.rules-content h3 {
  color: #e74c3c;
  margin: 20px 0 10px 0;
}

.rules-content ul,
.rules-content ol {
  margin-left: 20px;
  margin-bottom: 15px;
}

.rules-content li {
  margin-bottom: 8px;
  line-height: 1.5;
}

.rules-content strong {
  color: #f39c12;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  h1 {
    font-size: 2rem;
  }

  .game-info {
    flex-direction: column;
    gap: 10px;
    align-items: center;
  }

  .chess-board {
    grid-template-columns: repeat(8, 45px);
    grid-template-rows: repeat(8, 45px);
  }

  .square {
    width: 45px;
    height: 45px;
    font-size: 1.5rem;
  }

  .column-labels .label,
  .row-labels .label {
    width: 45px;
    height: 25px;
    font-size: 0.9rem;
  }

  .row-labels .label {
    height: 45px;
    width: 25px;
  }

  .controls {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .modal-content {
    width: 95%;
    margin: 10% auto;
    padding: 20px;
  }
}
