.gomoku-match {
  --gomoku-board-size: 390px;
  width: min(100%, var(--gomoku-board-size));
  margin: 14px auto;
  color: #523454;
}

.gomoku-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-bottom: 10px;
  font-size: .93rem;
  font-weight: 730;
}

.gomoku-legend > span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid #e3cbe7;
  border-radius: 99px;
  background: #fbf3fb;
}

.gomoku-legend > span:nth-child(2) { border-color: #edcea6; background: #fff3df; }
.gomoku-legend i { display: block; width: 13px; height: 13px; border-radius: 50%; box-shadow: inset 0 -2px 0 #4c195d4a; background: #a375df; }
.gomoku-legend > span:nth-child(2) i { background: #eeac52; box-shadow: inset 0 -2px 0 #7f42114a; }

.gomoku-board {
  --board-rim: clamp(5px, 1.5vw, 11px);
  --grid-ink: #a67247;
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: min(100%, 390px);
  aspect-ratio: 1;
  min-width: 0;
  margin-inline: auto;
  border: var(--board-rim) solid #e5a860;
  border-radius: clamp(15px, 3vw, 29px);
  box-shadow: inset 0 1px 0 #fff8bc, inset 0 0 0 1px #b97844, 0 4px 0 #b17548, 0 10px 20px #6a392128;
  background:
    repeating-linear-gradient(172deg, transparent 0 7px, #aa62350b 8px 9px, transparent 10px 15px),
    linear-gradient(143deg, #ffe1a7, #efbb77);
}

.gomoku-cell {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  isolation: isolate;
  touch-action: manipulation;
}

.gomoku-cell::before, .gomoku-cell::after {
  position: absolute;
  content: '';
  z-index: -1;
  pointer-events: none;
  background: var(--grid-ink);
}
.gomoku-cell::before { inset-inline: 0; top: 50%; height: 1px; }
.gomoku-cell::after { inset-block: 0; left: 50%; width: 1px; }
.gomoku-cell:nth-child(5n+1)::before { inset-inline-start: 50%; }
.gomoku-cell:nth-child(5n)::before { inset-inline-end: 50%; }
.gomoku-cell:nth-child(-n+5)::after { inset-block-start: 50%; }
.gomoku-cell:nth-child(n+21)::after { inset-block-end: 50%; }

.gomoku-cell[aria-disabled='true'] { cursor: default; }
.gomoku-cell:focus-visible { z-index: 1; outline: 3px solid #6536ab; outline-offset: -4px; border-radius: 11px; }
.gomoku-stone {
  position: relative;
  display: block;
  width: 67%;
  aspect-ratio: 1;
  border: 1px solid #7446ab;
  border-radius: 50%;
  box-shadow: inset 0 -3px 3px #45177371, 0 3px 4px #67411a54;
  background: radial-gradient(circle at 30% 23%, #f1cdff, #b37beb 35%, #7547bd 79%);
  pointer-events: none;
}
.gomoku-cell[data-piece='2'] .gomoku-stone {
  border-color: #b07536;
  box-shadow: inset 0 -3px 3px #994b1967, 0 3px 4px #67411a54;
  background: radial-gradient(circle at 30% 23%, #fff5c6, #ffc76d 39%, #dd8b32 80%);
}
.gomoku-cell[data-recent] .gomoku-stone::after {
  position: absolute;
  inset: 18%;
  border: 2px solid #fff9e3;
  border-radius: 50%;
  content: '';
}
.gomoku-cell[data-winning] .gomoku-stone { outline: 3px solid #fff4b3; outline-offset: 1px; }

.gomoku-status {
  min-height: 2.9em;
  margin: 11px 0 0;
  padding: 6px 0;
  text-align: center;
  font-weight: 800;
  line-height: 1.4;
  word-break: keep-all;
}
.gomoku-demo-step { display: block; min-height: 44px; margin: 0 auto; }

.gomoku-board.gomoku-compact {
  --board-rim: 4px;
  width: min(100%, 124px);
  border-radius: 11px;
  box-shadow: inset 0 0 0 1px #a66a44, 0 3px 0 #b17548;
}
.gomoku-compact .gomoku-stone { border-width: 0; box-shadow: inset 0 -1px 0 #76368862, 0 1px 1px #67411a54; }
.gomoku-compact .gomoku-cell[data-piece='2'] .gomoku-stone { box-shadow: inset 0 -1px 0 #7f421162, 0 1px 1px #67411a54; }

@media (hover: hover) {
  .gomoku-cell[data-piece='0'][aria-disabled='false']:hover { background: #7040a417; }
}
@media (prefers-reduced-motion: no-preference) {
  .gomoku-cell[data-recent] .gomoku-stone { animation: gomoku-place .24s cubic-bezier(.22, .7, .3, 1.4) both; }
  @keyframes gomoku-place { from { opacity: .45; transform: translateY(-6px) scale(.77); } }
}
