/* ==========================================================================
   非洲播棋（Mancala Kalah）
   ========================================================================== */

/* 统一布局：模式按钮（共用 .mode-tabs）居中，内容列等宽 */
.bq-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.bq {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(94vw, 470px);
}

.bq-slot:empty { display: none; }

/* ------------------------------ 状态栏 ---------------------------------- */

.bq-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.bq-turn { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }

.bq-turn-text { min-width: 0; line-height: 1.4; }

.bq-turn-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.14);
  transition: background .25s, box-shadow .25s;
}
.bq-turn-dot.is-red {
  background: radial-gradient(circle at 32% 28%, #fb9a7f, #d43a17 60%, #8d1e05);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.bq-turn-dot.is-blue {
  background: radial-gradient(circle at 32% 28%, #9ec5fb, #2f7fd6 60%, #14508f);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.bq-turn-dot.is-finished { background: rgba(255, 255, 255, 0.08); box-shadow: none; }

.bq-count { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }

.bq-count-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 12px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-dim);
}
.bq-count-item small { font-size: 11px; font-weight: 600; color: var(--text-mute); }

.bq-count-ico {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  align-self: center;
  flex: 0 0 auto;
}
.bq-count-ico.is-red { background: radial-gradient(circle at 32% 28%, #fb9a7f, #d43a17 60%, #8d1e05); }
.bq-count-ico.is-blue { background: radial-gradient(circle at 32% 28%, #9ec5fb, #2f7fd6 60%, #14508f); }
.bq-count-sep { color: var(--text-mute); font-weight: 700; }

/* ------------------------------ 结果横幅 -------------------------------- */

.bq-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: bq-banner-in .28s cubic-bezier(.2, .8, .3, 1);
}
.bq-banner[hidden] { display: none; }
.bq-banner.is-red { border-color: rgba(244, 114, 82, 0.5); }
.bq-banner.is-blue { border-color: rgba(96, 165, 250, 0.5); }
.bq-banner.is-draw { border-color: rgba(251, 191, 36, 0.4); }

@keyframes bq-banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.bq-banner-title { font-size: 18px; font-weight: 700; }
.bq-banner-detail { margin-top: 6px; font-size: 13px; color: var(--text-dim); }
.bq-banner-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.bq-banner-actions:empty { display: none; }

/* ------------------------------- 棋盘 ----------------------------------- */

.bq-board-wrap { display: grid; place-items: center; }

.bq-board {
  display: grid;
  grid-template-columns: 64px repeat(6, 1fr) 64px;
  gap: 7px;
  width: min(100%, 470px);
  padding: 10px;
  box-sizing: border-box;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  background:
    radial-gradient(120% 120% at 18% 0%, rgba(255, 255, 255, 0.1), transparent 55%),
    linear-gradient(155deg, #303a44, #232b34 58%, #1a2129);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    0 26px 54px -26px rgba(0, 0, 0, 0.92);
  user-select: none;
  touch-action: manipulation;
  transition: transform .3s ease;
}

/* 执蓝方视角：整体旋转 180°，让自己的坑显示在下方 */
.bq-board.is-flipped { transform: rotate(180deg); }
.bq-board.is-flipped .bq-pit-num,
.bq-board.is-flipped .bq-pit-dots,
.bq-board.is-flipped .bq-store-num,
.bq-board.is-flipped .bq-store-label { transform: rotate(180deg); }

/* ------------------------------ 小坑 ------------------------------------ */

.bq-pit {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.28) 68%);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.5);
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.bq-pit-num {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
}
.bq-pit:not(.has-seeds) .bq-pit-num { color: var(--text-mute); opacity: 0.55; }

.bq-pit-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  max-width: 72%;
  line-height: 0;
  pointer-events: none;
}
.bq-pit-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(250, 235, 200, 0.85);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.bq-board.is-interactive .bq-pit.is-playable { cursor: pointer; }
.bq-board.is-interactive .bq-pit.is-playable:hover {
  border-color: rgba(139, 92, 246, 0.75);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(139, 92, 246, 0.35);
}
.bq-board.is-interactive .bq-pit:not(.is-playable) { cursor: default; }

/* 最近一次播种：起点 / 终点 */
.bq-pit.is-from,
.bq-pit.is-to { border-color: rgba(250, 204, 21, 0.75); }
.bq-pit.is-to { box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.5), 0 0 10px rgba(250, 204, 21, 0.35); }

/* ------------------------------ 计分仓 ---------------------------------- */

.bq-store {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at 40% 28%, rgba(255, 255, 255, 0.09), rgba(0, 0, 0, 0.3) 66%);
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.55);
}
.bq-store.is-red { border-color: rgba(244, 114, 82, 0.45); }
.bq-store.is-blue { border-color: rgba(96, 165, 250, 0.45); }

.bq-store-label { font-size: 11px; color: var(--text-mute); writing-mode: vertical-rl; letter-spacing: 0.2em; }

