/* ============================================================
 *  中国象棋（小朋友学象棋）样式 - 命名隔离：所有 class 统一 xq- 前缀
 *  与 dark-chess.css 的 chess- 前缀保持区分，避免通用类名冲突
 * ============================================================ */

/* ========== 基础（作用域：body.xq-root 及其后代） ========== */
body.xq-root, body.xq-root * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body.xq-root {
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 50%, #fcd34d 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

body.xq-root h1 {
  font-size: clamp(24px, 4vw, 40px);
  color: #7c2d12;
  margin-bottom: 10px;
  text-shadow: 2px 2px 0 #fef3c7;
  letter-spacing: 4px;
  white-space: nowrap;
}

/* ========== 状态栏 ========== */
.xq-status-bar {
  background: #fffbeb;
  border: 3px solid #92400e;
  border-radius: 16px;
  padding: 8px 20px;
  margin-bottom: 10px;
  font-size: clamp(16px, 2.6vw, 22px);
  color: #78350f;
  font-weight: bold;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.xq-turn-dot {
  width: clamp(14px, 2.2vw, 20px);
  height: clamp(14px, 2.2vw, 20px);
  border-radius: 50%;
  border: 2px solid #78350f;
  flex-shrink: 0;
}
.xq-turn-dot.xq-red { background: #dc2626; }
.xq-turn-dot.xq-black { background: #1f2937; }

/* ========== 棋盘 ========== */
.xq-board-wrapper {
  position: relative;
  background: #fbbf24;
  border: 6px solid #78350f;
  border-radius: 12px;
  padding: clamp(10px, 2vw, 20px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  max-width: 100%;
}

.xq-canvas {
  display: block;
  cursor: pointer;
  background: #fde68a;
  border-radius: 6px;
  max-width: 100%;
  height: auto;
}

/* ========== 控制按钮 ========== */
.xq-controls {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.xq-btn {
  font-size: clamp(14px, 2vw, 18px);
  padding: clamp(10px, 1.8vw, 16px) clamp(20px, 3.5vw, 32px);
  border: none;
  border-radius: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
  box-shadow: 0 4px 0 rgba(0,0,0,0.2);
  color: white;
  min-height: 44px;
  line-height: 1.2;
}
.xq-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}
.xq-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.xq-btn-restart { background: #16a34a; }
.xq-btn-undo { background: #2563eb; }

/* ========== 游戏结束弹窗 ========== */
.xq-game-over-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.xq-game-over-modal.xq-show { display: flex; }
.xq-modal-content {
  background: white;
  padding: 30px 40px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-width: 90%;
}
.xq-modal-content h2 {
  font-size: clamp(24px, 5vw, 40px);
  margin-bottom: 16px;
  color: #7c2d12;
}
.xq-modal-content .xq-btn { font-size: clamp(18px, 3vw, 24px); padding: 12px 32px; }

/* ========== 底部提示 ========== */
.xq-footer-tip {
  margin-top: 10px;
  color: #92400e;
  font-size: clamp(12px, 2vw, 16px);
  text-align: center;
}

/* ========== 响应式：横屏 Pad 优化 ========== */
@media (orientation: landscape) and (max-height: 600px) {
  body.xq-root h1 { font-size: 24px; margin-bottom: 6px; }
  .xq-status-bar { padding: 6px 16px; margin-bottom: 6px; font-size: 16px; min-height: 36px; }
  .xq-board-wrapper { padding: 10px; border-width: 4px; }
  .xq-controls { margin-top: 8px; gap: 8px; }
  .xq-btn { padding: 8px 18px; font-size: 16px; }
  .xq-explain-box { margin-top: 8px; padding: 8px 12px; min-height: 56px; }
  .xq-explain-box h3 { font-size: 16px; margin-bottom: 2px; }
  .xq-explain-box p { font-size: 14px; line-height: 1.4; }
  .xq-footer-tip { margin-top: 6px; }
  .xq-captured-box { padding: 6px 10px; min-height: 44px; }
  .xq-captured-title { font-size: 12px; margin-bottom: 4px; }
  .xq-cap-piece { width: 24px; height: 24px; font-size: 13px; }
  .xq-ai-commentary { padding: 10px 14px; min-height: 80px; }
  .xq-ai-commentary-title { font-size: 16px; }
  .xq-ai-commentary-body { font-size: 14px; line-height: 1.4; min-height: 50px; }
  .xq-btn-commentary-toggle { font-size: 14px; padding: 4px 10px; }
}

/* ============================================================
 * 主布局 + AI 讲解模块 + 吃子展示样式
 * ============================================================ */

/* 主布局：移动端纵向堆叠，宽屏 3 列并排 */
.xq-main-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}
.xq-center-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.xq-side-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 420px;
}
.xq-left-col {
  display: none; /* 移动端隐藏左侧吃子栏，宽屏再显示 */
}

/* 吃子展示区 */
.xq-captured-box {
  background: transparent;        /* 去除底色，融入页面暖黄背景 */
  border: 2px solid #b45309;
  border-radius: 12px;
  padding: 8px 10px;
  min-height: 120px;             /* 加高，可放 3 排棋子 */
  justify-content: flex-start;   /* 内容靠上 */
}
.xq-captured-title {
  font-size: clamp(12px, 1.8vw, 14px);
  color: #78350f;
  font-weight: bold;
  margin-bottom: 6px;
}
.xq-captured-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: flex-start;      /* 棋子从顶部排列 */
  align-content: flex-start;
  min-height: 30px;
}
.xq-cap-piece {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(24px, 3.6vw, 30px);
  height: clamp(24px, 3.6vw, 30px);
  border-radius: 50%;
  font-size: clamp(13px, 2vw, 16px);
  font-weight: bold;
  font-family: "KaiTi", "STKaiti", serif;
  border: 2px solid;
}
.xq-cap-red {
  color: #dc2626;
  border-color: #dc2626;
  background: rgba(254, 242, 242, 0.6);
}
.xq-cap-black {
  color: #1f2937;
  border-color: #1f2937;
  background: rgba(243, 244, 246, 0.6);
}
.xq-captured-empty {
  color: #9ca3af;
  font-size: clamp(11px, 1.6vw, 13px);
  font-style: italic;
}

/* 讲解框（电脑走法） */
.xq-explain-box {
  margin-top: 0;
  background: #ecfdf5;
  border: 3px solid #059669;
  border-radius: 14px;
  padding: 8px 12px;
  width: 100%;
  max-width: 100%;
  min-height: 56px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  text-align: left;
}
.xq-explain-box h3 {
  color: #065f46;
  font-size: clamp(13px, 2vw, 15px);
  margin-bottom: 3px;
}
.xq-explain-box p {
  color: #064e3b;
  font-size: clamp(13px, 2vw, 15px);
  line-height: 1.5;
  white-space: pre-line;
}

/* AI 讲解区 */
.xq-ai-commentary {
  background: #fff;
  border: 3px solid #7c3aed;
  border-radius: 14px;
  padding: 8px 12px;
  width: 100%;
  max-width: 100%;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  min-height: 80px;
  text-align: left;
}
.xq-ai-commentary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 6px;
  flex-wrap: wrap;
}
.xq-ai-commentary-title {
  font-size: clamp(13px, 2vw, 15px);
  font-weight: bold;
  color: #6b21a8;
}
.xq-ai-commentary-body {
  font-size: clamp(13px, 2vw, 15px);
  line-height: 1.5;
  color: #1f2937;
  min-height: 50px;
  text-align: left;
}
.xq-ai-commentary-body p { margin: 0; }
.xq-ai-commentary-placeholder { color: #9ca3af; font-style: italic; }
.xq-ai-commentary-loading { color: #7c3aed; font-weight: bold; }
.xq-ai-commentary-error { color: #dc2626; }

/* 开关按钮 */
.xq-btn-commentary-toggle {
  font-size: clamp(11px, 1.6vw, 13px);
  padding: 3px 10px;
  border: none;
  border-radius: 10px;
  background: #7c3aed;
  color: white;
  cursor: pointer;
  font-weight: bold;
  font-family: inherit;
  min-height: 28px;
  transition: background 0.15s;
  white-space: nowrap;
}
.xq-btn-commentary-toggle.xq-off { background: #9ca3af; }

/* 关闭讲解态：弱化展示 */
.xq-ai-commentary.xq-commentary-off {
  opacity: 0.6;
  border-color: #9ca3af;
}

/* ========== 响应式：宽屏（平板横屏 / 电视大屏）3 列布局 ========== */
@media (min-width: 1024px) {
  .xq-main-layout {
    flex-direction: row;
    align-items: center;            /* 侧栏不再拉满高度，按内容居中贴齐棋盘 */
    justify-content: center;
    gap: 4px;                       /* 紧贴棋盘 */
    width: max-content;             /* 宽度由内容决定，三列紧贴 */
  }
  .xq-side-column {
    flex: 0 0 180px;
    max-width: 180px;
    justify-content: center;        /* 两侧两个模块在棋盘垂直方向居中聚拢 */
    gap: 8px;
    align-self: center;             /* 侧栏按内容高度居中，不再被拉伸 */
  }
  .xq-left-col {
    display: flex;
  }
  .xq-center-column {
    flex: 0 0 auto;
    justify-content: center;
  }
  .xq-ai-commentary-body {
    font-size: 15px;
  }
}
