/* Five in a Row — own styles, theme variables only. Grid lines are CSS gradients, stones are CSS circles. */

.gk {
  width: 100%;
  max-width: 640px;
}

.gk-frame {
  padding: 10px;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
  border-radius: var(--gm-radius, 12px);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.5);
}

.gk-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 6px;
}

.gk-board {
  --n: 15;
  --gk-line: var(--gm-board-edge, rgba(0, 0, 0, 0.45));
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  width: 100%;
  min-width: calc(var(--n) * 22px);
  padding: 0;
  background: var(--gm-sq-light, #e9e0cc);
  border: 1px solid var(--gm-board-edge, rgba(0, 0, 0, 0.45));
  border-radius: 6px;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.gk-cell {
  --h-pos: center;
  --h-size: 100% 1px;
  --v-pos: center;
  --v-size: 1px 100%;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: block;
  aspect-ratio: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  background:
    linear-gradient(var(--gk-line), var(--gk-line)) var(--h-pos) / var(--h-size) no-repeat,
    linear-gradient(var(--gk-line), var(--gk-line)) var(--v-pos) / var(--v-size) no-repeat,
    transparent;
}

.gk-cell.is-l { --h-pos: right center; --h-size: 50% 1px; }
.gk-cell.is-r { --h-pos: left center; --h-size: 50% 1px; }
.gk-cell.is-t { --v-pos: center bottom; --v-size: 1px 50%; }
.gk-cell.is-b { --v-pos: center top; --v-size: 1px 50%; }

.gk-cell.is-star::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--gk-line);
}

.gk-cell:focus-visible {
  outline: 3px solid var(--gm-accent-bright, #e0584a);
  outline-offset: -3px;
  z-index: 2;
}

.gk-cell.has-stone { cursor: default; }

/* a faint stone under the pointer while it is the player's turn */
@media (hover: hover) {
  .gk-board.is-live .gk-cell:not(.has-stone):hover::after {
    content: "";
    position: absolute;
    inset: 16%;
    border-radius: 50%;
    background: var(--gm-accent, #c0392b);
    opacity: 0.35;
  }
}

.gk-stone {
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

.gk-stone.b {
  background: radial-gradient(circle at 35% 32%, rgba(255, 255, 255, 0.28), transparent 45%), var(--gm-piece-b, #14161c);
}

.gk-stone.w {
  background: radial-gradient(circle at 35% 32%, #fff, transparent 50%), var(--gm-piece-w, #f7f3ea);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.gk-stone.is-new { animation: gk-pop 0.18s ease-out; }

.gk-cell.is-last .gk-stone::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28%;
  height: 28%;
  margin: -14% 0 0 -14%;
  border-radius: 50%;
  background: var(--gm-accent-bright, #e0584a);
}

.gk-cell.is-five .gk-stone {
  box-shadow: 0 0 0 3px var(--gm-accent-bright, #e0584a), 0 2px 4px rgba(0, 0, 0, 0.45);
}

#gm-gomoku .gm-status { margin-top: 12px; }

.gm-seg button, .gm-actions .gm-btn { min-height: 44px; }

@keyframes gk-pop {
  0% { transform: scale(0.6); }
  100% { transform: scale(1); }
}

@media (max-width: 480px) {
  .gk-frame { padding: 4px; margin: 0 -6px; }
  .gk-cell.is-star::before { width: 4px; height: 4px; margin: -2px 0 0 -2px; }
}

@media (prefers-reduced-motion: reduce) {
  .gk-stone.is-new { animation: none; }
  .gm-status.is-thinking .gm-dot { animation: none; }
}