.bq-store-num {
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
}
.bq-store.is-red .bq-store-num { color: #fb9a7f; }
.bq-store.is-blue .bq-store-num { color: #9ec5fb; }

/* ------------------------------- 控制区 --------------------------------- */

.bq-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}
.bq-controls:empty { display: none; }

.bq-seeds {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
}
.bq-seeds-label { font-size: 12px; color: var(--text-dim); }

.bq-seeds-btn {
  min-width: 34px;
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.bq-seeds-btn:hover { border-color: rgba(139, 92, 246, 0.5); }
.bq-seeds-btn.is-active,
.bq-seed-btn.is-active {
  border-color: rgba(139, 92, 246, 0.85);
  background: rgba(139, 92, 246, 0.16);
  color: var(--text);
}

/* ------------------------------ 房间模式 -------------------------------- */

.bq-lobby {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: min(94vw, 620px);
  align-items: stretch;
}
.bq-lobby > .bq-notice { grid-column: 1 / -1; }

.bq-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));
}
.bq-card h3 { margin: 0 0 6px; font-size: 16px; }
.bq-card .hint { margin: 0 0 16px; font-size: 12.5px; line-height: 1.6; color: var(--text-mute); }

.bq-field { display: block; margin-bottom: 14px; }
.bq-field > span { display: block; margin-bottom: 7px; font-size: 12.5px; color: var(--text-dim); }

.bq-input {
  width: 100%;
  box-sizing: border-box;
  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;
}
.bq-input:focus { border-color: rgba(139, 92, 246, 0.7); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }
.bq-input::placeholder { color: var(--text-mute); }
.bq-input.is-room { letter-spacing: 0.22em; text-align: center; font-size: 20px; font-weight: 700; }

.bq-lobby-actions { display: flex; gap: 10px; margin-top: auto; }
.bq-lobby-actions .btn { flex: 1 1 auto; }

.bq-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);
}

.bq-room-code { display: flex; align-items: center; gap: 10px; }
.bq-room-code small { font-size: 12px; color: var(--text-mute); }
.bq-room-code b { font-size: 22px; letter-spacing: 0.16em; font-variant-numeric: tabular-nums; }
.bq-copy { padding: 6px 12px; font-size: 12px; border-radius: 999px; }

.bq-seats { display: flex; flex-wrap: wrap; gap: 10px; }

.bq-seat {
  display: flex;
  align-items: center;
  gap: 9px;
  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);
}
.bq-seat-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.16);
}
.bq-seat-dot.is-red { background: radial-gradient(circle at 32% 28%, #fb9a7f, #d43a17 60%, #8d1e05); }
.bq-seat-dot.is-blue { background: radial-gradient(circle at 32% 28%, #9ec5fb, #2f7fd6 60%, #14508f); }
.bq-seat.is-active { color: var(--text); border-color: rgba(139, 92, 246, 0.5); background: rgba(139, 92, 246, 0.12); }
.bq-seat.is-me { box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.5); }
.bq-seat.is-offline { opacity: 0.55; }
.bq-seat.is-empty { opacity: 0.6; }

.bq-seat-info { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.bq-seat-info b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 8em; }
.bq-seat-info small { font-size: 11.5px; color: var(--text-mute); }

.bq-wait { font-size: 12.5px; color: var(--text-dim); align-self: center; }

.bq-notice {
  width: 100%;
  padding: 10px 16px;
  font-size: 12.5px;
  text-align: center;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}
.bq-notice[hidden] { display: none; }
.bq-notice.is-error {
  color: #fda4af;
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(251, 113, 133, 0.12);
}

/* ------------------------------ 规则面板 -------------------------------- */

.bq-rules { width: 100%; }
.bq-rules h4 { margin: 14px 0 6px; font-size: 13.5px; color: var(--text); }
.bq-rules h4:first-child { margin-top: 0; }
.bq-rules p,
.bq-rules li { font-size: 12.8px; line-height: 1.75; color: var(--text-dim); }
.bq-rules ul { margin: 0; padding-left: 18px; }

/* ------------------------------ 响应式 ---------------------------------- */

@media (max-width: 640px) {
  .bq-board { padding: 6px; gap: 5px; grid-template-columns: 46px repeat(6, 1fr) 46px; border-radius: 12px; }
  .bq-store { padding: 8px 4px; }
  .bq-store-num { font-size: 19px; }
  .bq-store-label { writing-mode: horizontal-tb; letter-spacing: 0; font-size: 10px; }
  .bq-pit-num { font-size: 15px; }
  .bq-pit-dots i { width: 3px; height: 3px; }
  .bq-status { padding: 11px 14px; }
  .bq-bar { flex-direction: column; align-items: flex-start; }
  .bq-lobby { gap: 12px; }
  .bq-card { padding: 15px; }
  .bq-seat-info b { max-width: 6em; }
}
