/* ==========================================================================
   海战棋（Battleship）
   ========================================================================== */

/* 统一宽度：模式标签与下方内容列（状态栏 / 双棋盘 / 控制区 / 规则）等宽 */
.bs-app {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  width: min(94vw, 620px);
  margin: 0 auto;
}

.bs {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.bs-slot:empty { display: none; }

/* 大厅状态下隐藏对局相关区域 */
.bs.is-lobby .bs-status,
.bs.is-lobby .bs-boards,
.bs.is-lobby .bs-controls,
.bs.is-lobby .bs-banner,
.bs.is-lobby .bs-notice { display: none; }

/* ------------------------------ 模式切换 -------------------------------- */

.bs-tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.bs-tab {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 15px;
  font-family: inherit;
  text-align: left;
  color: var(--text-dim);
  border: none;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: color .2s, background .2s, box-shadow .2s;
}
.bs-tab b { font-size: 14px; color: inherit; }
.bs-tab small { font-size: 11.5px; color: var(--text-mute); }
.bs-tab:hover { color: var(--text); background: var(--surface-2); }
.bs-tab.is-active {
  color: #0a0e1a;
  background: linear-gradient(120deg, #a78bfa, #22d3ee);
  box-shadow: 0 14px 30px -18px rgba(139, 92, 246, 0.95);
}
.bs-tab.is-active small { color: rgba(10, 14, 26, 0.7); }

.bs-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ------------------------------ 状态栏 ---------------------------------- */

.bs-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.bs-turn { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }

.bs-turn-icon {
  position: relative;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  transition: border-color .25s, background .25s;
}
.bs-turn-icon::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
}
.bs-turn-icon.is-mine { border-color: rgba(34, 211, 238, 0.85); background: rgba(34, 211, 238, 0.18); }
.bs-turn-icon.is-mine::after { background: #22d3ee; }
.bs-turn-icon.is-foe { border-color: rgba(248, 113, 113, 0.8); background: rgba(248, 113, 113, 0.16); }
.bs-turn-icon.is-foe::after { background: #f87171; }
.bs-turn-icon.is-finished { border-color: rgba(167, 139, 250, 0.7); }
.bs-turn-icon.is-finished::after { background: #a78bfa; }

.bs-stats { display: inline-flex; align-items: center; gap: 8px; }
.bs-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.035);
  font-variant-numeric: tabular-nums;
}
.bs-stat small { font-size: 11px; color: var(--text-mute); }
.bs-stat b { font-size: 14px; color: var(--text); }

/* ------------------------------ 结果横幅 -------------------------------- */

.bs-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: bs-banner-in .28s cubic-bezier(.2, .8, .3, 1);
}
.bs-banner[hidden] { display: none; }
.bs-banner.is-win { border-color: rgba(34, 211, 238, 0.5); }

@keyframes bs-banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.bs-banner-title { font-size: 18px; font-weight: 700; }
.bs-banner-detail { margin-top: 6px; font-size: 13px; color: var(--text-dim); }
.bs-banner-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.bs-banner-actions:empty { display: none; }

.bs-wait { font-size: 12.5px; color: var(--text-mute); align-self: center; }

/* ------------------------------ 双棋盘 ---------------------------------- */

.bs-boards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.bs-board {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  background:
    radial-gradient(120% 120% at 18% 0%, rgba(255, 255, 255, 0.1), transparent 55%),
    linear-gradient(155deg, #123c5e, #0d2f4a 58%, #082233);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 22px 46px -26px rgba(0, 0, 0, 0.92);
}

.bs-board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-height: 18px;
}
.bs-board-title { font-size: 13px; color: rgba(226, 240, 255, 0.92); }
.bs-board-tag { font-size: 11px; color: rgba(226, 240, 255, 0.6); font-variant-numeric: tabular-nums; }

.bs-grid {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  grid-template-rows: repeat(11, 1fr);
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.26);
}

.bs-coord {
  display: grid;
  place-items: center;
  font-size: 8.5px;
  color: rgba(226, 240, 255, 0.45);
  user-select: none;
}

.bs-cell {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.32);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.06));
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  transition: background .18s;
}
.bs-cell:disabled { cursor: default; }
.bs-cell.can-fire, .bs-cell.can-place { cursor: pointer; }
.bs-cell.can-fire:hover { background: rgba(248, 113, 113, 0.3); }
.bs-cell.can-place:hover { background: rgba(56, 189, 248, 0.3); }

/* 弹着点：未命中一个小点，命中一个叉，被击沉的格子染红 */
.bs-pin { width: 100%; height: 100%; display: grid; place-items: center; }

