:root {
  --paper: #f2e9da;
  --card: #fdf8ee;
  --ink: #241f19;
  --ink-2: #5c5147;
  --ink-3: #7c6d5d;
  --line: rgba(88, 64, 40, 0.18);
  --wood-1: #edd0a8;
  --wood-2: #ddb581;
  --wood-3: #cda26b;
  --seal: #a5432c;
  --seal-dark: #8a3221;
  --green: #486f52;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(74, 55, 33, 0.06), 0 14px 30px -22px rgba(74, 55, 33, 0.55);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1100px 520px at 10% -12%, #fbf5e9, transparent 62%),
    radial-gradient(820px 480px at 102% -4%, #e9dec8, transparent 58%),
    linear-gradient(180deg, #f4ecdf, #efe5d3 58%, #e9ddc8);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image: repeating-linear-gradient(
      94deg,
      rgba(140, 112, 74, 0.055) 0 1px,
      transparent 1px 6px
    ),
    repeating-linear-gradient(4deg, rgba(255, 255, 255, 0.3) 0 1px, transparent 1px 9px);
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 40px;
}

/* ---------- 头部 ---------- */
.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.seal {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 10px;
  background: linear-gradient(160deg, #b5543a, var(--seal-dark));
  color: #fdf3e6;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  font-size: 24px;
  line-height: 1;
  box-shadow: 0 6px 14px -8px rgba(138, 50, 33, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--ink-3);
}

h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  font-size: 34px;
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.15;
}

.tagline {
  margin: 0;
  max-width: 34ch;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink-2);
  text-align: right;
}

/* ---------- 布局 ---------- */
.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 336px;
  gap: 28px;
  align-items: start;
  margin-top: 28px;
}

.board-col {
  width: 100%;
  max-width: 620px;
  margin-inline: auto;
}

.board-frame {
  padding: 13px;
  border-radius: 20px;
  background: linear-gradient(158deg, #e7c79c 0%, #dcb481 45%, #c99c65 100%);
  box-shadow: 0 26px 40px -30px rgba(83, 58, 26, 0.85),
    inset 0 0 0 1px rgba(255, 252, 244, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.board {
  position: relative;
  border-radius: 9px;
  overflow: hidden;
  background: radial-gradient(115% 120% at 28% 8%, var(--wood-1), var(--wood-2) 58%, var(--wood-3));
  box-shadow: inset 0 0 0 1px rgba(104, 70, 34, 0.28),
    inset 0 2px 12px rgba(255, 255, 255, 0.28),
    inset 0 -18px 30px rgba(126, 86, 42, 0.16);
}

.board::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
      96deg,
      rgba(120, 80, 42, 0.075) 0 1px,
      transparent 1px 8px
    ),
    repeating-linear-gradient(7deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 13px);
}

svg#boardSvg {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  touch-action: manipulation;
  cursor: crosshair;
  outline: none;
}

svg#boardSvg:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: -8px;
  border-radius: 9px;
}

.board-lines {
  stroke: #6f4c28;
  stroke-opacity: 0.42;
  stroke-width: 0.032;
}

.board-frame-line {
  fill: none;
  stroke: #7b552d;
  stroke-opacity: 0.35;
  stroke-width: 0.04;
}

.board-label {
  fill: #7a5530;
  fill-opacity: 0.72;
  font-size: 0.5px;
  font-family: Georgia, "Songti SC", serif;
  text-anchor: middle;
}

.board-star {
  fill: #5c3d1e;
  fill-opacity: 0.72;
}

.ghost-stone {
  pointer-events: none;
}

.cursor-ring {
  pointer-events: none;
}

.stone--win {
  animation: stone-win 0.85s ease-out;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes stone-win {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.16);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- 结果条 ---------- */
.result-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 12px 10px 16px;
  border: 1px solid rgba(165, 67, 44, 0.3);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.96), rgba(252, 242, 228, 0.96));
  box-shadow: 0 14px 26px -22px rgba(110, 60, 30, 0.8);
  animation: strip-in 0.28s ease-out;
}

.result-strip[hidden] {
  display: none;
}

@keyframes strip-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.result-dot {
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  background: #171310;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.result-dot[data-side="2"] {
  background: #fdf8ee;
  box-shadow: inset 0 0 0 1px rgba(80, 58, 32, 0.4);
}

.result-dot.is-draw {
  background: linear-gradient(135deg, #22201c 0 50%, #fdf8ee 50% 100%);
  box-shadow: inset 0 0 0 1px rgba(80, 58, 32, 0.35);
}

.result-text {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.result-text em {
  font-style: normal;
  color: var(--seal);
}

.board-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 2px 0;
  font-size: 12.5px;
  color: var(--ink-3);
}

.hint-key {
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.7);
  font-size: 12px;
  color: var(--ink-2);
}

/* ---------- 侧栏卡片 ---------- */
.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 252, 245, 0.94), rgba(251, 245, 234, 0.88));
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--ink-3);
}

