/* ==========================================================================
   海战棋 · 页面样式
   ========================================================================== */

.game-shell { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }

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

.board-zone { min-width: 0; }

.bs-grids {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.bs-grid-title { font-size: 13px; font-weight: 700; color: var(--text-dim); margin-bottom: 8px; letter-spacing: 0.04em; }
.bs-grid-title b { color: var(--accent); }

.bs-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, minmax(0, 1fr)); /* 显式行：行高钉死，不随 💥/💨 内容变化 */
  gap: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  aspect-ratio: 1;
}

.bcell {
  overflow: hidden; /* 内容超出行高时裁剪，绝不撑格 */
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: clamp(8px, 1.2vw, 14px);
  padding: 0;
  font-family: inherit;
  transition: background 0.15s;
}

.bcell:hover { background: rgba(245, 176, 74, 0.12); }

.bs-grid.own .bcell.ship { background: rgba(245, 176, 74, 0.25); border-color: rgba(245, 176, 74, 0.4); }
.bs-grid.own .bcell.sunkship { background: rgba(180, 60, 60, 0.4); border-color: rgba(239, 90, 90, 0.55); }
.bcell.hit { background: rgba(239, 90, 90, 0.35); border-color: rgba(239, 90, 90, 0.5); }
.bcell.sunk { background: rgba(120, 60, 60, 0.5); }
.bcell.miss { background: rgba(255, 255, 255, 0.05); color: var(--text-faint); }

.enemy .bcell.hit { background: rgba(239, 90, 90, 0.45); }
.enemy .bcell.sunk { background: rgba(150, 70, 70, 0.55); border-color: rgba(239, 90, 90, 0.6); }

/* 最新一炮：橙色脉冲闪现（我方/敌方各自最新一发；className 每次渲染重建，新开一炮/新对局自动清除） */
.bcell.latest { animation: latestPulse 0.9s ease-out 3; }
.bs-grid .bcell.latest {
  border-color: rgba(245, 176, 74, 0.85);
  box-shadow: inset 0 0 0 1px rgba(245, 176, 74, 0.45);
}
@keyframes latestPulse {
  0% { box-shadow: inset 0 0 0 1px rgba(245, 176, 74, 0.45), 0 0 0 0 rgba(245, 176, 74, 0.75); }
  100% { box-shadow: inset 0 0 0 1px rgba(245, 176, 74, 0.45), 0 0 0 8px rgba(245, 176, 74, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .bcell.latest { animation: none; }
}

.fleet-status {
  list-style: none;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 96px; /* 固定高度：击沉提示变化时不推挤布局 */
}
.fleet-status li { font-size: 12px; color: var(--text-dim); }
.fleet-status li.sunk { color: var(--text-faint); text-decoration: line-through; }

.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 14.5px;
  min-height: 50px;
}

.status-text { color: var(--text); font-weight: 600; }

.thinking { display: none; align-items: center; gap: 7px; margin-left: auto; color: var(--accent); font-size: 13px; font-weight: 600; }
.thinking.show { display: inline-flex; }
.thinking i {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(245, 176, 74, 0.25); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 侧栏 ---------- */
.panel { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card.hidden { display: none; }

.card-title { font-size: 14px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-dim); margin-bottom: 14px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 8px; }
.field .hint { color: var(--text-faint); font-weight: 400; font-size: 12px; }
.field-note { font-size: 12px; color: var(--text-faint); margin-top: 8px; line-height: 1.6; }

.segmented {
  display: flex; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px; gap: 4px;
}
.segmented button {
  flex: 1; font-family: var(--font); font-size: 12.5px; font-weight: 600;
  color: var(--text-faint); background: transparent; border: none; border-radius: 9px;
  padding: 8px 4px; cursor: pointer; transition: background 0.2s, color 0.2s;
}
.segmented button:hover { color: var(--text-dim); }
.segmented button.on {
  color: var(--text); background: var(--surface-2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(245, 176, 74, 0.25) inset;
}

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.ship-list { display: flex; flex-direction: column; gap: 6px; }

.ship-item {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.2s, background 0.2s;
}

.ship-item i { font-style: normal; font-size: 11px; color: var(--text-faint); font-weight: 500; }
.ship-item.sel { border-color: var(--accent); color: var(--accent); background: var(--gradient-soft); }
.ship-item.placed { opacity: 0.55; cursor: default; }

/* ---------- 弹窗 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(6, 8, 12, 0.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.overlay.show { opacity: 1; pointer-events: auto; }

.dialog {
  width: min(420px, calc(100vw - 40px));
  background: linear-gradient(165deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border-strong); border-radius: 22px; padding: 36px 32px 30px;
  text-align: center; box-shadow: 0 40px 90px -20px rgba(0, 0, 0, 0.8);
  transform: translateY(14px) scale(0.96); transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.3, 1.2);
}
.overlay.show .dialog { transform: translateY(0) scale(1); }

.dialog-icon { font-size: 52px; line-height: 1; margin-bottom: 14px; }
.dialog h2 { font-size: 24px; font-weight: 800; }
.dialog > p { color: var(--text-dim); font-size: 14.5px; margin-top: 8px; }
.dialog-btns { display: flex; gap: 12px; margin-top: 26px; justify-content: center; }
.dialog-btns .btn { min-width: 120px; }

.rules-body { text-align: left; margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.rules-body p { font-size: 13.5px; color: var(--text-dim); line-height: 1.7; }
.rules-body b { color: var(--text); }

.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 20px);
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  font-size: 14px; font-weight: 600; padding: 11px 22px; border-radius: 999px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s; z-index: 400;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .bs-layout { grid-template-columns: 1fr; }
  .panel { position: static; }
  .game-shell { padding: 20px 14px 48px; }
  .bs-grids { grid-template-columns: 1fr; }
}
