/* ===== 重置与基础 ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --board-bg: #f4e4c1;
  --board-line: #8b4513;
  --red-piece: #c0392b;
  --black-piece: #1a1a1a;
  --gold: #f8d568;
  --primary: #8b4513;
  --primary-hover: #6b3410;
  --secondary: #5a6e7f;
  --secondary-hover: #445566;
  --bg: #faf6ee;
  --text: #2c1a0e;
  --text-light: #7a5c3c;
  --border: #d4b483;
  --shadow: rgba(0,0,0,0.15);
  --radius: 8px;
  --tab-active: #8b4513;
  --tab-bg: #f0e0c0;
  --header-h: 46px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'SimHei', sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  border: none;
  border-radius: var(--radius);
  transition: background 0.2s, transform 0.1s;
}
button:active {
  transform: scale(0.97);
}

/* 原生 select 仅作取值桥接，视觉用 .xva-select */
.xva-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.xva-select {
  position: relative;
  display: inline-block;
  min-width: 12.5rem;
  max-width: 100%;
  vertical-align: middle;
  font-size: 14px;
}

.xva-select__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 35px;
  height: 35px;
  padding: 0 12px;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fffdf8 0%, #f7edd8 100%);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.xva-select__trigger:hover {
  border-color: #c49a5c;
  background: linear-gradient(180deg, #fffaf0 0%, #f3e4c8 100%);
}

.xva-select__trigger:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.18);
}

.xva-select.is-open .xva-select__trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.14);
}

.xva-select__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xva-select__chevron {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--text-light);
  border-bottom: 2px solid var(--text-light);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s;
}

.xva-select.is-open .xva-select__chevron {
  transform: rotate(225deg) translateY(-1px);
}

.xva-select__menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fffaf2;
  box-shadow: 0 10px 28px rgba(60, 35, 10, 0.16);
  max-height: min(280px, 50vh);
  overflow-y: auto;
}

.xva-select__menu[hidden] {
  display: none !important;
}

.xva-select__option {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.xva-select__option:hover,
.xva-select__option:focus-visible {
  outline: none;
  background: #f0e0c0;
  color: var(--primary);
}

.xva-select__option.is-selected {
  background: #8b4513;
  color: #fffaf2;
  font-weight: 500;
}

.xva-select__option.is-selected:hover,
.xva-select__option.is-selected:focus-visible {
  background: #6b3410;
  color: #fffaf2;
}

/* ===== 通栏顶部导航 ===== */
.site-header {
  width: 100%;
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
  height: var(--header-h);
  position: relative;
  z-index: 100; /* 语言菜单需盖住棋盘区 */
  overflow: visible;
}

.header-inner {
  /* 对齐 shogigridbase：通栏导航，内容区限宽居中 */
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: visible;
}

@media (min-width: 768px) {
  .header-inner {
    padding: 0 32px;
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
}

.brand-link:hover {
  color: #fff;
  text-decoration: none;
}

.logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.logo img {
  display: block;
}

.site-name {
  font-size: 17px;
  font-weight: bold;
  letter-spacing: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: visible;
}

.header-right a {
  color: #f8d568;
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid rgba(248,213,104,0.7);
  border-radius: 4px;
  white-space: nowrap;
  transition: background 0.2s;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  line-height: inherit;
}
.header-right a:hover {
  background: rgba(248,213,104,0.2);
  text-decoration: none;
}

/* 顶栏语言下拉（对齐将棋交互：展开选择，不整页跳转） */
.xva-lang-switch {
  position: relative;
  flex-shrink: 0;
}
.xva-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 4px;
  border: 1px solid rgba(248, 213, 104, 0.7);
  background: transparent;
  color: #f8d568;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.xva-lang-btn:hover {
  background: rgba(248, 213, 104, 0.2);
  text-decoration: none;
  color: #f8d568;
}
a.xva-lang-btn {
  text-decoration: none;
}
a.xva-lang-btn.is-selected {
  background: rgba(248, 213, 104, 0.28);
}
.xva-lang-caret {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  opacity: 0.9;
  transition: transform 0.15s ease;
}
.xva-lang-switch.is-open .xva-lang-caret {
  transform: rotate(180deg);
}
.xva-lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 120;
  min-width: max(100%, 7.5rem);
  margin: 0;
  padding: 4px;
  list-style: none;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fffaf2;
  box-shadow: 0 12px 28px rgba(60, 35, 10, 0.18);
}
.xva-lang-menu[hidden] {
  display: none !important;
}
.xva-lang-option {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}
.xva-lang-option:hover {
  background: #f0e0c0;
  color: var(--primary);
  text-decoration: none;
}
.xva-lang-option.is-selected {
  background: var(--primary);
  color: #fffaf2;
}

