:root {
  --g-wood-1: #fef3c7;
  --g-wood-2: #fde68a;
  --g-line: rgba(15, 23, 42, 0.26);
  --g-sel: rgba(37, 99, 235, 0.18);
  --g-hint: rgba(245, 158, 11, 0.22);
}

.gHud {
  margin: 10px 0 12px;
  border-radius: 16px;
  padding: 12px 12px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.03), rgba(255, 255, 255, 0.0));
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gLeft {
  display: grid;
  gap: 4px;
}

.gTopRow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.gStatus {
  font-weight: 1000;
  font-size: 14px;
  color: rgba(15, 23, 42, 0.9);
}

.gHint {
  font-size: 12px;
  color: rgba(100, 116, 139, 0.95);
  /* 避免走子/提示文案变长导致 HUD 高度变化 → 棋盘抖动 */
  line-height: 1.45;
  min-height: calc(1.45em * 2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gRight {
  display: grid;
  place-items: center end;
  gap: 4px;
  min-width: 140px;
}

.gDiffLabel {
  font-size: 12px;
  font-weight: 900;
  color: rgba(15, 23, 42, 0.7);
}

.gDiffGrid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 10px;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(15, 23, 42, 0.1);
  user-select: none;
  touch-action: manipulation;
}

.gDiffDot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid rgba(15, 23, 42, 0.22);
  background: rgba(255, 255, 255, 0.55);
}
.gDiffDot.isDone {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(15, 23, 42, 0.92);
}
.gDiffDot.isCurrent {
  background: rgba(148, 163, 184, 0.92);
  border-color: rgba(148, 163, 184, 0.92);
}

.gProb {
  display: grid;
  grid-template-columns: 72px 10px auto;
  align-items: baseline;
  column-gap: 0;
  font-weight: 900;
  color: rgba(15, 23, 42, 0.72);
}
.gProbLabel,
.gProbSep {
  font-size: 14px;
  font-weight: 1000;
  text-align: center;
}
.gProbVal {
  font-size: 12px;
  font-weight: 1000;
}
.gProb.isLow {
  color: rgba(239, 68, 68, 0.95);
}
.gProb.isMid {
  color: rgba(245, 158, 11, 0.95);
}
.gProb.isHigh {
  color: rgba(34, 197, 94, 0.95);
}

.gBoard {
  /* 交叉点坐标系（棋子落在“点”上） */
  --cols: 9;
  --rows: 9;
  --stone: clamp(22px, 7.0vw, 40px);
  --pad: calc(var(--stone) / 2 + 8px);

  width: min(560px, 100%);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 18px;
  border: 3px solid rgba(15, 23, 42, 0.18);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  background: linear-gradient(180deg, var(--g-wood-1), var(--g-wood-2));
  position: relative;
}

.gCanvas {
  position: absolute;
  inset: var(--pad);
  border-radius: 12px;
  pointer-events: none;
  /* 边缘线条补全：用 inset shadow，不影响背景网格尺寸（避免交叉点/棋子偏移） */
  box-shadow: inset 0 0 0 2px var(--g-line);
  background-image:
    linear-gradient(to right, var(--g-line) 2px, transparent 2px),
    linear-gradient(to bottom, var(--g-line) 2px, transparent 2px);
  /* 9列交点=8个间隔；9行交点=8个间隔 */
  background-size: calc(100% / 8) calc(100% / 8);
  background-position: 0 0;
  opacity: 0.9;
}

/* 星位（9×9 常用：中心+四角） */
.gCanvas::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 25% 25%, rgba(15, 23, 42, 0.62) 0 3px, transparent 3.6px),
    radial-gradient(circle at 75% 25%, rgba(15, 23, 42, 0.62) 0 3px, transparent 3.6px),
    radial-gradient(circle at 25% 75%, rgba(15, 23, 42, 0.62) 0 3px, transparent 3.6px),
    radial-gradient(circle at 75% 75%, rgba(15, 23, 42, 0.62) 0 3px, transparent 3.6px),
    radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 0.62) 0 3px, transparent 3.6px);
  opacity: 0.95;
}

.gPoints {
  position: absolute;
  /* 与网格画布使用同一套 inset，确保交叉点/棋子与线条完全同坐标系 */
  inset: var(--pad);
}

.gPoint {
  appearance: none;
  border: 0;
  background: transparent;
  width: var(--stone);
  height: var(--stone);
  padding: 0;
  cursor: pointer;
  position: relative;
  user-select: none;
  touch-action: manipulation;
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
}

.gPoint:active {
  /* 保持交叉点居中，再做轻微按压缩放 */
  transform: translate(-50%, -50%) scale(0.99);
}

.gPoint.sel {
  background: var(--g-sel);
}

.gPoint.hintTo::after {
  content: "";
  position: absolute;
  inset: 20%;
  border-radius: 999px;
  border: 2px solid rgba(245, 158, 11, 0.75);
  box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.10), 0 10px 22px rgba(245, 158, 11, 0.10);
  pointer-events: none;
}
.gPoint.lastTo::after {
  content: "";
  position: absolute;
  inset: 20%;
  border-radius: 999px;
  border: 2px solid rgba(59, 130, 246, 0.70);
  background: rgba(59, 130, 246, 0.10);
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.10), 0 12px 26px rgba(59, 130, 246, 0.12);
  animation: gPulse 1.15s ease-in-out infinite;
  pointer-events: none;
}
.gPoint.lastTo::before {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 999px;
  background: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.18), rgba(59, 130, 246, 0) 62%);
  filter: blur(0.2px);
  pointer-events: none;
}
.gPoint.hintFrom::after {
  content: "";
  position: absolute;
  inset: 24%;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.22);
  box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.08);
  pointer-events: none;
}

@keyframes gPulse {
  0% {
    transform: scale(0.98);
    opacity: 0.92;
  }
  50% {
    transform: scale(1.04);
    opacity: 1;
  }
  100% {
    transform: scale(0.98);
    opacity: 0.92;
  }
}

.gStone {
  width: calc(var(--stone) * 0.96);
  height: calc(var(--stone) * 0.96);
  border-radius: 999px;
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.16);
  /* 用绝对定位 + translate 居中，避免不同浏览器的 grid/subpixel 取整造成轻微偏移 */
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.gStone.black {
  /* 按要求：纯黑，不要半透明/渐变 */
  background: #000;
}
.gStone.white {
  background: radial-gradient(circle at 30% 30%, #ffffff, rgba(226, 232, 240, 0.92));
  border: 1px solid rgba(15, 23, 42, 0.14);
}

@media (max-width: 420px) {
  .gHud {
    padding: 8px 10px;
    border-radius: 14px;
  }
  .gBoard {
    border-radius: 16px;
  }
}
