/* ============================================================
   五子棋 · 样式  gomoku.css
   ============================================================ */

/* ---------- 页头 ---------- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px 0;
  max-width: 720px;
  margin: 0 auto;
}

.back {
  font-size: .9rem;
  letter-spacing: .12em;
  color: var(--ink-soft);
  padding: 8px 4px;
}
.back:active { color: var(--cinnabar); }

.page-title {
  font-family: var(--font-kai);
  font-size: 1.5rem;
  letter-spacing: .4em;
  text-indent: .4em;
  color: var(--ink);
}

.page-head .seal {
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1.05rem;
}

/* ---------- 模式栏 ---------- */
.mode-bar {
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper-hi);
}

.seg-btn {
  border: none;
  background: transparent;
  padding: .5em 1.3em;
  font-size: .95rem;
  letter-spacing: .2em;
  color: var(--ink-soft);
  border-radius: 4px;
  transition: background .18s ease, color .18s ease;
  -webkit-user-select: none;
  user-select: none;
}
.seg-btn.active {
  background: var(--ink);
  color: var(--paper-hi);
}

.first-opt {
  display: flex;
  gap: 18px;
  font-size: .88rem;
  letter-spacing: .12em;
  color: var(--ink-soft);
}
.first-opt[hidden] { display: none; }   /* 避免 display:flex 覆盖 hidden */
.first-opt label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
}
.first-opt input { accent-color: var(--cinnabar); }

/* ---------- 棋盘 ---------- */
.board-wrap {
  margin: 16px auto 0;
  width: min(92vw, 440px);
}

#board {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  touch-action: none;          /* 禁双击缩放/滚动拖拽 */
  border-radius: 6px;
  background: var(--paper-hi);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px rgba(43, 42, 38, .06);
}

/* 落子提示 */
.turn-tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 14px 0 0;
  font-size: .98rem;
  letter-spacing: .2em;
  color: var(--ink);
}

.turn-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: inset -2px -3px 5px rgba(0,0,0,.35), inset 2px 2px 3px rgba(255,255,255,.5);
  transition: background .2s ease;
}
.turn-dot.is-white { background: #f2ece0; box-shadow: inset -2px -3px 5px rgba(0,0,0,.18), 0 0 0 1.5px rgba(43,42,38,.55); }

.turn-text.thinking { color: var(--cinnabar); }

/* ---------- 操作 ---------- */
.actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 20px 0 0;
}
.actions .btn { min-width: 128px; padding: .75em 1.6em; }

.board-hint {
  margin-top: 16px;
  text-align: center;
  font-size: .78rem;
  letter-spacing: .22em;
  color: var(--ink-faint);
}

/* ---------- 胜负弹层 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  background: rgba(43, 42, 38, .42);
  backdrop-filter: blur(2px);
  animation: fadeIn .25s ease;
}

.overlay[hidden] { display: none; }

.overlay-card {
  width: min(86vw, 340px);
  padding: 30px 24px 26px;
  background:
    linear-gradient(160deg, rgba(255,255,255,.5), transparent 55%),
    var(--paper-hi);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow-lift);
  text-align: center;
  animation: rise .3s ease;
}

.stamp {
  width: 76px;
  height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--cinnabar);
  color: var(--cinnabar);
  font-family: var(--font-kai);
  font-size: 1.7rem;
  letter-spacing: .1em;
  background: transparent;
  transform: rotate(-5deg);
  box-shadow: inset 0 0 0 2px rgba(176, 58, 46, .12);
  animation: stampIn .4s cubic-bezier(.2, 1.6, .4, 1);
}

.result-line {
  margin-top: 18px;
  font-size: .92rem;
  letter-spacing: .3em;
  color: var(--ink-soft);
}

.overlay-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}
.overlay-actions .btn { min-width: 118px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes stampIn {
  0%   { transform: rotate(-5deg) scale(1.6); opacity: 0; }
  100% { transform: rotate(-5deg) scale(1);   opacity: 1; }
}

/* ---------- 窄屏微调 ---------- */
@media (max-width: 380px) {
  .actions .btn { min-width: 112px; }
  .board-wrap { width: 94vw; }
}