/* ===== 整体容器 ===== */
.app-container {
  /* 对齐将棋：首屏通栏全宽，不再套比导航更窄的外壳 */
  max-width: none;
  margin: 0;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
}

/* ===== 首屏区（棋盘+广告，撑满视口高度） ===== */
.game-screen {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--header-h));
  flex-shrink: 0;
  width: 100%;
}

/* ===== 第二屏区（SEO 文案+页脚：限宽居中，不占满屏） ===== */
.second-screen {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 100%;
  max-width: 1100px; /* 对齐将棋 article 阅读宽 */
  /* 对齐 shogi article-container：走子提示与 SEO 卡片之间留白 */
  margin: 40px auto 8px;
  padding: 0 16px;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .second-screen {
    margin-top: 56px;
    padding: 0 24px;
  }
}

/* ===== 主内容区 ===== */
.main-content {
  display: flex;
  flex-direction: row;
  gap: 12px;
  padding: 10px 0 6px;
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
}

/* ===== 棋盘区 ===== */
.board-section {
  flex: 0 0 auto;
  width: 70%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 0;
}

.board-section h1 {
  font-size: 18px;
  color: var(--primary);
  text-align: center;
  font-weight: bold;
  max-width: min(800px, 100%);
}

.board-subtitle {
  font-size: 14px;
  color: var(--text-light);
  text-align: center;
  font-weight: normal;
  margin-top: -2px;
  margin-bottom: 4px;
  max-width: min(800px, 100%);
}

.canvas-wrapper {
  position: relative;
  /*
   * Reserve 9:10 board before script.js / shell paint (align shogigridbase .board-wrap).
   * Without this, soft nav remounts #chessCanvas at intrinsic/CSS-collapsed size → FOUC.
   */
  --xva-board-reserve: min(
    800px,
    100%,
    max(
      240px,
      calc((100dvh - var(--header-h) - env(safe-area-inset-top, 0px) - 200px) * 0.9)
    )
  );
  width: var(--xva-board-reserve);
  aspect-ratio: 9 / 10;
  height: auto;
  max-width: min(800px, 100%);
  margin: 0 auto;
  overflow: visible;
  box-sizing: border-box;
  background: var(--board-bg);
}

/* 对齐 shogigridbase：贴在棋盘右缘的侧栏开关箭头 */
.panel-toggle-arrow {
  display: none;
  position: absolute;
  right: -30px; /* 紧贴棋盘右缘向外伸出（wrapper 已与棋盘同宽） */
  top: 50%;
  margin-top: -24px; /* 固定半高偏移，避免和 svg transform 抢 translate */
  width: 30px;
  height: 48px;
  padding: 0;
  background: #fffaf2;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 12px 12px 0;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 3px 0 8px rgba(0, 0, 0, 0.08);
  z-index: 30;
  transition: background 0.2s;
}

.panel-toggle-arrow:hover {
  background: #f3e4c8;
}

.panel-toggle-arrow svg {
  color: var(--primary);
  transition: transform 0.3s;
  display: block;
}

#chessCanvas {
  /* Fill reserved wrapper; JS locks exact px after measure (same as #shogiBoard). */
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 6px;
  box-shadow: 0 4px 16px var(--shadow);
  cursor: pointer;
  touch-action: none;
  background: transparent;
}

.board-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  padding: 4px 8px;
}

