/* ==========================================================================
   路墙棋（步步为营 · 11 路）
   ========================================================================== */

/* 统一布局：模式按钮（共用 .mode-tabs）居中，内容列等宽 */
.lwq-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lwq {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(94vw, 620px);
}

.lwq-slot:empty { display: none; }

/* ------------------------------ 状态栏 ---------------------------------- */

.lwq-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);
}

.lwq-turn { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }

.lwq-turn-text { min-width: 0; line-height: 1.4; }

.lwq-turn-pawn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.14);
  transition: background .25s, box-shadow .25s;
}
.lwq-turn-pawn.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);
}
.lwq-turn-pawn.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);
}
.lwq-turn-pawn.is-finished { background: rgba(255, 255, 255, 0.08); box-shadow: none; }

.lwq-walls-score { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }

.lwq-walls-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  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);
}

.lwq-wall-ico {
  width: 14px;
  height: 8px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.lwq-wall-ico.is-black { background: linear-gradient(160deg, #3a4356, #10151f); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.lwq-wall-ico.is-white { background: linear-gradient(160deg, #f4f6fb, #c3cad9); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); }
.lwq-walls-sep { color: var(--text-mute); font-weight: 700; }

/* ------------------------------ 结果横幅 -------------------------------- */

.lwq-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: lwq-banner-in .28s cubic-bezier(.2, .8, .3, 1);
}
.lwq-banner[hidden] { display: none; }
.lwq-banner.is-black { border-color: rgba(148, 163, 184, 0.45); }
.lwq-banner.is-white { border-color: rgba(226, 232, 240, 0.4); }
.lwq-banner.is-draw { border-color: rgba(251, 191, 36, 0.4); }

@keyframes lwq-banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.lwq-banner-title { font-size: 18px; font-weight: 700; }
.lwq-banner-detail { margin-top: 6px; font-size: 13px; color: var(--text-dim); }
.lwq-banner-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.lwq-banner-actions:empty { display: none; }

/* ------------------------------- 棋盘 ----------------------------------- */

.lwq-board-wrap { display: grid; place-items: center; }

.lwq-board {
  position: relative;
  display: grid;
  width: min(100%, 560px);
  aspect-ratio: 1 / 1;
  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.14), transparent 55%),
    linear-gradient(155deg, #2b3a55, #1f2c42 58%, #172234);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 26px 54px -26px rgba(0, 0, 0, 0.92);
  user-select: none;
}

/* 墙体浮层：铺满棋盘内容区，轨道由 ui.js 复制棋盘网格（必须与棋盘一致），不拦截点击 */
.lwq-wall-layer {
  position: absolute;
  inset: 10px;
  display: grid;
  pointer-events: none;
}

/* 格子 */
.lwq-cell {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.14));
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  transition: background .2s, box-shadow .2s;
}
.lwq-cell:disabled { cursor: default; }
.lwq-cell.can-play { cursor: pointer; }
.lwq-cell.can-play:hover { background: rgba(255, 255, 255, 0.16); }

/* 合法落点提示 */
.lwq-cell.can-play::after {
  content: "";
  position: absolute;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.32);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.26);
  pointer-events: none;
}
.lwq-cell.can-play:hover::after { width: 30%; height: 30%; }

