/* ==============================================================
   五子棋 · 游戏专属样式
   选择器统一以 .g-gomoku 前缀限定
   ============================================================== */

.g-gomoku {
  gap: 10px;
}

/* ------------------------------ 模式切换 ------------------------------ */

.g-gomoku .gk-mode {
  display: flex;
  padding: 3px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  gap: 3px;
}
.g-gomoku .gk-mode-btn {
  min-height: 40px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--dim);
  border: 0;
  background: transparent;
  transition: background 0.16s, color 0.16s;
  white-space: nowrap;
}
.g-gomoku .gk-mode-btn.on {
  color: #fff;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 88%, #fff 12%), var(--accent2));
  box-shadow: 0 4px 12px -6px var(--accent);
}

/* ------------------------------ 状态条 ------------------------------ */

.g-gomoku .gk-hud {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  min-height: 38px;
  padding: 6px 10px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.g-gomoku .gk-turn {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.g-gomoku .gk-turn-t {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.g-gomoku .gk-turn-t.thinking { color: var(--accent); }
.g-gomoku .gk-turn-t.thinking::after {
  content: "…";
  display: inline-block;
  animation: gkBlink 1s steps(2) infinite;
}
.g-gomoku .gk-score {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  white-space: nowrap;
}
.g-gomoku .gk-sc { display: inline-flex; align-items: center; gap: 4px; }
.g-gomoku .gk-rate {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--faint);
  padding-left: 2px;
}

/* 棋子小圆点（状态/计分用） */
.g-gomoku .gk-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}
.g-gomoku .gk-dot.black {
  background: radial-gradient(circle at 35% 30%, #6f7a88, #232830 55%, #0c0f14);
  box-shadow: inset 0 -1px 2px rgba(255, 255, 255, 0.12);
}
.g-gomoku .gk-dot.white {
  background: radial-gradient(circle at 35% 30%, #fff, #eef1f5 55%, #c6cdd7);
  border: 1px solid rgba(20, 26, 34, 0.36);
}
.g-gomoku .gk-dot.draw {
  background: rgba(255, 255, 255, 0.12);
  border: 1px dashed rgba(255, 255, 255, 0.3);
}

/* ------------------------------ 棋盘 ------------------------------ */

.g-gomoku .gk-board-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
}
.g-gomoku .gk-board {
  position: relative;
  width: min(100%, 360px);
  width: min(100%, 360px, calc(100dvh - 336px));
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(84, 55, 22, 0.55);
  background:
    radial-gradient(120% 90% at 20% 10%, rgba(255, 246, 222, 0.5), transparent 55%),
    repeating-linear-gradient(93deg, rgba(120, 78, 34, 0.08) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(1deg, rgba(120, 78, 34, 0.04) 0 1px, transparent 1px 5px),
    linear-gradient(155deg, #e9c995 0%, #ddb77c 45%, #cfa366 100%);
  box-shadow: 0 26px 50px -28px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -2px 6px rgba(90, 55, 18, 0.35);
  touch-action: manipulation;
}
.g-gomoku .gk-board.over { cursor: default; }
.g-gomoku .gk-grid,
.g-gomoku .gk-stars,
.g-gomoku .gk-win {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.g-gomoku .gk-line {
  stroke: rgba(71, 43, 14, 0.55);
  stroke-width: 0.045;
}
.g-gomoku .gk-star { fill: rgba(66, 40, 12, 0.68); }

.g-gomoku .gk-stones { position: absolute; inset: 0; pointer-events: none; }
.g-gomoku .gk-stone {
  position: absolute;
  width: calc(100% / 15 * 0.86);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: gkDrop 0.14s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  will-change: transform;
}
.g-gomoku .gk-stone.black {
  background: radial-gradient(circle at 34% 28%, #7b8796 0%, #2b313a 38%, #12161c 68%, #07090d 100%);
  box-shadow: 0 2px 4px rgba(30, 16, 4, 0.5), inset 0 -2px 3px rgba(255, 255, 255, 0.1), inset 0 1px 2px rgba(255, 255, 255, 0.22);
}
.g-gomoku .gk-stone.white {
  background: radial-gradient(circle at 34% 28%, #ffffff 0%, #f6f8fa 38%, #e2e7ed 66%, #c3cbd5 100%);
  box-shadow: 0 2px 5px rgba(30, 16, 4, 0.42), inset 0 -2px 3px rgba(120, 130, 145, 0.28), inset 0 1px 2px #fff;
}
.g-gomoku .gk-stone.last::after {
  content: "";
  position: absolute;
  inset: 40%;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.g-gomoku .gk-stone.white.last::after { background: var(--accent2); box-shadow: 0 0 6px rgba(201, 48, 62, 0.7); }

.g-gomoku .gk-win-line {
  fill: none;
  stroke: #ff4757;
  stroke-width: 0.11;
  stroke-linecap: round;
  opacity: 0;
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  filter: drop-shadow(0 0 0.16px rgba(255, 71, 87, 0.8));
  transition: stroke-dashoffset 0.38s ease, opacity 0.12s;
}
.g-gomoku .gk-win-line.show { opacity: 1; stroke-dashoffset: 0; }

/* ------------------------------ 难度 / 操作 ------------------------------ */

.g-gomoku .gk-diff {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.g-gomoku .gk-diff-k { font-size: 10.5px; color: var(--faint); letter-spacing: 0.04em; flex: none; }
.g-gomoku .gk-diff-btns { display: flex; gap: 6px; margin-left: auto; }
.g-gomoku .gk-diff-btn {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dim);
  font-size: 11.5px;
  font-weight: 600;
}
.g-gomoku .gk-diff-btn.on {
  color: #ffe1e5;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.g-gomoku .gk-ctrl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  flex: none;
}
.g-gomoku .gk-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--dim);
  font-size: 12.5px;
  font-weight: 600;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
  touch-action: manipulation;
}
.g-gomoku .gk-btn:active { transform: scale(0.96); background: var(--surface-2); }
.g-gomoku .gk-btn.is-disabled { opacity: 0.38; pointer-events: none; }
.g-gomoku .gk-btn-i { font-size: 15px; color: var(--accent); line-height: 1; }

/* ------------------------------ 动画 ------------------------------ */

@keyframes gkDrop {
  from { opacity: 0.4; transform: translate(-50%, -50%) scale(1.28); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes gkBlink { 50% { opacity: 0.25; } }

/* ------------------------------ 适配 ------------------------------ */

@media (max-height: 710px) {
  .g-gomoku { gap: 8px; }
  .g-gomoku .gk-btn { min-height: 42px; }
  .g-gomoku .gk-mode-btn { min-height: 36px; }
  .g-gomoku .gk-hud { min-height: 34px; }
  .g-gomoku .gk-diff { min-height: 32px; }
}

@media (max-width: 365px) {
  .g-gomoku .gk-mode-btn { padding: 0 7px; font-size: 11px; }
  .g-gomoku .gk-btn { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .g-gomoku .gk-stone { animation: none; }
  .g-gomoku .gk-win-line { transition: none; }
  .g-gomoku .gk-turn-t.thinking::after { animation: none; }
}