.turn-indicator {
  font-size: 15px;
  font-weight: bold;
  color: var(--primary);
  padding: 3px 12px;
  background: #fff7e6;
  border: 1px solid var(--border);
  border-radius: 20px;
}

.turn-indicator.black-turn {
  color: #222;
  background: #f0f0f0;
  border-color: #aaa;
}

.game-status {
  font-size: 14px;
  color: var(--text-light);
}

.game-status.check {
  color: #fff;
  background: #e74c3c;
  font-weight: bold;
  font-size: 15px;
  padding: 3px 14px;
  border-radius: 20px;
  animation: checkPulse 0.65s ease-in-out infinite alternate;
}

@keyframes checkPulse {
  from { transform: scale(1);    box-shadow: 0 0 0 0 rgba(231,76,60,0.6); }
  to   { transform: scale(1.07); box-shadow: 0 0 0 7px rgba(231,76,60,0); }
}

.canvas-wrapper.in-check #chessCanvas {
  animation: checkBorder 0.55s ease-in-out infinite alternate;
}

@keyframes checkBorder {
  from { box-shadow: 0 4px 16px var(--shadow); }
  to   { box-shadow: 0 0 0 4px #e74c3c, 0 4px 20px rgba(231,76,60,0.45); }
}

/* ===== 控制区 ===== */
.control-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}


/* 玩家信息 */
.player-info {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.2s;
}

.player-row.active {
  background: #fff7e6;
}

.player-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.red-dot { background: var(--red-piece); }
.black-dot { background: var(--black-piece); }

.player-label {
  flex: 1;
  font-size: 14px;
}

.player-timer {
  font-size: 14px;
  font-family: monospace;
  color: var(--text-light);
}

/* 控制组 */
.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.control-group label {
  font-size: 14px;
  color: var(--text-light);
  white-space: nowrap;
}

.btn-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.btn {
  min-width: 0;
  padding: 7px 14px;
  font-size: 14px;
  border-radius: var(--radius);
  font-weight: 500;
}

.btn-group .btn {
  width: 100%;
  min-height: 38px;
  padding: 7px 8px;
}

.btn-group #focusModeBtn {
  grid-column: span 2;
}

.btn-group #replayBtn {
  grid-column: 1 / -1;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #f0e8d8;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: #e8d8c0;
}

.btn-danger {
  background: #fdecea;
  color: #c0392b;
  border: 1px solid #e6b0aa;
}
.btn-danger:hover {
  background: #f8d7d3;
}
.btn-danger:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 棋谱 */
.move-history {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.move-history h3 {
  font-size: 14px;
  color: var(--primary);
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  flex-shrink: 0;
}

.move-history-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-top: 2px;
  padding-right: 2px;
}

.move-list-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.9;
  white-space: pre-wrap;
  font-family: 'PingFang SC','Microsoft YaHei',monospace;
}

.move-item {
  display: inline-block;
  width: 100%;
  line-height: 1.9;
  font-family: 'PingFang SC','Microsoft YaHei',monospace;
  font-size: 13px;
}

.move-red {
  color: #c0392b;
  font-weight: 500;
}

.move-black {
  color: #1a1a1a;
}

.empty-hint {
  font-size: 13px;
  color: #aaa;
  text-align: center;
  padding: 10px 0 2px;
}

/* AI 评语 */
.ai-comment {
  background: #fffbf0;
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  min-height: 40px;
  line-height: 1.6;
  display: none;
}

.ai-comment.visible {
  display: block;
}

