/* ==========================================================================
   军棋（Junqi · 双人陆战棋）
   ========================================================================== */

.jq-app {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  width: min(94vw, 620px);
  margin: 0 auto;
}

.jq {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.jq-slot:empty { display: none; }

/* 大厅状态下隐藏对局相关区域 */
.jq.is-lobby .jq-status,
.jq.is-lobby .jq-board-wrap,
.jq.is-lobby .jq-tray-wrap,
.jq.is-lobby .jq-controls,
.jq.is-lobby .jq-banner,
.jq.is-lobby .jq-notice { display: none; }

/* ------------------------------ 模式切换 -------------------------------- */

.jq-tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.jq-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;
}
.jq-tab b { font-size: 14px; color: inherit; }
.jq-tab small { font-size: 11.5px; color: var(--text-mute); }
.jq-tab:hover { color: var(--text); background: var(--surface-2); }
.jq-tab.is-active {
  color: #0a0e1a;
  background: linear-gradient(120deg, #a78bfa, #22d3ee);
  box-shadow: 0 14px 30px -18px rgba(139, 92, 246, 0.95);
}
.jq-tab.is-active small { color: rgba(10, 14, 26, 0.7); }

.jq-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ------------------------------ 状态栏 ---------------------------------- */

.jq-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.jq-turn { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }
.jq-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;
}
.jq-turn-icon::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
}
.jq-turn-icon.is-mine { border-color: rgba(34, 211, 238, 0.85); background: rgba(34, 211, 238, 0.18); }
.jq-turn-icon.is-mine::after { background: #22d3ee; }
.jq-turn-icon.is-foe { border-color: rgba(248, 113, 113, 0.8); background: rgba(248, 113, 113, 0.16); }
.jq-turn-icon.is-foe::after { background: #f87171; }
.jq-turn-icon.is-finished { border-color: rgba(167, 139, 250, 0.7); }
.jq-turn-icon.is-finished::after { background: #a78bfa; }

.jq-stats { display: inline-flex; align-items: center; gap: 8px; }
.jq-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;
}
.jq-stat small { font-size: 11px; color: var(--text-mute); }
.jq-stat b { font-size: 14px; color: var(--text); }
.jq-stat.is-x b { color: #fca5a5; }
.jq-stat.is-o b { color: #7dd3fc; }

/* ------------------------------ 结果横幅 -------------------------------- */

.jq-banner {
  width: 100%;
  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: jq-banner-in .28s cubic-bezier(.2, .8, .3, 1);
}
.jq-banner[hidden] { display: none; }
.jq-banner.is-win { border-color: rgba(34, 211, 238, 0.5); }

@keyframes jq-banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.jq-banner-title { font-size: 18px; font-weight: 700; }
.jq-banner-detail { margin-top: 6px; font-size: 13px; color: var(--text-dim); }
.jq-banner-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.jq-banner-actions:empty { display: none; }
.jq-wait { font-size: 12.5px; color: var(--text-mute); align-self: center; }

/* ------------------------------- 棋盘 ----------------------------------- */

.jq-board-wrap { width: 100%; display: flex; justify-content: center; }

.jq-board {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(92vw, 430px);
  padding: 12px 12px 10px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.42);
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(255, 255, 255, 0.09), transparent 55%),
    linear-gradient(158deg, #2a3a2c, #1d2a22 55%, #141d18);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 22px 46px -26px rgba(0, 0, 0, 0.92);
}

.jq-side {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}
.jq-side b { font-size: 12px; color: rgba(226, 240, 255, 0.9); }
.jq-side small { font-size: 10.5px; color: rgba(226, 240, 255, 0.5); }
.jq-side.is-bottom b { color: rgba(254, 205, 211, 0.95); }

.jq-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  padding: 5px;
}

.jq-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 0.78;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 7px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.1));
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  transition: background .18s, box-shadow .18s;
}
.jq-cell:disabled { cursor: default; }

