/* ==========================================================================
   斗兽棋（丛林棋）
   ========================================================================== */

/* 统一布局：模式按钮（共用 .mode-tabs）居中，内容列等宽 */
.dsq-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.dsq {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(94vw, 470px);
}

.dsq-slot:empty { display: none; }

/* ------------------------------ 状态栏 ---------------------------------- */

.dsq-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);
}

.dsq-turn { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }

.dsq-turn-text { min-width: 0; line-height: 1.4; }

.dsq-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;
}
.dsq-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);
}
.dsq-turn-dot.is-green {
  background: radial-gradient(circle at 32% 28%, #9ef2b6, #1f9e55 60%, #0c5e33);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.dsq-turn-dot.is-finished { background: rgba(255, 255, 255, 0.08); box-shadow: none; }

.dsq-score { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }

.dsq-score-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);
}

.dsq-score-ico {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.dsq-score-ico.is-red { background: radial-gradient(circle at 32% 28%, #fb9a7f, #d43a17 60%, #8d1e05); }
.dsq-score-ico.is-green { background: radial-gradient(circle at 32% 28%, #9ef2b6, #1f9e55 60%, #0c5e33); }
.dsq-score-sep { color: var(--text-mute); font-weight: 700; }

/* ------------------------------ 结果横幅 -------------------------------- */

.dsq-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: dsq-banner-in .28s cubic-bezier(.2, .8, .3, 1);
}
.dsq-banner[hidden] { display: none; }
.dsq-banner.is-red { border-color: rgba(244, 114, 82, 0.5); }
.dsq-banner.is-green { border-color: rgba(74, 222, 128, 0.5); }
.dsq-banner.is-draw { border-color: rgba(251, 191, 36, 0.4); }

@keyframes dsq-banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.dsq-banner-title { font-size: 18px; font-weight: 700; }
.dsq-banner-detail { margin-top: 6px; font-size: 13px; color: var(--text-dim); }
.dsq-banner-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.dsq-banner-actions:empty { display: none; }

/* ------------------------------- 棋盘 ----------------------------------- */

.dsq-board-wrap { display: grid; place-items: center; }

.dsq-board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(9, 1fr);
  width: min(100%, 440px);
  aspect-ratio: 7 / 9;
  gap: 3px;
  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.12), transparent 55%),
    linear-gradient(155deg, #2f4436, #223428 58%, #182620);
  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;
}

/* 格子 */
.dsq-cell {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.16));
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  transition: background .2s, box-shadow .2s;
}
.dsq-cell:disabled { cursor: default; }
.dsq-cell:not(:disabled) { cursor: pointer; }
.dsq-cell:not(:disabled):hover { background: rgba(255, 255, 255, 0.12); }

/* 小河 */
.dsq-cell.is-water {
  border-color: rgba(125, 211, 252, 0.28);
  background:
    repeating-linear-gradient(-38deg, rgba(56, 130, 190, 0.28) 0 7px, rgba(28, 82, 140, 0.34) 7px 14px);
}
.dsq-cell.is-water:not(:disabled):hover { background: repeating-linear-gradient(-38deg, rgba(56, 130, 190, 0.38) 0 7px, rgba(28, 82, 140, 0.44) 7px 14px); }

/* 兽穴 */
.dsq-cell.is-den {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.35);
  background:
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.68) 12%, rgba(0, 0, 0, 0.22) 72%);
}
.dsq-cell.is-den::before {
  content: "穴";
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  pointer-events: none;
}
.dsq-cell.is-den-red { border-color: rgba(244, 114, 82, 0.55); }
.dsq-cell.is-den-green { border-color: rgba(74, 222, 128, 0.55); }

/* 陷阱 */
.dsq-cell.is-trap {
  border-style: dashed;
  border-color: rgba(251, 191, 36, 0.5);
  background:
    repeating-linear-gradient(45deg, rgba(251, 191, 36, 0.14) 0 5px, transparent 5px 11px),
    linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.14));
}
.dsq-cell.is-trap::before {
  content: "陷";
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 9px;
  line-height: 1;
  color: rgba(251, 191, 36, 0.75);
  pointer-events: none;
}

/* 棋子 */
.dsq-piece {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 86%;
  height: 86%;
  border-radius: 50%;
  transform: scale(0);
  transition: transform .18s cubic-bezier(.2, .9, .3, 1.4), background .2s, box-shadow .2s;
}
.dsq-cell.has-red .dsq-piece,
.dsq-cell.has-green .dsq-piece { transform: scale(1); }

