/* =====================
   BASE / LAYOUT
===================== */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: monospace;
  background: #0f172a;
  color: #e5e7eb;
}

#wrapper {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 16px;
}

header h1 {
  margin: 0 0 6px;
  font-size: 22px;
  color: #38bdf8;
}

.status {
  font-size: 14px;
  color: #94a3b8;
}

/* =====================
   BOARD
===================== */
#board-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1;
  border: 2px solid #1e293b;
  user-select: none;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(18px, 6vw, 34px);
  cursor: default;
  position: relative;
}

.cell.light {
  background: #e8d3b0;
}

.cell.dark {
  background: #b58863;
}

.cell.selected {
  box-shadow: inset 0 0 0 3px #38bdf8;
}

.cell.target {
  cursor: pointer;
}

.cell.target::after {
  content: "";
  position: absolute;
  width: 26%;
  height: 26%;
  background: rgba(56, 189, 248, 0.6);
  border-radius: 50%;
}

.cell.capture::after {
  width: 100%;
  height: 100%;
  border: 4px solid rgba(56, 189, 248, 0.6);
  background: transparent;
  border-radius: 50%;
}

.cell.last-move {
  background: #f0d188;
}

.piece {
  line-height: 1;
}

.piece.w {
  color: #ffffff;
  text-shadow: 0 0 2px #111827, 0 0 2px #111827;
}

.piece.b {
  color: #1f2937;
}

/* ===================== PANEL / STEPS
===================== */
.panel {
  background: #111c2e;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 16px;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  background: #1e293b;
  color: #e5e7eb;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.btn:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}

.btn.primary {
  background: #38bdf8;
  color: #0f172a;
  border-color: #38bdf8;
}

.step {
  margin-top: 14px;
}

.note {
  font-size: 13px;
  color: #94a3b8;
  margin: 0 0 10px;
}

textarea {
  width: 100%;
  min-height: 60px;
  background: #0f172a;
  color: #a5f3fc;
  border: 1px solid #334155;
  border-radius: 6px;
  font-family: monospace;
  font-size: 11px;
  padding: 8px;
  resize: vertical;
  margin-bottom: 8px;
}

canvas {
  display: block;
  margin: 0 auto 10px;
  image-rendering: pixelated;
}

.hidden {
  display: none;
}

#scan-status {
  font-size: 13px;
  color: #94a3b8;
  text-align: center;
}

/* ===================== PROMOTION
===================== */
#promo-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#promo-overlay.hidden {
  display: none;
}

#promo-box {
  background: #1e293b;
  border: 1px solid #38bdf8;
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

#promo-box p {
  margin: 0 0 12px;
  color: #e5e7eb;
}

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

.promo-btn {
  background: #334155;
  color: #e5e7eb;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.promo-btn:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}