.chess-table {
  --chess-paper: #fff0d5;
  --chess-muted: #d2decf;
  --chess-accent: #f1c47b;
  --chess-spot: #113a35;
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(240px, .9fr);
  gap: clamp(20px, 4vw, 54px);
  align-items: start;
  margin-top: 24px;
  padding: clamp(14px, 3vw, 32px);
  border-radius: 15px;
  background: radial-gradient(ellipse at 22% 17%, #305749, #172e2e 78%);
  color: var(--chess-paper);
}
.chess-table[hidden],
.chess-table [hidden] {
  display: none;
}
.chess-board-area {
  min-width: 0;
}
.chess-board {
  display: grid;
  aspect-ratio: 1;
  width: 100%;
  grid-template-rows: repeat(8, minmax(0, 1fr));
  outline: 1px solid #97754d;
  border: clamp(5px, 1vw, 11px) solid #262e28;
  border-radius: 7px;
  box-shadow: 0 5px 0 #182424, 0 10px 20px #11191b8a;
  overflow: hidden;
}
.chess-rank {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
}
.chess-cell {
  min-width: 0;
  min-height: 0;
}
.chess-square {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #dfc39a;
  color: #342a20;
  touch-action: manipulation;
  isolation: isolate;
}
.chess-square[data-dark="true"] {
  background: #699083;
  color: #101e1b;
}
.chess-square[data-last="true"] {
  background-image: linear-gradient(#edb95369, #edb95369);
}
.chess-square[data-check="true"] {
  background-image: radial-gradient(ellipse at center, #b6403f 23%, #d66954 64%, transparent 96%);
}
.chess-square[data-selected="true"] {
  box-shadow: inset 0 0 0 3px #123b38, inset 0 0 0 5px #fff2a9;
}
.chess-square[data-playable="true"],
.chess-square[data-target]:not([data-target=""]) {
  cursor: pointer;
}
.chess-square[data-target="move"]::after {
  position: absolute;
  width: 23%;
  aspect-ratio: 1;
  border: 1px solid #f9db9f;
  border-radius: 50%;
  background: var(--chess-spot);
  content: '';
}
.chess-square[data-target="capture"]::after {
  position: absolute;
  width: 81%;
  aspect-ratio: 1;
  border: clamp(2px, .33vw, 4px) dashed #193b34;
  border-radius: 50%;
  content: '';
}
.chess-square:focus-visible {
  z-index: 1;
  outline: 3px solid #fff0b0;
  outline-offset: -5px;
  box-shadow: inset 0 0 0 7px #192c2a;
}
.chess-square-piece {
  display: grid;
  width: 84%;
  aspect-ratio: 1;
  place-items: center;
  pointer-events: none;
}
.chess-piece {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 2px 1px #111b1a63);
}
.chess-piece g {
  stroke-width: 2.3;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chess-piece-w g {
  fill: #fff2d5;
  stroke: #694c37;
}
.chess-piece-b g {
  fill: #243b3d;
  stroke: #c2ab80;
}
.chess-notation {
  position: absolute;
  color: inherit;
  font: 800 clamp(.49rem, 1.4vw, .75rem)/1 var(--sans, sans-serif);
  pointer-events: none;
}
.chess-notation-rank {
  top: 3px;
  left: 4px;
}
.chess-notation-file {
  right: 4px;
  bottom: 2px;
}
.chess-board-note {
  margin: 16px 0 0;
  color: var(--chess-muted);
  font-size: .83rem;
}
.chess-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.chess-readout {
  min-height: 106px;
  padding: 13px 17px;
  border: 1px solid #c7b98666;
  border-radius: 11px;
  background: #132b2b80;
}
.chess-readout h2,
.chess-promotion h2 {
  margin: 0 0 4px;
  color: var(--chess-paper);
  font-size: clamp(1.5rem, 2.7vw, 2.4rem);
  line-height: 1.1;
}
.chess-readout p,
.chess-history p {
  margin: 0;
  color: var(--chess-muted);
}
.chess-settings {
  display: grid;
  gap: 11px;
}
.chess-settings label {
  display: grid;
  gap: 4px;
  font-weight: 650;
}
.chess-settings select {
  width: 100%;
  min-height: 43px;
  padding: 7px 12px;
  border: 1px solid #bfb389;
  border-radius: 8px;
  background: #fdf1d8;
  color: #253538;
  font: inherit;
}
.chess-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.chess-actions .btn {
  min-height: 43px;
}
.chess-actions .btn:disabled {
  opacity: .55;
  cursor: default;
}
.chess-history {
  min-width: 0;
  border-top: 1px solid #aeb9a36b;
  padding-top: 13px;
}
.chess-history h3 {
  margin: 0 0 5px;
  color: var(--chess-paper);
  font-size: 1rem;
}
.chess-log {
  max-height: 9.4rem;
  overflow: auto;
}
.chess-log table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.chess-log thead {
  position: sticky;
  top: 0;
  background: #253d36;
  color: var(--chess-muted);
}
.chess-log td,
.chess-log th {
  border-bottom: 1px solid #aeb9a345;
  padding: 3px 6px;
}
.chess-promotion {
  width: min(445px, calc(100% - 24px));
  padding: clamp(14px, 4vw, 24px);
  border: 1px solid #c2ab80;
  border-radius: 12px;
  background: #223d39;
  color: var(--chess-paper);
}
.chess-promotion::backdrop {
  background: #102523bb;
}
.chess-promotion p {
  margin: 0 0 12px;
}
.chess-promotion-choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 15px;
}
.chess-promotion-choices button {
  min-width: 0;
  padding: 4px 1px 6px;
  border: 1px solid #b19367;
  border-radius: 7px;
  background: #e6cda7;
  color: #261e17;
  font: 650 clamp(.7rem, 2vw, .9rem)/1.2 var(--sans, sans-serif);
  text-transform: capitalize;
  cursor: pointer;
}
.chess-promotion-choices button:hover,
.chess-promotion-choices button:focus-visible {
  outline: 2px solid #f6dd9c;
  outline-offset: 2px;
}
.chess-promotion-choices svg {
  width: 80%;
  height: auto;
  margin: auto;
}
.chess-rules {
  margin-top: 24px;
  padding: 14px 18px;
  border: 1px solid currentColor;
  border-radius: 10px;
}
.chess-rules summary {
  font-weight: 700;
  cursor: pointer;
}
.chess-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (max-width: 740px) {
  .chess-table {
    grid-template-columns: minmax(0, 1fr);
  }
  .chess-panel {
    gap: 13px;
  }
  .chess-readout {
    min-height: 72px;
  }
  .chess-settings {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  }
}
@media (prefers-contrast: more) {
  .chess-square[data-dark="true"] {
    background-color: #52796a;
  }
  .chess-square[data-dark="true"] .chess-notation {
    color: #fff1da;
  }
}
