:root {
  --bg: #f4f1ea;
  --panel: #ffffff;
  --text: #1f1d1a;
  --muted: #6b665e;
  --border: #ddd6c8;
  --light: #eedcb3;
  --dark: #b58863;
  --accent: #3b6f4f;
  --hl: rgba(255, 214, 0, 0.45);
  --check: rgba(220, 40, 40, 0.75);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b19;
    --panel: #272522;
    --text: #ece8e1;
    --muted: #a39d93;
    --border: #3a3732;
    --accent: #5fa77a;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.4 system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
}
main { max-width: 1000px; margin: 0 auto; padding: 16px; }
#lobby { text-align: center; padding-top: 15vh; }
#lobby h1 { font-size: 2.5rem; margin: 0 0 8px; }

#game { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; justify-content: center; }
.board-col { width: min(100%, 560px); }
aside {
  flex: 1 1 260px; max-width: 360px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.player { display: flex; align-items: center; gap: 8px; padding: 6px 2px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #999; display: inline-block; }
.dot.on { background: #3fbf5f; }
.player .you { color: var(--muted); font-weight: 400; }

#board {
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1; width: 100%;
  border-radius: 4px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,.25);
  user-select: none; touch-action: manipulation;
}
.sq { position: relative; min-width: 0; min-height: 0; aspect-ratio: 1; overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sq.l { background: var(--light); }
.sq.d { background: var(--dark); }
.sq.last::before, .sq.sel::before { content: ''; position: absolute; inset: 0; background: var(--hl); }
.sq.check::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, var(--check) 0%, transparent 70%); }
.sq.target::after {
  content: ''; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(0,0,0,.22);
}
.sq.target.capture::after {
  width: 92%; height: 92%; background: transparent; border: 5px solid rgba(0,0,0,.22);
}
.piece { position: relative; z-index: 1; font-size: min(10.5vw, 60px); line-height: 1; }
.piece svg { display: block; width: 1em; height: 1em; }
.piece.b svg path { stroke: #111; }
.piece.w { color: #fff; text-shadow: 0 0 2px #000, 0 0 1px #000, 0 1px 2px rgba(0,0,0,.6); }
.piece.b { color: #111; text-shadow: 0 0 1px #fff8; }
.coord { position: absolute; font-size: 11px; font-weight: 700; opacity: .75; pointer-events: none; }
.coord.file { right: 3px; bottom: 1px; }
.coord.rank { left: 3px; top: 1px; }
.sq.l .coord { color: var(--dark); }
.sq.d .coord { color: var(--light); }

.status { font-size: 1.1rem; font-weight: 600; }
.notice { background: var(--hl); color: #1f1d1a; padding: 10px; border-radius: 8px; }
.share label { font-size: .9rem; color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.share input { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.warn { color: #c0392b; font-size: .85rem; margin: 6px 0 0; }
.moves {
  margin: 0; padding: 0 0 0 2.2em; max-height: 280px; overflow-y: auto;
  font-family: ui-monospace, Menlo, monospace; font-size: .95rem;
}
.moves li span { display: inline-block; min-width: 5em; }
.controls { margin-top: 0; }
button {
  font: inherit; padding: 7px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .45; cursor: default; }
.small { font-size: .85rem; margin: 0; }
a { color: var(--accent); }

dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.4); }
#promo-choices button { font-size: 40px; width: 64px; height: 64px; padding: 0; }
