body {
  display: flex;
  align-items: center;
  justify-content: center;
  }
.chessBoard {
  width:80vw;
  height: 80vw;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.square {
  width:12.5%;
  height: 12.5%;
  float: left;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}
.white {
  background-color: #f0d9b5;
}
.black {
  background-color: #b58863;
}
.coordinate {
  height:auto;
  display:flex;
  bottom: 4%;
  left:4%;
  position: absolute;
  font-size: 12px;
  font-weight: bold;
  font-family: Verdana, Geneva, Tahoma, sans-serif;
}
.rank {
  top:4%;
  right:4%;
  left:auto;
}
.whiteText {
  color:#f0d9b5;
}
.blackText {
  color:#b58863;
}
.piece {
  width:100%;
  z-index: 1;
  cursor: pointer;
}
.piece img {
  max-width: 100%;
  width:100%;
  height: auto;
}

#alert {
  position: absolute;
  color: whitesmoke;
  width: 50vw;
  height: 12%;
  text-align: center;
  align-content: center;
  justify-content: center;
  font-size: 35px;
  font-weight: bold;
  z-index: 1000;
  display: none; 
  background: #008080bf;
  border-radius: 5px;
  align-items: center;
}

.promotionOption{
  border-radius: 50%;
  background-color: darkgray;
  transition: transform 0.2s;
  position: absolute;
  z-index: 1000;
}
.promotionOption:hover {
  cursor: pointer;
  border-radius: 0%;
  background-color:#539B0C;
  width: 100%;
}
.promotionOption img {
  max-width: 100%;
  width: 100%;
  height: auto;
}

.container{
  display: flex;
  flex-wrap: wrap-reverse;
  align-items: center;
  width: 90%;
}
.buttonContainer{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 10vw;
  margin: 20px 0px 0px 20px;
}
.buttonContainer button {
  width: 150px;
  height: 40px;
  border: none;
  cursor: pointer;
  border-radius: 5px;
  background-color: rgb(87,64,64);
  color: white;
  margin: 10px;
}
.buttonContainer button:hover{
  background-color: #FFFFFF;
  color: #000000;
  border: 1px solid #000000;
}
.buttonContainer select {
  width: 150px;
  height: 40px;
  background-color: whitesmoke;
  border-radius: 10px;
}
div:has(>#levelLabel) {
  margin-bottom: 5px;
}
@media (min-width:600px) {
  .chessBoard {
      width:550px;
      height: 550px;
  }
  #alert {
    width:450px;
    height: 80px;
  }
  .buttonContainer{
    margin: 20px 0px 0px 80px;
  }
  #levelLabel{
    margin-bottom: 5px;
  }
}
@media (max-width:600px) {
  .coordinate {
    font-size: 8px;
  }
  #alert {
    font-size: 20px;
  }
  button {
    font-size: 10px;
  }
  .buttonContainer {
    flex-direction: row;
    align-items: last baseline;
    justify-content: center;
    width: 80vw;
  }
  .buttonContainer button, .buttonContainer select {
    width: 20vw;
    margin-right: 5px;
  }
}



/* Responsive styles */
.chessBoard {
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
}
.chessBoard .square {
  width: 12.5%;
  height: 12.5%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.chessBoard .piece img {
  max-width: 90%;
  height: auto;
}
@media (max-width: 1024px) {
  .chessBoard {
    max-width: 90vw;
  }
  .buttonContainer {
    width: 90vw;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
  .buttonContainer button,
  .buttonContainer select {
    width: 30vw;
    margin: 5px;
  }
}
@media (max-width: 768px) {
  .chessBoard {
    max-width: 100vw;
  }
  .buttonContainer {
    width: 100vw;
    flex-direction: column;
    align-items: center;
  }
  .buttonContainer button,
  .buttonContainer select {
    width: 80vw;
    margin: 8px 0;
  }
}

/* Clamp-based responsive refinement */
.chessBoard {
  width: clamp(300px, 50vw, 600px);
  max-width: 100%;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}
@media (min-width: 768px) and (max-width: 1023px) {
  .chessBoard {
    width: clamp(250px, 70vw, 500px);
  }
}
@media (min-width: 1024px) and (max-width: 1199px) {
  .chessBoard {
    width: clamp(300px, 60vw, 550px);
  }
}
@media (min-width: 1200px) {
  .chessBoard {
    width: 600px;
  }
}
