/* ============================================================
   翻老爷暗棋游戏 - 样式表
   棋盘交替色 | 九宫对角线 | 坐标标注 | 纹饰 | 动画 | 音效按钮
   ============================================================ */

:root {
  --ink:          #3a2210;
  --ink-light:    #5a4230;
  --ink-pale:     #8a7a60;
  --cinnabar:     #c04030;
  --cinnabar-dark:#8b2020;
  --cinnabar-pale:#e8c8c4;
  --gold:         #c4a35a;
  --gold-light:   #d4b46a;
  --gold-dark:    #8b6914;
  --paper:        #efe4ce;
  --paper-dark:   #e0d0b0;
  --wood:         #5a3a18;
  --wood-dark:    #3a1a08;
  --jade:         #5a8a6a;
  --jade-dark:    #3a6a4a;
  --blue-dark:    #1a3860;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 15% 20%, rgba(139,90,43,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 75%, rgba(139,90,43,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(200,180,140,0.08) 0%, transparent 70%);
  min-height: 100vh;
  color: #333;
  user-select: none;
}

/* ---- 页面容器 ---- */
.page { display: none; }
.page.active { display: flex; }
#lobby-page.active { display: block; }

/* ---- 通用按钮（游戏页结算/面板使用） ---- */
.btn {
  padding: 12px 28px; border: none; border-radius: 10px;
  font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: #c0392b; color: #fff; }
.btn-primary:hover { background: #a93226; transform: translateY(-1px); }
.btn-secondary { background: #f0e6d3; color: #8B4513; border: 2px solid #d4c4a8; }
.btn-secondary:hover { background: #e8d8b8; }

/* ============================================================
   首页（大厅）样式
   ============================================================ */

#lobby-page {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  padding-bottom: 80px;
  font-family: 'ZCOOL XiaoWei', 'Noto Serif SC', 'STSong', 'SimSun', serif;
  color: var(--ink);
}

/* ---- 水墨装饰层 ---- */
#lobby-page .deco-bamboo-left {
  position: fixed; top: 0; left: 0;
  width: clamp(60px, 12vw, 120px); height: 100vh;
  opacity: 0.12; z-index: 0; pointer-events: none;
}
#lobby-page .deco-bamboo-right {
  position: fixed; top: 0; right: 0;
  width: clamp(50px, 10vw, 100px); height: 100vh;
  opacity: 0.10; z-index: 0; pointer-events: none;
}
#lobby-page .deco-ink {
  position: fixed; pointer-events: none; z-index: 0; opacity: 0.07;
}
#lobby-page .deco-ink-tl { top: -20px; left: -10px; width: 180px; height: 180px; }
#lobby-page .deco-ink-br { bottom: 40px; right: -20px; width: 200px; height: 200px; }
#lobby-page .deco-cloud {
  position: fixed; pointer-events: none; z-index: 0; opacity: 0.06;
}
#lobby-page .deco-cloud-tr { top: 5%; right: 3%; width: clamp(80px, 18vw, 140px); height: auto; }

/* ---- 印章装饰 ---- */
#lobby-page .seal-deco {
  position: fixed;
  width: clamp(50px, 12vw, 80px); height: clamp(50px, 12vw, 80px);
  border: 3px solid rgba(180,60,30,0.18); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transform: rotate(-15deg); pointer-events: none; z-index: 0;
}
#lobby-page .seal-deco.top { top: 8%; right: 2%; }
#lobby-page .seal-text {
  font-family: 'Ma Shan Zheng', serif;
  font-size: clamp(16px, 4.5vw, 22px);
  color: rgba(180,60,30,0.2); letter-spacing: 2px;
}

/* ---- 主内容区 ---- */
#lobby-page .main-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  padding: 12px clamp(12px, 3vw, 24px);
  max-width: 480px; margin: 0 auto;
}

/* ---- LOGO 横幅海报 ---- */
#lobby-page .logo-wrapper {
  width: 100%;
  margin-top: clamp(8px, 3vw, 18px);
  margin-bottom: 0;
  display: flex; justify-content: center;
}
#lobby-page .banner-logo {
  width: 100%; max-width: 480px; height: auto; display: block;
  border-radius: 6px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.25));
}

/* ---- 公共卡片容器 ---- */
#lobby-page .hp-card {
  width: 100%;
  background: linear-gradient(135deg, rgba(255,255,255,0.55), rgba(240,225,200,0.55));
  border: 1px solid rgba(139,90,43,0.12);
  border-radius: 10px;
  position: relative; overflow: hidden;
}
#lobby-page .hp-card::after {
  content: ''; position: absolute;
  top: -50%; right: -50%; width: 100%; height: 200%;
  background: radial-gradient(ellipse, rgba(196,163,90,0.05) 0%, transparent 70%);
  pointer-events: none;
}

/* ---- 用户卡片 ---- */
#lobby-page .user-card {
  display: flex; align-items: center;
  gap: clamp(10px, 3vw, 14px);
  padding: clamp(10px, 2.5vw, 14px) clamp(12px, 3vw, 16px);
  margin-bottom: clamp(8px, 2vw, 12px);
}
#lobby-page .avatar-frame {
  width: clamp(48px, 12vw, 60px); height: clamp(48px, 12vw, 60px);
  border-radius: 12px; border: 2px solid #a08050; flex-shrink: 0;
  background: linear-gradient(135deg, #d5c4a0, #e8dcc0);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
#lobby-page .avatar-svg { width: 85%; height: 85%; }
#lobby-page .user-info { flex: 1; min-width: 0; }
#lobby-page .user-name {
  font-family: 'Ma Shan Zheng', serif;
  font-size: clamp(18px, 4.5vw, 24px);
  color: var(--ink); line-height: 1.2;
}
#lobby-page .user-rank {
  font-size: clamp(10px, 2.5vw, 12px);
  color: var(--gold-dark); letter-spacing: 2px; margin-top: 1px;
}
#lobby-page .user-record {
  display: flex; align-items: center; gap: 6px; margin-top: 4px;
  font-size: clamp(12px, 3vw, 14px); color: var(--ink-light);
}
#lobby-page .record-win  { color: var(--cinnabar); font-weight: 700; }
#lobby-page .record-loss { color: var(--jade-dark); font-weight: 700; }
#lobby-page .record-sep  { color: var(--ink-pale); }

