/* ==========================================================================
   围棋
   ========================================================================== */

.go-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* 统一宽度：与上方 .mode-tabs（min(94vw, 620px)）等宽，保证状态栏 / 棋盘 / 控制区对齐 */
.go {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(94vw, 620px);
}

.go-slot:empty { display: none; }

/* ------------------------------ 状态栏 ---------------------------------- */

.go-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.go-turn { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }
.go-meta { font-size: 12.5px; color: var(--text-mute); }

.go-turn-stone {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.14);
  transition: background .25s, box-shadow .25s;
}
.go-turn-stone.is-black {
  background: radial-gradient(circle at 32% 28%, #6b7280, #111827 62%, #000);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16);
}
.go-turn-stone.is-white {
  background: radial-gradient(circle at 32% 28%, #ffffff, #e6e9f2 58%, #b8bfd0);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.go-turn-stone.is-finished {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

/* ------------------------------ 结果横幅 -------------------------------- */

.go-banner {
  padding: 16px 18px;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid rgba(139, 92, 246, 0.4);
  background: linear-gradient(120deg, rgba(139, 92, 246, 0.18), rgba(34, 211, 238, 0.1));
  animation: go-banner-in .28s cubic-bezier(.2, .8, .3, 1);
}
.go-banner[hidden] { display: none; }
.go-banner.is-black { border-color: rgba(148, 163, 184, 0.45); }
.go-banner.is-white { border-color: rgba(226, 232, 240, 0.4); }
.go-banner.is-draw { border-color: rgba(251, 191, 36, 0.4); }

@keyframes go-banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.go-banner-title { font-size: 18px; font-weight: 700; }
.go-banner-detail { margin-top: 6px; font-size: 13px; color: var(--text-dim); line-height: 1.7; }
.go-banner-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.go-banner-actions:empty { display: none; }

/* ------------------------------ 数子明细 -------------------------------- */

.go-score {
  display: grid;
  gap: 8px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.035);
}
.go-score[hidden] { display: none; }

.go-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.go-score-side { display: inline-flex; align-items: center; gap: 8px; color: var(--text-dim); }
.go-score-num { color: var(--text); font-variant-numeric: tabular-nums; }
.go-score-num b { font-size: 14.5px; }
.go-score-note { font-size: 12px; color: var(--text-mute); }

.go-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.go-dot.is-black { background: radial-gradient(circle at 32% 28%, #7b8494, #141b2b 60%, #04070f); }
.go-dot.is-white { background: radial-gradient(circle at 32% 28%, #fff, #e9ecf5 58%, #b6bdcf); }

/* ------------------------------ 棋盘规格 -------------------------------- */

.go-sizes {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.go-size-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 15px;
  font-family: inherit;
  text-align: left;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .2s, background .2s, color .2s, transform .18s;
}
.go-size-btn b { font-size: 14px; color: var(--text); }
.go-size-btn small { font-size: 11.5px; line-height: 1.5; }
.go-size-btn:hover { border-color: var(--border); transform: translateY(-1px); }
.go-size-btn.is-active {
  border-color: rgba(139, 92, 246, 0.65);
  background: rgba(139, 92, 246, 0.18);
  color: #cdbdfd;
}
.go-size-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ------------------------------- 棋盘 ----------------------------------- */

.go-board-wrap { display: grid; place-items: center; }

.go-board {
  --go-size: 9;
  position: relative;
  width: min(88vw, 560px);
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  background:
    radial-gradient(120% 120% at 18% 0%, rgba(255, 255, 255, 0.3), transparent 55%),
    linear-gradient(150deg, #eac79a, #d5a86c 58%, #c69154);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.25),
    0 26px 54px -26px rgba(0, 0, 0, 0.92);
  overflow: hidden;
}

/* 小棋盘不必撑满，大棋盘给足空间，使每格视觉尺寸接近 */
.go-board[data-size="9"] { width: min(86vw, 470px); }
/* 19 路棋盘的宽度上限不超过内容列（620px），避免溢出 */
.go-board[data-size="19"] { width: min(92vw, 600px); }

.go-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.go-grid path {
  fill: none;
  stroke: rgba(56, 34, 10, 0.55);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.go-board[data-size="19"] .go-grid path { stroke: rgba(56, 34, 10, 0.5); stroke-width: 0.85; }
.go-star { fill: rgba(56, 34, 10, 0.7); }

.go-points {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--go-size), 1fr);
  grid-template-rows: repeat(var(--go-size), 1fr);
}

.go-cell {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}
.go-cell:disabled { cursor: default; }
.go-cell.can-play { cursor: pointer; }

.go-stone {
  display: grid;
  place-items: center;
  width: 88%;
  height: 88%;
  border-radius: 50%;
  transform: scale(0);
  transition: transform .16s cubic-bezier(.2, .9, .3, 1.4), background .2s, box-shadow .2s;
}

.go-cell.is-black .go-stone,
.go-cell.is-white .go-stone { transform: scale(1); }

.go-cell.is-black .go-stone {
  background: radial-gradient(circle at 32% 28%, #7b8494, #141b2b 58%, #04070f);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45);
}
.go-cell.is-white .go-stone {
  background: radial-gradient(circle at 32% 28%, #ffffff, #e9ecf5 55%, #b6bdcf);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.32);
}

.go-cell.can-play:hover .go-stone {
  transform: scale(0.56);
  background: rgba(40, 24, 6, 0.26);
  box-shadow: none;
}

/* 最后一手：在棋子上标一个小点 */
.go-cell.is-last .go-stone::after {
  content: '';
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: #f59e0b;
}

/* 打劫禁着点：一个红色空心提示 */
.go-cell.is-ko .go-stone {
  transform: scale(0.3);
  background: transparent;
  box-shadow: none;
  border: 1.5px solid rgba(248, 113, 113, 0.85);
}

/* 终局：空点标出归属 */
.go-cell.is-territory-black .go-stone {
  transform: scale(0.36);
  background: rgba(4, 7, 15, 0.6);
  box-shadow: none;
}
.go-cell.is-territory-white .go-stone {
  transform: scale(0.36);
  background: rgba(255, 255, 255, 0.75);
  box-shadow: none;
}

/* ------------------------------- 控制区 --------------------------------- */

.go-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.go-controls:empty { display: none; }

/* ------------------------------ 房间模式 -------------------------------- */

/* 左：创建房间；右：加入房间。两列等宽，同行内等高 */
/* 与 .mode-tabs 等宽，保持全站统一布局 */
.go-lobby {
  display: grid;
  gap: 18px;
  width: min(94vw, 620px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.go-lobby > .go-notice { grid-column: 1 / -1; }

.go-card {
  display: flex;
  flex-direction: column;
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
}
.go-card h3 { margin: 0 0 6px; font-size: 16px; }
.go-card p.hint { margin: 0 0 16px; font-size: 12.5px; line-height: 1.6; color: var(--text-mute); }

.go-field { display: block; margin-bottom: 14px; }
.go-field > span { display: block; margin-bottom: 7px; font-size: 12.5px; color: var(--text-dim); }

.go-input {
  width: 100%;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(6, 9, 18, 0.55);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.go-input:focus { border-color: rgba(139, 92, 246, 0.7); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }
.go-input::placeholder { color: var(--text-mute); }

.go-input.is-room {
  letter-spacing: 0.22em;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
}

/* 下拉选择：与输入框同款外观 */
.go-select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
.go-select option { background: #121829; color: var(--text); }

.go-lobby-actions { display: flex; gap: 10px; margin-top: auto; }
.go-lobby-actions .btn { flex: 1 1 auto; }

.go-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.go-room-code { display: flex; align-items: center; gap: 10px; }
.go-room-code small { font-size: 12px; color: var(--text-mute); }
.go-room-code b { font-size: 22px; letter-spacing: 0.16em; }

.go-seats { display: flex; flex-wrap: wrap; gap: 10px; }

.go-seat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-dim);
}
.go-seat .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.16);
}
.go-seat .dot.is-black { background: radial-gradient(circle at 32% 28%, #7b8494, #141b2b 60%, #04070f); }
.go-seat .dot.is-white { background: radial-gradient(circle at 32% 28%, #fff, #e9ecf5 58%, #b6bdcf); }
.go-seat .dot.is-empty { background: transparent; border: 1px dashed rgba(255, 255, 255, 0.32); }
.go-seat.is-me { color: var(--text); border-color: rgba(139, 92, 246, 0.45); background: rgba(139, 92, 246, 0.14); }
.go-seat.is-offline { opacity: 0.55; }
.go-seat.is-empty { opacity: 0.6; }

.go-seat-info { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.go-seat-info b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.go-seat-info small { font-size: 11.5px; color: var(--text-mute); }

.go-copy { padding: 6px 12px; font-size: 12px; border-radius: 999px; }

.go-wait { font-size: 12.5px; color: var(--text-dim); }

.go-notice {
  padding: 11px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(251, 191, 36, 0.32);
  background: rgba(251, 191, 36, 0.1);
  color: #fcd88a;
}
.go-notice[hidden] { display: none; }
.go-notice.is-error { border-color: rgba(251, 113, 133, 0.4); background: rgba(251, 113, 133, 0.12); color: #fda4af; }

@media (max-width: 640px) {
  .go-board { width: min(94vw, 440px); }
  .go-board[data-size="9"] { width: min(90vw, 380px); }
  .go-board[data-size="19"] { width: min(94vw, 500px); }
  .go-status { flex-direction: column; align-items: flex-start; gap: 6px; }
  /* 窄屏仍保持左创建 / 右加入，仅收窄间距与内边距 */
  .go-lobby { gap: 12px; }
  .go-card { padding: 15px; }
  .go-sizes { gap: 8px; }
  .go-size-btn { padding: 11px 10px; }
}