/* 铁路线：横线 / 竖线（黑白相间的轨道） */
.jq-cell.is-rail-h::before,
.jq-cell.is-rail-v::after {
  content: "";
  position: absolute;
  background: repeating-linear-gradient(90deg, rgba(226, 240, 255, 0.5) 0 5px, rgba(226, 240, 255, 0.1) 5px 10px);
  z-index: 0;
}
.jq-cell.is-rail-h::before { left: 0; right: 0; top: 50%; height: 6px; transform: translateY(-50%); }
.jq-cell.is-rail-v::after {
  top: 0; bottom: 0; left: 50%; width: 6px; transform: translateX(-50%);
  background: repeating-linear-gradient(0deg, rgba(226, 240, 255, 0.5) 0 5px, rgba(226, 240, 255, 0.1) 5px 10px);
}

/* 行营：圆圈，子力安全区 */
.jq-cell.is-camp {
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.12));
  box-shadow: inset 0 0 0 2px rgba(226, 240, 255, 0.3);
}
.jq-cell.is-camp .jq-chip { border-radius: 50%; }

/* 大本营：橙色扁框，军旗的家 */
.jq-cell.is-hq {
  border-color: rgba(251, 191, 36, 0.55);
  background: linear-gradient(160deg, rgba(251, 191, 36, 0.26), rgba(251, 146, 60, 0.14));
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.35);
}
.jq-cell.is-hq::before {
  content: "大本营";
  position: absolute;
  right: 3px;
  top: 2px;
  font-size: 7px;
  line-height: 1;
  color: rgba(253, 230, 138, 0.75);
  z-index: 0;
}

/* 棋子 */
.jq-chip {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 86%;
  height: 84%;
  border-radius: 6px;
  font-size: clamp(11px, 3.2vw, 16px);
  font-weight: 700;
  color: #0b1020;
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.7);
}
.jq-chip:empty { border: none; background: none; box-shadow: none; }