@media (min-width: 768px) {
  .game-screen {
    height: calc(100dvh - var(--header-h));
  }

  /* 第二屏撑满视口 */
  .second-screen {
    height: calc(100dvh - var(--header-h));
  }

  .second-screen .content-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    overflow: hidden;
  }

  .second-screen .hero-cont {
    flex-shrink: 0;
  }

  .second-screen .info-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .second-screen .info-panel .bottom-tabs {
    flex-shrink: 0;
  }

  .second-screen .info-panel .tab-content.active {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .second-screen .site-footer {
    flex-shrink: 0;
    margin-top: 0;
  }

  body.focus-mode {
    overflow: hidden;
    background: var(--bg);
  }

  body.focus-mode .site-header,
  body.focus-mode .ad-placeholder,
  body.focus-mode .hero-cont,
  body.focus-mode .info-panel,
  body.focus-mode .site-footer,
  body.focus-mode .board-section h1,
  body.focus-mode .board-subtitle {
    display: none;
  }

  body.focus-mode .app-container {
    max-width: none;
    height: 100dvh;
    padding: 0;
  }

  body.focus-mode .game-screen {
    height: 100dvh;
    min-height: 100dvh;
    justify-content: center;
  }

  body.focus-mode .main-content {
    width: 100%;
    height: 100dvh;
    margin: 0;
    padding: 18px 32px;
    gap: 0;
    align-items: stretch;
  }

  body.focus-mode .board-section {
    width: 100%;
    flex: 1 1 auto;
    height: 100%;
    min-height: 100%;
    justify-content: center; /* 专注模式无标题，可垂直居中棋盘 */
  }

  body.focus-mode .canvas-wrapper {
    max-width: min(840px, 100%);
  }

  /* 桌面：首屏高度尽量给棋盘（对齐将棋 stage 吃满） */
  .game-screen {
    min-height: calc(100dvh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    overflow: hidden;
  }

  .game-screen .main-content {
    flex: 1 1 auto;
    min-height: 0;
  }

  /* 桌面提示条不占首屏高度，避免将棋盘压小 */
  .game-screen .ad-placeholder {
    display: none;
  }

  .board-section h1 {
    font-size: 17px;
    line-height: 1.25;
  }

  .board-subtitle {
    font-size: 13px;
    margin-bottom: 2px;
  }

  .board-info {
    padding: 2px 8px;
  }

  body.focus-mode .control-section {
    top: 18px;
    right: 32px;
    bottom: 18px;
    height: auto;
    max-height: none;
    padding: 14px;
    border: 1px solid rgba(139,69,19,0.22);
    border-radius: 14px;
    background: rgba(255,250,238,0.94);
    box-shadow: 0 12px 36px rgba(0,0,0,0.16);
  }

  body.focus-mode:not(.sidebar-collapsed) .main-content {
    padding-right: calc(var(--xva-panel-w) + 32px);
  }

  /* PC：侧栏浮层开合（对齐 shogigridbase overlay） */
  :root {
    /* Wider so EN select labels like “Black — move second” stay one line */
    --xva-panel-w: min(372px, 34vw);
  }

  /* Label above select — full panel width, no squeezed wrap */
  .control-section .control-group:not(.btn-group) {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 4px;
  }

  .control-section .control-group:not(.btn-group) .xva-select {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .panel-toggle-arrow {
    display: flex;
  }

  .main-content {
    position: relative;
    gap: 0;
    padding-left: 32px;
    padding-right: 32px;
  }

  body.sidebar-layout-ready .main-content {
    transition: padding-right 0.2s ease;
  }

  body:not(.sidebar-collapsed) .main-content {
    padding-right: calc(var(--xva-panel-w) + 32px);
  }

  .board-section {
    width: 100%;
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    justify-content: flex-start; /* 标题置顶，避免居中后被顶栏裁切 */
    overflow: visible;
  }

  .control-section {
    position: absolute;
    top: 10px;
    right: 0;
    bottom: 6px;
    width: var(--xva-panel-w);
    flex: none;
    z-index: 25;
    background: var(--bg);
  }

  body.sidebar-layout-ready .control-section {
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease;
  }

  body.sidebar-collapsed .control-section {
    transform: translateX(calc(100% + 20px));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  body.focus-mode .btn-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.focus-mode .btn-group #focusModeBtn {
    grid-column: 1 / -1;
  }

  body.focus-mode #focusModeBtn {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
  }

  body.focus-mode .move-history {
    flex: 1 1 auto;
    min-height: 120px;
    max-height: none;
  }

  body.focus-mode .move-history-scroll {
    min-height: 0;
  }

  body.focus-mode .ai-comment {
    flex: 0 0 auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
    white-space: normal;
  }

  .ai-comment {
    display: block;
    min-height: 72px;
    visibility: hidden;
    opacity: 0;
  }

  .ai-comment.visible {
    visibility: visible;
    opacity: 1;
  }
}

/* ===== 温馨提示（广告位预留） ===== */
.ad-placeholder {
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #fef9ee 0%, #fdf3d6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  margin: 6px 0;
  padding: 12px 16px;
  flex-shrink: 0;
}

.ad-placeholder span {
  font-size: 14px;
  color: #8b6914;
  text-align: center;
  line-height: 1.8;
}

/* 统一卡片容器：将 hero-cont 与 info-panel 融为一体 */
.content-card {
  border: 1px solid var(--border);
  border-radius: 0; /* 对齐国内站：文案区直角接页脚 */
  box-shadow: 0 2px 12px rgba(139, 69, 19, 0.10);
  overflow: hidden;
  margin: 0;
}

.hero-cont {
  background: linear-gradient(135deg, #fffaf0 0%, #f6e1b8 100%);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
}

.hero-cont h2 {
  font-size: 17px;
  color: var(--primary);
  margin-bottom: 8px;
}

.hero-cont p {
  font-size: 14px;
  line-height: 1.85;
  color: var(--text);
}

/* ===== 面包屑导航 ===== */
.breadcrumb {
  padding: 8px 4px 2px;
  font-size: 13px;
  color: var(--text-light);
  flex-shrink: 0;
}

.breadcrumb a {
  color: var(--primary);
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  margin: 0 6px;
  color: #bbb;
}

.breadcrumb-current {
  color: var(--text);
}

/* ===== 信息面板 ===== */
.info-panel {
  background: #fff;
  flex-shrink: 0;
}

/* Bottom Tabs */
.bottom-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: var(--tab-bg);
  overflow-x: auto;
  scrollbar-width: none;
}

.bottom-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  font-size: 14px;
  text-decoration: none;
  background: transparent;
  color: var(--text-light);
  border: none;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  background: rgba(139,69,19,0.08);
  color: var(--primary);
  text-decoration: none;
}

