:root {
  --board-wood: #9a7a55;
  --board-wood-dark: #806344;
  --board-line: #5f4935;
  --stone-black: #202933;
  --stone-white: #e8e0d1;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    #171715;
  background-size: 16px 16px;
  color: var(--px-ink);
  font-family: "Courier New", "Microsoft YaHei", monospace;
}

.game-layout {
  width: min(1120px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(76px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(640px, 680px) minmax(250px, 320px);
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 4vw, 54px);
}

.board-column { min-width: 0; }
.game-heading { width: min(640px, 100%); margin: 0 auto 14px; display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.game-heading h1 { margin: 5px 0 0; font-size: clamp(25px, 4vw, 38px); letter-spacing: 0; }
.turn-chip { display: flex; min-height: 34px; align-items: center; gap: 9px; border: 2px solid var(--px-line); padding: 0 10px; background: #22221e; color: var(--px-muted); font-size: 11px; font-weight: 900; white-space: nowrap; }
.turn-chip i { width: 12px; height: 12px; border: 2px solid #0d1014; background: var(--stone-black); box-shadow: 1px 1px 0 #000; }
.turn-chip.is-white i { border-color: #9b958b; background: var(--stone-white); }

.board-frame { width: fit-content; margin: auto; padding: 10px; border-color: #65523b; background: #493a2c; }
#board { display: block; width: 320px; height: 320px; background: var(--board-wood); image-rendering: pixelated; touch-action: none; cursor: crosshair; outline: none; }
#board:focus-visible { box-shadow: 0 0 0 3px var(--px-accent); }

.touch-confirm { width: min(640px, 100%); margin: 12px auto 0; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; }
.touch-confirm[hidden] { display: none; }
.touch-confirm span { color: var(--px-muted); font-size: 12px; font-weight: 800; }

.control-column { display: grid; gap: 14px; }
.status-panel, .settings-panel { padding: 16px; }
.players { display: grid; gap: 8px; }
.player-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; min-height: 58px; border-left: 3px solid transparent; padding: 8px 10px; background: #1d1d1a; color: var(--px-muted); }
.player-row.is-active { border-color: var(--px-accent); background: #302b20; color: var(--px-ink); }
.player-row small { display: block; margin-bottom: 3px; font-size: 9px; }
.player-row strong { font-size: 14px; }
.player-row output { color: var(--px-accent); font-weight: 900; }
.stone-icon { width: 26px; height: 26px; border: 3px solid #101216; background: var(--stone-black); box-shadow: 2px 2px 0 #0b0b0a; }
.stone-icon.white { border-color: #9c958b; background: var(--stone-white); }
.thinking { margin: 12px 0 0; color: var(--px-accent); font-size: 11px; font-weight: 800; }
.thinking i { display: inline-block; width: 7px; height: 7px; margin-right: 8px; background: var(--px-accent); animation: think 600ms steps(2, end) infinite; }
.thinking[hidden] { display: none; }
@keyframes think { 50% { opacity: .2; } }

.panel-title { margin: 0 0 14px; color: var(--px-ink); font-size: 13px; font-weight: 900; }
.settings-grid { display: grid; gap: 12px; }
.settings-hint { margin: 10px 0 0; color: var(--px-muted); font-size: 11px; font-weight: 700; line-height: 1.5; }
.settings-hint[hidden] { display: none; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr 42px 42px; gap: 8px; }
/* 音乐关闭时按钮压暗,开启时用强调色标出 */
#music-button { color: var(--px-muted); }
#music-button.is-active { border-color: var(--px-accent); color: var(--px-accent); }

.result-layer { position: fixed; z-index: 140; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(12,12,11,.76); backdrop-filter: blur(3px); }
.result-layer[hidden] { display: none; }
.result-panel { width: min(390px, 100%); padding: 24px; text-align: center; }
.result-panel h2 { margin: 9px 0 8px; color: var(--px-accent); font-size: 28px; }
.result-panel > p:not(.pixel-kicker) { margin: 0 0 20px; color: var(--px-muted); }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

@media (min-width: 980px) and (min-height: 760px) {
  #board { width: 640px; height: 640px; }
}

@media (max-width: 900px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); align-items: start; padding-top: max(72px, env(safe-area-inset-top)); }
  .control-column { width: min(640px, 100%); margin: 0 auto; grid-template-columns: 1fr 1fr; }
  .action-grid { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .game-layout { padding-inline: 10px; gap: 16px; }
  .game-heading { padding-inline: 3px; }
  .game-heading h1 { font-size: 24px; }
  .board-frame { padding: 6px; }
  .control-column { grid-template-columns: 1fr; }
  .action-grid { grid-column: auto; }
  .status-panel, .settings-panel { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .thinking i { animation: none; }
}
