:root {
  --board-length: 400px;
  --board-squares: 8;

  overflow: hidden;
  position: absolute;
  top:0;
  right: 0;
  bottom: 0;
  left: 0;
  max-width: 100vw;
  max-height: 100vh;
}

* {
  box-sizing: border-box;
}

.slide {
  transition: transform .1s;
}

html {
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -o-user-select: none;
  user-select: none;
}

body {
  touch-action: manipulation;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

#board {
  touch-action: none;
  position: absolute;
  background-image: url("../graphics/chessboard.png");
  background-repeat: no-repeat;
  background-size: cover;
  width: var(--board-length);
  height: var(--board-length);
}

.flipped {
  transform: rotate(180deg);
}

#board.flipped .pieceImage {
  transform: rotate(180deg);
}

.piece {
  z-index: 1; /* To be above highlights. */
  cursor: grab;
  position: absolute;
}

.pieceImage {
  background-repeat: no-repeat;
  background-size: cover;
  width: calc(var(--board-length) / var(--board-squares));
  height: calc(var(--board-length) / var(--board-squares));
}

.dragging {
  z-index: 3; /* To be above pieces and markers. */
  cursor: grabbing;
  touch-action: none;
}

.highlight {
  z-index: 0; /* To be below pieces. */
  position: absolute;
  background-color: yellow;
  opacity: .5;
  width: calc(var(--board-length) / 8);
  height: calc(var(--board-length) / 8);
}

.move-marker {
  z-index: 2; /* To be above pieces. */
  position: absolute;
  background-clip: content-box;
  background-color: black;
  opacity: .4;
  border-radius: 50%;
  padding: calc(var(--board-length) / 24);
  width: calc(var(--board-length) / 8);
  height: calc(var(--board-length) / 8);
}

.capture-marker {
  z-index: 2; /* To be above move pieces. */
  position: absolute;
  border: calc(var(--board-length) / 64) solid black;
  opacity: .4;
  border-radius: 50%;
  width: calc(var(--board-length) / 8);
  height: calc(var(--board-length) / 8);
}

#promotion-window {
  z-index: 4; /* To be above draggeed pieces. */
  display: none;
  position: absolute;
  flex-direction: column;
  border: 1px solid black;
  box-shadow: 5px 5px;
}

.promotion-option {
  background-color: white;
  cursor: pointer;
  width: calc(var(--board-length) / 8);
  height: calc(var(--board-length) / 8);
}

#game-over-modal {
  z-index: 5; /* To be above everything. */
  position: absolute;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: white;
  border: 1px solid black;
  padding: 10px;
}

#rematch-button {
  cursor: pointer;
  background-color: gainsboro;
  border-radius: 5px;
  margin-top: 15px;
}

#rematch-button:hover {
  background-color: dimgrey;
}