.tab-btn.active {
  color: var(--tab-active);
  font-weight: bold;
  border-bottom-color: var(--tab-active);
  background: #fff;
}

/* Tab 内容 */
.tab-content {
  display: none;
  padding: 18px 20px;
}

.tab-content.active {
  display: block;
}

/* 内容块 */
.content-block {
  margin-bottom: 20px;
}

.content-block:last-child {
  margin-bottom: 0;
}

.content-block p {
  font-size: 14px;
  line-height: 1.85;
  margin-bottom: 10px;
  color: var(--text);
}

.content-block p:last-child {
  margin-bottom: 0;
}

/* 文本列表 */
.text-list {
  padding-left: 18px;
  line-height: 1.85;
  font-size: 14px;
  color: var(--text);
}

.text-list li {
  margin-bottom: 6px;
}

.text-list li:last-child {
  margin-bottom: 0;
}

/* 示例步骤 */
.example-steps {
  padding-left: 22px;
  line-height: 2;
  font-size: 14px;
  color: var(--text);
  background: #fdf9f0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 18px 12px 36px;
  margin: 8px 0;
}

.example-steps li {
  margin-bottom: 3px;
}

/* 棋子卡片网格 */
.piece-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.piece-card {
  background: #fdf9f0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.piece-card h4 {
  font-size: 14px;
  color: var(--primary);
  margin-bottom: 6px;
  font-weight: bold;
}

.piece-card p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  margin: 0;
}