.bs-cell.is-ship { background: linear-gradient(160deg, rgba(148, 163, 184, 0.85), rgba(100, 116, 139, 0.75)); }
.bs-cell.is-ship .bs-pin::after {
  content: "";
  width: 52%;
  height: 52%;
  border-radius: 3px;
  background: rgba(15, 23, 42, 0.55);
}

.bs-cell.is-hit { background: rgba(248, 113, 113, 0.34); }
.bs-cell.is-hit .bs-pin::after {
  content: "×";
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  color: #fca5a5;
}

.bs-cell.is-sunk { background: rgba(220, 38, 38, 0.52); }
.bs-cell.is-sunk .bs-pin::after {
  content: "×";
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  color: #fee2e2;
}

.bs-cell.is-miss { background: rgba(255, 255, 255, 0.06); }
.bs-cell.is-miss .bs-pin::after {
  content: "";
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(226, 240, 255, 0.5);
}

/* 刚落下的炮弹 */
.bs-cell.is-last { animation: bs-hit .34s ease-out; }
@keyframes bs-hit {
  from { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85); }
  to { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0); }
}

/* ------------------------------ 舰队清单 -------------------------------- */

.bs-fleet { display: flex; flex-wrap: wrap; gap: 5px; }
.bs-fleet:empty { display: none; }

.bs-ship {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 999px;
  border: 1px solid rgba(226, 240, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(226, 240, 255, 0.78);
}
.bs-ship b { font-weight: 600; }
.bs-ship small { font-size: 10px; color: rgba(226, 240, 255, 0.55); font-variant-numeric: tabular-nums; }
.bs-ship.is-sunk { border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.14); color: #fecaca; }
.bs-ship.is-sunk small { color: rgba(254, 202, 202, 0.75); }
.bs-ship.is-active { border-color: rgba(56, 189, 248, 0.55); background: rgba(56, 189, 248, 0.16); color: #bae6fd; }
.bs-ship.is-active small { color: rgba(186, 230, 253, 0.8); }

/* ------------------------------- 控制区 --------------------------------- */

.bs-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.bs-controls:empty { display: none; }

.bs-hint-inline { font-size: 12.5px; color: var(--text-mute); align-self: center; }

/* ------------------------------- 提示行 --------------------------------- */

.bs-notice {
  padding: 10px 14px;
  font-size: 13px;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-dim);
}
.bs-notice[hidden] { display: none; }
.bs-notice.is-error { border-color: rgba(248, 113, 113, 0.45); color: #fca5a5; }

/* ------------------------------- 规则 ----------------------------------- */

.bs-rules h4 { margin: 14px 0 6px; font-size: 13.5px; color: var(--text); }
.bs-rules h4:first-child { margin-top: 0; }
.bs-rules p, .bs-rules li { font-size: 12.8px; line-height: 1.75; color: var(--text-dim); }
.bs-rules ul { margin: 0; padding-left: 18px; }

/* ------------------------------ 房间模式 -------------------------------- */

/* 左：创建房间；右：加入房间 */
.bs-lobby {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.bs-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}
.bs-card h3 { margin: 0; font-size: 15px; }
.bs-card p { margin: 0; font-size: 12.5px; line-height: 1.7; color: var(--text-mute); }
.bs-card .btn { margin-top: auto; }

.bs-field { display: flex; flex-direction: column; gap: 5px; }
.bs-field span { font-size: 12px; color: var(--text-mute); }
.bs-field input {
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  border-radius: 11px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.04);
  outline: none;
  transition: border-color .2s, background .2s;
}
.bs-field input:focus { border-color: rgba(139, 92, 246, 0.6); background: rgba(255, 255, 255, 0.06); }

.bs-room {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.bs-room-code { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-mute); }
.bs-room-code b { font-size: 17px; letter-spacing: 2px; color: var(--text); font-variant-numeric: tabular-nums; }

.bs-seats { display: inline-flex; align-items: center; gap: 10px; }
.bs-seat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-dim);
}
.bs-seat b { font-size: 11.5px; color: var(--text-mute); }
.bs-seat span { color: var(--text); }
.bs-seat small { font-size: 11px; color: var(--text-mute); }
.bs-seat em { font-size: 11px; font-style: normal; color: var(--text-mute); }
.bs-seat em.is-ok { color: #6ee7b7; }
.bs-seat.is-mine { border-color: rgba(139, 92, 246, 0.5); background: rgba(139, 92, 246, 0.14); }

/* ------------------------------ 窄屏适配 -------------------------------- */

@media (max-width: 620px) {
  .bs-boards { gap: 10px; }
  .bs-board { padding: 8px; }
  .bs-coord { font-size: 7.5px; }
  .bs-cell.is-hit .bs-pin::after,
  .bs-cell.is-sunk .bs-pin::after { font-size: 12px; }
  .bs-lobby { grid-template-columns: minmax(0, 1fr); }
  .bs-room { padding: 11px 13px; }
}
