.cb {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 0 6px #21180f, 0 0 0 7px rgba(212, 168, 71, 0.25);
  user-select: none;
  touch-action: none;
  overflow: hidden;
}

.cb-squares {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}

.cb-square {
  position: relative;
}

.cb-square.light {
  background: #efe2c8 linear-gradient(145deg, rgba(255, 255, 255, 0.25), rgba(120, 80, 30, 0.12));
}

.cb-square.dark {
  background: #9c6b45 linear-gradient(145deg, rgba(255, 230, 190, 0.16), rgba(30, 12, 0, 0.22));
}

.cb-square.last-move::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(212, 168, 71, 0.42);
}

.cb-square.selected::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(232, 192, 106, 0.55);
}

.cb-square.hint::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(111, 191, 115, 0.45);
}

.cb-square.in-check::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(224, 80, 60, 0.85) 18%, rgba(224, 80, 60, 0.25) 55%, transparent 75%);
}

.cb-square.move-target::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(20, 14, 5, 0.32) 0 26%, transparent 27%);
}

.cb-square.capture-target::after {
  content: '';
  position: absolute;
  inset: 6%;
  border: 4px solid rgba(20, 14, 5, 0.34);
  border-radius: 50%;
}

.cb-square.drag-over {
  box-shadow: inset 0 0 0 4px rgba(232, 192, 106, 0.85);
}

.cb-pieces {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cb-piece {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  transition: transform 0.18s ease, opacity 0.2s ease;
  will-change: transform;
  z-index: 2;
}

.cb-piece.no-anim {
  transition: none;
}

.cb-piece svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.4));
}

.cb-piece.dragging {
  transition: none;
  z-index: 10;
  cursor: grabbing;
}

.cb-piece.dragging svg {
  transform: scale(1.12);
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.5));
}

.cb-piece.cb-captured {
  opacity: 0;
  transform: scale(0.6);
  z-index: 1;
}

.cb-arrows {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.cb-arrow line {
  stroke-width: 16;
  stroke-linecap: round;
}

.cb-arrow.best line {
  stroke: rgba(212, 168, 71, 0.9);
}

.cb-arrow.best polygon {
  fill: rgba(212, 168, 71, 0.9);
}

.cb-arrow.alt line {
  stroke: rgba(120, 150, 200, 0.55);
}

.cb-arrow.alt polygon {
  fill: rgba(120, 150, 200, 0.55);
}

.cb-arrow.hint line {
  stroke: rgba(111, 191, 115, 0.9);
}

.cb-arrow.hint polygon {
  fill: rgba(111, 191, 115, 0.9);
}

.cb-arrow-dot {
  fill: rgba(13, 16, 23, 0.88);
  stroke: rgba(212, 168, 71, 0.7);
  stroke-width: 3;
}

.cb-arrow.alt .cb-arrow-dot {
  stroke: rgba(120, 150, 200, 0.6);
}

.cb-arrow-num {
  fill: #e9e6df;
  font-size: 30px;
  font-weight: 700;
  font-family: var(--font-body);
  text-anchor: middle;
  dominant-baseline: central;
}

.cb-coords {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.cb-coord {
  position: absolute;
  font-size: clamp(8px, 1.4vw, 12px);
  font-weight: 700;
  font-family: var(--font-body);
}

.cb-coord.file {
  bottom: 1px;
}

.cb-coord.rank {
  left: 3px;
}

.cb-coord.on-light {
  color: rgba(80, 50, 20, 0.75);
}

.cb-coord.on-dark {
  color: rgba(248, 235, 210, 0.8);
}

.cb-promotion {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(10, 8, 4, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cb-promotion-box {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow);
}

.cb-promotion-box button {
  width: clamp(48px, 10vw, 72px);
  height: clamp(48px, 10vw, 72px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.cb-promotion-box button:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.cb-promotion-box button svg {
  width: 100%;
  height: 100%;
}

.cb-mini {
  max-width: 320px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4), 0 0 0 4px #21180f;
}

.eval-bar {
  width: 14px;
  border-radius: 7px;
  background: #25160e;
  overflow: hidden;
  position: relative;
  align-self: stretch;
  border: 1px solid var(--line);
}

.eval-bar .eval-white {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, #fdf8ec, #cfc5ab);
  transition: height 0.4s ease;
}

.eval-bar.flipped .eval-white {
  bottom: auto;
  top: 0;
}