/* 信息面板标题 */
.info-panel h2 {
  font-size: 18px;
  color: var(--primary);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.info-panel h3 {
  font-size: 15px;
  color: var(--primary);
  margin-bottom: 8px;
}

/* FAQ */
.faq-list {
  font-size: 14px;
  line-height: 1.8;
}

.faq-list dt {
  font-weight: bold;
  color: var(--primary);
  margin-top: 14px;
  margin-bottom: 4px;
}

.faq-list dt:first-child {
  margin-top: 0;
}

.faq-list dd {
  margin-left: 0;
  color: var(--text);
  margin-bottom: 6px;
}

/* 保留旧的规则列表兼容 */
.rule-list {
  padding-left: 16px;
  line-height: 2;
  font-size: 14px;
}

.rule-list li {
  margin-bottom: 4px;
}

.tab-content p {
  font-size: 14px;
  line-height: 1.8;
  margin-bottom: 8px;
  color: var(--text);
}

/* ===== 页脚 ===== */
.site-footer {
  background: var(--primary);
  color: rgba(255,255,255,0.85);
  text-align: center;
  padding: 14px 16px;
  font-size: 13px;
  border-radius: 0;
  line-height: 2;
  flex-shrink: 0;
  margin-top: auto;
}

.footer-main {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  margin-bottom: 2px;
}

.footer-links a {
  color: inherit;
  margin: 0 8px;
  font-size: 13px;
}

.footer-links a:hover {
  color: inherit;
}

.footer-copy {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
}

/* ===== 弹窗 ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.visible {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 340px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  animation: popIn 0.2s ease;
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-title {
  font-size: 20px;
  color: var(--primary);
  margin-bottom: 10px;
}

.modal-result {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 8px;
}

.modal-comment {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 18px;
  line-height: 1.6;
}

.modal-box .btn {
  margin: 4px 6px;
}
/* ===== AI 思考指示 ===== */
.thinking-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-light);
  justify-content: center;
  padding: 4px 0;
}

.thinking-indicator.visible {
  display: flex;
}

.dot-anim span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  margin: 0 2px;
  animation: bounce 1.2s infinite;
}
.dot-anim span:nth-child(2) { animation-delay: 0.2s; }
.dot-anim span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ===== 滚动条美化 ===== */
.move-history-scroll::-webkit-scrollbar,
.second-screen .tab-content::-webkit-scrollbar {
  width: 4px;
}
.move-history-scroll::-webkit-scrollbar-thumb,
.second-screen .tab-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ===== 响应式 移动端 ===== */
@media (max-width: 767px) {
  .app-container {
    padding: 0;
  }

  .game-screen {
    padding: 0 4px;
    min-height: calc(100dvh - var(--header-h));
  }

  .second-screen {
    padding: 0 8px;
  }

  .main-content {
    flex-direction: column;
    gap: 8px;
    padding: 6px 0;
  }

  .board-section {
    width: 100%;
  }

  .board-section h1 {
    font-size: 16px;
  }

  .board-subtitle {
    font-size: 13px;
  }

  .canvas-wrapper {
    max-width: 100% !important;
  }

  /* 单DOM控制区：移动端紧凑两行布局 */
  .control-section {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    overflow-y: visible;
    padding: 0 0 4px;
  }

  /* 隐藏移动端不需要的块（棋谱、玩家计时器） */
  .control-section .player-info,
  .control-section .move-history {
    display: none;
  }

  /* 难度 / 执子 各占半行，标签与下拉框保持在同一列内 */
  .control-section .control-group:not(.btn-group) {
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .control-section .control-group:not(.btn-group) label {
    line-height: 1.3;
  }

  .control-section .control-group:not(.btn-group) .xva-select {
    width: 100%;
    min-width: 0;
  }

  /* 专注模式按钮 / 侧栏箭头在移动端隐藏；侧栏恢复文档流 */
  #focusModeBtn,
  .panel-toggle-arrow {
    display: none !important;
  }

  .main-content {
    position: static;
    gap: 6px;
    padding-right: 0 !important;
    transition: none !important;
  }

  .control-section {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: auto !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition: none !important;
    background: transparent;
  }

  body.sidebar-collapsed .control-section {
    display: flex !important;
  }

  .control-section .btn-group #soundToggleBtn,
  .control-section .btn-group #replayBtn {
    grid-column: 1 / -1;
  }

  /* 移动端维持两列操作网格，避免单独悬挂的最后一个按钮 */
  .control-section .btn-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }

  .control-section .btn-group .btn {
    min-width: 0;
    min-height: 36px;
    padding: 8px;
    font-size: 13px;
    white-space: nowrap;
  }

  /* 画布高度需为控制区留出空间（与 --xva-board-reserve 同源） */
  .canvas-wrapper {
    --xva-board-reserve: min(
      100%,
      max(240px, calc((100dvh - var(--header-h) - env(safe-area-inset-top, 0px) - 200px) * 0.9))
    );
    width: var(--xva-board-reserve);
    max-width: 100% !important;
  }

  /* 移动端温馨提示 */
  .ad-placeholder {
    padding: 10px 12px;
  }
  .ad-placeholder span {
    font-size: 13px;
  }

  .content-card {
    margin: 0;
  }

  .hero-cont {
    padding: 12px 14px;
  }

  .hero-cont h2 {
    font-size: 15px;
  }

  .hero-cont p {
    font-size: 13px;
    line-height: 1.75;
  }

  .header-inner {
    padding: 0 10px;
  }

  .site-name {
    font-size: 15px;
  }

  /* 移动端顶栏只留语言切换；Rules/Guide/FAQ 走下方 SEO tabs */
  .header-right a[data-nav-tab] {
    display: none;
  }

  .header-right {
    gap: 0;
    flex-shrink: 0;
    overflow: visible;
  }

  .xva-lang-btn {
    min-height: 32px;
    -webkit-tap-highlight-color: transparent;
  }

  .tab-btn {
    font-size: 12px;
    padding: 9px 3px;
    white-space: nowrap;
  }

  .tab-content {
    padding: 14px 12px;
  }

  .board-info {
    gap: 10px;
  }

  .turn-indicator {
    font-size: 14px;
    padding: 2px 10px;
  }

  .modal-box {
    padding: 20px 18px;
  }

  .modal-title {
    font-size: 18px;
  }
}