.jq-cell.is-x .jq-chip { background: linear-gradient(165deg, #fca5a5, #ef4444); color: #2b0606; }
.jq-cell.is-o .jq-chip { background: linear-gradient(165deg, #93c5fd, #3b82f6); color: #06132b; }

/* 暗棋：未知棋子显示为背面 */
.jq-cell.is-hidden .jq-chip {
  background: linear-gradient(160deg, rgba(148, 163, 184, 0.5), rgba(71, 85, 105, 0.75));
  color: rgba(226, 240, 255, 0.85);
  border-color: rgba(226, 240, 255, 0.18);
}
/* 交锋后亮明的棋子加一圈光 */
.jq-cell.is-revealed .jq-chip { box-shadow: inset 0 0 0 2px rgba(253, 224, 71, 0.75); }

/* 选中 / 可落点 / 布阵落点 */
.jq-cell.is-selected { box-shadow: inset 0 0 0 3px #a78bfa; }
.jq-cell.is-pick .jq-chip { cursor: pointer; }
.jq-cell.is-occupied.is-pick { cursor: pointer; }
.jq-cell.is-valid { box-shadow: inset 0 0 0 2px rgba(34, 211, 238, 0.55); cursor: pointer; }
.jq-cell.is-target { background: rgba(34, 211, 238, 0.16); cursor: pointer; }
.jq-cell.is-target .jq-chip:empty::after {
  content: "";
  width: 34%;
  height: 34%;
  border-radius: 50%;
  background: #22d3ee;
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.8);
}
.jq-cell.is-target.is-occupied .jq-chip { box-shadow: inset 0 0 0 3px #f87171; }

.jq-cell.is-last-from { background: rgba(167, 139, 250, 0.18); }
.jq-cell.is-last-to { box-shadow: inset 0 0 0 2px rgba(167, 139, 250, 0.7); }

/* ------------------------------ 棋子槽 ---------------------------------- */

.jq-tray-wrap { width: 100%; }
.jq-tray {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}
.jq-tray-title { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }

.jq-tray-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.jq-tray-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  font-family: inherit;
  border-radius: 9px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color .18s, background .18s, color .18s, transform .18s;
}
.jq-tray-item b { font-size: 12px; color: var(--text); font-weight: 600; }
.jq-tray-item small { font-size: 10px; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.jq-tray-item:hover:not(.is-disabled) { border-color: rgba(139, 92, 246, 0.5); background: rgba(139, 92, 246, 0.12); transform: translateY(-1px); }
.jq-tray-item.is-active { border-color: rgba(34, 211, 238, 0.7); background: rgba(34, 211, 238, 0.16); }
.jq-tray-item.is-active b { color: #a5f3fc; }
.jq-tray-item.is-disabled, .jq-tray-item:disabled { opacity: 0.42; cursor: default; }
.jq-tray-item.is-placed b { color: var(--text-mute); }

.jq-tray-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-mute);
}
.jq-tray-count b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ------------------------------- 控制区 --------------------------------- */

.jq-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: 100%;
}
.jq-controls:empty { display: none; }
.jq-hint-inline { font-size: 12.5px; color: var(--text-mute); align-self: center; }

/* ------------------------------- 提示行 --------------------------------- */

.jq-notice {
  width: 100%;
  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);
}
.jq-notice[hidden] { display: none; }
.jq-notice.is-error { border-color: rgba(248, 113, 113, 0.45); color: #fca5a5; }

/* ------------------------------- 规则 ----------------------------------- */

.jq-rules { width: 100%; }
.jq-rules h4 { margin: 14px 0 6px; font-size: 13.5px; color: var(--text); }
.jq-rules h4:first-child { margin-top: 0; }
.jq-rules p, .jq-rules li { font-size: 12.8px; line-height: 1.75; color: var(--text-dim); }
.jq-rules ul { margin: 0; padding-left: 18px; }

/* ------------------------------ 房间模式 -------------------------------- */

.jq-lobby {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.jq-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}
.jq-card h3 { margin: 0; font-size: 15px; }
.jq-card p { margin: 0; font-size: 12.5px; line-height: 1.7; color: var(--text-mute); }
.jq-card-tip { color: var(--text-mute); }
.jq-card .btn { margin-top: auto; }

.jq-field { display: flex; flex-direction: column; gap: 5px; }
.jq-field > span { font-size: 12px; color: var(--text-mute); }
.jq-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;
}
.jq-field input:focus { border-color: rgba(139, 92, 246, 0.6); background: rgba(255, 255, 255, 0.06); }

.jq-open-options { display: flex; gap: 8px; }
.jq-open-options .pc-btn { flex: 1 1 0; }

.jq-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);
}

.jq-room-code { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-mute); }
.jq-room-code b { font-size: 17px; letter-spacing: 2px; color: var(--text); font-variant-numeric: tabular-nums; }

.jq-seats { display: inline-flex; align-items: center; gap: 10px; }
.jq-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);
}
.jq-seat b { font-size: 11.5px; color: var(--text-mute); }
.jq-seat span { color: var(--text); }
.jq-seat small { font-size: 11px; color: var(--text-mute); }
.jq-seat em { font-size: 11px; font-style: normal; color: var(--text-mute); }
.jq-seat em.is-ok { color: #6ee7b7; }
.jq-seat.is-mine { border-color: rgba(139, 92, 246, 0.5); background: rgba(139, 92, 246, 0.14); }

/* ------------------------------ 窄屏适配 -------------------------------- */

@media (max-width: 620px) {
  .jq-board { width: min(96vw, 400px); padding: 10px 10px 8px; }
  .jq-grid { gap: 4px; padding: 4px; }
  .jq-tray-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .jq-lobby { grid-template-columns: minmax(0, 1fr); }
  .jq-room { padding: 11px 13px; }
  .jq-status { padding: 11px 13px; }
  .jq-turn { font-size: 13.5px; }
}