/* ---- 三段统计 ---- */
#lobby-page .stats-row {
  width: 100%; display: flex; gap: clamp(6px, 2vw, 10px);
  margin-bottom: clamp(10px, 2.5vw, 14px);
}
#lobby-page .stat-card {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: clamp(10px, 2.5vw, 14px) 4px;
  background: linear-gradient(180deg, rgba(255,255,255,0.45), rgba(240,225,200,0.5));
  border: 1px solid rgba(139,90,43,0.1); border-radius: 8px;
  position: relative; z-index: 1;
}
#lobby-page .stat-value {
  font-family: 'Noto Serif SC', serif; font-weight: 900;
  font-size: clamp(20px, 5vw, 28px); color: var(--ink); line-height: 1;
}
#lobby-page .stat-value.gold  { color: var(--gold-dark); }
#lobby-page .stat-value.red   { color: var(--cinnabar); }
#lobby-page .stat-value.green { color: var(--jade-dark); }
#lobby-page .stat-label {
  font-size: clamp(9px, 2.2vw, 11px); color: var(--ink-pale);
  letter-spacing: 1px; margin-top: 4px;
}

/* ---- 分区标题装饰 ---- */
#lobby-page .section-title {
  width: 100%; display: flex; align-items: center; gap: 8px;
  margin-bottom: clamp(6px, 1.5vw, 10px); padding: 0 4px;
}
#lobby-page .section-title .line {
  flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,90,43,0.2), transparent);
}
#lobby-page .section-title .text {
  font-size: clamp(11px, 2.5vw, 13px); color: var(--ink-pale);
  letter-spacing: 3px; white-space: nowrap;
}

/* ---- 房间号输入 ---- */
#lobby-page .room-section { width: 100%; margin-bottom: clamp(10px, 2.5vw, 14px); }
#lobby-page .room-row { display: flex; gap: 8px; }
#lobby-page .room-input {
  flex: 1; min-width: 0;
  padding: clamp(10px, 2.5vw, 13px) clamp(12px, 3vw, 16px);
  background: rgba(255,255,255,0.6);
  border: 1.5px solid rgba(139,90,43,0.25); border-radius: 8px;
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(14px, 3.5vw, 17px); font-weight: 700;
  color: var(--ink); letter-spacing: 3px;
  outline: none; transition: border-color 0.2s; text-align: center;
}
#lobby-page .room-input::placeholder {
  color: var(--ink-pale); font-weight: 400; letter-spacing: 1px;
  font-size: clamp(12px, 3vw, 14px); opacity: 0.5;
}
#lobby-page .room-input:focus {
  border-color: var(--gold); box-shadow: 0 0 0 2px rgba(196,163,90,0.15);
}
#lobby-page .room-btn {
  flex-shrink: 0;
  padding: clamp(10px, 2.5vw, 13px) clamp(16px, 4vw, 24px);
  background: linear-gradient(180deg, #b8382a, #8b2020);
  border: 1px solid #6a1010; border-radius: 8px;
  color: #f5e0c0; font-family: 'Ma Shan Zheng', serif;
  font-size: clamp(16px, 4vw, 22px); letter-spacing: 2px;
  cursor: pointer; white-space: nowrap;
  transition: transform 0.12s, filter 0.12s;
  box-shadow: 0 2px 6px rgba(140,20,15,0.25);
  -webkit-tap-highlight-color: transparent;
}
#lobby-page .room-btn:active { transform: scale(0.96); filter: brightness(0.88); }

/* ---- 线上匹配按钮 ---- */
#lobby-page .match-btn-wrap {
  width: 100%; margin-bottom: 8px;
  border-radius: 8px; overflow: hidden; cursor: pointer;
  transition: transform 0.12s, filter 0.12s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 8px rgba(60,50,100,0.25);
}
#lobby-page .match-btn-wrap img { width: 100%; height: auto; display: block; }
#lobby-page .match-btn-wrap:active { transform: scale(0.97); filter: brightness(0.88); }

/* ---- 对局按钮区 ---- */
#lobby-page .play-section { width: 100%; margin-bottom: clamp(10px, 2.5vw, 14px); }

/* AI 双按钮行 */
#lobby-page .ai-btns-row {
  display: flex; gap: clamp(8px, 2vw, 12px);
  margin-bottom: clamp(8px, 2vw, 12px);
}
#lobby-page .ai-btn {
  flex: 1; aspect-ratio: 1 / 1; padding: 0; border: none; border-radius: 10px;
  cursor: pointer; position: relative; overflow: hidden;
  transition: transform 0.12s, filter 0.12s, box-shadow 0.12s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 3px 10px rgba(0,0,0,0.18); background: none;
}
#lobby-page .ai-btn:active {
  transform: scale(0.96); filter: brightness(0.88);
  box-shadow: 0 1px 5px rgba(0,0,0,0.12);
}
#lobby-page .ai-btn img {
  width: 100%; height: 100%; object-fit: cover;
  display: block; border-radius: inherit;
}

/* 本地双人对战按钮 */
#lobby-page .local-btn {
  width: 100%; display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: clamp(12px, 3vw, 16px);
  background: linear-gradient(180deg, #5a4230, #3a2210, #2a1808);
  border: 2px solid #6b4a28; border-radius: 10px; cursor: pointer;
  color: #e8d5a0; font-family: 'Ma Shan Zheng', serif;
  font-size: clamp(17px, 4.5vw, 24px); letter-spacing: 4px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  position: relative; overflow: hidden;
  transition: transform 0.12s, filter 0.12s;
  -webkit-tap-highlight-color: transparent;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
#lobby-page .local-btn:active { transform: scale(0.97); filter: brightness(0.9); }
#lobby-page .local-btn::after {
  content: ''; position: absolute; top: 2px; left: 6px; right: 6px;
  height: 1px; background: rgba(255,255,255,0.1); border-radius: 1px;
}
#lobby-page .local-btn-icon { width: clamp(22px, 5vw, 28px); height: clamp(22px, 5vw, 28px); flex-shrink: 0; }

/* ---- 底部导航 ---- */
#lobby-page .bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; display: flex;
  background: linear-gradient(180deg, var(--wood), #4a2a10, var(--wood-dark));
  border-top: 2px solid #6b4a28;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
  z-index: 100; padding: 6px 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}
#lobby-page .nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  padding: 6px 2px; color: var(--ink-pale);
  cursor: pointer; transition: color 0.2s; position: relative;
  -webkit-tap-highlight-color: transparent;
}
#lobby-page .nav-item:hover, #lobby-page .nav-item:active { color: #e8d5a0; }
#lobby-page .nav-item.active { color: var(--gold); }
#lobby-page .nav-item.active .nav-icon-wrap { filter: drop-shadow(0 0 4px rgba(196,163,90,0.6)); }
#lobby-page .nav-item.active::after {
  content: ''; position: absolute; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: clamp(20px, 5vw, 28px); height: 2.5px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
