:root {
  --bg: #f5f2eb;
  --panel: #ffffff;
  --ink: #1c2024;
  --muted: #68737d;
  --line: rgba(28, 32, 36, 0.14);
  --accent: #0f766e;
  --wood: #d7a85f;
  --wood-line: rgba(50, 30, 12, 0.35);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 760;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.gomoku-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.gomoku-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 18px;
  align-items: center;
}

.back-link {
  color: var(--accent);
  font-weight: 760;
}

.gomoku-header p {
  margin: 0 0 4px;
  color: #c97a22;
  font-size: 0.78rem;
  font-weight: 820;
  text-transform: uppercase;
}

.gomoku-header h1 {
  margin: 0;
  font-size: 2.3rem;
  line-height: 1;
}

.connection {
  min-width: 78px;
  text-align: right;
  color: var(--muted);
  font-size: 0.92rem;
}

.toolbar,
.table-panel,
.side-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(16, 20, 23, 0.07);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(5, auto);
  gap: 10px;
  align-items: end;
  margin-top: 22px;
  padding: 14px;
}

.danger-button {
  background: #b5442e;
}

.idle-button {
  background: #4d5962;
}

.name-field {
  display: grid;
  gap: 6px;
}

.name-field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
}

.name-field input {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
}

.table-panel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
  margin-top: 14px;
  padding: 14px;
}

.seat,
.status {
  min-height: 66px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 12px;
  border-radius: 8px;
  background: #fbfaf7;
}

.seat span,
.status span,
.side-heading span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.seat strong,
.status strong {
  font-size: 1.08rem;
}

.black-seat {
  border-left: 5px solid #111;
}

.white-seat {
  border-left: 5px solid #d8d8d8;
}

.status {
  min-width: 190px;
  text-align: center;
}

.gomoku-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.board-wrap {
  display: grid;
  place-items: center;
  min-width: 0;
  width: 100%;
}

.board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  width: min(100%, 720px);
  min-width: 0;
  max-width: 100%;
  aspect-ratio: 1;
  padding: 10px;
  border: 1px solid rgba(55, 34, 15, 0.4);
  border-radius: 8px;
  background: var(--wood);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 16px 42px rgba(16, 20, 23, 0.16);
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  min-inline-size: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  touch-action: manipulation;
  background:
    linear-gradient(90deg, transparent calc(50% - 0.5px), var(--wood-line) 50%, transparent calc(50% + 0.5px)),
    linear-gradient(0deg, transparent calc(50% - 0.5px), var(--wood-line) 50%, transparent calc(50% + 0.5px));
}

.cell::after {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0);
  transition: transform 120ms ease, opacity 120ms ease;
}

.cell.black::after,
.cell.white::after {
  opacity: 1;
  transform: scale(1);
}

.cell.black::after {
  background: radial-gradient(circle at 35% 30%, #555, #050505 68%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.cell.white::after {
  background: radial-gradient(circle at 35% 30%, #fff, #d8d8d8 74%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.24);
}

.cell.last {
  background-color: transparent;
}

.cell.last.black::after {
  box-shadow: 0 0 0 2px #f7d875, 0 3px 8px rgba(0, 0, 0, 0.4);
}

.cell.last.white::after {
  box-shadow: 0 0 0 2px #bd5b30, 0 3px 8px rgba(0, 0, 0, 0.24);
}

.cell.can-move:hover {
  background-color: rgba(255, 255, 255, 0.18);
}

.side-panel {
  display: grid;
  gap: 14px;
}

.side-card {
  padding: 14px;
}

.side-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.side-heading strong {
  color: var(--accent);
}

.player-list,
.record-list {
  display: grid;
  gap: 8px;
  min-height: 38px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.player-list li,
.record-list li {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  color: #263036;
  line-height: 1.45;
}

.record-list small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.result-dialog {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 24, 28, 0.58);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.result-dialog.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.result-card {
  width: min(100%, 420px);
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.result-eyebrow {
  margin: 0 0 8px;
  color: #c97a22;
  font-size: 0.82rem;
  font-weight: 820;
}

.result-card h2 {
  margin: 0;
  font-size: 1.65rem;
}

.result-summary {
  margin: 14px 0 0;
  color: #364149;
  line-height: 1.65;
}

.result-countdown {
  min-height: 1.5em;
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 940px) {
  .gomoku-header,
  .toolbar,
  .table-panel,
  .gomoku-layout {
    grid-template-columns: 1fr;
  }

  .connection,
  .status {
    text-align: left;
  }

  .status {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .gomoku-shell {
    width: calc(100% - 20px);
    padding-top: 18px;
  }

  .board {
    padding: 6px;
  }

  .toolbar {
    gap: 8px;
  }

  .result-dialog {
    padding: 14px;
  }

  .result-card {
    padding: 22px 18px;
  }
}
