.bg-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.bg-board {
  display: grid;
  grid-template-columns: repeat(var(--bg-size, 10), 1fr);
  grid-template-rows: repeat(var(--bg-size, 10), 1fr);
  gap: 3px;
  width: min(100%, 440px);
  aspect-ratio: 1 / 1;
  padding: 6px;
  border-radius: var(--radius-md);
  background: #1c1f26;
  box-shadow: inset 0 0 0 3px var(--color-border);
}

.bg-cell {
  padding: 0;
  border: none;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}

.bg-cell--filled {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}

.bg-cell--preview-ok {
  background: rgba(79, 216, 224, 0.45);
}

.bg-cell--preview-bad {
  background: rgba(238, 111, 168, 0.4);
}

.bg-cell--cursor {
  box-shadow: inset 0 0 0 2px var(--color-accent, #4fd8e0);
}

/* Woodoku-style 3x3 sub-box boundary lines (only present when the engine's
   boxSize config is set). Kept as light outset margins rather than borders
   so they don't fight the cell's own inset box-shadow states above. */
.bg-cell--box-top { margin-top: 2px; }
.bg-cell--box-left { margin-left: 2px; }
.bg-cell--box-bottom { margin-bottom: 2px; }
.bg-cell--box-right { margin-right: 2px; }

.bg-tray {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  width: 100%;
}

.bg-piece {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  min-height: 84px;
  padding: 8px;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.bg-piece--selected {
  border-color: var(--color-accent, #4fd8e0);
  background: rgba(79, 216, 224, 0.12);
}

.bg-piece--empty {
  border-style: dashed;
  opacity: 0.35;
  cursor: default;
}

.bg-piece-shape {
  display: grid;
  grid-template-columns: repeat(var(--pw), 16px);
  grid-template-rows: repeat(var(--ph), 16px);
  gap: 2px;
}

.bg-piece-block {
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