#lobby-page .nav-icon-wrap { width: clamp(22px, 5.5vw, 28px); height: clamp(22px, 5.5vw, 28px); }
#lobby-page .nav-label { font-size: clamp(9px, 2.5vw, 12px); letter-spacing: 1px; }
#lobby-page .nav-item.center-btn { position: relative; margin-top: -20px; }
#lobby-page .nav-item.center-btn .nav-icon-wrap {
  width: clamp(44px, 11vw, 56px); height: clamp(44px, 11vw, 56px);
  background: linear-gradient(180deg, var(--gold), var(--gold-dark));
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3); border: 2px solid #6b4e15;
}
#lobby-page .nav-item.center-btn .nav-icon-wrap svg { width: 60%; height: 60%; }

/* ---- 首页响应式 ---- */
@media (min-width: 600px) {
  #lobby-page .main-content { padding: 20px 32px; }
  #lobby-page .logo-wrapper { margin-top: 32px; }
}
@media (max-width: 360px) {
  #lobby-page .main-content { padding: 8px 8px; }
  #lobby-page .user-card { gap: 6px; padding: 8px 10px; }
  #lobby-page .ai-btns-row { gap: 6px; }
  #lobby-page .room-row { gap: 6px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  #lobby-page .logo-wrapper { margin-top: 4px; }
  #lobby-page .logo-wrapper .banner-logo { max-height: 120px; object-fit: contain; }
  #lobby-page .ai-btns-row { gap: 6px; }
  #lobby-page .ai-btn { border-radius: 8px; }
  #lobby-page .local-btn { padding: 8px 12px; }
  #lobby-page .bottom-nav { padding: 2px 0; }
}

/* ---- 棋盘署名 ---- */
.board-credit {
  position: absolute;
  bottom: 2px; right: 8px;
  font-size: 10px;
  color: rgba(139, 90, 43, 0.35);
  font-family: 'Noto Serif SC', serif;
  letter-spacing: 0.5px;
  pointer-events: none;
  user-select: none;
}

/* ---- 游戏页面 ---- */
#game-page {
  flex-direction: row; min-height: 100vh; padding: 16px; gap: 20px;
  position: relative;
}

/* ---- 左侧棋盘区 ---- */
.board-container {
  flex: 0 0 auto; background: #fff; border-radius: 16px; padding: 16px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.08); position: relative;
  align-self: flex-start;
}

.board-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.board-header .room-tag { background: #f0e6d3; padding: 4px 12px; border-radius: 20px; font-size: 13px; color: #8B4513; }
.board-header .step-tag { font-size: 13px; color: #888; }

/* 棋盘+坐标的包裹 */
.board-wrapper {
  display: grid;
  grid-template-columns: 22px repeat(8, 64px) 22px;
  grid-template-rows: 20px repeat(9, 64px) 20px;
  gap: 1px;
}

/* 顶部列坐标: 阿拉伯数字1-8 */
.col-coord {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #8B4513; font-weight: 600;
}

/* 左侧行坐标: 九八七六河四三二一 */
.row-coord {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #8B4513; font-weight: 600;
}

/* 棋盘网格 */
#board-grid {
  display: grid;
  grid-template-columns: repeat(8, 64px);
  grid-template-rows: repeat(9, 64px);
  gap: 1px;
  background-color: #b89a7a;
  background-image: url(../assets/board-bg.png);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  /* 用 box-shadow 代替 border，不影响布局尺寸，避免格子与底图错位 */
  box-shadow: 0 0 0 3px #8B4513;
  position: relative;
}

/* ---- 楚河汉界 & 河界底纹: 已合并到棋盘底图 ---- */
#board-grid::before { content: none; }
#board-grid::after { content: none; }

/* ---- 单元格 ---- */
.cell {
  width: 64px; height: 64px;
  position: relative; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; z-index: 1;
}

/* 格子交替色: 已合并到棋盘底图，格子透明 */
.cell-light { background: transparent; }
.cell-dark  { background: transparent; }

.cell:hover { background: rgba(232, 213, 181, 0.35) !important; }

/* 河界格子: 已合并到棋盘底图 */
.cell.river-light { background: transparent; }
.cell.river-dark  { background: transparent; }

/* 九宫格子不再覆盖背景色，跟随棋盘交替色 */
.cell.palace {
  /* 仅作标记用途，背景由 cell-light/cell-dark 控制 */
}

/* 九宫虚线框 —— 已合并到棋盘底图 */
.palace-box { display: none; }

/* 初始位置直角纹饰: 已合并到棋盘底图 */
.cell.initial-pos::before { content: none; }

/* ---- 走法标记 ---- */

/* 可移动: 蓝色圆点 */
.cell.move-target::after {
  content: '';
  width: 28px; height: 28px;
  background-image: url(../assets/icons/move.png);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: absolute; pointer-events: none; z-index: 15;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

/* 可杀伤: 交叉剑图标 */
.cell.kill-target::after {
  content: '';
  width: 36px; height: 36px;
  background-image: url(../assets/icons/kill.png);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: absolute; pointer-events: none; z-index: 15;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: kill-pulse 1.2s ease-in-out infinite;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}

@keyframes kill-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.15); }
}

/* 技能目标: 紫色五边形 */
.cell.skill-target::after {
  content: '';
  width: 32px; height: 32px;
  background-image: url(../assets/icons/skill.png);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: absolute; pointer-events: none; z-index: 15;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

/* 技能关联棋子标记（如斗转星移互换目标、调兵遣将的帅/将） */
.cell.skill-linked::after {
  content: '';
  width: 44px; height: 44px;
  background-image: url(../assets/icons/skill-linked.png);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: absolute; pointer-events: none; z-index: 20;
  top: 50%; left: 50%;
  filter: drop-shadow(0 0 6px rgba(142,68,173,0.8));
  animation: pulse-skill 1.2s ease-in-out infinite;
}

@keyframes pulse-skill {
  0%, 100% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.8; }
  50% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
}

