:root {
  --bg: #f2e7d0;
  --ink: #1f2937;
  --panel: #fff8e7;
  --line: #a98052;
  --board: #e8c796;
  --hl: #0ea5e9;
  --cap: #dc2626;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #fff7e2, #f2e7d0 50%, #ebddc1);
  color: var(--ink);
}

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.top h1 { margin: 0; font-size: 1.45rem; }
.top p { margin: 4px 0 0; color: #4b5563; }

#restartBtn {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.hud {
  margin: 12px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.chip {
  border: 1px solid #d7ba8f;
  background: var(--panel);
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 580px) 1fr;
  gap: 14px;
}

.board {
  width: min(580px, calc(100vw - 28px));
  aspect-ratio: 9 / 10;
  border: 2px solid #7c5c34;
  border-radius: 12px;
  overflow: hidden;
  background: var(--board);
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(10, 1fr);
  position: relative;
}

.cell {
  border: 1px solid rgba(124, 92, 52, 0.58);
  display: grid;
  place-items: center;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.cell.river::before {
  content: "CHU HE  HAN JIE";
  position: absolute;
  inset: 28% 0 auto;
  text-align: center;
  font-size: clamp(11px, 1.6vw, 14px);
  letter-spacing: 0.12em;
  color: rgba(31, 41, 55, 0.42);
  pointer-events: none;
}

.cell.selected { box-shadow: inset 0 0 0 3px var(--hl); }
.cell.target::after,
.cell.capture::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  position: absolute;
}

.cell.target::after { background: rgba(14, 165, 233, 0.5); }
.cell.capture::after { background: rgba(220, 38, 38, 0.78); }

.piece {
  width: min(88%, 48px);
  height: min(88%, 48px);
  border-radius: 999px;
  border: 2px solid #8f6840;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: clamp(15px, 2.2vw, 20px);
  background: #fff9eb;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
}

.piece.red {
  color: #b91c1c;
  border-color: #c2410c;
}

.piece.black {
  color: #111827;
  border-color: #374151;
}

.panel {
  border: 1px solid #d7ba8f;
  border-radius: 12px;
  background: var(--panel);
  padding: 12px;
}

.panel h2,
.panel h3 { margin: 0 0 8px; }
.panel p { margin: 0 0 8px; color: #4b5563; }
.small { font-size: 0.9rem; }

#moves {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding-left: 20px;
}

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .board { margin: 0 auto; }
}
