@font-face {
  font-family: chess;
  src: url("https://cdn.jsdelivr.net/gh/joshwalters/open-chess-font@master/OpenChessFont.ttf");
}

.chessboard-container {
  position: relative;
}

.chessboard {
  display: grid;
  place-items: center;
  width: min(100%, 675px);
  margin: 0 auto;
  overflow: hidden;

  ul {
    display: grid;
    margin: 0;
    width: 100%;
    grid-template-columns: 1fr;
    border: 2px solid var(--border-color);
    box-sizing: border-box;
  }

  .rank {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    margin: 0;
    width: 100%;
  }

  li {
    list-style: none;
    display: grid;
    place-items: center;
    border: none;
  }

  .square {
    width: 100%;
    padding: 0;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 0;
  }

  .piece {
    margin: 0;
    width: 95%;
    height: 95%;
    object-fit: contain;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
  }

  .lightsquare {
    background-color: #ffce9e;
  }

  .darksquare {
    background-color: #d18b47;
  }

  .movable,
  .castleable {
    position: relative;
  }

  .movable.empty::after,
  .castleable::after {
    content: '';
    display: inline-block;
    width: 33%;
    height: 33%;
    background-color: rgba(0, 128, 0, 0.5);
    border-radius: 50%;
    vertical-align: middle;
  }
  
  .movable.notempty {
    box-shadow: inset 0 0 0 0.25em rgba(0, 128, 0, 0.5);
  }

  .checked img {
    filter: drop-shadow(0 0 0.75em rgba(255, 0, 0, 1));
  }

  .selected {
    background-color: rgba(0, 128, 0, 0.5);
  }
}

.chessboard.blocked {
  filter: brightness(50%);
  pointer-events: none;
}

.promotion {
  position: absolute;
  inset: 0;
  width: calc(min(100%, 675px) / 2);
  margin: 0 auto 5px auto;
  display: none;

  ul {
    display: grid;
    margin: 0;
    width: 100%;
    grid-template-columns: 1fr;
    border: 2px solid var(--border-color);
    box-sizing: border-box;
  }

  .rank {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0;
    height: 100%;
  }

  li {
    list-style: none;
    display: grid;
    place-items: center;
    border: none;
  }

  .square {
    width: 100%;
    padding: 0;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 0;
    background-color: #e8ac72;
  }

  .piece {
    margin: 0;
    width: 95%;
    height: 95%;
    object-fit: contain;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
  }
}

.promotion.visible {
  display: grid;
  place-items: center;
  overflow: hidden;
}