:root {
  color-scheme: light;
  --bg: #16211c;
  --panel: #f6f0df;
  --panel-strong: #efe1bd;
  --ink: #1e211d;
  --muted: #686154;
  --line: #5c3a1c;
  --board: #d8a752;
  --board-dark: #ad7932;
  --red: #b62024;
  --black: #1f2422;
  --gold: #f3cc73;
  --focus: #136f63;
  --shadow: 0 20px 60px rgba(0, 0, 0, .28);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(243, 204, 115, .20), transparent 34rem),
    linear-gradient(135deg, #16211c 0%, #31402f 50%, #5f2a28 100%);
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(320px, 740px) minmax(280px, 360px);
  gap: 20px;
  align-items: start;
}

.play-area,
.side-panel {
  background: rgba(246, 240, 223, .96);
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.play-area {
  padding: 22px;
}

.side-panel {
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #7c312f;
  font-weight: 700;
  letter-spacing: .08em;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
}

h2 {
  font-size: 18px;
}

.status-card {
  min-width: 150px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff7e6;
  border: 1px solid #e1c988;
  text-align: right;
}

.status-card span,
.score-grid span,
.field span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.status-card strong {
  display: block;
  margin-top: 3px;
  font-size: 17px;
}

.board-frame {
  padding: 30px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(92, 58, 28, .22) 1px, transparent 1px),
    linear-gradient(rgba(92, 58, 28, .18) 1px, transparent 1px),
    var(--board);
  background-size: 24px 24px;
  border: 3px solid var(--board-dark);
}

.board-grid {
  position: relative;
  width: min(100%, 640px);
  aspect-ratio: 8 / 9;
  margin: 0 auto;
}

.board-lines {
  position: absolute;
  inset: 0;
  overflow: visible;
}

.grid-lines {
  fill: none;
  stroke: var(--line);
  stroke-width: .035;
  stroke-linecap: square;
}

.board-lines text {
  fill: rgba(92, 58, 28, .65);
  font-size: .45px;
  font-weight: 700;
  letter-spacing: .18em;
}

.points {
  position: absolute;
  inset: 0;
}

.point {
  --x: 0;
  --y: 0;
  position: absolute;
  left: calc(var(--x) * 12.5%);
  top: calc(var(--y) * 11.111111%);
  width: clamp(34px, 8.2vw, 58px);
  aspect-ratio: 1;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 999px;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.point:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.point.legal::before,
.point.capture::before,
.point.selected::before,
.point.last::before {
  content: "";
  position: absolute;
  inset: 21%;
  border-radius: 999px;
  pointer-events: none;
}

.point.legal::before {
  background: rgba(19, 111, 99, .35);
}

.point.capture::before {
  inset: 6%;
  border: 3px solid rgba(182, 32, 36, .75);
}

.point.selected::before,
.point.last::before {
  inset: -4px;
  border: 3px solid var(--focus);
}

.piece {
  position: relative;
  z-index: 1;
  width: 88%;
  height: 88%;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 35% 28%, #fff9e8 0 18%, transparent 19%),
    linear-gradient(145deg, #f9e7b6, #d7aa5a);
  border: 3px solid #714412;
  box-shadow: 0 4px 10px rgba(47, 31, 13, .32), inset 0 0 0 2px rgba(255, 250, 231, .55);
  color: var(--black);
  font-size: clamp(19px, 4.7vw, 34px);
  font-weight: 800;
  line-height: 1;
}

.piece.red {
  color: var(--red);
  border-color: #933016;
}

.piece.black {
  color: var(--black);
}

.panel-section {
  padding: 16px 0;
  border-bottom: 1px solid #ddcda9;
}

.panel-section:first-child {
  padding-top: 0;
}

.panel-section:last-child {
  border-bottom: 0;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 42px;
  border: 1px solid #cbb77d;
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
  padding: 0 12px;
}

input[type="range"] {
  accent-color: var(--focus);
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 16px 0 4px;
}

button {
  min-height: 42px;
  border: 1px solid #8f6b2f;
  border-radius: 8px;
  background: #fff4d9;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: #ffe7ad;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

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

.score-grid div {
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  background: #fff7e6;
  border: 1px solid #e1c988;
}

.score-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.hint {
  min-height: 44px;
  margin: 12px 0 0;
  color: #5b4532;
}

.move-log {
  height: min(38vh, 360px);
  margin: 12px 0 0;
  padding-left: 26px;
  overflow: auto;
}

.move-log li {
  padding: 5px 0;
  border-bottom: 1px dashed #ddcda9;
}

.log-section {
  padding-bottom: 0;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 14px 0 24px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .status-card {
    text-align: left;
  }

  .board-frame {
    padding: 24px;
  }
}

@media (max-width: 480px) {
  .app-shell {
    width: calc(100vw - 16px);
  }

  .play-area,
  .side-panel {
    padding: 14px;
  }

  .board-frame {
    padding: 18px;
  }

  .button-row {
    grid-template-columns: 1fr;
  }
}
