/* ==========================================================================
   角斗士棋（格格不入 / Blokus 14×14）
   ========================================================================== */

/* 统一布局：模式按钮（共用 .mode-tabs）居中，内容列等宽 */
.jds-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.jds {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(94vw, 470px);
}

.jds-slot:empty { display: none; }

/* ------------------------------ 状态栏 ---------------------------------- */

.jds-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);
}

.jds-turn { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }

.jds-turn-text { min-width: 0; line-height: 1.4; }

.jds-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;
}
.jds-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);
}
.jds-turn-dot.is-blue {
  background: radial-gradient(circle at 32% 28%, #9ec5fb, #2f7fd6 60%, #14508f);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.jds-turn-dot.is-finished { background: rgba(255, 255, 255, 0.08); box-shadow: none; }

.jds-count { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }

.jds-count-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  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);
}
.jds-count-item small { font-size: 11px; font-weight: 600; color: var(--text-mute); }

.jds-count-ico {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  align-self: center;
  flex: 0 0 auto;
}
.jds-count-ico.is-red { background: radial-gradient(circle at 32% 28%, #fb9a7f, #d43a17 60%, #8d1e05); }
.jds-count-ico.is-blue { background: radial-gradient(circle at 32% 28%, #9ec5fb, #2f7fd6 60%, #14508f); }
.jds-count-sep { color: var(--text-mute); font-weight: 700; }

/* ------------------------------ 结果横幅 -------------------------------- */

.jds-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: jds-banner-in .28s cubic-bezier(.2, .8, .3, 1);
}
.jds-banner[hidden] { display: none; }
.jds-banner.is-red { border-color: rgba(244, 114, 82, 0.5); }
.jds-banner.is-blue { border-color: rgba(96, 165, 250, 0.5); }
.jds-banner.is-draw { border-color: rgba(251, 191, 36, 0.4); }

@keyframes jds-banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.jds-banner-title { font-size: 18px; font-weight: 700; }
.jds-banner-detail { margin-top: 6px; font-size: 13px; color: var(--text-dim); }
.jds-banner-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.jds-banner-actions:empty { display: none; }

/* ------------------------------ 选子预览条 ------------------------------ */

.jds-pickbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  min-height: 78px;
  box-sizing: border-box;
}

.jds-pick-stage {
  --jds-cell: 20px;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
}

.jds-pick-hint { font-size: 12.5px; color: var(--text-mute); text-align: center; line-height: 1.5; }

.jds-pick-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.jds-pick-actions:empty { display: none; }

/* ------------------------------- 棋盘 ----------------------------------- */

.jds-board-wrap { display: grid; place-items: center; }

.jds-board {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  width: min(100%, 460px);
  gap: 2px;
  padding: 8px;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  background:
    radial-gradient(120% 120% at 18% 0%, rgba(255, 255, 255, 0.1), transparent 55%),
    linear-gradient(155deg, #303a44, #232b34 58%, #1a2129);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    0 26px 54px -26px rgba(0, 0, 0, 0.92);
  user-select: none;
  touch-action: manipulation;
}

.jds-cell {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.04);
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, box-shadow .15s;
}
.jds-board.is-interactive .jds-cell { cursor: pointer; }
.jds-board.is-interactive .jds-cell:hover { background: rgba(255, 255, 255, 0.1); }

.jds-cell.has-red {
  border-color: rgba(255, 190, 170, 0.35);
  background: linear-gradient(145deg, #e2582e, #a92f10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.jds-cell.has-blue {
  border-color: rgba(170, 210, 255, 0.35);
  background: linear-gradient(145deg, #3d8de0, #1c5394);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

/* 起始格（空着时显示 ★） */
.jds-cell.is-start-red::after,
.jds-cell.is-start-blue::after {
  content: "★";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  pointer-events: none;
}
.jds-cell.is-start-red::after { color: rgba(251, 154, 127, 0.85); }
.jds-cell.is-start-blue::after { color: rgba(158, 197, 251, 0.85); }

/* 最近一次放置的棋子描边 */
.jds-cell.is-last { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6); }

/* 落子预览虚影 */
.jds-cell.is-ghost {
  border: 1px dashed rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.22);
}
.jds-cell.is-ghost.is-bad {
  border-color: rgba(248, 113, 113, 0.9);
  background: rgba(248, 113, 113, 0.28);
}

/* ------------------------------ 棋子缩略图 ------------------------------ */

.jds-mini { display: grid; gap: 1px; }

.jds-mini-cell {
  width: var(--jds-cell, 12px);
  height: var(--jds-cell, 12px);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.05);
}
.jds-mini.is-red .jds-mini-cell.is-on {
  background: linear-gradient(145deg, #e2582e, #a92f10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.jds-mini.is-blue .jds-mini-cell.is-on {
  background: linear-gradient(145deg, #3d8de0, #1c5394);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

/* ------------------------------ 剩余棋子托盘 ---------------------------- */

.jds-tray-wrap {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.jds-tray-head { font-size: 12.5px; color: var(--text-dim); margin-bottom: 10px; }

.jds-tray { display: flex; flex-wrap: wrap; gap: 6px; }

.jds-tray-piece {
  --jds-cell: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 7px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.jds-tray-piece:hover {
  border-color: rgba(139, 92, 246, 0.5);
  background: rgba(255, 255, 255, 0.08);
}
.jds-tray-piece.is-selected {
  border-color: rgba(139, 92, 246, 0.85);
  background: rgba(139, 92, 246, 0.16);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3);
  transform: translateY(-2px);
}

.jds-tray-empty { font-size: 12.5px; color: var(--text-mute); padding: 6px 2px; }

/* ------------------------------- 控制区 --------------------------------- */

.jds-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.jds-controls:empty { display: none; }

/* ------------------------------ 房间模式 -------------------------------- */

.jds-lobby {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: min(94vw, 620px);
  align-items: stretch;
}
.jds-lobby > .jds-notice { grid-column: 1 / -1; }

.jds-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));
}
.jds-card h3 { margin: 0 0 6px; font-size: 16px; }
.jds-card .hint { margin: 0 0 16px; font-size: 12.5px; line-height: 1.6; color: var(--text-mute); }

.jds-field { display: block; margin-bottom: 14px; }
.jds-field > span { display: block; margin-bottom: 7px; font-size: 12.5px; color: var(--text-dim); }

.jds-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;
}
.jds-input:focus { border-color: rgba(139, 92, 246, 0.7); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }
.jds-input::placeholder { color: var(--text-mute); }
.jds-input.is-room { letter-spacing: 0.22em; text-align: center; font-size: 20px; font-weight: 700; }

.jds-lobby-actions { display: flex; gap: 10px; margin-top: auto; }
.jds-lobby-actions .btn { flex: 1 1 auto; }

.jds-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);
}