.dsq-piece.is-red {
  background: radial-gradient(circle at 34% 26%, #ffb09a, #d84a20 58%, #8d2205);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 190, 170, 0.35);
}
.dsq-piece.is-green {
  background: radial-gradient(circle at 34% 26%, #b8f5cc, #23a45c 58%, #0b5e34);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(180, 255, 205, 0.32);
}

.dsq-face { font-size: 21px; line-height: 1; }
.dsq-rank {
  position: absolute;
  right: -3px;
  bottom: -3px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: rgba(10, 14, 26, 0.92);
  color: #f5d78e;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.dsq-cell.is-last .dsq-piece { animation: dsq-drop .3s cubic-bezier(.2, .9, .3, 1.5); }
@keyframes dsq-drop {
  from { transform: scale(0.4); }
  to { transform: scale(1); }
}

/* 选中棋子 */
.dsq-cell.is-selected { box-shadow: inset 0 0 0 2px rgba(167, 139, 250, 0.9), 0 0 14px rgba(139, 92, 246, 0.45); }

/* 合法落点：中心点 + 光圈 */
.dsq-cell.can-play::after {
  content: "";
  position: absolute;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
  pointer-events: none;
  z-index: 2;
}
.dsq-cell.can-play:hover::after { width: 28%; height: 28%; }
.dsq-cell.can-play { box-shadow: inset 0 0 0 2px rgba(251, 191, 36, 0.55); }

/* 起点淡标记（上一步来源格） */
.dsq-cell.is-src:not(.is-selected)::after {
  content: "";
  position: absolute;
  inset: 34%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

/* ------------------------------- 控制区 --------------------------------- */

.dsq-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.dsq-controls:empty { display: none; }

/* ------------------------------ 房间模式 -------------------------------- */

.dsq-lobby {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: min(94vw, 620px);
  align-items: stretch;
}
.dsq-lobby > .dsq-notice { grid-column: 1 / -1; }

.dsq-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));
}
.dsq-card h3 { margin: 0 0 6px; font-size: 16px; }
.dsq-card .hint { margin: 0 0 16px; font-size: 12.5px; line-height: 1.6; color: var(--text-mute); }

.dsq-field { display: block; margin-bottom: 14px; }
.dsq-field > span { display: block; margin-bottom: 7px; font-size: 12.5px; color: var(--text-dim); }

.dsq-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;
}
.dsq-input:focus { border-color: rgba(139, 92, 246, 0.7); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }
.dsq-input::placeholder { color: var(--text-mute); }
.dsq-input.is-room { letter-spacing: 0.22em; text-align: center; font-size: 20px; font-weight: 700; }

.dsq-lobby-actions { display: flex; gap: 10px; margin-top: auto; }
.dsq-lobby-actions .btn { flex: 1 1 auto; }

.dsq-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);
}

.dsq-room-code { display: flex; align-items: center; gap: 10px; }
.dsq-room-code small { font-size: 12px; color: var(--text-mute); }
.dsq-room-code b { font-size: 22px; letter-spacing: 0.16em; font-variant-numeric: tabular-nums; }
.dsq-copy { padding: 6px 12px; font-size: 12px; border-radius: 999px; }

.dsq-seats { display: flex; flex-wrap: wrap; gap: 10px; }

.dsq-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);
}
.dsq-seat-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.16);
}
.dsq-seat-dot.is-red { background: radial-gradient(circle at 32% 28%, #fb9a7f, #d43a17 60%, #8d1e05); }
.dsq-seat-dot.is-green { background: radial-gradient(circle at 32% 28%, #9ef2b6, #1f9e55 60%, #0c5e33); }
.dsq-seat.is-active { color: var(--text); border-color: rgba(139, 92, 246, 0.5); background: rgba(139, 92, 246, 0.12); }
.dsq-seat.is-me { box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.5); }
.dsq-seat.is-offline { opacity: 0.55; }
.dsq-seat.is-empty { opacity: 0.6; }

.dsq-seat-info { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.dsq-seat-info b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 8em; }
.dsq-seat-info small { font-size: 11.5px; color: var(--text-mute); }

.dsq-wait { font-size: 12.5px; color: var(--text-dim); align-self: center; }

.dsq-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);
}
.dsq-notice[hidden] { display: none; }
.dsq-notice.is-error {
  color: #fda4af;
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(251, 113, 133, 0.12);
}

/* ------------------------------ 规则面板 -------------------------------- */

.dsq-rules { width: 100%; }
.dsq-rules h4 { margin: 14px 0 6px; font-size: 13.5px; color: var(--text); }
.dsq-rules h4:first-child { margin-top: 0; }
.dsq-rules p,
.dsq-rules li { font-size: 12.8px; line-height: 1.75; color: var(--text-dim); }
.dsq-rules ul { margin: 0; padding-left: 18px; }

/* ------------------------------ 响应式 ---------------------------------- */

@media (max-width: 640px) {
  .dsq-board { padding: 6px; gap: 2px; border-radius: 12px; }
  .dsq-face { font-size: 17px; }
  .dsq-rank { min-width: 13px; height: 13px; line-height: 13px; font-size: 8.5px; }
  .dsq-status { padding: 11px 14px; }
  .dsq-bar { flex-direction: column; align-items: flex-start; }
  .dsq-lobby { gap: 12px; }
  .dsq-card { padding: 15px; }
  .dsq-seat-info b { max-width: 6em; }
}
