/* ============================================================
 * 将棋 · AI对战 —— 样式（暖木和风主题）
 * ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f0e1;
  --ink: #3e2723;
  --brown: #8b5e3c;
  --brown-d: #6b4423;
  --muted: #8d6e63;
  --line: #e8dcc8;
  --line-soft: #f0e8d8;
  --player: #1e88e5;
  --ai: #e53935;
  --board: #d4b483;
  --board-cell: #f4d1a1;
  --board-frame: #8b7355;
  --panel-width: 340px;
  --tabbar-h: 56px;
}

/* 小屏桌面：收窄侧边栏，给棋盘留更多空间 */
@media (min-width: 1024px) and (max-width: 1280px) {
  :root { --panel-width: 280px; }
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.header-inner {
  max-width: 1440px; margin: 0 auto;
  height: 56px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
}
@media (min-width: 1024px) { .header-inner { padding: 0 32px; } }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.logo-img { width: 32px; height: 32px; border-radius: 8px; display: block; }
.logo-text { font-size: 1.25rem; font-weight: 700; letter-spacing: .04em; }
.logo-dot { color: var(--muted); font-weight: 400; margin: 0 4px; }

.desktop-nav { display: none; align-items: center; gap: 24px; }
@media (min-width: 1024px) { .desktop-nav { display: flex; } }
.nav-link { font-size: 1rem; color: var(--muted); text-decoration: none; font-weight: 500; transition: color .2s; }
.nav-link:hover, .nav-link.active { color: var(--brown); font-weight: 700; }

/* ===== Game Screen ===== */
.game-screen {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.game-main {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
}
.game-stage {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; padding: 8px;
}

/* 移动端：纵向满屏，各区块同宽对齐，棋盘+广告位首屏自适应 */
@media (max-width: 1023px) {
  .game-screen { height: calc(100dvh - var(--tabbar-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom, 0px)); }
  /* 给底部 TabBar 预留空间，使广告位落在 TabBar 之上的首屏内 */
  .game-main {
    --game-content-w: calc(100vw - 24px);
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    justify-content: center;
  }
  .game-stage {
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    flex: 0 1 auto;
    width: 100%;
  }
  /* 状态栏、驹台、棋盘列统一宽度 */
  .board-status,
  .komadai,
  .board-col {
    width: var(--game-content-w);
    max-width: 100%;
    min-width: 0;
  }
  .board-col { flex: 0 0 auto; }
  .board-wrap {
    width: auto;
    max-width: 100%;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
  }
  .board-status {
    min-width: 0;
    font-size: 0.88rem;
    padding: 4px 10px;
  }
  .komadai {
    min-height: 40px;
    padding: 3px 8px;
    max-width: none;
  }
  .komadai-label { font-size: 0.88rem; padding-right: 6px; }
  .komadai-empty { font-size: 0.88rem; }
  .ad-slot:not(:empty) {
    width: var(--game-content-w);
    max-width: calc(100vw - 24px);
    margin: 4px auto 0;
    flex: 0 0 60px;
  }
  #shogiBoard { max-width: 100%; max-height: 100%; }
}

/* 桌面端：横向，stage 左、面板右 */
@media (min-width: 1024px) {
  .game-screen {
    flex-direction: row;
    height: calc(100dvh - 56px);
    overflow: hidden;
    position: relative; /* 为控制面板提供绝对定位的参考 */
  }
  .game-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden; /* 改为 hidden，内部自适应，不要出大滚动条 */
    display: flex;
    flex-direction: column;
  }
  .game-screen[data-panel-mode="push"] .game-main {
    transition: flex-basis 0.2s ease, max-width 0.2s ease;
  }
  /* 优化：使用 grid 居中布局，确保在不同屏幕下都能完美居中并自适应 */
  .game-stage {
    display: grid;
    grid-template-columns: 140px auto 140px;
    grid-template-rows: auto auto;
    grid-template-areas:
      "ai status player"
      "ai board  player";
    gap: 16px 40px;
    padding: 24px;
    justify-content: center;
    align-content: center;
    flex: 1;
    min-height: 0; /* 允许子元素比这小，防止撑开 */
  }
  .komadai-ai    { grid-area: ai;     align-self: center; }
  .board-status  { grid-area: status; max-width: none; width: auto; justify-self: center; }
  .board-col     { grid-area: board;  max-width: none; width: auto; align-self: center; }
  .komadai-player{ grid-area: player; align-self: center; }
}

/* ===== 驹台 Komadai ===== */
.komadai {
  background: var(--line);
  border: 2px solid var(--board-frame);
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
  display: flex;
}
/* 移动端：横条 */
.komadai {
  flex-direction: row; align-items: center;
  width: 100%; max-width: 420px;
  padding: 4px 8px; gap: 8px;
  min-height: 46px;
}
@media (max-width: 1023px) {
  .komadai { max-width: none; }
}
.komadai-label {
  font-size: 0.95rem; font-weight: 700; color: var(--ink);
  white-space: nowrap; flex-shrink: 0;
  border-right: 1px solid rgba(139,115,85,.3); padding-right: 8px;
}
.komadai-sub { display: none; }
.komadai-pieces {
  display: flex; align-items: center; gap: 6px;
  flex: 1; overflow-x: auto; min-height: 38px;
  flex-wrap: nowrap;
}
.komadai-pieces::-webkit-scrollbar { height: 4px; }
.komadai-pieces::-webkit-scrollbar-thumb { background: #c4a878; border-radius: 2px; }
.komadai-empty { color: rgba(139,115,85,.6); font-size: 0.95rem; font-style: italic; }

/* 桌面端：竖向卡片 */
@media (min-width: 1024px) {
  .komadai {
    flex-direction: column; align-items: stretch;
    width: 132px; max-width: none;
    padding: 12px; gap: 8px; min-height: 0;
    align-self: flex-start; max-height: 60vh;
  }
  .komadai-sub { display: inline; }
  .komadai-ai .komadai-label { text-align: right; }
  .komadai-label {
    border-right: none; padding-right: 0;
    border-bottom: 1px solid rgba(139,115,85,.3); padding-bottom: 8px;
  }
  .komadai-pieces {
    flex-direction: row; flex-wrap: wrap; align-content: flex-start;
    overflow-x: hidden; overflow-y: auto; gap: 6px;
  }
}

/* 驹台棋子 */
.kdp {
  position: relative; flex-shrink: 0;
  width: 34px; height: 38px;
  cursor: pointer; border: none; background: none; padding: 0;
  transition: transform .15s;
}
.kdp:hover { transform: translateY(-2px); }
.kdp.selected { transform: scale(1.12); }
.kdp.selected .kdp-svg { filter: drop-shadow(0 0 6px rgba(255,235,59,.9)); }
.kdp-svg { width: 100%; height: 100%; display: block; }
.kdp-count {
  position: absolute; right: -4px; bottom: -4px;
  min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 8px; background: var(--brown); color: #fff;
  font-size: 0.7rem; font-weight: 700; line-height: 16px; text-align: center;
  border: 1px solid var(--line); z-index: 2;
}
@media (min-width: 1024px) { .kdp { width: 40px; height: 46px; } }

/* ===== 棋盘列 ===== */
.board-col {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; min-height: 0; flex: 1;
  width: 100%; max-width: 96vw;
}
@media (min-width: 1024px) { .board-col { max-width: none; align-self: stretch; } }
@media (max-width: 1023px) {
  .board-status,
  .komadai,
  .board-col {
    width: var(--game-content-w);
    max-width: 100%;
  }
  .board-col { flex: 0 0 auto; }
  .board-wrap {
    width: auto;
    max-width: 100%;
    display: inline-flex;
  }
}

.board-status {
  display: flex; align-items: center; justify-content: center; position: relative;
  width: 100%; max-width: 420px; min-width: 0;
  padding: 5px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #eef4fb;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  font-size: 0.95rem; transition: background .25s, border-color .25s;
}
.board-status.turn-player { background: #eef4fb; border-color: #cfe2f6; color: #1565c0; }
.board-status.turn-ai { background: #fdecea; border-color: #f7cdc8; color: #c62828; }
.board-status.over { background: var(--brown); border-color: var(--brown); color: #fff; }
.bs-left { display: flex; align-items: center; gap: 8px; justify-content: center; }
.bs-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--player); flex-shrink: 0; }
.turn-player .bs-dot { background: #1e88e5; animation: pulse 1.4s infinite; }
.turn-ai .bs-dot { background: #e53935; animation: pulse 1.4s infinite; }
.over .bs-dot { background: #fff; animation: none; }
.bs-text { font-weight: 700; }
.bs-diff { position: absolute; right: 12px; font-size: 0.85rem; opacity: .85; font-weight: 600; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

.board-wrap {
  position: relative; display: flex;
  align-items: center; justify-content: center;
  flex: 0 0 auto;
}

/* Panel toggle arrow: absolute, hugs the right edge of the board frame */
.panel-toggle-arrow {
  display: none;
  position: absolute;
  right: -30px; /* 向右移动，避免遮挡棋盘 */
  top: 50%; transform: translateY(-50%);
  width: 30px; height: 48px;
  background: white;
  border: 1px solid var(--line);
  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: 20;
  transition: background 0.2s;
}
@media (min-width: 1024px) { .panel-toggle-arrow { display: flex; } }
.panel-toggle-arrow:hover { background: #f9f6f0; }
.panel-toggle-arrow svg { color: var(--brown); transition: transform 0.3s; }
#shogiBoard {
  display: block; border-radius: 6px;
  box-shadow: 0 10px 34px rgba(0,0,0,.28), 0 2px 8px rgba(0,0,0,.12);
  cursor: pointer; touch-action: manipulation;
}

/* 思考中内联状态 */
.thinking-inline {
  display: flex; align-items: center; gap: 6px;
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.85rem; font-weight: 600;
}
.thinking-inline[hidden] { display: none; }
.spinner-small {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(139,115,85,.3); border-top-color: var(--brown);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 广告位 ===== */
.ad-slot {
  display: none; min-height: 60px; max-height: 60px;
  margin: 8px 12px; color: #999; font-size: 14px;
  /* border-radius: 8px; border: 1px dashed #ccc; background: #fafafa; */
  align-items: center; justify-content: center; overflow: hidden;
}
.ad-slot:not(:empty) { display: flex; flex: 0 0 60px; }
@media (min-width: 1024px) { .ad-slot { margin: 10px 16px; } }

/* ===== 桌面控制面板 ===== */
.control-panel {
  display: none;
  flex-direction: column;
  width: var(--panel-width);
  flex-shrink: 0;
  border-left: 1px solid var(--line);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
  height: 100%;
  overflow: hidden;
  z-index: 40;
  box-shadow: -4px 0 16px rgba(0,0,0,0.05);
}
@media (min-width: 1024px) {
  .control-panel { display: flex; }

  /* 大屏：浮层模式，不挤压棋盘 */
  .game-screen[data-panel-mode="overlay"] .control-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  .game-screen[data-panel-mode="overlay"] .control-panel[data-open="false"] {
    transform: translateX(100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .game-screen[data-panel-mode="overlay"] .control-panel[data-open="true"] {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  /* 小屏桌面：撑开模式，面板占位、棋盘同步左移（不做透明度渐变） */
  .game-screen[data-panel-mode="push"] .control-panel {
    position: relative;
    transform: none;
    opacity: 1;
    transition: margin-right 0.2s ease;
  }
  .game-screen[data-panel-mode="push"] .control-panel[data-open="false"] {
    margin-right: calc(-1 * var(--panel-width));
    pointer-events: none;
  }
  .game-screen[data-panel-mode="push"] .control-panel[data-open="true"] {
    margin-right: 0;
    pointer-events: auto;
  }
}
.panel-inner {
  width: 100%; height: 100%;
  padding: 18px 16px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  scrollbar-width: thin; scrollbar-color: #d4a574 transparent;
}
@media (min-width: 1024px) and (max-width: 1280px) {
  .panel-inner { padding: 14px 12px; gap: 11px; }
  .panel-header { padding: 12px 12px 10px; }
  .panel-title { font-size: 1.05rem; }
  .field-label { font-size: 0.9rem; margin-bottom: 6px; }
  .seg-btn { padding: 7px 4px; font-size: 0.88rem; }
  .action-grid { gap: 8px; }
  .btn { padding: 9px 8px; font-size: 0.88rem; }
  .card { padding: 11px; border-radius: 10px; }
  .hint-title { font-size: 0.9rem; }
  .hint-content { font-size: 0.88rem; line-height: 1.55; }
  .tab-card { padding: 8px 10px 10px; min-height: 110px; }
  .tab-head-btn { font-size: 0.8rem; padding: 5px 3px; }
  .move-list li { font-size: 0.85rem; }
  .record-item { padding: 6px 8px; font-size: 0.85rem; }
  .panel-foot { padding-top: 10px; }
  .foot-label { font-size: 0.9rem; }
}

.panel-inner::-webkit-scrollbar { width: 5px; }
.panel-inner::-webkit-scrollbar-thumb { background: #d4a574; border-radius: 3px; }
.panel-title { font-size: 1.15rem; font-weight: 700; color: var(--ink); margin: 0; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.panel-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.panel-close-btn:hover {
  background: var(--line-soft);
  color: var(--ink);
}

/* ===== 表单 / 分段控件 ===== */
.field-label { font-size: 0.95rem; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.seg {
  display: flex; gap: 4px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 4px;
}
.seg-btn {
  flex: 1; padding: 8px 6px; border: none; border-radius: 7px;
  background: transparent; color: var(--muted);
  font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all .18s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--brown); color: #fff; box-shadow: 0 1px 4px rgba(139,94,60,.4); }

/* 操作按钮 */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 10px; border-radius: 10px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: background .18s, border-color .18s, transform .1s;
}
.btn .ico { font-size: 1rem; line-height: 1; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brown); color: #fff; box-shadow: 0 2px 6px rgba(139,94,60,.3); }
.btn-primary:hover { background: #7a5234; }
.btn-outline { background: #fff; border-color: var(--brown); color: var(--brown); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }

/* ===== 卡片 ===== */
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.hint-card { background: linear-gradient(135deg, #fdf6ea, #fbf1e0); border-color: #ecdcbf; }
.hint-title { font-size: 0.95rem; font-weight: 700; color: var(--brown); margin-bottom: 6px; }
.hint-content { font-size: 0.95rem; color: #5d4037; line-height: 1.6; }
.hint-content .best { color: var(--brown); font-weight: 700; }

.section-label { font-size: 0.9rem; font-weight: 700; color: var(--brown); margin-bottom: 10px; }

/* 棋谱 / 战绩 Tab 卡片 */
.tab-card { flex: 1; min-height: 130px; display: flex; flex-direction: column; padding: 10px 12px 12px; }
.tab-head {
  display: flex; gap: 4px; margin-bottom: 10px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 9px; padding: 3px;
}
.tab-head-btn {
  flex: 1; padding: 6px 4px; border: none; border-radius: 6px;
  background: transparent; color: var(--muted);
  font-size: 0.85rem; font-weight: 700; cursor: pointer; transition: all .18s;
}
.tab-head-btn:hover { color: var(--ink); }
.tab-head-btn.active { background: #fff; color: var(--brown); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.tab-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tab-pane[hidden] { display: none; }

.move-list {
  list-style: none; flex: 1; overflow-y: auto; max-height: none;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; align-content: start;
}
.move-list::-webkit-scrollbar { width: 4px; }
.move-list::-webkit-scrollbar-thumb { background: #d4c4b0; border-radius: 2px; }
.move-list li { font-size: 0.9rem; padding: 2px 4px; border-radius: 4px; display: flex; gap: 6px; }
.move-list li.player { color: var(--player); }
.move-list li.ai { color: var(--ai); }
.move-list li.latest { background: var(--bg); font-weight: 700; }
.move-no { color: var(--muted); min-width: 20px; }
.move-empty { grid-column: 1/-1; text-align: center; color: #bbb; font-style: italic; padding: 16px 0; font-size: 0.9rem; }

.record-list { display: flex; flex-direction: column; gap: 6px; flex: 1; overflow-y: auto; }
.record-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: 8px; background: var(--bg);
  font-size: 0.9rem; border: 1px solid var(--line-soft);
}
.record-meta { color: var(--muted); }
.record-date { font-weight: 700; color: var(--ink); }
.record-result { font-weight: 700; padding: 1px 8px; border-radius: 6px; }
.record-result.win { background: #e7f1fb; color: #1565c0; }
.record-result.lose { background: #fdeceb; color: #c62828; }
.record-empty { text-align: center; color: #bbb; font-style: italic; padding: 14px 0; font-size: 0.9rem; }

/* 面板底部音效开关 */
.panel-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; border-top: 1px solid var(--line);
}
.foot-label { font-size: 0.95rem; color: var(--muted); }
.sound-toggle { border: none; background: none; cursor: pointer; padding: 0; }
.switch-track {
  display: block; width: 42px; height: 22px; border-radius: 999px;
  background: var(--brown); position: relative; transition: background .2s;
}
.switch-thumb {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: right .2s;
}
.sound-toggle[aria-checked="false"] .switch-track { background: #c9bfae; }
.sound-toggle[aria-checked="false"] .switch-thumb { right: 22px; }

/* ===== 文章内容区 ===== */
.article-container { padding: 40px 16px 48px; background: var(--bg); }
@media (min-width: 768px) { .article-container { padding: 56px 24px 56px; } }
.info-section {
  max-width: 1100px; margin: 0 auto 20px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 20px; box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
@media (min-width: 768px) { .info-section { padding: 36px 40px; margin-bottom: 24px; } }

.info-hero { background: transparent; border: none; box-shadow: none; text-align: center; }
.hero-title { font-size: 1.6rem; font-weight: 700; color: var(--brown); margin-bottom: 12px; line-height: 1.35; }
@media (min-width: 768px) { .hero-title { font-size: 2.1rem; } }
.hero-sub { font-size: 1.1rem; color: var(--muted); max-width: 760px; margin: 0 auto; line-height: 1.7; }

.section-title {
  font-size: 1.35rem; font-weight: 700; color: var(--brown);
  border-bottom: 1px solid var(--bg); padding-bottom: 12px; margin-bottom: 18px;
}
@media (min-width: 768px) { .section-title { font-size: 1.6rem; } }
.section-subtitle { font-size: 1rem; color: var(--muted); margin: -6px 0 18px; line-height: 1.6; }

.prose p { font-size: 1.05rem; color: #5d4037; line-height: 1.85; margin-bottom: 14px; }
.dot-list { list-style: none; margin: 6px 0 14px; display: flex; flex-direction: column; gap: 12px; }
.dot-list li { position: relative; padding-left: 18px; font-size: 1.02rem; color: #5d4037; line-height: 1.75; }
.dot-list li::before { content: ""; position: absolute; left: 0; top: 11px; width: 8px; height: 8px; border-radius: 50%; background: #d4a96a; }
.dot-list b { color: var(--ink); }

.note-box {
  background: #fdf6ea; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; font-size: 1rem; color: #5d4037; line-height: 1.7;
}
.note-strong { font-weight: 700; color: var(--brown); }

/* 优势网格 */
.feature-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 18px; }
@media (min-width: 640px) { .feature-grid { grid-template-columns: 1fr 1fr; } }
.feature-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px; border: 1px solid var(--line-soft); border-radius: 12px;
  transition: background .2s;
}
.feature-item:hover { background: #fffaf0; }
.feature-ico { font-size: 1.6rem; flex-shrink: 0; line-height: 1; }
.feature-h { font-weight: 700; color: var(--ink); margin-bottom: 5px; font-size: 1.05rem; }
.feature-d { font-size: 0.98rem; color: #5d4037; line-height: 1.6; }

/* 棋子速查 */
.piece-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .piece-grid { grid-template-columns: 1fr 1fr; } }
.piece-card { border: 1px solid var(--line-soft); border-radius: 12px; padding: 16px; transition: background .2s; }
.piece-card:hover { background: #fffaf0; }
.piece-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.piece-kanji {
  width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
  background: #d4a96a; color: #fff; font-weight: 700; font-size: 1.15rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.15); font-family: serif;
}
.piece-name { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.piece-move { font-size: 0.98rem; color: #5d4037; line-height: 1.6; }
.piece-note { font-size: 0.9rem; color: var(--brown); background: #fdf6ea; border-radius: 6px; padding: 6px 10px; margin-top: 10px; line-height: 1.5; }

/* 教程步骤 */
.step-list { display: flex; flex-direction: column; gap: 22px; }
.step { display: flex; gap: 16px; }
.step-num { flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px; background: var(--brown); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 0.95rem; }
.step-h { font-weight: 700; color: var(--ink); margin-bottom: 6px; font-size: 1.08rem; }
.step p { font-size: 1rem; color: #5d4037; line-height: 1.7; }

/* 策略 */
.strategy-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 18px; }
@media (min-width: 768px) { .strategy-grid { grid-template-columns: 1fr 1fr; } }
.strategy-card { border: 1px solid var(--line-soft); border-radius: 12px; padding: 18px; transition: background .2s; }
.strategy-card:hover { background: #fffaf0; }
.strategy-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.strategy-head h5 { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.tag { font-size: 0.8rem; background: #d4a96a; color: #fff; padding: 2px 10px; border-radius: 999px; }
.strategy-card p { font-size: 0.98rem; color: #5d4037; line-height: 1.65; }

/* PWA */
.pwa-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 768px) { .pwa-grid { grid-template-columns: 1fr 1fr; } }
.pwa-card { border: 1px solid var(--line-soft); border-radius: 12px; padding: 18px; }
.pwa-h { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); margin-bottom: 12px; font-size: 1.08rem; }
.num-list { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.num-list li { font-size: 0.98rem; color: #5d4037; line-height: 1.6; }

/* FAQ */
.faq-list { display: flex; flex-direction: column; }
.faq-item { border-bottom: 1px solid var(--line-soft); }
.faq-item:last-child { border-bottom: none; }
.faq-q {
  list-style: none; cursor: pointer; padding: 16px 0;
  font-size: 1.05rem; font-weight: 700; color: var(--ink);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.faq-q::-webkit-details-marker { display: none; }
.faq-q::after { content: "+"; color: var(--brown); font-size: 1.3rem; flex-shrink: 0; }
details[open] .faq-q::after { content: "\2212"; }
.faq-a { padding: 0 0 16px; font-size: 1rem; color: #5d4037; line-height: 1.75; }

/* 术语 */
.term-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 640px) { .term-grid { grid-template-columns: repeat(3,1fr); } }
@media (min-width: 1024px) { .term-grid { grid-template-columns: repeat(4,1fr); } }
.term { display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 1px solid var(--line-soft); border-radius: 10px; }
.term-zh { font-weight: 700; color: var(--ink); font-size: 1rem; }
.term-jp { font-size: 0.82rem; color: var(--brown); font-family: monospace; }

/* ===== Footer ===== */
.site-footer { background: var(--ink); color: var(--line); padding: 40px 16px; padding-bottom: calc(40px + var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 1024px) { .site-footer { padding-bottom: 40px; } }
.footer-inner { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.footer-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: #fff; }
.footer-logo .logo-img { border-radius: 6px; }
.footer-desc { font-size: 0.98rem; color: rgba(255,255,255,.55); line-height: 1.7; max-width: 640px; }
.footer-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: center; font-size: 0.9rem; color: rgba(255,255,255,.4); }
.footer-link { color: rgba(255,255,255,.55); text-decoration: none; transition: color .2s; }
.footer-link:hover { color: #fff; }

/* ===== 返回顶部 ===== */
.back-to-top {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom, 0px));
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; color: var(--brown); border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(0,0,0,.14); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 60; opacity: 0; visibility: hidden; transition: all .3s;
}
@media (min-width: 1024px) { .back-to-top { right: 28px; bottom: 28px; } }
.back-to-top.show { opacity: 1; visibility: visible; }
.back-to-top:hover { background: var(--bg); transform: translateY(-3px); }

/* ===== 移动端 TabBar ===== */
.mobile-tabbar {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  /* 内容区固定 56px，安全区额外垫高，避免 PWA 下图标被裁切 */
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff; border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(0,0,0,.05);
  align-items: center; justify-content: space-around;
  box-sizing: border-box;
}
@media (min-width: 1024px) { .mobile-tabbar { display: none; } }
.tab-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; flex: 1; height: var(--tabbar-h); min-height: var(--tabbar-h);
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 0.78rem; font-weight: 500; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn svg { flex-shrink: 0; display: block; }
.tab-btn.active { color: var(--brown); }

/* ===== 移动端抽屉 ===== */
.drawer-overlay { position: fixed; inset: 0; z-index: 80; background: rgba(62,39,35,.45); }
.mobile-drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: #fff; border-radius: 18px 18px 0 0;
  height: 78dvh; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.16,1,.3,1);
  box-shadow: 0 -4px 30px rgba(0,0,0,.18);
}
.mobile-drawer[data-open="true"] { transform: translateY(0); }
.drawer-handle { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 4px; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 6px 18px 12px; border-bottom: 1px solid var(--line-soft); }
.drawer-title { font-size: 1.1rem; font-weight: 700; color: var(--ink); }
.drawer-close { width: 30px; height: 30px; border-radius: 50%; background: var(--bg); border: none; cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }

/* ===== 弹窗 ===== */
.dialog-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(62,39,35,.5); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.dialog-mask[hidden] { display: none; }
.dialog-box {
  background: #fff; border-radius: 20px; padding: 30px 26px;
  width: 100%; max-width: 360px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.dialog-msg { font-size: 1.4rem; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.dialog-tip { font-size: 0.95rem; color: var(--muted); margin-bottom: 20px; }
.dialog-btns { display: flex; flex-direction: column; gap: 10px; }
.dialog-btns .btn { padding: 13px; font-size: 1rem; }

@media (max-width: 400px) {
  .logo-text { font-size: 1.1rem; }
  .game-stage { gap: 5px; padding: 6px 10px; }
  .game-main { --game-content-w: calc(100vw - 20px); }
  .ad-slot:not(:empty) { max-width: calc(100vw - 20px); }
}
