.xq-wrap {
  position: relative;
  width: min(94vmin, 460px);
  /* 9 cols × 10 rows; we render 9 lines × 10 lines, with extra ~half-cell padding around. */
  aspect-ratio: 9 / 10;
  background: linear-gradient(160deg, #f2d9a8 0%, #deb96e 100%);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 28px rgba(120,75,20,0.28), 0 2px 8px rgba(0,0,0,0.16), 0 0 0 3px rgba(180,130,60,0.28);
  user-select: none;
  touch-action: manipulation;
  overflow: hidden;
}
body.dark .xq-wrap {
  background: linear-gradient(160deg, #c09a5a 0%, #8a6a30 100%);
  box-shadow: 0 8px 28px rgba(0,0,0,0.50), 0 2px 8px rgba(0,0,0,0.30), 0 0 0 3px rgba(100,70,20,0.50);
}

#board-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.xq-board {
  position: absolute;
  inset: 0;
}

.xq-piece {
  position: absolute;
  width: 11.1%;     /* 1 / 9 */
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: clamp(18px, 5vmin, 28px);
  border-radius: 50%;
  cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease, filter .15s ease;
  font-family: 'Noto Serif TC', 'Source Han Serif TC', 'SimSun', 'Microsoft JhengHei', serif;
  background: radial-gradient(circle at 30% 25%, #fff5d8 0%, #e0b462 60%, #a07028 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.28), inset 0 -2px 0 rgba(0, 0, 0, 0.18), inset 0 1px 2px rgba(255,255,255,0.6);
  border: 2px solid #6e4818;
  line-height: 1;
}

.xq-piece:hover {
  transform: translate(-50%, -50%) scale(1.12);
  filter: brightness(1.08);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.32), inset 0 -2px 0 rgba(0, 0, 0, 0.18), inset 0 1px 2px rgba(255,255,255,0.6);
}
.xq-piece.r { color: #c01818; }
.xq-piece.b { color: #1a1410; }
/* In dark mode the piece gradient is still light-gold, so dark text stays readable.
   Add a slightly warmer tone so it doesn't feel too stark. */
body.dark .xq-piece.b { color: #2e1e0a; }

.xq-piece.selected {
  box-shadow: 0 0 0 3px var(--accent), 0 2px 8px rgba(0,0,0,0.3);
  transform: translate(-50%, -50%) scale(1.06);
}

.xq-marker {
  position: absolute;
  width: 4.6%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.xq-marker.capture {
  width: 11.1%;
  background: transparent;
  border: 3px solid rgba(192, 24, 24, 0.5);
}

.xq-last-from, .xq-last-to {
  position: absolute;
  width: 11.1%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border-radius: 50%;
}
.xq-last-from { background: rgba(245, 215, 88, 0.35); }
.xq-last-to   { background: rgba(245, 215, 88, 0.6); }

.xq-piece.in-check {
  box-shadow: 0 0 0 3px var(--danger), 0 2px 8px rgba(0,0,0,0.3);
}

.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 100;
  animation: fadein .25s ease-in-out;
}
.overlay[hidden] { display: none; }
.overlay-text {
  font-size: clamp(36px, 8vmin, 56px);
  font-weight: 800;
  color: var(--text-strong);
  text-align: center;
}
.overlay-sub {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 600;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
