:root {
  --wood: #c99a4b;
  --line: #7a5220;
  --ink: #2b2118;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #1d2430;
  color: #eee;
  display: flex;
  justify-content: center;
  overflow-x: hidden; /* 兜底：任何溢出都不产生横向滚动条 */
}

.wrap { max-width: 640px; width: 100%; padding: 16px; }

header h1 { margin: 0 0 4px; font-size: 26px; }
.sub { margin: 0 0 14px; font-size: 13px; color: #9fb0c3; }

/* ---------- 棋盘 ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  gap: 1px;
  background: var(--line); /* 缝隙即网格线 */
  border: 2px solid var(--line);
  border-radius: 6px;
  width: 100%;               /* 撑满 .wrap 内容区，与上下文字同宽对齐 */
  aspect-ratio: 1 / 1;       /* 随宽度等比缩放，保证棋格为正方形 */
  max-width: 100%;
  touch-action: manipulation;
  margin: 0 auto;
}

.cell {
  background: var(--wood);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  position: relative;
}

.cell.clickable { cursor: pointer; }
.cell.clickable:hover { filter: brightness(1.12); }

.stone {
  width: 86%; height: 86%;  /* 相对棋格缩放，移动端小棋格也不会溢出 */
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.45);
  animation: drop .15s ease-out;
}
.stone.black { background: radial-gradient(circle at 35% 30%, #555, #0a0a0a 70%); }
.stone.white { background: radial-gradient(circle at 35% 30%, #fff, #cfcfcf 75%); }

@keyframes drop { from { transform: scale(.5); opacity: .4; } }

/* 鱼竿高亮：呼吸金框 */
.cell.rod::after {
  content: "";
  position: absolute; inset: 1px;
  border: 2px solid #ffd54a;
  border-radius: 4px;
  animation: pulse 1s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulse { 50% { opacity: .25; } }

/* 可提走的对方棋子：红圈 */
.cell.prey::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px dashed #ff6b6b;
  pointer-events: none;
}
.cell.prey { cursor: pointer; }

/* 最后一步落点标记 */
.cell.last .stone { outline: 2px solid #4dd0e1; outline-offset: 1px; }

/* ---------- 提示 ---------- */
.msg {
  min-height: 24px;
  margin: 10px 2px;
  font-size: 15px;
  color: #ffd54a;
}
.msg.warn { color: #ff8a80; }
.msg.over { color: #69f0ae; font-weight: 700; font-size: 18px; }

/* ---------- 提子计分板 ---------- */
.score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #26303f;
  border: 1px solid #3a4757;
  border-radius: 10px;
  padding: 10px 14px;
}
.side { display: flex; align-items: center; gap: 10px; }
.side .right { text-align: right; }
.side .label { font-size: 12px; color: #9fb0c3; }
.side .num { font-size: 26px; font-weight: 800; line-height: 1.1; }
.side.black .num { color: #8fe3ff; }
.side.white .num { color: #ffe082; }

.stone-icon {
  width: 34px; height: 34px; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.stone-icon.black { background: radial-gradient(circle at 35% 30%, #555, #0a0a0a 70%); }
.stone-icon.white { background: radial-gradient(circle at 35% 30%, #fff, #cfcfcf 75%); }

.vs { font-size: 13px; color: #9fb0c3; text-align: center; min-width: 110px; }
.vs .target { font-size: 11px; color: #6d7d92; }

/* 电脑思考中：轻微呼吸提示 */
#turn-indicator.thinking {
  color: #ffd54a;
  animation: thinkpulse 1.1s ease-in-out infinite;
}
@keyframes thinkpulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.actions { margin-top: 10px; display: flex; gap: 10px; }
button {
  font: inherit;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid #4a90d9;
  background: #2f6fb0;
  color: #fff;
  cursor: pointer;
}
button:hover { filter: brightness(1.15); }
button.ghost { background: transparent; border-color: #55647a; color: #bcc8d8; }

.rules { margin-top: 16px; font-size: 13px; color: #9fb0c3; }
.rules summary { cursor: pointer; color: #cfd8e3; }
.rules ol { padding-left: 20px; }

/* ---------- 玩法说明行内链接（与正文同色，保持不显眼） ---------- */
.rules summary a { color: inherit; text-decoration: none; cursor: pointer; }

/* ---------- 移动端优化（窄屏自适应） ---------- */
@media (max-width: 600px) {
  .wrap { padding: 10px; }
  header h1 { font-size: 22px; margin-bottom: 2px; }
  .sub { font-size: 12px; margin-bottom: 10px; line-height: 1.5; }

  .msg { font-size: 14px; min-height: 20px; margin: 8px 2px; }

  /* 计分板：缩小间距与字号，避免 15 路布局在窄屏溢出 */
  .score { padding: 8px 10px; gap: 6px; }
  .side { gap: 6px; }
  .side .label { font-size: 10px; }
  .side .num { font-size: 20px; }
  .stone-icon { width: 26px; height: 26px; }
  .vs { min-width: 0; font-size: 12px; }
  .vs .target { font-size: 10px; }

  /* 操作按钮：允许换行并均分宽度，手指更好点 */
  .actions { gap: 8px; }
  button { padding: 9px 12px; flex: 1 1 auto; }

  .rules { font-size: 12px; }
  .rules ol { padding-left: 18px; }
}

/* 超窄屏（如 320px）进一步收紧 */
@media (max-width: 360px) {
  header h1 { font-size: 20px; }
  .side .num { font-size: 18px; }
  .stone-icon { width: 22px; height: 22px; }
  .vs .target { display: none; } /* 隐藏次要提示，给主信息让位 */
}