/* 船坚炮利/调兵遣将落点: 虚线圆 — 用 ::before 避免覆盖移动标记 ::after */
.cell.teleport-target::before {
  content: '';
  width: 44px; height: 44px;
  background-image: url(../assets/icons/teleport.png);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: absolute; pointer-events: none; z-index: 14;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

/* 船坚炮利/调兵遣将连接线 SVG — 统一紫色虚线 */
.teleport-line-svg {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 13;
  overflow: visible;
}
.teleport-line-svg line {
  stroke: rgba(142, 68, 173, 0.65);
  stroke-width: 2.5;
  stroke-dasharray: 6, 4;
}

/* ---- 棋子 ---- */
.piece {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; cursor: pointer;
  transition: box-shadow 0.15s;
  position: relative; z-index: 3;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  border: 2px solid rgba(0,0,0,0.12);
}

/* 暗子 */
.piece.hidden {
  background: linear-gradient(135deg, #5D4037, #4E342E);
  color: #BCAAA4; font-size: 20px; border-color: #3E2723;
}
.piece.hidden::after {
  content: ''; position: absolute; inset: 3px; border-radius: 50%;
  border: 1px solid rgba(188, 170, 164, 0.3);
}

/* 红方明子 */
.piece.revealed.red {
  background: linear-gradient(135deg, #fdecea, #f5c6c2);
  color: #c0392b; border-color: #c0392b;
}

/* 绿方明子 */
.piece.revealed.green {
  background: linear-gradient(135deg, #eafaf1, #a9dfbf);
  color: #1e8449; border-color: #1e8449;
}

/* 选中效果 */
.piece.selected {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px #f39c12, 0 4px 12px rgba(0,0,0,0.2);
  z-index: 5;
}
.piece:hover { transform: scale(1.05); }
.piece.selected:hover { transform: scale(1.08); }

/* ---- 棋子动画 ---- */

/* 翻子动画：3D翻转 */
@keyframes flip-reveal {
  0% { transform: rotateY(0deg); }
  50% { transform: rotateY(90deg); }
  100% { transform: rotateY(0deg); }
}
.piece.flipping {
  animation: flip-reveal 0.5s ease-in-out;
  transform-style: preserve-3d;
}

/* 走子动画：跳跃 */
@keyframes piece-jump {
  0% { transform: translateY(0); }
  30% { transform: translateY(-10px) scale(1.06); }
  60% { transform: translateY(-2px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}
.piece.jumping {
  animation: piece-jump 0.4s ease-out;
}

/* 吃子特效：变大后淡出 */
@keyframes piece-captured {
  0% { transform: scale(1); opacity: 1; }
  40% { transform: scale(1.35); opacity: 0.9; }
  100% { transform: scale(1.5); opacity: 0; }
}
.piece.captured-anim,
.captured-float.captured-anim {
  animation: piece-captured 0.6s ease-out forwards;
  pointer-events: none;
}

/* 吃子浮动覆盖层 —— 圆形棋子外观 */
.captured-float {
  position: absolute;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  z-index: 25;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  border: 2px solid rgba(0,0,0,0.12);
}
.captured-float.red {
  background: linear-gradient(135deg, #fdecea, #f5c6c2);
  color: #c0392b; border-color: #c0392b;
}
.captured-float.green {
  background: linear-gradient(135deg, #eafaf1, #a9dfbf);
  color: #1e8449; border-color: #1e8449;
}

/* 技能文字浮动 —— 向上淡出动画 */
.skill-float-text {
  position: absolute;
  font-size: 20px; font-weight: 800;
  pointer-events: none; z-index: 30;
  white-space: nowrap;
  padding: 4px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 12px rgba(0,0,0,0.25), 0 0 0 2px rgba(0,0,0,0.08);
  letter-spacing: 1px;
  /* 用 margin 居中而非 transform，避免与动画 transform 冲突 */
  transform: translateX(-50%);
  opacity: 0;
  animation: skill-float-up 2s ease-out forwards;
}

@keyframes skill-float-up {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.8);
  }
  15% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) translateY(-20px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-65px) scale(0.9);
  }
}

/* ---- 动画展示区 ---- */
.anim-display-area {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none; z-index: 25; overflow: visible;
}

/* ---- 右侧信息栏 ---- */
/* ---- PC右侧侧边栏 ---- */
.pc-sidebar {
  flex: 0 0 280px; width: 280px;
  display: flex; flex-direction: column; gap: 10px;
}

/* ---- LOGO + 返回 + 设置 ---- */
.pc-logo-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0;
}
.pc-logo-img {
  height: 36px; width: auto;
  filter: drop-shadow(0 1px 3px rgba(58,34,16,0.18));
}
.pc-logo-actions {
  display: flex; align-items: center; gap: 6px;
}
.pc-back-btn {
  padding: 4px 10px; border: 1.5px solid var(--cinnabar);
  border-radius: 8px; background: rgba(192,64,48,0.06);
  color: var(--cinnabar); font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  font-family: 'Ma Shan Zheng', serif; letter-spacing: 1px;
  transition: all 0.2s;
}
.pc-back-btn:hover { background: var(--cinnabar); color: #fff; }
.pc-settings-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--gold-dark);
  background: rgba(196,163,90,0.08);
  color: var(--gold-dark); font-size: 15px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.25s;
  padding: 0;
}
.pc-settings-btn:hover {
  background: var(--gold-dark); color: #fff;
  transform: rotate(60deg);
}

/* ---- 房间 + 步数 + 回合 ---- */
.pc-room-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 10px;
  background: linear-gradient(135deg, rgba(255,255,255,0.5), rgba(240,225,200,0.4));
  border: 1px solid rgba(139,90,43,0.12);
  font-size: 13px; color: var(--ink-light);
}
.pc-room-row span:first-child { flex: 1; white-space: nowrap; }
.pc-step {
  font-family: 'Courier New', monospace;
  font-size: 12px; color: var(--ink-pale);
  padding: 2px 8px; border-radius: 8px;
  background: rgba(196,163,90,0.12); white-space: nowrap;
}
.pc-step strong { color: var(--ink-light); }
.pc-turn-badge {
  padding: 3px 10px; border-radius: 12px;
  font-weight: 700; font-size: 12px; white-space: nowrap;
  letter-spacing: 1px;
}
.pc-turn-badge.red { background: var(--cinnabar); color: #fff; }
.pc-turn-badge.green { background: var(--jade-dark); color: #fff; }

/* ---- info卡片 (选中棋子+技能) ---- */
.pc-info-card {
  background: #fff; border-radius: 12px; padding: 14px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.pc-info-title { font-size: 12px; color: var(--ink-pale); letter-spacing: 1px; margin-bottom: 6px; }
.pc-skill-area { margin-top: 10px; padding-top: 8px; border-top: 1px dashed rgba(139,90,43,0.15); }

.hint-text { color: #bbb; font-size: 13px; text-align: center; padding: 8px 0; }

/* 选中棋子图形化展示 */
.selected-piece-info {
  display: flex; align-items: center; gap: 12px;
}
.piece-visual-mini {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-family: 'Ma Shan Zheng', serif; font-size: 22px;
  border: 2px solid rgba(0,0,0,0.12);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  position: relative;
}
.piece-visual-mini.red {
  background: linear-gradient(135deg, #fff5f5, #ffe0d8);
  color: var(--cinnabar);
  border-color: rgba(192,64,48,0.3);
  box-shadow: 0 2px 8px rgba(192,64,48,0.15);
}
.piece-visual-mini.green {
  background: linear-gradient(135deg, #f5faf8, #d8efe2);
  color: var(--jade-dark);
  border-color: rgba(46,139,87,0.3);
  box-shadow: 0 2px 8px rgba(46,139,87,0.15);
}
/* 棋子底纹装饰 */
.piece-visual-mini::after {
  content: ''; position: absolute; top: 3px; left: 3px; right: 3px; bottom: 3px;
  border-radius: 50%; border: 1px solid rgba(0,0,0,0.04); pointer-events: none;
}
.piece-visual-mini .piece-visual-char {
  position: relative; z-index: 1;
}
.piece-visual-meta {
  display: flex; flex-direction: column; gap: 3px;
}
.piece-visual-type {
  font-size: 12px; color: var(--ink-pale); letter-spacing: 1px;
}
.piece-visual-moves {
  font-size: 13px; color: var(--ink-light);
}
.piece-visual-moves strong {
  color: var(--cinnabar); font-size: 16px;
}

/* ---- 统计卡片 ---- */
.pc-stats-card {
  background: #fff; border-radius: 12px; padding: 12px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

/* ---- 阵亡卡片 ---- */
.pc-captured-card {
  background: #fff; border-radius: 12px; padding: 14px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.pc-captured-card .casualty-section { margin-bottom: 6px; }
.pc-captured-card .casualty-none { font-size: 12px; color: #bbb; }

/* ---- PC静音按钮 (已移除,保留占位) ---- */
/* pc-mute-row 已废弃 */

/* 存活统计 */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-item { padding: 8px 4px; border-radius: 8px; }
.stat-item.red-stat { background: #fdecea; }
.stat-item.green-stat { background: #eafaf1; }
.stat-item.dark-stat { background: #f5f0e8; }
.stat-side { display: block; font-size: 11px; color: #999; margin-bottom: 2px; }
.stat-count { display: block; font-size: 22px; font-weight: 700; }
.red-stat .stat-count { color: #c0392b; }
.green-stat .stat-count { color: #1e8449; }
.dark-stat .stat-count { color: #5D4037; }
.stat-label { display: block; font-size: 10px; color: #bbb; }

/* ---- 阵亡情况面板 ---- */
.casualty-timeline {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.casualty-token {
  display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
  position: relative;
}
.casualty-piece {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 12px; font-weight: 700; font-family: 'Ma Shan Zheng', serif;
  position: relative; transition: all 0.3s;
}
.casualty-piece.red { background: #fdecea; color: #c0392b; border: 1px solid #e74c3c; }
.casualty-piece.green { background: #eafaf1; color: #1e8449; border: 1px solid #27ae60; }
.casualty-piece::after {
  content: '✕'; position: absolute; right: -1px; top: -1px;
  font-size: 7px; color: rgba(0,0,0,0.3);
  line-height: 1; font-family: sans-serif; font-weight: 400;
}

.casualty-order {
  font-size: 9px; color: var(--ink-pale); font-family: 'Courier New', monospace;
  letter-spacing: 0.5px;
}

/* 木质墓碑 - 最新阵亡标识 (CSS绘制, 不依赖emoji) */
.casualty-tombstone {
  position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  font-size: 8px; line-height: 1;
  padding: 1px 4px;
  background: linear-gradient(180deg, #a07820, #6B4914);
  color: #fff;
  border-radius: 3px;
  font-family: 'Microsoft YaHei', sans-serif;
  font-weight: 700;
  pointer-events: none; z-index: 2;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  animation: tombstone-appear 0.5s ease-out;
}
@keyframes tombstone-appear {
  from { opacity: 0; transform: translateX(-50%) translateY(4px) scale(0.6); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* 移动端小墓碑 - 绝对定位角标，不影响棋子内部布局 */
.mg-tombstone-mini {
  position: absolute; top: -3px; right: -3px;
  font-size: 7px; line-height: 1;
  padding: 1px 2px;
  background: linear-gradient(180deg, #a07820, #6B4914);
  color: #fff;
  border-radius: 2px;
  font-family: 'Microsoft YaHei', sans-serif;
  font-weight: 700;
  pointer-events: none; z-index: 3;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  white-space: nowrap;
  animation: tombstone-appear 0.5s ease-out;
}

.casualty-none { font-size: 11px; color: #bbb; padding: 2px 0; }

/* 技能说明 */
.skill-desc {
  background: #fef9f0; border: 1px solid #f0d89d;
  border-radius: 8px; padding: 8px 10px; margin-bottom: 6px;
}
.skill-desc .skill-name { font-size: 13px; font-weight: 600; color: #8B4513; margin-bottom: 3px; }
.skill-desc .skill-detail { font-size: 11px; color: #888; line-height: 1.5; }
.no-skill { font-size: 12px; color: #bbb; text-align: center; padding: 8px 0; }

/* 按钮组 */
.panel-actions { display: flex; gap: 8px; }
.panel-actions .btn { flex: 1; font-size: 13px; padding: 10px 16px; }

/* 静音按钮 */
.btn-icon {
  width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid #d4c4a8; background: #f0e6d3;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; transition: all 0.2s;
}
.btn-icon:hover { background: #e8d8b8; }
.btn-icon.muted { background: #ddd; border-color: #ccc; }

/* ---- 结算弹窗 ---- */
.result-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.65); z-index: 100;
  align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.result-overlay.show { display: flex; }

.result-card {
  position: relative;
  background: linear-gradient(160deg,
    rgba(255,250,240,0.98) 0%,
    rgba(248,240,220,0.98) 25%,
    rgba(245,235,215,0.98) 60%,
    rgba(240,228,200,0.98) 100%);
  border-radius: 20px;
  padding: 0;
  text-align: center;
  box-shadow:
    0 8px 40px rgba(0,0,0,0.25),
    0 0 0 1px rgba(139,90,43,0.15),
    inset 0 1px 0 rgba(255,255,255,0.6);
  border: 1.5px solid rgba(139,90,43,0.2);
  animation: result-pop 0.4s ease-out;
  max-width: 90vw;
  width: min(420px, 92vw);
  overflow: hidden;
}

/* 顶部渐变装饰带 */
.result-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg,
    var(--cinnabar) 0%,
    var(--gold) 50%,
    var(--jade-dark) 100%);
  opacity: 0.6;
  z-index: 2;
}

/* 角落水墨晕染 - 左上 */
.result-corner-tl {
  position: absolute;
  top: 8px; left: 8px;
  width: 70px; height: 70px;
  background: radial-gradient(ellipse at 30% 30%, var(--ink) 0%, transparent 70%);
  border-radius: 50%;
  opacity: 0.06; pointer-events: none; z-index: 1;
}
/* 角落水墨晕染 - 右下 */
.result-corner-br {
  position: absolute;
  bottom: 8px; right: 8px;
  width: 60px; height: 60px;
  background: radial-gradient(ellipse at 70% 70%, var(--cinnabar) 0%, transparent 70%);
  border-radius: 50%;
  opacity: 0.05; pointer-events: none; z-index: 1;
}

/* 印章装饰 */
.result-seal {
  position: absolute;
  top: 18px; right: 18px;
  width: 34px; height: 34px;
  border: 2px solid rgba(180,60,30,0.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transform: rotate(-12deg);
  font-family: 'Ma Shan Zheng', serif;
  font-size: 13px;
  color: rgba(180,60,30,0.22);
  letter-spacing: 1px;
  pointer-events: none; z-index: 3;
}

/* 卷轴背景图 + 叠写文字 */
.result-banner-bg {
  position: relative;
  width: 100%;
  height: 200px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.result-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(0,0,0,0.15) 0%,
    rgba(0,0,0,0.05) 40%,
    rgba(0,0,0,0.35) 100%);
  pointer-events: none;
}
.result-title {
  position: relative;
  z-index: 2;
  font-family: 'Ma Shan Zheng', serif;
  font-size: 36px;
  letter-spacing: 8px;
  color: #fff;
  text-shadow:
    0 2px 8px rgba(0,0,0,0.5),
    0 0 20px rgba(0,0,0,0.3);
  animation: result-title-glow 0.6s ease-out 0.3s both;
}
@keyframes result-title-glow {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* 场景副标题 - 诗意描述 */
.result-scenario {
  font-family: 'Ma Shan Zheng', serif;
  font-size: 17px;
  color: var(--ink-light);
  letter-spacing: 5px;
  padding: 4px 24px 2px 24px;
  position: relative; z-index: 2;
}

/* 装饰分割线 */
.result-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 40px;
  margin: 6px 0;
  position: relative; z-index: 2;
}
.result-divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,90,43,0.2), transparent);
}
.result-divider-icon {
  font-size: 9px;
  color: var(--gold);
  opacity: 0.5;
}

/* 中间渐变区域 - 填充空白，国风暖色 */
.result-mid-band {
  padding: 10px 28px 12px 28px;
  background: linear-gradient(180deg,
    rgba(255,255,255,0) 0%,
    rgba(240,225,200,0.3) 30%,
    rgba(235,215,185,0.2) 70%,
    rgba(255,255,255,0) 100%);
  position: relative; z-index: 2;
}

.result-steps {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  color: var(--ink-pale);
  letter-spacing: 3px;
}

/* 底部按钮区 */
.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 12px 28px 24px 28px;
  position: relative; z-index: 2;
}

/* 结算按钮 - 国风样式 */
.result-actions .btn {
  font-family: 'Ma Shan Zheng', serif;
  font-size: 16px;
  letter-spacing: 3px;
  padding: 11px 0;
  flex: 1;
  border-radius: 10px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.result-actions .btn::after {
  content: '';
  position: absolute;
  top: 1px; left: 6px; right: 6px;
  height: 1px;
  background: rgba(255,255,255,0.15);
  border-radius: 1px;
}
.result-actions .btn-primary {
  background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-dark));
  color: #fff;
  border: 1px solid rgba(140,20,15,0.3);
  box-shadow: 0 3px 10px rgba(140,20,15,0.25), inset 0 1px 0 rgba(255,255,255,0.15);
}
.result-actions .btn-primary:hover {
  background: linear-gradient(180deg, #d44a3a, #9b2a2a);
  transform: translateY(-2px);
  box-shadow: 0 5px 16px rgba(140,20,15,0.3);
}
.result-actions .btn-primary:active {
  transform: translateY(0) scale(0.98);
}
.result-actions .btn-secondary {
  background: linear-gradient(180deg, #f5f0e0, #e8dcc0);
  color: var(--wood);
  border: 1.5px solid rgba(139,90,43,0.25);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.5);
}
.result-actions .btn-secondary:hover {
  background: linear-gradient(180deg, #faf5e8, #f0e8d0);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.result-actions .btn-secondary:active {
  transform: translateY(0) scale(0.98);
}

@keyframes result-pop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---- 设置弹窗 ---- */
.settings-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); z-index: 120;
  align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.settings-overlay.show { display: flex; }

.settings-card {
  background: linear-gradient(160deg,
    rgba(255,250,240,0.97) 0%,
    rgba(245,235,215,0.97) 100%);
  border-radius: 18px; padding: 0;
  width: min(340px, 90vw);
  box-shadow:
    0 12px 48px rgba(0,0,0,0.22),
    0 0 0 1px rgba(139,90,43,0.18),
    inset 0 1px 0 rgba(255,255,255,0.6);
  animation: settings-pop 0.3s ease-out;
  overflow: hidden;
}

@keyframes settings-pop {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* 头部 */
.settings-head {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 24px 16px 24px;
  border-bottom: 1px solid rgba(139,90,43,0.12);
  background: linear-gradient(180deg,
    rgba(196,163,90,0.08) 0%,
    transparent 100%);
}
.settings-head-icon {
  font-size: 20px; filter: grayscale(0.3);
}
.settings-head-title {
  font-family: 'Ma Shan Zheng', serif;
  font-size: 22px; color: var(--ink);
  letter-spacing: 3px; flex: 1;
}
.settings-close-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(139,90,43,0.2);
  background: rgba(255,255,255,0.6);
  color: var(--ink-pale); font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.settings-close-btn:hover {
  background: rgba(192,64,48,0.1); color: var(--cinnabar);
  border-color: rgba(192,64,48,0.3);
}

/* 主体 */
.settings-body {
  padding: 20px 24px 24px 24px;
}

/* 设置项 */
.settings-item {
  display: flex; flex-direction: column; gap: 12px;
}
.settings-item-head {
  display: flex; align-items: center; justify-content: space-between;
}
.settings-item-label {
  font-size: 15px; font-weight: 600; color: var(--ink);
  letter-spacing: 1px;
}
.settings-item-value {
  font-family: 'Courier New', monospace;
  font-size: 14px; font-weight: 700; color: var(--gold-dark);
  background: rgba(196,163,90,0.1);
  padding: 2px 10px; border-radius: 10px;
  min-width: 48px; text-align: center;
  transition: all 0.2s;
}
.settings-item-value.muted { color: #bbb; background: rgba(0,0,0,0.04); }

/* 滑块行 */
.settings-slider-row {
  display: flex; align-items: center; gap: 12px;
}
.settings-vol-icon {
  font-size: 22px; flex-shrink: 0;
  transition: transform 0.2s;
}

/* 音量滑块 - 自定义样式 */
.volume-slider {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg,
    var(--gold-light) 0%,
    var(--gold) 50%,
    rgba(139,90,43,0.3) 100%);
  outline: none; cursor: pointer;
  transition: background 0.1s;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, #f5edd8, #e8d5a0);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 2px 6px rgba(58,34,16,0.18);
  cursor: pointer; transition: all 0.15s;
}
.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 3px 10px rgba(58,34,16,0.25);
}
.volume-slider::-webkit-slider-thumb:active {
  transform: scale(1.05);
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
}
.volume-slider::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, #f5edd8, #e8d5a0);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 2px 6px rgba(58,34,16,0.18);
  cursor: pointer;
}

/* 滑块底部文字 */
.settings-slider-labels {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--ink-pale); letter-spacing: 1px;
  padding: 0 2px; margin-top: -4px;
}

/* ---- 移动端设置按钮 (齿轮 FAB) ---- */
.mg-settings-fab {
  display: flex; position: absolute; top: 6px; right: 8px;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(58,34,16,0.7); color: #e8d5a0;
  align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; z-index: 50;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  transition: transform 0.2s;
}
.mg-settings-fab:active { transform: scale(0.9); }

/* ---- 撒花Canvas ---- */
#confetti-canvas {
  position: fixed; inset: 0; z-index: 150;
  pointer-events: none; display: none;
}
#confetti-canvas.active { display: block; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 40px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #333; color: #fff; padding: 10px 24px;
  border-radius: 20px; font-size: 14px;
  opacity: 0; transition: all 0.3s; z-index: 200; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- 移动端游戏页布局 (桌面端隐藏) ---- */
.mg-top-bar, .mg-bottom-bar, .mg-back-fab, .mg-logo-bar, .mg-room-bar { display: none; }
.game-deco { display: none; }
/* PC侧边栏移动端隐藏 */
.pc-sidebar { display: flex; }
/* ---- 玩家卡片 (右对齐头像) ---- */
.mg-player-card {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: linear-gradient(145deg,
    rgba(255,255,255,0.75) 0%,
    rgba(240,225,200,0.6) 60%,
    rgba(220,205,180,0.5) 100%);
  border: 1px solid rgba(139,90,43,0.2);
  box-shadow: 0 2px 8px rgba(58,34,16,0.08), inset 0 1px 0 rgba(255,255,255,0.5);
  min-width: 0; overflow: visible;
}
.mg-player-card.opponent {
  border-top-color: rgba(30,100,50,0.35);
  box-shadow: 0 2px 8px rgba(30,100,50,0.08), inset 0 1px 0 rgba(255,255,255,0.5), inset 0 -2px 0 rgba(30,100,50,0.06);
}
.mg-player-card.self {
  border-right-color: rgba(192,64,48,0.3);
  box-shadow: 0 2px 8px rgba(192,64,48,0.08), inset 0 1px 0 rgba(255,255,255,0.5), inset 0 -2px 0 rgba(192,64,48,0.05);
}

/* 装饰底纹 */
.mg-pcard-deco {
  position: absolute; top: -2px; bottom: -2px; left: -2px; right: -2px;
  border-radius: 12px; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at 85% 20%, rgba(196,163,90,0.12) 0%, transparent 60%);
  border: 1px solid transparent;
}
.mg-pcard-deco.opp { background: radial-gradient(ellipse at 85% 20%, rgba(30,130,60,0.1) 0%, transparent 60%); }
.mg-pcard-deco.self { background: radial-gradient(ellipse at 85% 20%, rgba(192,64,48,0.1) 0%, transparent 60%); }

/* 头像 - 右侧 */
.mg-pcard-avatar {
  width: 40px; height: 40px; border-radius: 10px;
  object-fit: cover; flex-shrink: 0;
  border: 2px solid rgba(139,90,43,0.35);
  background: linear-gradient(135deg, #e8dcc0, #f5edd8);
  box-shadow: 0 2px 6px rgba(58,34,16,0.15);
}
.mg-pcard-avatar.opp {
  border-color: rgba(30,130,60,0.35);
  background: linear-gradient(135deg, #d4e8d6, #eafaf1);
}
.mg-pcard-avatar.self {
  border-color: rgba(192,64,48,0.4);
  background: linear-gradient(135deg, #f5c6c2, #fdecea);
  box-shadow: 0 2px 6px rgba(192,64,48,0.15);
}

/* 信息主体 */
.mg-pcard-body {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 2px;
  flex: 1; min-width: 0;
}
/* 名称 + 积分 同行 */
.mg-pcard-name-row {
  display: flex; align-items: center; gap: 8px;
}
.mg-pcard-name {
  font-family: 'Ma Shan Zheng', serif;
  font-size: 15px; color: var(--ink); line-height: 1.2;
  white-space: nowrap; letter-spacing: 1px;
}
.mg-pcard-title { font-size: 10px; color: var(--ink-pale); letter-spacing: 2px; }

/* 积分徽章 - 名称右侧 */
.mg-pcard-seal {
  display: inline-block; padding: 1px 7px;
  font-family: 'Courier New', monospace;
  font-size: 12px; font-weight: 700;
  border-radius: 4px; letter-spacing: 0.5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  line-height: 1.4;
}
.mg-pcard-seal.opp {
  background: linear-gradient(135deg, #1e6b34, #155724);
  color: #d4edda;
}
.mg-pcard-seal.self {
  background: linear-gradient(135deg, #c04030, #8b2020);
  color: #ffe8c0;
}

/* 计时器 */
.mg-pcard-timer {
  display: flex; align-items: center; gap: 3px;
  font-family: 'Courier New', monospace;
  font-size: 12px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
  background: rgba(58,34,16,0.07); color: var(--ink);
  width: fit-content;
}
.mg-pcard-timer.opp { color: var(--jade-dark); background: rgba(30,130,60,0.08); }
.mg-pcard-timer.self { color: var(--cinnabar); background: rgba(192,64,48,0.08); }
.mg-timer-icon { width: 12px; height: 12px; opacity: 0.6; flex-shrink: 0; }

/* ---- 阵亡棋子图标 (全局共享) ---- */
.mg-captured-area {
  display: flex; flex-wrap: wrap; gap: 2px;
  align-items: center; min-height: 18px;
}
.mg-captured-none { font-size: 10px; color: var(--ink-pale); letter-spacing: 1px; }
.mg-captured-piece {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  font-family: 'KaiTi', 'STKaiti', 'FangSong', serif;
  font-size: 11px; line-height: 1; font-weight: 700;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
  position: relative; flex-shrink: 0;
}
.mg-captured-piece.red { background: #fce4e4; color: var(--cinnabar); border: 1px solid rgba(192,64,48,0.35); }
.mg-captured-piece.green { background: #e4f0e6; color: var(--jade-dark); border: 1px solid rgba(58,106,74,0.35); }

/* ---- 响应式 ---- */
@media (max-width: 900px) {
  #game-page { flex-direction: column; align-items: stretch; padding: 8px; gap: 6px; padding-top: 6px; position: relative; }
  #game-page::before {
    content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
    background:
      radial-gradient(ellipse at 20% 10%, rgba(139,90,43,0.05) 0%, transparent 45%),
      radial-gradient(ellipse at 80% 90%, rgba(139,90,43,0.04) 0%, transparent 45%),
      radial-gradient(ellipse at 95% 15%, rgba(200,180,140,0.06) 0%, transparent 40%);
  }

  /* ---- 背景装饰墨点 ---- */
  .game-deco { display: block; position: fixed; pointer-events: none; z-index: 0; }
  .game-deco-tr { top: 0; right: 0; width: clamp(80px, 20vw, 160px); height: auto; opacity: 0.6; }
  .game-deco-bl { bottom: 0; left: 0; width: clamp(80px, 22vw, 170px); height: auto; opacity: 0.55; }

  /* ---- 翻老爷 LOGO横幅 (裁切版) ---- */
  .mg-logo-bar {
    display: flex; align-items: center; justify-content: center;
    position: relative; z-index: 1; margin-bottom: 0;
    padding: 4px 0 0 0;
  }
  .mg-logo-img {
    height: 36px; width: auto;
    filter: drop-shadow(0 1px 2px rgba(58,34,16,0.2));
  }

  /* ---- 房间标签 + 步数条 ---- */
  .mg-room-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 2px 6px 3px 6px; position: relative; z-index: 1;
  }
  .mg-room-tag {
    display: inline-flex; align-items: center;
    font-size: 11px; color: var(--ink-pale); letter-spacing: 1px;
  }
  .mg-step-badge {
    font-family: 'Courier New', monospace;
    font-size: 11px; color: var(--ink-pale);
    padding: 1px 8px; border-radius: 10px;
    background: rgba(196,163,90,0.12);
    letter-spacing: 0.5px;
  }
  .mg-step-badge strong { color: var(--ink-light); font-size: 13px; }

  /* ---- 移动端回合指示 ---- */
  .mg-turn-badge {
    padding: 2px 8px; border-radius: 10px;
    font-weight: 700; font-size: 11px; white-space: nowrap;
    letter-spacing: 1px;
  }
  .mg-turn-badge.red { background: rgba(192,64,48,0.12); color: var(--cinnabar); }
  .mg-turn-badge.green { background: rgba(30,130,60,0.12); color: var(--jade-dark); }

  /* ---- 移动端统计卡片 ---- */
  .mg-stats-card {
    flex: 1; display: flex; flex-direction: column; gap: 4px;
    padding: 5px 8px; border-radius: 8px;
    background: linear-gradient(135deg, rgba(255,255,255,0.55), rgba(240,225,200,0.5));
    border: 1px solid rgba(139,90,43,0.12); min-width: 0;
  }
  .mg-stats-row {
    display: flex; align-items: center; gap: 4px;
  }
  .mg-sdot {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  }
  .mg-sdot.red { background: var(--cinnabar); }
  .mg-sdot.green { background: var(--jade-dark); }
  .mg-sdot.dark { background: var(--ink-pale); border: 1px solid rgba(0,0,0,0.2); }
  .mg-sval {
    font-family: 'Courier New', monospace;
    font-size: 13px; font-weight: 700; color: var(--ink-light);
    margin-right: 8px; min-width: 16px;
  }

  /* ---- 移动端显示顶部/底部信息栏 ---- */
  .mg-top-bar { display: flex; gap: 6px; align-items: stretch; position: relative; z-index: 1; }
  .mg-bottom-bar { display: flex; gap: 6px; align-items: stretch; position: relative; z-index: 1; }
  .mg-top-bar .mg-player-card, .mg-bottom-bar .mg-player-card { flex: 0 0 auto; }
  .pc-sidebar { display: none; }
  .board-header { display: none; }

  /* ---- 浮动返回按钮 ---- */
  .mg-back-fab {
    display: flex; position: absolute; top: 6px; left: 8px;
    width: 26px; height: 26px; border-radius: 50%;
    background: rgba(58,34,16,0.7); color: #e8d5a0;
    align-items: center; justify-content: center;
    font-size: 18px; cursor: pointer; z-index: 50;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  }

  /* ---- 技能区域 ---- */
  .mg-skill-area {
    flex: 1; display: flex; flex-direction: column; gap: 4px;
    padding: 5px 8px; border-radius: 8px;
    background: linear-gradient(135deg, rgba(255,255,255,0.6), rgba(240,225,200,0.55));
    border: 1px solid rgba(139,90,43,0.15);
  }
  .mg-skill-header { font-size: 10px; color: var(--ink-pale); text-transform: uppercase; letter-spacing: 2px; }
  .mg-skill-text { font-size: 12px; color: var(--ink-light); line-height: 1.3; min-height: 16px; }
  .mg-anim-frame {
    flex: 1; min-height: 48px;
    border: 2px dashed rgba(139,90,43,0.3);
    border-radius: 6px;
    background: rgba(58,34,16,0.06);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; color: var(--ink-pale);
    font-family: 'Courier New', monospace; letter-spacing: 1px;
  }

  /* ---- 棋盘尺寸 (46px格子, 适配窄屏) ---- */
  .board-container { padding: 6px; align-self: center; max-width: 100%; }
  .board-wrapper {
    grid-template-columns: 12px repeat(8, 46px) 12px;
    grid-template-rows: 12px repeat(9, 46px) 12px;
  }
  #board-grid {
    grid-template-columns: repeat(8, 46px);
    grid-template-rows: repeat(9, 46px);
  }
  .cell { width: 46px; height: 46px; }
  .piece { width: 38px; height: 38px; font-size: 16px; }

  .cell.move-target::after { width: 23px; height: 23px; }
  .cell.kill-target::after { width: 30px; height: 30px; }
  .cell.skill-target::after { width: 28px; height: 28px; }
  .cell.skill-linked::after { width: 34px; height: 34px; }
  .cell.teleport-target::before { width: 37px; height: 37px; }

  .col-coord { font-size: 10px; }
  .row-coord { font-size: 10px; }

  .skill-float-text {
    font-size: 14px; font-weight: 700;
    padding: 2px 8px; border-radius: 6px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.06);
  }
}
