/* 象棋頁（2026-10-04）：沿用 css/style.css 的按鈕、對話框與字型，這裡只放棋桌的外框。
   色調取暖色木頭（參考 Just Xiangqi 的木質棋盤與象牙棋子），與麻將的深藍桌面刻意分開。 */
/* 字級倍率：麻將頁由設定面板寫在 <html> 上（css/themes.css）；象棋頁沒有那個面板，固定 1——
   少了它，所有 calc(… * var(--fs)) 都會失效、退回瀏覽器預設字級（實際看過：結算的大字變成一般字）。 */
:root { --fs: 1; }
body.xq { background: #1a110b; }
#xq-gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- 教學頁（xiangqi-learn.html，2026-10-04） ----------
   教學頁的畫布是「頁面裡的一塊」，不是整頁的棋桌（與對弈頁的 #xq-gl 相反），
   所以尺寸由外框決定，`js/xiangqi/scene.js` 的 resize() 讀的是畫布自己的 rect。
   棋盤的底色沿用對弈頁的木頭色，但用圓角卡片包起來，與教學文字同一欄。 */
body.xq.learn-page { background: var(--site-bg-color, #f6f1e6); }
.learn-main code { font-size: .92em; background: rgba(0, 0, 0, .06); padding: 1px 5px; border-radius: 4px; }

.xq-board-card { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px;
  align-items: center; margin: 18px 0 8px; padding: 16px; border: 1px solid var(--site-line, #d9cfbd);
  border-radius: 10px; background: #241a12; }
.xq-board-canvas { position: relative; aspect-ratio: 3 / 3.4; border-radius: 8px; overflow: hidden; background: #1a110b; }
.xq-board-canvas canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.xq-board-side { color: #efe3cd; }
.xq-board-title { margin: 0 0 6px; font: 900 calc(18px * var(--fs)) var(--site-display, "Noto Serif TC", serif); letter-spacing: .06em; }
.xq-board-note { margin: 0 0 8px; color: #c9b79a; font-size: calc(14px * var(--fs)); line-height: 1.7; }
.xq-board-count { margin: 0 0 10px; color: #ffd166; font-weight: 700; font-size: calc(14px * var(--fs)); }
.xq-board-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.xq-demo-list { display: grid; gap: 22px; margin-top: 20px; }
.xq-demo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px; align-items: center;
  padding: 16px; border: 1px solid var(--site-line, #d9cfbd); border-radius: 10px; background: #fff; }
.xq-demo-board { position: relative; aspect-ratio: 1 / 1.12; border-radius: 8px; overflow: hidden; background: #1a110b; }
.xq-demo-board canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.xq-demo-text h3 { margin: 0 0 8px; font: 900 calc(17px * var(--fs)) var(--site-display, "Noto Serif TC", serif); color: var(--site-heading, #2a2622); }
.xq-demo-text p { margin: 0 0 8px; line-height: 1.8; }
.xq-demo-count { color: var(--site-accent, #8a5a2b); font-weight: 700; font-size: calc(13px * var(--fs)); }
@media (max-width: 760px) {
  .xq-board-card, .xq-demo { grid-template-columns: minmax(0, 1fr); }
}

.xq-loading { position: fixed; inset: 0; display: grid; place-content: center; gap: 14px; justify-items: center;
  background: #1a110b; color: #e8d9bf; z-index: 30; transition: opacity .4s ease; }
.xq-loading.done { opacity: 0; pointer-events: none; }

.xq-top { position: fixed; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; gap: 14px; z-index: 5; pointer-events: none; }
.xq-top > * { pointer-events: auto; }
.xq-top > .btn { display: inline-flex; align-items: center; flex: 0 0 auto; width: auto; }
.xq-title { white-space: nowrap; display: flex; align-items: baseline; gap: 12px; margin-right: auto; color: #f3e6cf; text-shadow: 0 2px 10px rgba(0, 0, 0, .6); }
.xq-title h1 { margin: 0; font-family: var(--serif); font-weight: 900; font-size: calc(26px * var(--fs)); letter-spacing: .2em; }
.xq-title p { margin: 0; font-size: calc(13px * var(--fs)); color: #d6c2a1; letter-spacing: .06em; }

.xq-panel { position: fixed; top: 70px; right: 12px; width: min(240px, 34vw); max-height: calc(100% - 150px);
  display: flex; flex-direction: column; padding: 14px 16px; border-radius: 14px; z-index: 4;
  background: rgba(30, 19, 11, .78); border: 1px solid rgba(232, 200, 150, .18); color: #f0e4cf; backdrop-filter: blur(4px); }
.xq-panel h2 { margin: 14px 0 6px; font-size: calc(13px * var(--fs)); font-weight: 500; color: #c8b08a; letter-spacing: .12em; }
.xq-turn { display: flex; align-items: center; gap: 10px; font-size: calc(16px * var(--fs)); letter-spacing: .08em; }
.xq-dot { width: 14px; height: 14px; border-radius: 50%; background: #c0392b; box-shadow: 0 0 0 3px rgba(192, 57, 43, .25); transition: background .3s, box-shadow .3s; }
.xq-turn.black .xq-dot { background: #2b2b2b; box-shadow: 0 0 0 3px rgba(240, 230, 210, .25); }
.xq-status { min-height: 1.4em; margin: 8px 0 0; font-size: calc(14px * var(--fs)); color: #ffb199; font-weight: 700; letter-spacing: .1em; }
.xq-moves { margin: 0; padding: 0 0 0 2.4em; overflow-y: auto; font-family: var(--serif); font-size: calc(15px * var(--fs)); line-height: 1.75;
  display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }
.xq-moves li { white-space: nowrap; }
.xq-moves li.red { color: #ff9e8a; }
.xq-moves li.black { color: #f0e4cf; list-style: none; }
.xq-moves li.last { text-decoration: underline; text-underline-offset: 4px; }

.xq-actions { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; gap: 10px; z-index: 5;
  padding: 8px; border-radius: 999px; background: rgba(30, 19, 11, .6); backdrop-filter: blur(4px); }
.xq-actions .btn[disabled] { opacity: .45; pointer-events: none; }

.xq-result { text-align: center; }
.xq-result .big { font-family: var(--serif); font-size: calc(34px * var(--fs)); font-weight: 900; letter-spacing: .2em; margin: 6px 0 4px; }
.xq-result .why { color: var(--muted); margin: 0 0 6px; }

/* 手機：棋譜面板收到底部操作列上方，只留最近幾手 */
@media (max-width: 720px) {
  .xq-title p { display: none; }
  .xq-title h1 { letter-spacing: .1em; }
  .xq-panel { top: auto; bottom: 74px; right: 12px; left: 12px; width: auto; max-height: 128px; padding: 10px 12px; }
  .xq-panel h2 { display: none; }
  .xq-moves { max-height: 52px; }
  .xq-actions { left: 12px; right: 12px; transform: none; justify-content: center; border-radius: 16px; }
}
