:root {
  --light: #eedab6;
  --dark: #b58863;
  --bg: #1d2126;
  --panel: #262b31;
  --text: #e8e6e3;
  --muted: #8b9298;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 12px 40px;
}

main { max-width: 860px; width: 100%; }

h1 { font-size: 1.35rem; font-weight: 600; margin-bottom: 14px; }
.sub { color: var(--muted); font-weight: 400; font-size: 0.95rem; }

.layout { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }

/* ---------- board ---------- */

#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(72vw, 480px);
  height: min(72vw, 480px);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}
.sq.light { background: var(--light); }
.sq.dark  { background: var(--dark); }

.piece {
  font-size: clamp(26px, 6.4vw, 44px);
  line-height: 1;
  z-index: 1;
}
.piece.w { color: #ffffff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55); }
.piece.b { color: #1a1a1a; text-shadow: 0 1px 2px rgba(255, 255, 255, 0.25); }

.sq.selected { background: rgba(255, 213, 79, 0.55); }
.sq.last     { background: rgba(255, 213, 79, 0.3); }

.sq.target::after {
  content: "";
  position: absolute;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.25);
}
.sq.target-capture::after {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 3px solid rgba(20, 20, 20, 0.3);
}
.sq.check {
  background: radial-gradient(circle, #e33 35%, transparent 70%);
}

/* ---------- sidebar ---------- */

.side {
  background: var(--panel);
  border-radius: 10px;
  padding: 16px;
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status { font-weight: 600; min-height: 1.4em; }
.status.result { color: #7fd47f; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: #aab2b8; }

select, button {
  background: #333a41;
  color: var(--text);
  border: 1px solid #454d55;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.9rem;
  cursor: pointer;
}
button:hover { background: #3d454d; }

.buttons { display: flex; gap: 8px; }

.moves-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.moves {
  font-size: 0.85rem;
  color: #c6ccd1;
  height: 160px;
  overflow-y: auto;
  line-height: 1.7;
  white-space: pre;
  font-variant-numeric: tabular-nums;
}

.note {
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid #333a41;
  padding-top: 10px;
  line-height: 1.5;
}

/* ---------- promotion modal ---------- */

.promo {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.promo.visible { display: flex; }

.promo-box {
  background: var(--panel);
  padding: 18px 22px;
  border-radius: 12px;
  text-align: center;
}
.promo-pieces button { font-size: 1.9rem; padding: 6px 14px; margin: 8px 3px 2px; }
.cancel { margin-top: 10px; font-size: 0.8rem; }
