/* 五子棋棋盘：样式只作用于本模块，避免影响共享棋盘组件。 */

.gomoku {
  position: relative;
  width: 100%;
  max-width: 600px;
  min-width: 0;
  margin-inline: auto;
}

.gomoku__board {
  width: 100%;
  min-width: 0;
  padding: clamp(7px, 2.2%, 12px);
  border: 1px solid #b4a078;
  border-radius: 12px;
  background:
    radial-gradient(
      circle at 28% 14%,
      rgba(255, 255, 255, 0.3),
      transparent 42%
    ),
    linear-gradient(145deg, #eadfc6 0%, #d9c59d 56%, #cbb181 100%);
  box-shadow:
    inset 0 0 26px rgba(87, 65, 32, 0.16),
    0 8px 20px rgba(70, 55, 30, 0.1);
}

.gomoku__grid {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  grid-template-rows: repeat(15, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
}

.gomoku__point {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  appearance: none;
  background: transparent;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.gomoku__point:disabled {
  cursor: default;
}

.gomoku__point--playable {
  cursor: pointer;
}

/* 棋盘线：每个交叉点格负责自身的一半线段，首末行/列只画到中心。 */
.gomoku__point::before,
.gomoku__point::after {
  position: absolute;
  z-index: 0;
  background: rgba(72, 55, 30, 0.72);
  content: "";
  pointer-events: none;
}

.gomoku__point::before {
  top: calc(50% - 0.5px);
  left: 0;
  width: 100%;
  height: 1px;
}

.gomoku__point::after {
  top: 0;
  left: calc(50% - 0.5px);
  width: 1px;
  height: 100%;
}

.gomoku__point--first-col::before {
  left: 50%;
  width: 50%;
}

.gomoku__point--last-col::before {
  left: 0;
  width: 50%;
}

.gomoku__point--first-row::after {
  top: 50%;
  height: 50%;
}

.gomoku__point--last-row::after {
  top: 0;
  height: 50%;
}

.gomoku__point:focus-visible {
  z-index: 4;
  border-radius: 50%;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.gomoku__point--winning {
  background: radial-gradient(
    circle at 50% 50%,
    rgba(240, 190, 80, 0.34),
    transparent 66%
  );
}

.gomoku__star {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 16%;
  height: 16%;
  border-radius: 50%;
  background: rgba(72, 55, 30, 0.62);
  transform: translate(-50%, -50%);
}

.gomoku__ghost,
.gomoku__stone {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 84%;
  height: 84%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.gomoku__ghost {
  z-index: 1;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.gomoku__point--playable:hover .gomoku__ghost,
.gomoku__point--playable:focus-visible .gomoku__ghost {
  opacity: 0.32;
  transform: translate(-50%, -50%) scale(1);
}

.gomoku__ghost--black {
  background: #1d1d1b;
}

.gomoku__ghost--white {
  background: #f7f3e9;
  box-shadow: inset 0 0 0 1px rgba(70, 60, 45, 0.3);
}

.gomoku__stone {
  z-index: 2;
  box-shadow:
    0 1px 2px rgba(40, 30, 15, 0.38),
    inset 0 1px 1px rgba(255, 255, 255, 0.16);
}

.gomoku__stone--black {
  background: radial-gradient(
    circle at 34% 28%,
    #71716a 0%,
    #2b2b27 38%,
    #080808 100%
  );
}

.gomoku__stone--white {
  background: radial-gradient(
    circle at 34% 28%,
    #ffffff 0%,
    #f6f2e8 45%,
    #cfc5b2 100%
  );
  box-shadow:
    inset 0 0 0 1px rgba(92, 78, 54, 0.2),
    0 1px 2px rgba(40, 30, 15, 0.28);
}

.gomoku__stone--winning {
  box-shadow:
    0 0 0 2px #f4e8cc,
    0 0 0 3.5px #c98a2e,
    0 0 12px rgba(201, 138, 46, 0.85);
}

.gomoku__last-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: #d23c2c;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.68);
  transform: translate(-50%, -50%);
}

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