/* 棋子 */
.lwq-pawn {
  width: 74%;
  height: 74%;
  border-radius: 50%;
  transform: scale(0);
  transition: transform .18s cubic-bezier(.2, .9, .3, 1.4), background .2s, box-shadow .2s;
}
.lwq-cell.has-black .lwq-pawn,
.lwq-cell.has-white .lwq-pawn { transform: scale(1); }
.lwq-cell.has-black .lwq-pawn {
  background: radial-gradient(circle at 32% 28%, #7b8494, #141b2b 58%, #04070f);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.lwq-cell.has-white .lwq-pawn {
  background: radial-gradient(circle at 32% 28%, #ffffff, #e9ecf5 55%, #b6bdcf);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.36);
}
.lwq-cell.is-last .lwq-pawn { animation: lwq-drop .3s cubic-bezier(.2, .9, .3, 1.5); }
@keyframes lwq-drop {
  from { transform: scale(0.4); }
  to { transform: scale(1); }
}

/* 墙缝交叉点（放墙的点击位） */
.lwq-junc {
  position: relative;
  z-index: 3;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}
.lwq-junc::before {
  content: "";
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  transition: background .2s, box-shadow .2s;
}
.lwq-junc.is-ok { cursor: pointer; }
.lwq-junc.is-ok::before { background: rgba(251, 191, 36, 0.65); box-shadow: 0 0 8px rgba(251, 191, 36, 0.5); }

/* 筑墙模式下的悬停预览：按当前方向显示幽灵墙 */
.lwq-board.is-wall-mode.orient-h .lwq-junc.is-ok::after,
.lwq-board.is-wall-mode.orient-v .lwq-junc.is-ok::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 4px;
  background: rgba(251, 191, 36, 0.35);
  pointer-events: none;
}
/* 536% ≈ (2 × 1fr + 0.42fr) / 0.42fr：与实际墙体的长度（跨 2 格 + 1 缝）保持一致 */
.lwq-board.is-wall-mode.orient-h .lwq-junc.is-ok::after { width: 536%; height: 52%; }
.lwq-board.is-wall-mode.orient-v .lwq-junc.is-ok::after { width: 52%; height: 536%; }
.lwq-board.is-wall-mode .lwq-junc.is-ok:hover::after { background: rgba(251, 191, 36, 0.6); }

/* 已放置的墙 */
.lwq-wall {
  z-index: 2;
  align-self: center;
  justify-self: stretch;
  border-radius: 5px;
  background: linear-gradient(160deg, #f7c45c, #d98f1f 60%, #a8680e);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.28),
    0 2px 6px rgba(0, 0, 0, 0.45);
  animation: lwq-wall-in .22s cubic-bezier(.2, .9, .3, 1.4);
}
.lwq-wall.is-h { height: 52%; margin: 0 3px; }
.lwq-wall.is-v { width: 52%; margin: 3px 0; justify-self: center; align-self: stretch; }
.lwq-wall.is-last { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28), 0 0 12px rgba(251, 191, 36, 0.75); }

@keyframes lwq-wall-in {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

/* ------------------------------- 控制区 --------------------------------- */

.lwq-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.lwq-controls:empty { display: none; }

.lwq-controls .btn.is-active {
  color: #0a0e1a;
  border-color: transparent;
  background: linear-gradient(120deg, #a78bfa, #22d3ee);
}

.lwq-ctl-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border-soft);
}

/* ------------------------------ 房间模式 -------------------------------- */

.lwq-lobby {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: min(94vw, 620px);
  align-items: stretch;
}
.lwq-lobby > .lwq-notice { grid-column: 1 / -1; }

.lwq-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));
}
.lwq-card h3 { margin: 0 0 6px; font-size: 16px; }
.lwq-card .hint { margin: 0 0 16px; font-size: 12.5px; line-height: 1.6; color: var(--text-mute); }

.lwq-field { display: block; margin-bottom: 14px; }
.lwq-field > span { display: block; margin-bottom: 7px; font-size: 12.5px; color: var(--text-dim); }

.lwq-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;
}
.lwq-input:focus { border-color: rgba(139, 92, 246, 0.7); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }
.lwq-input::placeholder { color: var(--text-mute); }
.lwq-input.is-room { letter-spacing: 0.22em; text-align: center; font-size: 20px; font-weight: 700; }

.lwq-lobby-actions { display: flex; gap: 10px; margin-top: auto; }
.lwq-lobby-actions .btn { flex: 1 1 auto; }

.lwq-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);
}

.lwq-room-code { display: flex; align-items: center; gap: 10px; }
.lwq-room-code small { font-size: 12px; color: var(--text-mute); }
.lwq-room-code b { font-size: 22px; letter-spacing: 0.16em; font-variant-numeric: tabular-nums; }
.lwq-copy { padding: 6px 12px; font-size: 12px; border-radius: 999px; }

.lwq-seats { display: flex; flex-wrap: wrap; gap: 10px; }

.lwq-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);
}
.lwq-seat-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.16);
}
.lwq-seat-dot.is-black { background: radial-gradient(circle at 32% 28%, #7b8494, #141b2b 58%, #04070f); }
.lwq-seat-dot.is-white { background: radial-gradient(circle at 32% 28%, #fff, #e9ecf5 58%, #b6bdcf); }
.lwq-seat.is-active { color: var(--text); border-color: rgba(139, 92, 246, 0.5); background: rgba(139, 92, 246, 0.12); }
.lwq-seat.is-me { box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.5); }
.lwq-seat.is-offline { opacity: 0.55; }
.lwq-seat.is-empty { opacity: 0.6; }

.lwq-seat-info { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.lwq-seat-info b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 8em; }
.lwq-seat-info small { font-size: 11.5px; color: var(--text-mute); }

.lwq-wait { font-size: 12.5px; color: var(--text-dim); align-self: center; }

.lwq-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);
}
.lwq-notice[hidden] { display: none; }
.lwq-notice.is-error {
  color: #fda4af;
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(251, 113, 133, 0.12);
}

/* ------------------------------ 规则面板 -------------------------------- */

.lwq-rules { width: 100%; }
.lwq-rules h4 { margin: 14px 0 6px; font-size: 13.5px; color: var(--text); }
.lwq-rules h4:first-child { margin-top: 0; }
.lwq-rules p,
.lwq-rules li { font-size: 12.8px; line-height: 1.75; color: var(--text-dim); }
.lwq-rules ul { margin: 0; padding-left: 18px; }

/* ------------------------------ 响应式 ---------------------------------- */

@media (max-width: 640px) {
  .lwq-board { padding: 7px; }
  .lwq-wall-layer { inset: 7px; }
  .lwq-status { padding: 11px 14px; }
  .lwq-bar { flex-direction: column; align-items: flex-start; }
  .lwq-lobby { gap: 12px; }
  .lwq-card { padding: 15px; }
  .lwq-seat-info b { max-width: 6em; }
  .lwq-ctl-sep { display: none; }
}
