* {
  margin: 0;
  padding: 0;
}

body {
  /* disables double tap zoom on ios */
  touch-action: manipulation;
}

button {
  padding: 1em;
  outline: none;
  background-color: green;
  color: white;
  border: none;
  cursor: pointer;
}
button:disabled {
  background-color: grey;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  min-height: 80vh;
}

.WHITE {
  background-color: white;
}

.BLACK {
  background-color: rgb(57, 128, 66);
}

.valid-spot {
  position: relative;
}

.valid-spot::after {
  content: "";
  position: absolute;
  width: calc(var(--block-width) / 2);
  height: calc(var(--block-height) / 2);
  background-color: rgba(7, 2, 46, 0.6);
  border-radius: 50%;
}

.layout-split {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2em;
}
.game-container {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.player-display {
  font-size: 1.5em;
  margin-inline-start: 50px;
}
.player-display .pieces-taken {
  line-height: 1.5;
  min-height: 1.5em;
}
.board-container {
  --block-width: 50px;
  --block-height: 50px;


  display: grid;

  grid-template-areas:
    "ranks board"
    "ranks board"
    "empty files";
  grid-template-rows: var(--block-width) auto;
  transition: transform 0.5s linear;
}

.board {
  /* --num-of-rows: 3; */
  grid-area: board;

  position: relative;

  --num-of-columns: 8;
  font-size: 1.2rem;

  display: grid;
  grid-template-columns: repeat(var(--num-of-columns), auto);

  border: 2px solid black;
}

.ranks-container {
  grid-area: ranks;
}

.files-container {
  grid-area: files;
  display: flex;
  flex-direction: row;
}

.ranks-container .rank,
.files-container .file {
  width: var(--block-width);
  height: var(--block-height);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.ranks-container .rank {
  border-radius: 1rem 0 0 1rem;
}
.files-container .file {
  border-radius: 0 0 1rem 1rem;
}
.rank.highlighted,
.file.highlighted {
  /* background-color: rgb(102, 102, 102); */
}

.board-container.flipped {
  transform: rotateX(180deg);
}

.board-container.flipped .block {
  transform: rotateX(180deg);
}

.board .block {
  --rotation: 0deg;
  position: relative;
  display: flex;

  width: var(--block-width);
  height: var(--block-height);

  margin: 0;
  padding: 0;

  font-weight: 500;

  align-items: center;
  justify-content: center;
  font-size: 2em;
  cursor: pointer;

  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.block .fade-in-element {
  all: inherit;
  position: absolute;
  width: 100%;
  height: 100%;
}

.modal-container {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  padding: 0;

  width: 100%;
  height: 100%;
  color: white;

  pointer-events: none;
}

.modal-container .modal {
  padding: 0.5em 1em;
  position: relative;
  background-color: black;
  border-radius: 0.5rem;

  pointer-events: all;

  display: none;

  font-size: 2.5rem;
}

.modal h5 {
  text-align: center;
}

.modal .top {
  padding: 0.3em 0.5em;
}

.top .modal-close {
  position: absolute;
  top: 0.15em;
  right: 0.15em;
  padding: 0.3em;
  font-size: 0.8em;
  border-radius: 0.2em;
  background-color: rgba(172, 185, 150, 0.521);
  cursor: pointer;
}

.modal .display {
  text-align: center;
  position: relative;

  -webkit-user-select: none; /* Safari */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* IE10+/Edge */
  user-select: none; /* Standard */
}

.modal .display.win {
  font-size: 5em;
}

.modal .display.win .avatar {
  background-color: rgb(26, 171, 26);

  display: flex;
  align-items: center;
  justify-content: center;

  width: 15rem;
  height: 15rem;
  border-radius: 50%;
}

.modal .display.stalemate {
  font-size: 3em;
}

.modal .display.stalemate .avatar {
  margin: 0;
  padding: 0;
  display: inline-block;
}

.modal .display.stalemate :nth-child(1) {
  transform: rotate(-45deg);
}

.modal .display.stalemate :nth-child(2) {
  transform: rotate(45deg);
}

.avatar.win-black {
  color: black;
}

.avatar.win-white {
  color: white;
}

.block.incheck {
  color: red;
  /* background-color: rgb(241, 91, 91); */
}

.block.animation-block {
  --rotation: 0deg;
  position: absolute;
  top: var(--from-row);
  left: var(--from-col);
}

.block.animation-block.flipped {
  --rotation: 180deg;
}

.promotion-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 50%;
  transform: translate(50%, 50%);

  background-color: #000000;
  color: white;
  display: grid;
  grid-template-columns: repeat(2, 50%);
  justify-items: center;
  align-items: center;
}
.promotion-modal-item {
  font-size: 6rem;
  cursor: pointer;
}

@media only screen and (max-width: 600px) {
  .board-container {
    --block-width: 45px;
    --block-height: 45px;
  }
}

@media only screen and (max-width: 500px) {
  .board-container {
    --block-width: 40px;
    --block-height: 40px;
  }
}

@media only screen and (max-width: 400px) {
  .ranks-container,
  .files-container {
    display: none;
  }

  .player-display {
    margin-inline-start: 0;
  }
  .modal .display.stalemate {
    font-size: 2em;
  }
}

@keyframes animate-move {
  0% {
    top: var(--from-row);
    left: var(--from-col);
    transform: rotate3d(1, 0, 0, var(--rotation)) scale(1);
  }

  20% {
    top: var(--from-row);
    left: var(--from-col);
    transform: rotate3d(1, 0, 0, var(--rotation)) scale(1.5);
  }

  80% {
    top: var(--to-row);
    left: var(--to-col);
    transform: rotate3d(1, 0, 0, var(--rotation)) scale(1.5);
  }

  100% {
    top: var(--to-row);
    left: var(--to-col);
    transform: rotate3d(1, 0, 0, var(--rotation)) scale(1);
  }
}

@keyframes zoom-in {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

@keyframes zoom-out {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(0);
  }
}
