.gomoku-game {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.gomoku-game__topbar,
.gomoku-game__controls,
.gomoku-game__stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.gomoku-game__topbar {
  justify-content: space-between;
  margin-bottom: 1rem;
}

.gomoku-game__title,
.gomoku-game__subtitle {
  margin: 0;
}

.gomoku-game__title {
  font-size: 1.3rem;
}

.gomoku-game__subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.gomoku-stat {
  min-width: 4.8rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.gomoku-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
}

.gomoku-stat strong {
  display: block;
  color: var(--ink);
  font-size: 0.98rem;
}

.gomoku-game__message {
  min-height: 2.8rem;
  margin-bottom: 1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid #d8e5dc;
  border-radius: var(--radius);
  background: #f4faf6;
  color: #294a3b;
  font-weight: 700;
}

.gomoku-game__message.is-win {
  border-color: #d7bd6b;
  background: #fff8df;
  color: #684f11;
}

.gomoku-game__message.is-loss {
  border-color: #dfc4c1;
  background: #fff5f4;
  color: #7c342f;
}

.gomoku-game__board-wrap {
  overflow: auto;
  padding: 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  background: #1b3c32;
}

.gomoku-game__board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  position: relative;
  width: min(100%, 680px);
  min-width: 320px;
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 0;
  border: 10px solid #8a5c2d;
  border-radius: 4px;
  background-color: #d8a45e;
  background-image:
    linear-gradient(90deg, rgba(75, 45, 20, 0.15), transparent 22%, rgba(255, 245, 210, 0.2) 52%, transparent 78%),
    repeating-linear-gradient(0deg, rgba(90, 55, 26, 0.045) 0 1px, transparent 1px 5px);
  box-shadow: inset 0 0 0 1px rgba(72, 41, 17, 0.46), 0 12px 22px rgba(0, 0, 0, 0.22);
}

.gomoku-game__board::before {
  content: "";
  position: absolute;
  inset: calc(100% / 30);
  pointer-events: none;
  border-right: 1px solid rgba(55, 34, 16, 0.86);
  border-bottom: 1px solid rgba(55, 34, 16, 0.86);
  background-image:
    linear-gradient(to right, rgba(55, 34, 16, 0.86) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(55, 34, 16, 0.86) 1px, transparent 1px);
  background-size: calc(100% / 14) calc(100% / 14);
  background-position: 0 0;
}

.gomoku-cell {
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.gomoku-cell:focus-visible {
  z-index: 4;
  outline: 3px solid #f7e7a9;
  outline-offset: -2px;
}

.gomoku-cell:not(:disabled):hover::before {
  content: "";
  width: 66%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(27, 35, 29, 0.26);
}

.gomoku-cell.is-star:not(.is-black):not(.is-white)::after {
  content: "";
  position: absolute;
  width: 11%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #5b3518;
}

.gomoku-stone {
  display: none;
  position: relative;
  z-index: 2;
  width: 88%;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 3px 5px rgba(26, 15, 7, 0.46);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.gomoku-stone::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.is-black .gomoku-stone,
.is-white .gomoku-stone {
  display: block;
}

.is-black .gomoku-stone::before {
  background: radial-gradient(circle at 34% 26%, #68746d 0, #252c29 34%, #050706 72%);
}

.is-white .gomoku-stone::before {
  background: radial-gradient(circle at 30% 22%, #ffffff 0, #e8e4d8 48%, #a9a59b 100%);
}

.gomoku-stone img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gomoku-cell.is-last .gomoku-stone {
  box-shadow: 0 0 0 3px #e8b93e, 0 3px 5px rgba(26, 15, 7, 0.5);
}

.gomoku-cell.is-winning .gomoku-stone {
  transform: scale(1.08);
  box-shadow: 0 0 0 4px #53a986, 0 0 16px rgba(83, 169, 134, 0.76);
}

.gomoku-game__controls {
  margin-top: 1rem;
}

.gomoku-game__controls label {
  display: grid;
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.gomoku-game__controls select,
.gomoku-control {
  min-height: 2.55rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.gomoku-control {
  cursor: pointer;
}

.gomoku-control--primary {
  border-color: var(--jade);
  background: var(--jade);
  color: white;
}

.gomoku-control:disabled,
.gomoku-game__controls select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.gomoku-pattern {
  display: inline-flex;
  gap: 0.22rem;
  margin: 0.5rem 0 1rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #d8c59e;
  border-radius: var(--radius);
  background: #f7e7c5;
  color: #3c2a17;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

.gomoku-pattern .pattern-x { color: #14201b; }
.gomoku-pattern .pattern-o { color: #a8433e; }
.gomoku-pattern .pattern-win { color: #1d7558; }

@media (max-width: 560px) {
  .gomoku-game { padding: 0.75rem; }
  .gomoku-game__message {
    display: flex;
    align-items: center;
    height: 5rem;
    min-height: 5rem;
    line-height: 1.4;
  }
  .gomoku-game__board-wrap { padding: 0.45rem; }
  .gomoku-game__board { min-width: 286px; border-width: 7px; }
  .gomoku-game__stats { gap: 0.35rem; }
  .gomoku-stat { min-width: 4.1rem; }
  .gomoku-game__controls { align-items: end; }
}
