.chess-container {
  max-width: 980px;
}

.chess-status {
  align-items: center;
  color: var(--text);
  display: flex;
  font-size: 1rem;
  font-weight: 800;
  min-height: 2.6rem;
  padding: .45rem .65rem;
}

.chess-board {
  aspect-ratio: 1;
  border: clamp(6px, 1.2vw, 12px) solid var(--surface-elevated);
  border-radius: 10px;
  box-shadow: var(--shadow-raised);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  margin: 0 auto;
  max-width: min(76vh, 720px, 100%);
  overflow: hidden;
  touch-action: manipulation;
  width: 100%;
}

.chess-square {
  align-items: center;
  aspect-ratio: 1;
  border: 0;
  color: var(--accent-ink);
  cursor: pointer;
  display: flex;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  padding: 0;
  position: relative;
  touch-action: manipulation;
}

.chess-square.light {
  background: #d8b77a;
}

.chess-square.dark {
  background: #7b4e35;
}

.chess-square.last-move::before {
  background: rgba(242, 187, 104, .38);
  content: '';
  inset: 0;
  position: absolute;
}

.chess-square.selected {
  box-shadow: inset 0 0 0 clamp(3px, .7vw, 6px) var(--accent-hover);
  z-index: 1;
}

.chess-square.legal-move::after {
  background: rgba(23, 21, 18, .45);
  border-radius: 50%;
  content: '';
  height: 24%;
  position: absolute;
  width: 24%;
}

.chess-square.legal-capture::after {
  border: clamp(4px, .8vw, 8px) solid rgba(23, 21, 18, .45);
  border-radius: 50%;
  content: '';
  inset: 5%;
  position: absolute;
}

.chess-square.in-check {
  background: var(--danger);
}

.chess-piece {
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Arial Unicode MS", serif;
  font-size: clamp(2rem, 8.2vw, 4.65rem);
  font-style: normal;
  font-synthesis: none;
  font-weight: 400;
  line-height: 1;
  pointer-events: none;
  position: relative;
  transform: translateY(-2%);
  z-index: 1;
}

.white-piece {
  color: #fff8e8;
  filter: drop-shadow(0 2px 1px rgba(15, 14, 12, .85));
}

.black-piece {
  color: #211c18;
  filter: drop-shadow(0 1px 0 rgba(255, 248, 232, .45));
}

.file-label,
.rank-label {
  bottom: 1px;
  font-size: clamp(.52rem, 1.5vw, .78rem);
  font-weight: 900;
  opacity: .8;
  pointer-events: none;
  position: absolute;
  right: 3px;
  text-transform: uppercase;
}

.rank-label {
  bottom: auto;
  left: 3px;
  right: auto;
  top: 1px;
}

.promotion-dialog {
  align-items: center;
  background: rgba(15, 14, 12, .84);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 1rem;
  position: fixed;
  z-index: 1000;
}

.promotion-dialog[hidden] {
  display: none;
}

.promotion-panel {
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-raised);
  max-width: 26rem;
  padding: 1.4rem;
  text-align: center;
  width: 100%;
}

.promotion-panel h2 {
  color: var(--accent);
  font-size: 1.35rem;
  margin-bottom: 1rem;
}

.promotion-choices {
  display: grid;
  gap: .6rem;
  grid-template-columns: repeat(4, 1fr);
}

.promotion-choice {
  align-items: center;
  background: #d8b77a;
  border: 2px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Arial Unicode MS", serif;
  font-size: clamp(2.5rem, 12vw, 4rem);
  font-style: normal;
  font-synthesis: none;
  font-weight: 400;
  justify-content: center;
  min-height: 64px;
}

.promotion-choice:hover {
  border-color: var(--accent-hover);
}

@media (max-width: 480px) {
  .chess-container {
    padding-inline: .5rem;
  }

  .chess-board {
    border-width: 4px;
  }

  .chess-piece {
    font-size: clamp(1.9rem, 10.7vw, 3.25rem);
  }

  .chess-status {
    padding-inline: .2rem;
  }
}
