/* chess.css -- styles specific to chess.html. Loaded in addition to
   style.css so the rest of the site is untouched. */

.chess-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  padding: 20px 20px 60px 20px;
}

.board-shell {
  display: grid;
  grid-template-columns: 24px auto;
  grid-template-rows: auto 14px;
  align-items: stretch;
  background: #f6dfa1;
  border-radius: 6px;
  overflow: hidden;
  color: #222;
  font-family: "Trebuchet MS", sans-serif;
  font-size: 13px;
  font-weight: bold;
}

.board-stage {
  grid-column: 2;
  grid-row: 1;
}

.rank-labels,
.file-labels {
  display: flex;
  align-items: center;
  justify-content: space-around;
  color: #3a2412;
  text-shadow: none;
}

.rank-labels {
  grid-column: 1;
  grid-row: 1;
  flex-direction: column;
  padding: 8px 0;
}

.file-labels {
  flex-direction: row;
  height: 14px;
  margin: 0 8px;
  line-height: 1;
}

.file-labels span {
  width: 64px;
  text-align: center;
}

.board-shell.flipped {
  grid-template-columns: auto 24px;
}

.board-shell.flipped .board-stage {
  grid-column: 1;
}

.board-shell.flipped .rank-labels {
  grid-column: 2;
  flex-direction: column-reverse;
}

.board-shell.flipped .file-labels {
  flex-direction: row-reverse;
}

#board {
  display: grid;
  grid-template-columns: repeat(8, 64px);
  grid-template-rows: repeat(8, 64px);
  border: 8px solid #8a5a2b;
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  transform: rotate(0deg);
  user-select: none;
}

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

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

.square {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  line-height: 1;
  cursor: pointer;
  position: relative;
}

.piece-glyph[draggable="true"] {
  cursor: grab;
}

.piece-glyph[draggable="true"]:active {
  cursor: grabbing;
}

.square.light {
  background: #ffdb72;
}

.square.dark {
  background: #8a5a2b;
}

.piece-glyph {
  display: inline-block;
  line-height: 1;
}

.square.white-piece .piece-glyph {
  color: #fefefe;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}

.square.black-piece .piece-glyph {
  color: #111111;
  text-shadow: 0 0 2px #fff;
}

.square.selected {
  box-shadow: none;
}

.square.selected.white-piece {
  text-shadow: none;
}

.square.selected.black-piece {
  text-shadow: none;
}

.square.selected.white-piece .piece-glyph {
  text-shadow: 0 0 2px #000, 0 0 5px #d62828, 0 0 10px rgba(214, 40, 40, 0.85);
}

.square.selected.black-piece .piece-glyph {
  text-shadow: 0 0 2px #fff, 0 0 5px #d62828, 0 0 10px rgba(214, 40, 40, 0.85);
}

.square.legal-target::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(214, 40, 40, 0.65);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.chess-sidebar {
  background: #252525;
  border: 1px solid #333333;
  border-radius: 10px;
  padding: 20px;
  min-width: 240px;
  color: white;
  font-family: "Trebuchet MS", sans-serif;
}

.chess-sidebar h3 {
  margin-top: 0;
  font-family: "Playwrite US Modern", sans-serif;
  font-size: 22px;
}

.chess-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.chess-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.chess-controls select {
  padding: 6px;
  border-radius: 6px;
  border: none;
}

#new-game {
  background: linear-gradient(#007acc, #0065a9);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 15px;
  font-family: "Trebuchet MS", sans-serif;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

#new-game:hover {
  background: linear-gradient(white, lightgrey);
  color: black;
  transform: scale(1.03);
}

#status {
  font-weight: bold;
  min-height: 1.4em;
  margin-bottom: 12px;
}

#move-history {
  list-style: none;
  padding-left: 0;
  max-height: 300px;
  overflow-y: auto;
  font-size: 14px;
  counter-reset: moves;
}

#move-history li {
  counter-increment: moves;
  display: grid;
  grid-template-columns: 30px 1fr;
  column-gap: 8px;
}

#move-history li::before {
  content: counter(moves) ".";
  text-align: left;
}

.chess-note {
  font-size: 13px;
  color: #aaaaaa;
  margin-top: 16px;
}

@media (max-width: 600px) {
  #board {
    grid-template-columns: repeat(8, 40px);
    grid-template-rows: repeat(8, 40px);
  }

  .square {
    width: 40px;
    height: 40px;
    font-size: 28px;
  }

  .file-labels {
    margin: 0 4px;
  }

  .file-labels span {
    width: 40px;
  }

  .board-shell {
    grid-template-columns: 18px auto;
    grid-template-rows: auto 12px;
    font-size: 10px;
  }

  .board-shell.flipped {
    grid-template-columns: auto 18px;
  }

  .file-labels {
    height: 12px;
  }
}