/* ===== 极小屏适配 ===== */
@media (max-width: 380px) {
  .site-name {
    font-size: 14px;
  }

  .tab-btn {
    font-size: 11px;
    padding: 8px 2px;
  }
}

/* ===== 打印 ===== */
@media print {
  .site-header, .control-section, .ad-placeholder,
  .bottom-tabs, .mobile-controls, .site-footer {
    display: none !important;
  }
}

/* ===== 复盘回放 ===== */
.move-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.move-history-header h3 {
  margin: 0;
}

.btn-icon {
  background: none;
  border: 1px solid #c8a06e;
  border-radius: 6px;
  color: #8b4513;
  font-size: 12px;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.btn-icon:hover {
  background: #f4dea8;
  color: #5a2d0c;
}

.replay-bar {
  background: #fdf6e3;
  border: 1px solid #e0c080;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.replay-bar[hidden] {
  display: none;
}

.replay-seek {
  display: flex;
  align-items: center;
}

.replay-seek input[type="range"] {
  flex: 1;
  width: 100%;
  accent-color: #8b4513;
  height: 4px;
  cursor: pointer;
}

.replay-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.replay-btn {
  background: #fff8ee;
  border: 1px solid #c8a06e;
  border-radius: 6px;
  color: #8b4513;
  font-size: 18px;
  line-height: 1;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.replay-btn:hover {
  background: #f4dea8;
}

.replay-btn.replay-play {
  font-size: 14px;
  width: 38px;
}

.replay-progress {
  font-size: 13px;
  color: #8b4513;
  margin-left: 4px;
  white-space: nowrap;
}

.replay-speed {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #8b6030;
}

.replay-speed input[type="range"] {
  flex: 1;
  accent-color: #8b4513;
  height: 4px;
  cursor: pointer;
}

.replay-exit {
  font-size: 12px;
  padding: 5px 10px;
  align-self: flex-start;
}

.move-item.replay-current {
  background: rgba(255, 160, 0, 0.22);
  border-radius: 3px;
  font-weight: bold;
}

.canvas-wrapper.board-replaying::after {
  content: '复盘中';
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(139, 69, 19, 0.82);
  color: #fff;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 5;
}


/* Xiangqi vs AI — PWA safe-area (anti-fingerprint chrome class) */
.xiangqivsai-chrome-header {
  padding-top: env(safe-area-inset-top);
  height: calc(var(--header-h) + env(safe-area-inset-top));
}
.xiangqivsai-chrome-footer {
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.game-screen {
  min-height: calc(100dvh - var(--header-h) - env(safe-area-inset-top));
}
@media (min-width: 768px) {
  .game-screen {
    height: calc(100dvh - var(--header-h) - env(safe-area-inset-top));
  }
  .second-screen {
    height: calc(100dvh - var(--header-h) - env(safe-area-inset-top));
  }
}

/* ===== PWA install chip + rich guide (header; Chromium → native dialog) ===== */
.xva-pwa-chip {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}
/* Only style the trigger — never `.xva-pwa-chip button` (backdrop is also a button) */
.xva-pwa-chip > span > button:first-of-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  padding: 0;
  border-radius: 4px;
  border: 1px solid rgba(248, 213, 104, 0.7);
  background: transparent;
  color: #f8d568;
  box-shadow: none;
  opacity: 1;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.xva-pwa-chip > span > button:first-of-type:hover:not(:disabled) {
  background: rgba(248, 213, 104, 0.2);
  color: #f8d568;
}
.xva-pwa-chip .pwa-install-backdrop {
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: rgba(44, 26, 14, 0.4) !important;
  color: inherit !important;
  inset: 0;
  backdrop-filter: blur(2px);
}

.pwa-guide-card {
  z-index: 120;
  width: min(20.5rem, calc(100vw - 1.5rem));
  overflow: hidden;
  text-align: left;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fffaf2;
  box-shadow: 0 18px 48px rgba(44, 26, 14, 0.22);
}
.pwa-guide-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 16px 12px;
  background: linear-gradient(165deg, #f5ebe0 0%, #fffaf2 55%);
  border-bottom: 1px solid rgba(212, 180, 131, 0.55);
}
.pwa-guide-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
  display: block;
  box-shadow: 0 2px 8px rgba(44, 26, 14, 0.14);
  background: var(--bg);
}
.pwa-guide-meta { min-width: 0; flex: 1; }
.pwa-guide-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.pwa-guide-host {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--text-light);
  line-height: 1.3;
}
.pwa-guide-blurb {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.4;
}
.pwa-guide-title-plain {
  margin: 0;
  padding: 14px 16px 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.pwa-guide-preview {
  margin: 0 16px 4px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(212, 180, 131, 0.55);
  background: var(--bg);
  aspect-ratio: 16 / 9;
}
.pwa-guide-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}
.pwa-guide-kicker {
  margin: 10px 16px 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
}
.pwa-guide-note {
  margin: 6px 16px 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-light);
}
.pwa-guide-steps {
  list-style: none;
  margin: 10px 16px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pwa-guide-steps li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--text);
}
.pwa-guide-steps strong { color: var(--text); font-weight: 700; }
.pwa-guide-step-n {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  margin-top: 1px;
}
.pwa-guide-share-glyph {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin: 0 2px;
  vertical-align: -2px;
  color: var(--primary);
}
.pwa-guide-actions {
  display: flex;
  gap: 8px;
  padding: 14px 16px 16px;
}
.pwa-guide-btn-primary,
.pwa-guide-btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pwa-guide-btn-primary {
  flex: 1;
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 0 14px;
}
.pwa-guide-btn-primary:hover { background: var(--primary-hover); }
.pwa-guide-btn-ghost {
  border: 1px solid var(--border);
  background: #fffaf2;
  color: var(--text-light);
  padding: 0 12px;
}
.pwa-guide-btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #f5ebe0;
}

@media (max-width: 767px) {
  .header-right {
    gap: 6px;
  }
  .xva-pwa-chip > span > button:first-of-type {
    width: 34px;
    height: 32px;
  }
  .pwa-guide-card {
    width: min(20.5rem, calc(100vw - 1.25rem));
  }
  .pwa-guide-btn-primary,
  .pwa-guide-btn-ghost {
    min-height: 44px;
  }
}
