.chess-page {
  background:
    radial-gradient(circle at 18% 14%, rgba(255, 208, 76, 0.18), transparent 24%),
    radial-gradient(circle at 82% 20%, rgba(88, 184, 255, 0.18), transparent 26%),
    linear-gradient(135deg, #101820 0%, #19302b 47%, #241820 100%);
}

.chess-layout {
  grid-template-columns: minmax(240px, 0.72fr) minmax(440px, 1.34fr) minmax(240px, 0.72fr);
}

.chess-side-panel .arcade-button {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
}

.chess-score-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chess-score-grid .arcade-stat strong {
  font-size: clamp(18px, 2.2vw, 26px);
}

.chess-stage {
  background:
    linear-gradient(180deg, rgba(250, 252, 247, 0.98), rgba(227, 238, 232, 0.98));
  min-width: 0;
}

.chess-table {
  align-items: center;
  display: grid;
  gap: 12px;
  justify-items: center;
  min-height: 100%;
}

.chess-board {
  aspect-ratio: 1;
  background: #151a20;
  border: 8px solid #151a20;
  border-radius: 8px;
  box-shadow: 0 22px 54px rgba(4, 9, 14, 0.34);
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  max-width: min(72vh, 100%);
  overflow: hidden;
  position: relative;
  width: min(100%, 680px);
}

.chess-square {
  align-items: center;
  border: 0;
  color: #101820;
  cursor: pointer;
  display: flex;
  justify-content: center;
  line-height: 1;
  min-height: 0;
  padding: 0;
  position: relative;
}

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

.chess-square.dark {
  background: #5e8f6f;
}

.chess-square.selected {
  box-shadow: inset 0 0 0 5px #ffd04c;
}

.chess-square.last-move {
  background-image: linear-gradient(0deg, rgba(255, 208, 76, 0.36), rgba(255, 208, 76, 0.36));
}

.chess-square.legal::after,
.chess-square.capture::after {
  border-radius: 999px;
  content: "";
  height: 24%;
  position: absolute;
  width: 24%;
}

.chess-square.legal::after {
  background: rgba(17, 24, 33, 0.34);
}

.chess-square.capture::after {
  border: 5px solid rgba(255, 75, 86, 0.78);
  height: 76%;
  width: 76%;
}

.chess-square small {
  bottom: 4px;
  color: rgba(16, 24, 32, 0.7);
  font-family: Arial, sans-serif;
  font-size: 10px;
  font-weight: 900;
  left: 5px;
  position: absolute;
  text-transform: uppercase;
}

.chess-piece {
  align-items: center;
  display: flex;
  height: 92%;
  justify-content: center;
  pointer-events: none;
  position: relative;
  width: 92%;
  z-index: 1;
}

.chess-piece-svg {
  display: block;
  filter: drop-shadow(0 9px 7px rgba(0, 0, 0, 0.28));
  height: 100%;
  overflow: visible;
  width: 100%;
}

.chess-piece-white {
  --piece-main: #f8efe0;
  --piece-side: #d7c09a;
  --piece-highlight: rgba(255, 255, 255, 0.72);
  --piece-shade: rgba(124, 96, 60, 0.26);
  --piece-stroke: rgba(92, 68, 42, 0.72);
  --piece-ground: rgba(43, 28, 18, 0.28);
}

.chess-piece-black {
  --piece-main: #202733;
  --piece-side: #0d1219;
  --piece-highlight: rgba(130, 151, 173, 0.35);
  --piece-shade: rgba(0, 0, 0, 0.34);
  --piece-stroke: rgba(243, 225, 191, 0.32);
  --piece-ground: rgba(0, 0, 0, 0.34);
}

.piece-main,
.piece-side,
.piece-highlight,
.piece-shade,
.piece-cut,
.piece-stroke,
.piece-outline,
.piece-stroke-fill,
.piece-ground {
  vector-effect: non-scaling-stroke;
}

.piece-main {
  fill: var(--piece-main);
  stroke: var(--piece-stroke);
  stroke-linejoin: round;
  stroke-width: 2.6;
}

.piece-side {
  fill: var(--piece-side);
  stroke: var(--piece-stroke);
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.piece-highlight {
  fill: var(--piece-highlight);
}

.piece-shade {
  fill: var(--piece-shade);
}

.piece-cut,
.piece-stroke,
.piece-outline {
  fill: none;
  stroke: var(--piece-stroke);
  stroke-linecap: round;
}

.piece-cut {
  stroke-width: 5;
}

.piece-stroke {
  stroke-width: 4;
}

.piece-outline {
  stroke-width: 3.2;
}

.piece-stroke-fill {
  fill: var(--piece-stroke);
}

.piece-ground {
  fill: var(--piece-ground);
}

.captured-row {
  align-items: center;
  background: rgba(17, 24, 33, 0.08);
  border: 2px solid rgba(17, 24, 33, 0.1);
  border-radius: 8px;
  color: #151a20;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  min-height: 42px;
  padding: 5px 10px;
  width: min(100%, 680px);
}

.captured-piece {
  display: inline-flex;
  height: 30px;
  width: 26px;
}

.captured-piece .chess-piece-svg {
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.22));
}

.promotion-dialog {
  align-items: center;
  background: rgba(8, 12, 16, 0.54);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: absolute;
  z-index: 5;
}

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

.promotion-dialog > div {
  background: #fff;
  border: 4px solid #ffd04c;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  color: #172017;
  display: grid;
  gap: 14px;
  max-width: 340px;
  padding: 18px;
  text-align: center;
  width: min(100%, 340px);
}

.promotion-dialog strong {
  font-size: 24px;
}

.promotion-choices {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.promotion-choices button {
  align-items: center;
  aspect-ratio: 1;
  background: linear-gradient(180deg, #fff9ec, #e6f0e8);
  border: 2px solid #cddbd1;
  border-radius: 8px;
  color: #111821;
  cursor: pointer;
  display: flex;
  justify-content: center;
  padding: 4px;
}

.promotion-choices button .chess-piece-svg {
  filter: drop-shadow(0 5px 4px rgba(0, 0, 0, 0.24));
}

.move-panel {
  background: #fff;
  border: 2px solid #dde7df;
  border-radius: 8px;
  overflow: hidden;
}

.move-panel-head {
  align-items: center;
  background: #14202a;
  color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
}

.move-panel-head span {
  background: #ffd04c;
  border-radius: 999px;
  color: #172017;
  font-weight: 900;
  min-width: 34px;
  padding: 4px 8px;
  text-align: center;
}

.move-list {
  display: grid;
  gap: 4px;
  margin: 0;
  max-height: 320px;
  overflow: auto;
  padding: 12px 12px 12px 34px;
}

.move-list li {
  color: #172017;
  font-weight: 900;
  line-height: 1.35;
  padding-left: 4px;
}

.move-pair {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.move-pair span {
  background: #eef5ea;
  border-radius: 6px;
  min-height: 30px;
  padding: 6px 8px;
}

@media (max-width: 1040px) {
  .chess-layout {
    grid-template-columns: 1fr;
  }

  .chess-board {
    max-width: min(92vw, 680px);
  }
}

@media (max-width: 620px) {
  .chess-board {
    border-width: 5px;
    width: min(100%, 94vw);
  }

  .chess-square {
    min-height: 0;
  }

  .chess-square small {
    display: none;
  }

  .captured-row {
    width: min(100%, 94vw);
  }
}