.jds-room-code { display: flex; align-items: center; gap: 10px; }
.jds-room-code small { font-size: 12px; color: var(--text-mute); }
.jds-room-code b { font-size: 22px; letter-spacing: 0.16em; font-variant-numeric: tabular-nums; }
.jds-copy { padding: 6px 12px; font-size: 12px; border-radius: 999px; }

.jds-seats { display: flex; flex-wrap: wrap; gap: 10px; }

.jds-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);
}
.jds-seat-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.16);
}
.jds-seat-dot.is-red { background: radial-gradient(circle at 32% 28%, #fb9a7f, #d43a17 60%, #8d1e05); }
.jds-seat-dot.is-blue { background: radial-gradient(circle at 32% 28%, #9ec5fb, #2f7fd6 60%, #14508f); }
.jds-seat.is-active { color: var(--text); border-color: rgba(139, 92, 246, 0.5); background: rgba(139, 92, 246, 0.12); }
.jds-seat.is-me { box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.5); }
.jds-seat.is-offline { opacity: 0.55; }
.jds-seat.is-empty { opacity: 0.6; }

.jds-seat-info { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.jds-seat-info b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 8em; }
.jds-seat-info small { font-size: 11.5px; color: var(--text-mute); }

.jds-wait { font-size: 12.5px; color: var(--text-dim); align-self: center; }

.jds-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);
}
.jds-notice[hidden] { display: none; }
.jds-notice.is-error {
  color: #fda4af;
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(251, 113, 133, 0.12);
}

/* ------------------------------ 规则面板 -------------------------------- */

.jds-rules { width: 100%; }
.jds-rules h4 { margin: 14px 0 6px; font-size: 13.5px; color: var(--text); }
.jds-rules h4:first-child { margin-top: 0; }
.jds-rules p,
.jds-rules li { font-size: 12.8px; line-height: 1.75; color: var(--text-dim); }
.jds-rules ul { margin: 0; padding-left: 18px; }

/* ------------------------------ 响应式 ---------------------------------- */

@media (max-width: 640px) {
  .jds-board { padding: 5px; gap: 1px; border-radius: 10px; }
  .jds-status { padding: 11px 14px; }
  .jds-pickbar { padding: 8px 10px; min-height: 64px; }
  .jds-pick-stage { --jds-cell: 16px; min-height: 46px; }
  .jds-tray-wrap { padding: 10px 11px; }
  .jds-tray-piece { --jds-cell: 10px; padding: 4px 5px; }
  .jds-bar { flex-direction: column; align-items: flex-start; }
  .jds-lobby { gap: 12px; }
  .jds-card { padding: 15px; }
  .jds-seat-info b { max-width: 6em; }
}
