.chess-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  justify-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 4px 0 0;
}

.board-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.turn-pill {
  border-color: rgba(197, 163, 91, 0.72);
  color: #9f7b39;
  background: rgba(255, 251, 239, 0.96);
  font-size: 11px;
  min-height: 30px;
  padding: 0 10px;
  white-space: nowrap;
}

.turn-pill--your-turn {
  color: var(--green);
}

.turn-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

.status-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.capture-rail,
.control-row--board,
.history-dock {
  width: 100%;
  max-width: min(540px, 100%);
  margin-inline: auto;
}

.board-wrap {
  width: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  container-type: size;
}

.captured-strip,
.captured-icons {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-height: 16px;
}

.capture-rail__label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.captured-placeholder {
  width: 1px;
  height: 1px;
  opacity: 0;
}

.board-surface {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(129, 106, 77, 0.2);
  border-radius: 16px;
  background: rgba(255, 252, 246, 0.7);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

chess-board {
  display: block;
  width: min(100cqi, 100cqb);
  height: min(100cqi, 100cqb);
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 16px;
  --light-color: var(--board-light);
  --dark-color: var(--board-dark);
  --highlight-color: rgba(92, 138, 103, 0.28);
  --check-color: rgba(211, 102, 80, 0.36);
  --coord-color: rgba(47, 38, 29, 0.42);
}

chess-board::part(board) {
  border: 0;
  border-radius: 16px;
  box-shadow: none;
}

.move-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.move-marker {
  position: absolute;
  width: 12.5%;
  aspect-ratio: 1;
}

.move-marker::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.move-marker--quiet::before {
  width: 16%;
  height: 16%;
  border-radius: 999px;
  background: rgba(121, 141, 110, 0.38);
}

.move-marker--capture::before {
  width: 50%;
  height: 50%;
  border-radius: 999px;
  border: 2px solid rgba(211, 102, 80, 0.42);
}

.move-marker--selected::before {
  inset: 10%;
  left: auto;
  top: auto;
  transform: none;
  border-radius: 12px;
  border: 2px solid rgba(197, 163, 91, 0.6);
  background: rgba(250, 241, 214, 0.22);
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.control-row--board {
  justify-content: center;
  margin-top: 6px;
}

.control-row--board button {
  min-height: 34px;
  padding: 0 13px;
  border-radius: 11px;
  font-size: 12px;
  gap: 6px;
}

.control-row--board button::before {
  font-size: 12px;
  line-height: 1;
}

.control-row--board button[data-icon="flip"]::before {
  content: "<>";
  font-size: 11px;
}

.control-row--board button[data-icon="draw"]::before {
  content: "=";
}

.control-row--board button[data-icon="takeback"]::before {
  content: "<";
}

.control-row--board button[data-icon="resign"]::before {
  content: "!";
}

.control-row--board button[data-icon="new"]::before {
  content: "+";
}

.control-row--board button[data-icon="accept"]::before {
  content: "+";
}

.control-row--board button[data-icon="decline"]::before {
  content: "x";
}

.history-dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-dock-toggle {
  min-height: 34px;
  padding: 0 13px;
  border-radius: 999px;
}

.move-list {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.move-list-item {
  display: grid;
  grid-template-columns: 34px 1fr 1fr;
  align-items: center;
  min-height: 38px;
}

.move-list-item:nth-child(even) {
  background: rgba(232, 224, 212, 0.72);
}

.move-list-item:last-child {
  border-bottom: 0;
}

.move-list__number {
  padding: 0 10px;
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.move-list__move {
  justify-content: flex-start;
  min-height: 38px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
}

.move-list__move:hover:not(:disabled) {
  background: rgba(243, 234, 221, 0.88);
}

.move-list__move.is-active {
  color: #5a8a67;
  background: rgba(92, 138, 103, 0.14);
}

.move-list__move--placeholder {
  pointer-events: none;
  color: var(--text-faint);
}

.empty-history {
  display: grid;
  place-items: center;
  min-height: clamp(180px, 32vh, 340px);
  margin: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdfa;
  color: var(--text-soft);
}

.history-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(102, 82, 56, 0.12);
}

.history-nav button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 10px;
  background: var(--surface-soft);
}

.mobile-history-bar {
  display: none;
}

.mobile-move-strip {
  list-style: none;
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0 0 2px;
  overflow-x: auto;
}

.mobile-move-strip__chip {
  flex: 0 0 auto;
}

.mobile-move-strip__button {
  min-height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(102, 82, 56, 0.16);
  background: #f2eadf;
  color: var(--text);
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.mobile-move-strip__button.is-active {
  border-color: rgba(92, 138, 103, 0.42);
  background: rgba(92, 138, 103, 0.15);
  color: var(--green);
}