.meta-chip {
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(88, 64, 40, 0.16);
  background: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.status-main {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 2px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.turn-dot {
  width: 15px;
  height: 15px;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #4d4a45, #16130f 70%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.turn-dot[data-side="2"] {
  background: radial-gradient(circle at 34% 28%, #ffffff, #e3d8c2 78%);
  box-shadow: inset 0 0 0 1px rgba(96, 72, 42, 0.35), 0 1px 2px rgba(0, 0, 0, 0.12);
}

.turn-dot.is-win {
  background: var(--seal);
  box-shadow: 0 0 0 4px rgba(165, 67, 44, 0.14);
}

.status-detail {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--ink-2);
  min-height: 20px;
}

.players {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  grid-template-areas:
    "stone name score"
    "stone sub score";
  align-items: center;
  column-gap: 10px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.player.is-active {
  background: rgba(165, 67, 44, 0.07);
  border-color: rgba(165, 67, 44, 0.26);
}

.player.is-winner {
  background: rgba(72, 111, 82, 0.1);
  border-color: rgba(72, 111, 82, 0.3);
}

.player-stone {
  grid-area: stone;
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.player-stone.is-black {
  background: radial-gradient(circle at 34% 28%, #55514b, #17140f 72%);
  box-shadow: inset 0 -1px 2px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.22);
}

.player-stone.is-white {
  background: radial-gradient(circle at 34% 28%, #ffffff, #e2d7c1 80%);
  box-shadow: inset 0 0 0 1px rgba(96, 72, 42, 0.32), 0 1px 2px rgba(0, 0, 0, 0.12);
}

.player-name {
  grid-area: name;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
}

.player-sub {
  grid-area: sub;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.4;
}

.player.is-active .player-sub {
  color: var(--seal);
  font-weight: 600;
}

.player.is-winner .player-sub {
  color: var(--green);
  font-weight: 600;
}

.player-score {
  grid-area: score;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--ink);
}

.player-score .unit {
  margin-left: 2px;
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-3);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1.12fr;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(88, 64, 40, 0.22);
  border-radius: 11px;
  background: #fffdf8;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.1s ease,
    box-shadow 0.18s ease;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn:hover:not(:disabled) {
  background: #ffffff;
  border-color: rgba(165, 67, 44, 0.45);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  border-color: var(--seal-dark);
  background: linear-gradient(180deg, #ad4a31, #963a25);
  color: #fdf5e9;
  box-shadow: 0 10px 18px -14px rgba(138, 50, 33, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #b95337, #9d3d26);
  border-color: var(--seal-dark);
}

.btn-primary:focus-visible {
  outline-color: var(--seal-dark);
  outline-offset: 2px;
}

.btn-sm {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 10px;
}

.btn-sm svg {
  width: 16px;
  height: 16px;
}

.link-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 6px;
  border: none;
  background: none;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-decoration: underline;
  text-decoration-color: rgba(124, 109, 93, 0.45);
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-btn:hover:not(:disabled) {
  color: var(--seal);
}

.link-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.link-btn:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- 记录 ---------- */
.move-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 296px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 109, 93, 0.4) transparent;
}

.move-list::-webkit-scrollbar {
  width: 6px;
}

.move-list::-webkit-scrollbar-thumb {
  background: rgba(124, 109, 93, 0.35);
  border-radius: 3px;
}

.move-row {
  display: grid;
  grid-template-columns: 36px 12px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
}

.move-row.is-latest {
  background: rgba(165, 67, 44, 0.08);
  color: var(--ink);
  font-weight: 600;
}

.move-index {
  font-size: 12.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.move-stone {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.move-stone.is-black {
  background: #1b1712;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.move-stone.is-white {
  background: #fbf6ec;
  box-shadow: inset 0 0 0 1px rgba(96, 72, 42, 0.42);
}

.move-coord {
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.move-side {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 400;
}

.move-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 12px 18px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.7;
}

.move-empty svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  opacity: 0.55;
}

.move-empty strong {
  display: block;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
}

/* ---------- 页脚 ---------- */
.foot {
  margin-top: 30px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.foot p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-3);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
  .game {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }

  .panel {
    max-width: 620px;
    width: 100%;
    margin-inline: auto;
  }

  .masthead {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .tagline {
    max-width: none;
    text-align: left;
  }
}

@media (min-width: 641px) and (max-width: 980px) {
  .panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    max-width: 700px;
  }

  .move-list {
    max-height: 348px;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 22px 16px 32px;
  }

  .game {
    margin-top: 20px;
    gap: 18px;
  }

  .board-frame {
    padding: 9px;
    border-radius: 16px;
  }

  .status-main {
    font-size: 20px;
  }

  .card {
    padding: 15px;
  }

  .move-list {
    max-height: 216px;
  }

  .actions {
    gap: 8px;
  }

  .btn {
    font-size: 13.5px;
    padding: 0 10px;
  }
}

@media (max-width: 380px) {
  .seal {
    width: 40px;
    height: 40px;
    font-size: 21px;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .player-score {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
