/* 欢乐跳棋 —— 网页版样式
 * 设计语言：精品休闲桌游（Premium Casual Board Game）
 *  - 明亮青绿游戏桌面 + 暖金实体棋盘 + 柔和彩色营地 + 低存在感棋孔
 *  - 首页/大厅：暖米白；对局页：明亮青绿（两者共享圆角/阴影/字体 token）
 */
:root {
  /* —— 全局浅色（首页/大厅）—— */
  --bg1: #f5f0e4;
  --bg2: #eae1cc;
  --bg3: #d9cdb2;
  --panel: #fdfcf8;
  --ink: #284047;
  --muted: #7d898a;
  --accent: #f07b5f;
  --accent-dark: #d95f43;
  --danger: #e5544a;
  --line: #e4ddca;
  --ready: #4e9b6f;

  /* —— 对局桌面（明亮青绿）—— */
  --table-1: #39adb5;
  --table-2: #2498a5;
  --table-deep: #1f8592;
  --surface: rgba(255, 255, 255, 0.3);          /* 浅色半透明面板（游戏 HUD） */
  --surface-strong: rgba(255, 255, 255, 0.92);  /* 近白实心表面（toolbar/胶囊） */
  --on-table: #ffffff;                          /* 青绿底上的文字 */
  --on-table-soft: rgba(255, 255, 255, 0.88);
  --table-line: rgba(255, 255, 255, 0.4);
  --table-line-strong: rgba(255, 255, 255, 0.65);
  --gold: #f2b544;                              /* 回合/行动高亮 */
  --coral: #f07b5f;                             /* 游戏状态 tag / 警告 */
  --ink-deep: #284047;                          /* 浅表面上的主文字 */
  --ink-soft: #647b80;                          /* 浅表面上的次文字 */

  /* —— 设计 token —— */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;
  --shadow-sm: 0 2px 8px rgba(23, 60, 70, 0.18);
  --shadow-md: 0 10px 26px rgba(23, 60, 70, 0.22);
  --shadow-lg: 0 18px 46px rgba(23, 60, 70, 0.3);
  --font-stack: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body.in-game, html.in-game { overflow: hidden; }
body {
  font-family: var(--font-stack);
  background:
    radial-gradient(rgba(120,100,70,0.035) 1.5px, transparent 2px) 0 0 / 26px 26px,
    linear-gradient(160deg, var(--bg1), var(--bg2) 60%, var(--bg3));
  color: var(--ink);
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
  font-size: 14px;
  line-height: 1.45;
}

#app { min-height: 100vh; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

.hidden { display: none !important; }

/* ---------- 首页 ---------- */
.home-wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 6vh 16px 40px;
  text-align: center;
}
.logo {
  color: #4a4233;
  font-size: 44px;
  letter-spacing: 6px;
  margin-bottom: 14px;
  font-weight: 800;
}
.logo-marbles {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 8px;
}
.marble {
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-block;
  box-shadow: inset -6px -6px 9px rgba(0,0,0,0.22), 0 3px 6px rgba(60,45,20,0.18);
  animation: float 2.6s ease-in-out infinite;
}
.marble:nth-child(2) { animation-delay: 0.15s; }
.marble:nth-child(3) { animation-delay: 0.3s; }
.marble:nth-child(4) { animation-delay: 0.45s; }
.marble:nth-child(5) { animation-delay: 0.6s; }
.marble:nth-child(6) { animation-delay: 0.75s; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
.marble.m1 { background: radial-gradient(circle at 32% 30%, #f2b39e, #d97757 60%, #a8552f); }
.marble.m2 { background: radial-gradient(circle at 32% 30%, #f4dfa4, #d9a62e 60%, #a87c14); }
.marble.m3 { background: radial-gradient(circle at 32% 30%, #b9d3bb, #5e8c61 60%, #3d5f40); }
.marble.m4 { background: radial-gradient(circle at 32% 30%, #aac5e7, #4a72a8 60%, #2f4d78); }
.marble.m5 { background: radial-gradient(circle at 32% 30%, #cfb9e6, #8a5fa8 60%, #5f3f7d); }
.marble.m6 { background: radial-gradient(circle at 32% 30%, #b3aaf0, #534AD8 60%, #37309b); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 18px;
  box-shadow: 0 8px 28px rgba(90,70,40,0.12);
  text-align: left;
}
.field { margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; }
input[type="text"], input:not([type]) {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
  background: #faf7ef;
}
input:focus { border-color: var(--accent); background: #fff; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1;
  min-width: 52px;
  min-height: 44px;   /* 手机触控友好：足够大的点按区域 */
  border: 1.5px solid var(--line);
  background: #faf7ef;
  border-radius: 10px;
  padding: 10px 4px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}
.seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 15px;
  cursor: pointer;
  background: #ede9dc;
  color: var(--ink);
  transition: transform .06s ease, filter .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(135deg, #f48a6e, var(--accent-dark)); color: #fff; font-weight: 700; }
.btn.big { width: 100%; padding: 14px; font-size: 16px; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.ghost { background: transparent; border: 1.5px solid rgba(59,55,43,0.28); }
.btn.ghost.on { background: #f7ece3; border-color: var(--accent); color: var(--accent-dark); font-weight: 700; }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 12px; margin: 18px 0 14px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; text-align: center; }

/* ---------- 大厅 ---------- */
/* 布局：顶部房间码+信息+复制分享 → 中间座位面板（可滚动）→ 底部开始/离开 → 聊天 */
.lobby-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(12px + env(safe-area-inset-bottom, 0px));
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
/* 房间信息与邀请合并卡：唯一暖白外框（背景/边框/圆角/阴影沿用原大厅头部） */
.lobby-room-card {
  background: #FDFCF8;
  border: 1px solid #E4DDCA;
  border-radius: 18px;
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 6px 18px rgba(90,70,40,0.1);
  flex-shrink: 0;
}
/* 上半部：左房间码、右对局信息胶囊，同一水平栏（右组整体与左组垂直居中） */
.lobby-room-summary {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}
.lobby-code-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}
/* 标签与号码完全同字号同字重、同基线、不换行；号码仅多 2px 字间距 */
.room-code-label,
.room-code {
  font-size: clamp(18px, 5vw, 20px);
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
}
.room-code-label { color: var(--muted); }
.room-code { color: var(--accent-dark); letter-spacing: 2px; }
/* 右侧权威对局信息：三个同高 20px 暖灰小胶囊，宽屏一行、窄屏最多两行且右对齐 */
.lobby-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-content: center;
  gap: 4px;
  min-width: 0;
}
.lobby-chip {
  height: 20px;
  line-height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  background: #F2EEE3;
  color: #57503D;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex: 0 0 auto;
}
/* 上下区域之间的淡分隔线（左右随卡片内边距留 16px） */
.lobby-room-divider {
  height: 1px;
  background: #EEE7D8;
  margin: 0;
  flex-shrink: 0;
}
/* 下半部：主邀请按钮（柔和绿，同 --ready 色）+ 两个同排弱按钮 */
.lobby-invite-actions { display: flex; flex-direction: column; gap: 8px; }
.btn.lobby-invite-primary {
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 12px;
  background: var(--ready);   /* #4E9B6F，柔和绿，不用高饱和微信绿 */
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}
.lobby-invite-secondary { display: flex; gap: 8px; }
.btn.lobby-invite-weak {
  flex: 1 1 0;
  min-width: 0;
  height: 44px;
  padding: 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: #4a4233;
  background: #f6f2e7;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  white-space: nowrap;
}
/* 窄屏（320px 级）：同时缩小左右间距，左右两组仍保持同一水平栏 */
@media (max-width: 359px) {
  .lobby-room-card { padding: 12px 12px 14px; }
  .lobby-room-summary { gap: 8px; }
  .lobby-code-line { gap: 4px; }
  .room-code { letter-spacing: 1px; }
}

/* 中间：状态提示 + 座位面板（谁加入了、是否准备），可滚动 */
.lobby-mid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px;
}
.lobby-status {
  font-size: 13.5px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
  flex-shrink: 0;
}
.lobby-status b { color: var(--accent-dark); }

/* 底部：开始游戏（准备）/ +机器人 / 离开 / 通话 / 消息 —— 两列 CSS Grid（短屏纵向布局改造） */
.lobby-bottom { flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; }
.lobby-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
/* 主操作始终独占整行；通话始终在消息正上方（各占整行） */
#btn-start, #btn-ready, #btn-lobby-voice, #lobby-chat-btn { grid-column: 1 / -1; }
/* 房主 + 等待 + 有空位：#btn-addbot 与 #btn-leave-room 各占半行（has-addbot 由 renderLobby 与隐藏条件同源联动）；
   其余情况离开按钮占满整行，不留空白列 */
#btn-addbot { grid-column: auto; }
#btn-leave-room { grid-column: 1 / -1; }
.lobby-actions.has-addbot #btn-leave-room { grid-column: auto; }
.lobby-act {
  width: 100%;
  min-width: 0;
  padding: 16px 8px;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  border: 1.5px solid var(--line);
  background: #f6f2e7;
  position: relative;
  border-radius: 12px;
}
.lobby-act.primary { border: none; }
.lobby-act.ghost { background: transparent; border: 1.5px solid rgba(59,55,43,0.28); }
.lobby-act:disabled { opacity: 0.5; cursor: not-allowed; }
.lobby-act .msg-dot { top: 8px; right: 10px; width: 11px; height: 11px; }

/* 短屏（max-height:680px）：压缩按钮与间距；触控区域 ≥44px，开始/准备保持 50px 高 */
@media (max-height: 680px) {
  .lobby-wrap { gap: 6px; }
  .lobby-room-card { padding: 10px 16px 12px; gap: 8px; }
  .lobby-mid { gap: 6px; }
  .lobby-actions { gap: 6px; }
  .lobby-act {
    height: 44px;
    line-height: 44px;
    padding: 0 8px;
  }
  #btn-start, #btn-ready { height: 50px; line-height: 50px; }
}

/* 聊天大按钮（准备界面底部 / 对局界面底部整行，双端统一） */
.chat-row { flex-shrink: 0; }
.btn.chat-big {
  position: relative;
  display: block;
  width: 100%;
  padding: 13px;
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, #fdfcf8, #f2edde);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(90,70,40,0.1);
}
.btn.chat-big:active { transform: scale(0.985); }
.btn.chat-big .msg-dot {
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
}

.seats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 640px) { .seats { grid-template-columns: repeat(3, 1fr); } }
.seat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: 0 4px 12px rgba(90,70,40,0.08);
  position: relative;
  min-height: 56px;
  transition: transform .12s ease, box-shadow .12s ease;
}
@media (hover: hover) {
  .seat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(90,70,40,0.14); }
}
.seat-card.empty { opacity: 0.55; }
/* 空位头像：圆框完全留空（不渲染图片/emoji/剪影/加号），虚线空框 */
.seat-card.empty .seat-avatar {
  background: #F0ECE2;
  border: 1.5px dashed #D4CCB8;
  box-shadow: none;
}
/* 预设头像：座位色圆底 + 动物头像（干净圆形，图片不被遮挡） */
.seat-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  box-shadow: 0 2px 5px rgba(60,45,20,0.15);
  border: 2px solid rgba(255,255,255,0.85);
  overflow: hidden;
}
.seat-info { flex: 1; min-width: 0; }
.seat-name { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-sub { font-size: 11.5px; color: var(--muted); }
.seat-sub .ready-yes { color: var(--ready); font-weight: 700; }
.badges { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
}
.badge.host { background: var(--accent); }
.badge.bot { background: #8a5fa8; }
.badge.off { background: var(--muted); }
.seat-card .seat-ops { margin-left: 4px; }

/* 仅房主可见的轻提示：紧跟整个座位网格之后（2/4/6 人房在对应座位卡下面），无背景/边框/图标/动画 */
.lobby-host-invite-hint {
  margin: 2px 4px 0;
  color: #8A9290;
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
}

/* ---------- 聊天（弹出面板，大厅与对局共用） ---------- */
.chat-msgs { overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; }
.chat-msg { font-size: 13px; line-height: 1.5; word-break: break-all; background: #f4f1e7; border-radius: 10px; padding: 6px 10px; align-self: flex-start; max-width: 92%; display: flex; align-items: flex-start; gap: 6px; }
.chat-msg > span { min-width: 0; word-break: break-all; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-msg .who { font-weight: 700; white-space: nowrap; }
.chat-msg .who-avatar { font-size: 14px; line-height: 1; }
.chat-msg.sys { color: var(--muted); font-size: 12px; text-align: center; background: transparent; align-self: center; }
.chat-input-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px; border-top: 1px solid var(--line); flex-shrink: 0; background: var(--panel); margin-top: auto; height: 54px; box-sizing: border-box; }
.chat-input-row input { border: 1px solid var(--line); border-radius: 14px; background: #f4f1e7; flex: 1; min-width: 0; padding: 9px 12px; font-size: 14px; outline: none; }
.chat-input-row input:focus { border-color: var(--coral); }
#chat-send { border-radius: 14px; padding: 9px 16px; background: var(--coral); color: #fff; border: none; font-weight: 700; }
#chat-send:active { filter: brightness(0.94); }
/* ---------- 对局（明亮青绿桌面 + 暖金实体棋盘） ---------- */
#screen-game {
  background:
    repeating-linear-gradient(90deg,
      rgba(255, 255, 255, 0.05) 0, rgba(255, 255, 255, 0.05) 44px,
      rgba(20, 70, 80, 0.05) 44px, rgba(20, 70, 80, 0.05) 88px),
    linear-gradient(180deg, var(--table-1) 0%, var(--table-2) 100%);
  color: var(--on-table);
  overflow-x: clip;   /* 棋盘放大后左右对称超出视口的部分在此裁掉，不产生横向滚动 */
}
/* 背景皮肤（只作用于 #screen-game 的背景层；canvas/棋盘尺寸/孔位/棋子/大厅背景不受影响）：
   - 碧海竖纹（默认星海鎏金）：青绿竖向 repeating-linear-gradient（上方定义）
   - 米杏浅纹（暖木瓷韵）：Beta 0.1 暖米杏渐变 + 间距约 26px 的极淡圆点纹 */
#screen-game.skin-bg-ivory {
  background:
    radial-gradient(rgba(120, 100, 70, 0.035) 1.5px, transparent 2px) 0 0 / 26px 26px,
    linear-gradient(160deg, #f0eadc, #e6ddc8 60%, #d9cdb2);
}

.game-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
  max-width: 430px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  position: relative;
}
.game-main { flex: 0 1 auto; display: flex; flex-direction: column; min-height: 0; }

/* 顶部状态胶囊：跳法（珊瑚 tag）· 回合（白色胶囊）· 规则（右） */
.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  min-height: 30px;
}
.gt-meta { display: flex; align-items: center; gap: 7px; min-width: 0; }
.gt-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.gt-chip b {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 14px;
  text-align: center;
}
/* 跳法：明亮珊瑚 tag */
#gi-mode {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 2px 6px rgba(217, 95, 67, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
/* 回合：白色胶囊 */
.gt-round {
  background: var(--surface-strong);
  color: var(--ink-deep);
  box-shadow: var(--shadow-sm);
}
.gt-round.mine {
  box-shadow: 0 0 0 2px var(--gold), var(--shadow-sm);
}
.gt-round.mine b { color: #b5760c; }
/* 规则：白色半透明小胶囊 + 官方信息图标（18-22px） */
.gt-rule {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 10px 0 7px;
  background: var(--surface);
  border: 1px solid var(--table-line);
  border-radius: var(--radius-pill);
  color: var(--on-table);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.gt-rule-icon { width: 20px; height: 20px; object-fit: contain; flex-shrink: 0; pointer-events: none; }
.gt-rule:active { background: rgba(255, 255, 255, 0.45); }

/* 玩家对战 HUD：一体化浅色半透明面板（两名玩家同一视觉整体） */
.seats-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 3px 6px;
  background: rgba(255, 249, 235, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 15px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(23, 60, 70, 0.1);
}
.seats-2 .seat-slot { max-width: 168px; }
.seat-slot {
  flex: 1 1 0;
  min-width: 0;
  max-width: 96px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 1px 4px;
  padding: 3px 2px 2px;
  border-radius: 12px;
  transition: background 0.18s ease;
}
.seat-slot.empty { opacity: 0.55; }
.seat-slot.on { background: rgba(255, 255, 255, 0.34); }
.seats-vs {
  width: 36px;
  height: 36px;
  align-self: center;
  flex-shrink: 0;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(23, 60, 70, 0.3));
}
.slot-avatar-box {
  position: relative;
  flex-shrink: 0;
  flex-basis: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 6px rgba(23, 60, 70, 0.25);
  overflow: hidden;
}
.seats-2 .slot-avatar { width: 48px; height: 48px; font-size: 25px; }
.slot-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-deep);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}
.slot-sub {
  font-size: 10.5px;
  color: var(--ink-soft);
  font-weight: 600;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slot-sub.warn { color: #d95f43; }
.slot-sub.dim { opacity: 0.6; }
/* 倒计时胶囊：官方计时器图标 + 动态秒数；≤10 秒转珊瑚红 */
.slot-count {
  position: absolute;
  top: -6px;
  right: -12px;
  display: none;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 7px 0 5px;
  border-radius: var(--radius-pill);
  background: rgba(255, 249, 232, 0.96);
  border: 1px solid rgba(120, 90, 40, 0.18);
  color: var(--ink-deep);
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(23, 60, 70, 0.25);
}
.slot-count.show { display: inline-flex; }
.slot-count-icon { width: 12px; height: 15px; object-fit: contain; pointer-events: none; }
.slot-count.urgent {
  background: var(--coral);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
  animation: count-alert 1s ease-in-out infinite;
}
@keyframes count-alert {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.62; }
}

/* 棋盘容器：跟随棋盘实际尺寸（棋盘可横向超出列宽、左右对称溢出视口被裁切），
 * 顶部留 20px 间隙（8px 列间隙 + 12px 上边距）贴近玩家信息卡；
 * 柔和悬浮阴影由 CSS drop-shadow 提供（贴合星形轮廓，无黑色晕边）。 */
.board-box {
  position: relative;
  flex: 0 0 auto;
  min-height: 0;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
.board-inner { position: relative; }
/* 棋盘加载遮罩：QIPAN 七张素材全部加载并解码前覆盖棋盘区；就绪后由 JS 关闭 */
.board-loading {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(23, 60, 70, 0.32);
  border-radius: 14px;
}
.board-loading.hidden { display: none; }
.board-loading-text {
  background: rgba(255, 253, 246, 0.95);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  animation: loadPulse 1.2s ease-in-out infinite;
}
@keyframes loadPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.62; }
}
#board-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  filter:
    drop-shadow(0 10px 14px rgba(20, 60, 70, 0.2))
    drop-shadow(0 3px 4px rgba(20, 40, 50, 0.14));
}

/* 底部游戏工具栏：奶油白半透明 dock + 官方 PNG 图标 + HTML 标签；
 * margin-top:auto 把工具栏钉在屏幕底部，多余垂直空间留在棋盘与工具栏之间 */
.func-row {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  margin: auto 4px 0;
  background: rgba(255, 250, 238, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 17px;
  padding: 5px 6px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.func-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 52px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  color: #5a4635;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.06s ease;
  -webkit-tap-highlight-color: transparent;
}
.func-btn .fc-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  pointer-events: none;
}
.func-btn:active,
.func-btn.on {
  transform: scale(0.96);
  background: rgba(240, 123, 95, 0.14);
  color: #8a4a2f;
}
@media (hover: hover) {
  .func-btn:hover { background: rgba(240, 123, 95, 0.1); color: #8a4a2f; }
}
#msg-btn { position: relative; }
#msg-btn .msg-dot {
  top: 5px;
  right: calc(50% - 20px);
  width: 10px;
  height: 10px;
}

/* ---------- 对局面板（#panel-options）：左列对局动态（可滚动）+ 右列对局操作 ----------
 * 面板顶部没有单独的「对局」标题行：两列标题即面板首行（水平对齐），
 * 关闭按钮绝对定位在右上角、不占一行；顶部内边距压到最小让内容明显上提。
 * 本段所有规则一律以 #panel-options 作用域限定（含 opt-close/opt-cols/opt-col/
 * dyn-col-title/opt-items/opt-item 与 dyn-msgs/dyn-msg 家族），绝不外泄到其他容器；
 * 设置面板等其他 sheet-panel 的 .sheet-head 标题布局与配色完全不受影响。 */
#panel-options {
  /* 不要在此覆盖 position：.sheet-panel 的 position: fixed 已为绝对定位的关闭按钮建立包含块 */
  width: min(560px, calc(100vw - 24px));
  padding-top: 8px;
  gap: 0;
}
/* 关闭按钮：绝对定位在面板右上角（不参与列布局、不单独占一行）。
 * ID 作用域天然压过 .btn.small 的内边距，使按钮完整落在标题行高度内。 */
#panel-options .opt-close {
  position: absolute;
  top: 5px;
  right: 8px;
  z-index: 2;
  width: 28px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  border-radius: 8px;
}
#panel-options .opt-cols {
  display: flex;
  gap: 12px;
  min-height: 0;
}
#panel-options .opt-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
#panel-options .opt-col .dyn-msgs {
  flex: 1;
  min-height: 96px;
  max-height: min(300px, 42vh);
}
#panel-options .opt-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* 两列标题：13px / 700 深棕，标题下浅色分隔线 + 8px 间距；两列标题顶端水平对齐 */
#panel-options .dyn-col-title {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  color: #4a3423;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(122, 96, 66, 0.18);
  margin-bottom: 8px;
}
/* 右列标题为关闭按钮预留空间（禁止与 ✕ 重叠），高度与左列标题保持一致 */
#panel-options .dyn-col-title-actions {
  padding-right: 34px;
}
#panel-options .dyn-msgs {
  flex: 1;
  min-height: 0;
  display: block;              /* 普通块级滚动容器：手机上下滑动最稳（避开 flex 滚动怪癖） */
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain; /* 左列独立纵向滚动：滚到头不带动面板/页面 */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
#panel-options .dyn-msg {
  font-size: 11.5px;
  line-height: 1.55;
  font-weight: 400;
  color: #6b5c49;
  white-space: normal;         /* 长消息完整换行显示，不截断 */
  overflow-wrap: anywhere;
  word-break: break-all;
  display: flex;
  align-items: flex-start;
  gap: 3px;
  margin-bottom: 3px;
}
/* 非最新消息保持原色不弄淡；仅用加粗区分最新一条 */
#panel-options .dyn-msg.old { opacity: 1; }
#panel-options .dyn-msg > span { min-width: 0; }
#panel-options .dyn-name { flex-shrink: 0; }
#panel-options .dyn-sticker {
  width: 26px;
  height: 26px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(45, 38, 25, 0.2));
}
#panel-options .dyn-msg.new {
  animation: dynIn 0.35s ease;
}
@keyframes dynIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
/* 对局操作按钮：四个按钮尺寸/间距/圆角完全统一（间距见 .opt-items 的 gap: 8px） */
#panel-options .opt-item {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  text-align: center;
  padding: 11px 10px;
  font-size: 14.5px;
  line-height: 1.2;
  font-weight: 700;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: #f8f4e9;
}
#panel-options .opt-item:disabled { opacity: 0.45; }

/* 窄屏（320-359px）：进一步压缩玩家条与边距，保证 6 人局放得下 */
@media (max-width: 359px) {
  .game-wrap { padding-left: 4px; padding-right: 4px; gap: 6px; }
  .seats-row { gap: 4px; padding-left: 0; padding-right: 0; }
  .slot-avatar { width: 38px; height: 38px; font-size: 19px; }
  .seats-2 .slot-avatar { width: 44px; height: 44px; font-size: 23px; }
  .slot-name { font-size: 10.5px; }
  .gt-chip { padding: 0 10px; }
}
@media (min-width: 390px) {
  .seats-2 .slot-avatar { width: 50px; height: 50px; font-size: 26px; }
}

/* ---------- 设置面板 / 选项菜单（底部弹出小面板） ---------- */
.sheet-panel {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 24px));
  z-index: 46;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(23, 60, 70, 0.28);
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: pop .2s ease;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0 8px;
}
.sheet-title { font-size: 15px; font-weight: 800; color: #4a4233; }
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 4px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
/* 键盘操作可见焦点：Space/Enter 切换开关时滑块显示焦点环 */
.switch-row input:focus-visible + .sw {
  outline: 2px solid #2ca0ad;
  outline-offset: 2px;
}
.switch-row .sw {
  width: 44px; height: 24px;
  border-radius: 999px;
  background: #d8d2c0;
  position: relative;
  transition: background .15s ease;
  flex-shrink: 0;
}
.switch-row .sw::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: left .15s ease;
}
.switch-row input:checked + .sw { background: #2ca0ad; }
.switch-row input:checked + .sw::after { left: 22px; }
/* 设置项右侧：说明按钮 + 开关 */
.switch-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
/* “i”说明按钮：黑色细圆圈，圆圈里一个 i */
.info-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #000;
  background: transparent;
  color: #000;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.info-btn:active { background: rgba(0, 0, 0, 0.08); }
/* “i”说明弹窗：贴在按钮旁的小气泡（窄幅，居中放置，不遮左右内容） */
.info-popup {
  position: absolute;
  left: 50%;
  width: 180px;
  margin-left: -90px;
  z-index: 5;
  background: rgba(40, 64, 71, 0.95);
  color: #faf7ef;
  font-size: 11.5px;
  line-height: 1.5;
  padding: 7px 9px;
  border-radius: 9px;
  box-shadow: 0 8px 22px rgba(23, 60, 70, 0.3);
  animation: pop .18s ease;
}
body.in-game .info-btn { border-color: var(--ink); color: var(--ink); }
body.in-game .info-popup { background: rgba(40, 64, 71, 0.95); color: #faf7ef; }

/* ---------- 设置面板内的入口行（外观设置 / 声音设置） ---------- */
.sheet-entry {
  width: 100%;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  text-align: left;
  font-family: inherit;
}
.sheet-entry:active { background: rgba(0, 0, 0, 0.04); }
.entry-arrow {
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  font-weight: 400;
}

/* ---------- 外观设置面板（三组独立双选项） ---------- */
.skin-group {
  border-top: 1px solid var(--line);
  padding: 8px 2px 2px;
}
.skin-group-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: 0.3px;
}
.skin-options {
  display: flex;
  gap: 8px;
}
.skin-opt {
  flex: 1 1 0;
  min-width: 0;
  padding: 9px 6px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #faf7ef;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.skin-opt:active { background: #f2ecdd; }
.skin-opt.on {
  border-color: var(--accent);
  background: #fdf0e8;
  color: var(--accent-dark);
  font-weight: 800;
}
/* 目标素材未就绪：锁定对应选择（继续显示切换前的完整组合） */
.skin-group.locked .skin-options {
  position: relative;
}
.skin-group.locked .skin-opt {
  opacity: 0.55;
  cursor: default;
}
.skin-group.locked .skin-opt.on { opacity: 1; }
/* 对局页配色下的外观面板仍保持浅色纸面（与设置面板一致） */
body.in-game .sheet-entry { color: var(--ink); border-top-color: var(--line); }
body.in-game .skin-group { border-top-color: var(--line); }
/* 对局操作按钮的样式全部收在上方 #panel-options 段内（本段只放设置面板相关规则） */

/* ---------- 通用确认框 / 手动复制面板 ---------- */
.confirm-text {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 14px;
  text-align: left;
  word-break: break-all;
}
.copy-text {
  width: 100%;
  height: 92px;
  margin-bottom: 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #faf7ef;
  padding: 8px;
  font-size: 14px;
  color: var(--ink);
  resize: none;
}

/* ---------- 语音通话面板 ---------- */
.voice-panel {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(400px, calc(100vw - 24px));
  z-index: 46;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(23, 60, 70, 0.28);
  padding: 12px 14px;
  animation: pop .2s ease;
}
.voice-body { display: flex; flex-direction: column; gap: 8px; }
.voice-title { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 800; color: #4a4233; }
.voice-title-icon { width: 22px; height: 22px; aspect-ratio: 1 / 1; object-fit: contain; display: block; }
.voice-status { font-size: 12.5px; color: var(--muted); }
.voice-status.live { color: var(--ready); font-weight: 700; }
.voice-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.voice-btns .btn { flex: 1; min-width: 76px; padding: 9px 6px; font-size: 13.5px; font-weight: 700; }
.voice-hint {
  font-size: 11.5px;
  line-height: 1.55;
  color: #8a6d3b;
  background: #fbf3df;
  border: 1px solid #ecdcb8;
  border-radius: 8px;
  padding: 6px 9px;
}
.voice-diag {
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--muted);
  word-break: break-all;
}

/* ---------- 微信分享指引层（微信内点击邀请/分享链接时显示） ---------- */
#wechat-share-guide {
  position: fixed;
  inset: 0;
  z-index: 80;   /* 高于聊天/语音面板/弹窗/toast */
  background: rgba(17, 32, 36, 0.74);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: guide-fade-in 0.2s ease;
}
@keyframes guide-fade-in { from { opacity: 0; } to { opacity: 1; } }
/* 纯 CSS 箭头指向右上角微信 ··· 菜单 */
#wechat-share-guide .wsg-arrow {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: 26px;
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-bottom: 28px solid #ffffff;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
  animation: wsg-bob 1.5s ease-in-out infinite;
}
@keyframes wsg-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
#wechat-share-guide .wsg-card {
  width: min(312px, calc(100vw - 40px));
  margin-top: calc(74px + env(safe-area-inset-top, 0px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 20px 18px 18px;
  text-align: center;
}
#wechat-share-guide .wsg-title {
  font-size: 19px;
  font-weight: 800;
  color: #4a4233;
}
#wechat-share-guide .wsg-text {
  margin-top: 8px;
  font-size: 14.5px;
  color: var(--muted);
  line-height: 1.7;
}
#wechat-share-guide .wsg-ok { margin-top: 16px; width: 100%; }
/* 减弱动态：去掉箭头摆动，只保留 120ms 淡入 */
@media (prefers-reduced-motion: reduce) {
  #wechat-share-guide .wsg-arrow { animation: none; }
  #wechat-share-guide { animation: guide-fade-in 0.12s ease; }
}

.msg-dot {
  position: absolute;
  top: 3px; right: 5px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 2px var(--panel);
}

/* ---------- 弹幕（玩家消息飘屏，大厅与对局共用） ---------- */
.danmaku {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  overflow: hidden;
}
.danmaku-item {
  position: absolute;
  left: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 74vw;
  background: rgba(40, 64, 71, 0.9);
  color: #fdf8ea;
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;          /* 单行弹幕：20 字内一行显示，超长由 JS 截断 */
  box-shadow: 0 4px 14px rgba(23, 60, 70, 0.3);
  animation: dm-move var(--dm-dur, 9s) linear forwards;
  will-change: transform;
}
.danmaku-item .dm-name { font-weight: 800; flex-shrink: 0; }
.danmaku-item .dm-text { overflow: hidden; text-overflow: ellipsis; }
@keyframes dm-move {
  to { transform: translateX(var(--dm-shift, -1500px)); }
}

/* ---------- 悔棋/和棋请求确认卡（居中弹窗，需处理才能继续走子） ---------- */
.undo-card {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  background: rgba(31, 80, 90, 0.42);
  padding: 20px;
}
.undo-card-body {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 10px 30px rgba(45, 38, 25, 0.32);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(360px, 100%);
  animation: pop .25s ease;
}
.undo-card-text { font-size: 15px; font-weight: 700; line-height: 1.5; text-align: center; }
.undo-card-text b { color: var(--accent-dark); }
.undo-card-btns { display: flex; gap: 10px; }
.undo-card-btns .btn { padding: 10px 26px; font-size: 15px; font-weight: 700; }

/* ---------- 首页：欢迎回来 / 邀请进房提示 ---------- */
.welcome-back {
  margin: -4px 0 12px;
  padding: 9px 16px;
  display: inline-block;
  background: #fdf3ea;
  border: 1px solid #efd9c4;
  border-radius: 999px;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(90,70,40,0.1);
}
.join-hint {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--accent-dark);
  background: #fdf3ea;
  border: 1px dashed #eccdb6;
  border-radius: 10px;
  padding: 9px 11px;
  line-height: 1.55;
  text-align: left;
}
.join-hint b { letter-spacing: 1px; }

/* 消息弹窗：点 💬 弹出，不点不显示（浮在功能区上方，避开输入法） */
.msg-popup {
  position: fixed;
  right: 10px;
  bottom: calc(80px + var(--kb-h, 0px) + env(safe-area-inset-bottom, 0px));
  width: min(360px, calc(100vw - 20px));
  height: 486px;
  max-height: min(62vh, 520px);
  z-index: 45;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(23, 60, 70, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 4px 8px;
}
.msg-title { font-size: 15px; font-weight: 800; color: #4a4233; }
.msg-tabs { display: flex; gap: 4px; padding: 6px 8px 8px; border-top: 1px solid var(--line); }
.msg-tab {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-tab img {
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.msg-tab:not(.on) img { opacity: 0.6; }
.msg-tab.on img { opacity: 1; filter: drop-shadow(0 2px 3px rgba(45, 38, 25, 0.28)); }
/* 消息记录贴内容区上沿：高度随消息量自动伸缩（上限 196px，约 10 条完整可见），
 * 少消息时无空白；内容区 flex 填满剩余空间，猫包/狗包 16 个表情一屏全部显现。
 * 弹窗固定总高（bottom 锚定）→ 切换页签顶部齐平、不抖动。 */
.msg-history { flex: 0 0 auto; max-height: 196px; min-height: 0; }
.msg-content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
/* 文字页：记录区填满、消息底部对齐（贴输入框，无下方空白），输入框贴底 */
#chat-popup.tab-text .msg-history { flex: 1 1 auto; max-height: none; }
#chat-popup.tab-text .msg-history .chat-msg:first-child { margin-top: auto; }
#chat-popup.tab-text .msg-content { flex: 0 0 auto; }
/* 对局页：消息记录已转到棋盘下方动态条右列，弹窗只留发送区（表情/常用语），
 * 高度收窄；文字页保留记录区（贴着输入框看最近消息）。总高固定 → 切换不抖动 */
body.in-game .msg-popup { height: 356px; }
body.in-game #chat-popup:not(.tab-text) .msg-history { display: none; }
.msg-presets {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  height: 100%;
  overflow-y: auto;
}
.msg-preset {
  background: #f4f1e7;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 14px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--ink);
  text-align: left;
  flex-shrink: 0;
}
.msg-preset:active { background: #eadfc8; }
.msg-stickers-wrap {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px 2px;
  padding: 8px;
  border-top: 1px solid var(--line);
  height: 100%;
  overflow: hidden;
  align-content: start;
}
.msg-sticker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 2px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 10px;
}
.msg-sticker img { width: 44px; height: 44px; display: block; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(45, 38, 25, .15)); }
.msg-sticker span { font-size: 10.5px; color: var(--muted); line-height: 1; }
.msg-sticker:active { background: #f1ecdd; }
.chat-sticker { width: 64px; height: auto; max-height: 80px; display: block; align-self: flex-start; object-fit: contain; }
.dm-sticker { width: 40px; height: 40px; display: block; flex-shrink: 0; margin: -8px 0; object-fit: contain; }

/* ---------- 登录资料（昵称 / 性别 / 头像） ---------- */
.profile-card { width: min(420px, 100%); }
.profile-avatar-preview { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 10px; }
.profile-avatar-box {
  width: 88px; height: 88px; border-radius: 50%;
  border: 2.5px solid var(--line);
  background: #f4f1e7;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
  overflow: hidden;
  cursor: pointer;
}
.profile-avatar-box img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-tip { font-size: 11.5px; color: var(--muted); }
.profile-name-field { margin-bottom: 10px; }
.profile-avatar-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.profile-hint { font-size: 12px; color: var(--muted); }
.profile-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.profile-preset {
  border: 2.5px solid transparent; border-radius: 50%;
  padding: 0; background: none; cursor: pointer;
  width: 100%; aspect-ratio: 1; overflow: hidden;
}
.profile-preset img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.profile-preset.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201, 106, 74, 0.25); }
.profile-error { color: var(--danger); font-size: 13px; margin-bottom: 8px; text-align: center; }
/* 首页迷你资料卡 */
.profile-mini { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.profile-avatar-mini {
  width: 44px; height: 44px; border-radius: 50%;
  background: #f4f1e7; border: 2px solid var(--line);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.profile-avatar-mini img { width: 100%; height: 100%; object-fit: cover; }
.profile-name-mini { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 各处的头像图（大厅座位 / 对局头像排 / 聊天 / 弹幕） */
.seat-avatar img, .slot-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.who-avatar img { width: 17px; height: 17px; border-radius: 50%; object-fit: cover; display: inline-block; vertical-align: -3px; }
.dm-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }

/* ---------- 结算 ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(31, 80, 90, 0.42);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-card {
  background: #fdfcf8;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 16px 44px rgba(23, 60, 70, 0.3);
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-card h2 { color: #4a4233; margin-bottom: 14px; }
.result-list { list-style: none; text-align: left; margin-bottom: 18px; }
.result-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
}
.result-list li:nth-child(1) { background: #f7efe0; font-size: 16px; }
.result-list li:nth-child(2) { background: #f2f0e8; }
.result-list li:nth-child(3) { background: #f6e8e1; }
.result-list li.draw-note { justify-content: center; text-align: center; font-size: 15px; background: #f7efe0; }
.result-list li .r-medal { width: 26px; text-align: center; font-size: 18px; }
.result-list li .r-name { flex: 1; }
.result-list li .r-rank { color: var(--muted); font-size: 12px; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .btn { flex: 1; }

/* ---------- 连接遮罩 / Toast ---------- */
.conn-overlay {
  position: fixed; inset: 0;
  background: rgba(31, 80, 90, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
}
.conn-card { background: #fdfcf8; border-radius: 14px; padding: 24px 32px; text-align: center; box-shadow: 0 8px 30px rgba(23, 60, 70, 0.25); }
.spinner {
  width: 30px; height: 30px;
  border: 3px solid #e2dcc8;
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#conn-text { font-size: 14px; color: var(--muted); }

/* ---------- 服务器离线提示（首页连接失败时显示） ---------- */
.offline-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(160deg, rgba(245, 240, 228, 0.9), rgba(217, 205, 178, 0.92));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 60; padding: 16px;
  overflow-y: auto;
}
.offline-card {
  background: var(--panel);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow-lg);
  max-width: 360px; width: 100%;
  max-height: 100%;
  padding: 20px;
  text-align: center;
}
.offline-head { position: relative; width: 76px; height: 76px; margin: 0 auto 6px; }
.offline-cat {
  width: 76px; height: 76px; object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(23, 60, 70, 0.18));
}
.offline-zzz {
  position: absolute; top: -2px; right: -8px;
  font-size: 22px;
  animation: offline-zzz 2.2s ease-in-out infinite;
}
@keyframes offline-zzz {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(-6px); opacity: 1; }
}
.offline-title { font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.offline-desc { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 12px; }
.offline-desc-em {
  display: inline-block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-dark);
}

/* 金色按钮（离线页「再试一次」） */
.btn.gold {
  background: linear-gradient(135deg, #f8cd6b, #f2b544);
  color: #4a3200;
  font-weight: 700;
  border: 1px solid rgba(180, 128, 30, 0.4);
  box-shadow: 0 2px 6px rgba(180, 128, 30, 0.25);
}
.btn.gold:active { box-shadow: none; }

/* 微信名片卡（竖版名片原比例展示，不裁剪不压缩；左右结构，点击可看原图） */
.offline-wechat {
  display: flex; flex-direction: row; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #fff9ea, #fdf0d3);
  border: 1px solid rgba(242, 181, 68, 0.45);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: left;
}
.offline-qr-link { flex: 0 0 auto; line-height: 0; }
.offline-qr {
  width: 124px; height: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  display: block;
}
.offline-wechat-info { min-width: 0; flex: 1; text-align: left; }
.offline-wechat-value { font-size: 12px; color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.offline-wechat-num { font-size: 15px; font-weight: 700; color: var(--accent-dark); margin-bottom: 8px; white-space: nowrap; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: rgba(40, 64, 71, 0.92);
  color: #faf7ef;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 70;
  max-width: 86vw;
  text-align: center;
}

/* ---------- 对局弹层：统一明亮休闲卡片风格（与全局浅色面板一致） ---------- */
body.in-game .sheet-panel,
body.in-game .voice-panel,
body.in-game .msg-popup,
body.in-game .undo-card-body,
body.in-game .modal-card {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: 0 18px 46px rgba(23, 60, 70, 0.3);
}
body.in-game .sheet-title,
body.in-game .voice-title,
body.in-game .modal-card h2,
body.in-game .undo-card-text {
  color: var(--ink);
}
body.in-game .undo-card-text b { color: var(--accent-dark); }
body.in-game .conn-card { background: var(--panel); }
body.in-game .switch-row { border-top-color: var(--line); color: var(--ink); }
body.in-game .switch-row .sw { background: #d3d9d6; }
body.in-game .switch-row input:checked + .sw { background: #2ca0ad; }
/* 对局面板四个操作按钮的对局态配色：历史上 `body.in-game .opt-item` 与
 * `body.in-game .btn` 同优先级、被后者按源码顺序压过，实际渲染为 .btn 的奶油白 #efece1。
 * 收紧到 #panel-options 后本规则优先级升高，这里显式写回当前实际渲染值，
 * 保证「限定作用域」是纯粹的无视觉变更改动（不再依赖源码顺序，行为确定）。 */
body.in-game #panel-options .opt-item {
  background: #efece1;
  border-color: var(--line);
  color: var(--ink);
}
body.in-game .btn { background: #efece1; color: var(--ink); }
body.in-game .btn.primary {
  background: linear-gradient(135deg, #f48a6e, var(--accent-dark));
  color: #fff;
}
body.in-game .btn.ghost {
  background: transparent;
  border-color: rgba(40, 64, 71, 0.3);
  color: var(--ink);
}
body.in-game .chat-msg { background: #f2efe4; color: var(--ink); }
body.in-game .chat-msg.sys { color: var(--muted); background: transparent; }
body.in-game .chat-input-row {
  background: var(--panel);
  border-top-color: var(--line);
}
body.in-game .chat-input-row input { background: #f2efe4; color: var(--ink); }
body.in-game .msg-presets { border-top-color: var(--line); }
body.in-game .msg-preset {
  background: #f2efe4;
  border-color: var(--line);
  color: var(--ink);
}
body.in-game .msg-preset:active { background: #e8e1cf; }
body.in-game .msg-stickers-wrap { border-top-color: var(--line); }
body.in-game .msg-sticker span { color: var(--muted); }
body.in-game .msg-sticker:active { background: #f1ecdd; }
body.in-game .msg-tabs { border-top-color: var(--line); }
body.in-game .msg-tab:not(.on) img { opacity: 0.65; }
body.in-game .voice-status { color: var(--muted); }
body.in-game .voice-status.live { color: #3f9d6b; }
body.in-game .voice-hint {
  color: #8a6d3b;
  background: #fbf3df;
  border-color: #ecdcb8;
}
body.in-game .voice-diag { color: var(--muted); }
body.in-game .confirm-text { color: var(--ink); }
body.in-game .copy-text {
  background: #faf7ef;
  border-color: var(--line);
  color: var(--ink);
}
body.in-game .result-list li { background: #f2f0e8; }
body.in-game .result-list li:nth-child(1) { background: #f7efe0; }
body.in-game .result-list li:nth-child(2) { background: #f2f0e8; }
body.in-game .result-list li:nth-child(3) { background: #f6e8e1; }
body.in-game .result-list li.draw-note { background: #f7efe0; }
body.in-game .result-list li .r-rank { color: var(--muted); }
body.in-game .msg-dot { box-shadow: 0 0 0 2px var(--panel); }

/* DEV 预览角标：仅本地 8091 预览时显示，线上永不显示 */
.dev-badge {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 9999;
  padding: 5px 12px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .28);
}

/* ---------- 情人节冠军彩蛋（仅当前客户端本人触发，其余走原结算样式） ---------- */
/* 遮罩：深青调 + 模糊，220ms 淡入 */
#modal-result.valentine-modal {
  background: rgba(22, 68, 76, .58);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: valentine-mask-in .22s ease;
}
@keyframes valentine-mask-in { from { opacity: 0; } to { opacity: 1; } }

/* 卡片：覆盖原 modal-card 的尺寸/底色/圆角，360ms 位移缩放进入 */
.valentine-card {
  width: min(420px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 18px 20px 16px;
  border: 2px solid rgba(236, 185, 93, .85);
  border-radius: 26px;
  background: linear-gradient(180deg, #fff9f2 0%, #fff4f5 100%);
  box-shadow: 0 20px 56px rgba(27, 39, 39, .34);
  animation: valentine-card-in .36s cubic-bezier(.2, .8, .2, 1);
}
@keyframes valentine-card-in {
  from { transform: translateY(16px) scale(.96); }
  to { transform: none; }
}

/* 彩蛋徽章 */
.valentine-badge {
  display: inline-block;
  background: #ffedbc;
  color: #8f531e;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 2px;
}

/* 插画（WebP 首选 / PNG 回退，picture 包裹；原图不裁切不加字） */
.valentine-art {
  display: block;
  width: 206px;
  height: 206px;
  margin: 8px auto 6px;
  object-fit: contain;
  border-radius: 28px;
}
@media (max-width: 480px) {
  .valentine-art { width: 190px; height: 190px; }
}

/* 标题 / 正文 / 分割线 */
.valentine-title {
  color: #6f4134;
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 6px;
}
@media (max-width: 480px) {
  .valentine-title { font-size: 21px; }
}
.valentine-text {
  color: #69534c;
  font-size: 15px;
  line-height: 1.8;
  text-align: center;
  margin: 0 0 8px;
}
.valentine-divider {
  border: none;
  border-top: 1px solid #eadacc;
  margin: 10px 0 12px;
}

/* 第一名行高亮（排名本身仍来自服务端权威 ranking） */
#modal-result.valentine-modal .result-list li.valentine-first {
  background: #ffefce;
  border-radius: 13px;
}

/* 主按钮：粉红渐变、白字、46px 高；次按钮沿用原「返回首页」样式 */
#modal-result.valentine-modal .btn-valentine-primary {
  height: 46px;
  border: none;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, #ff7a7f, #ef5c6a);
  box-shadow: 0 6px 16px rgba(239, 92, 106, .35);
}

/* CSS 心形粒子（span + 两圆伪元素）：上浮渐隐，结束后由 JS 删除节点 */
.valentine-heart {
  position: absolute;
  pointer-events: none;
  width: 16px;
  height: 16px;
  background: var(--vh-color, #ff7c87);
  transform: rotate(45deg);
  opacity: 0;
  animation: valentine-heart-rise var(--vh-dur, 2.2s) ease-out forwards;
}
.valentine-heart::before,
.valentine-heart::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: inherit;
}
.valentine-heart::before { left: -8px; top: 0; }
.valentine-heart::after { left: 0; top: -8px; }
@keyframes valentine-heart-rise {
  0% { transform: translateY(0) translateX(0) rotate(45deg) scale(.9); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(-42vh) translateX(var(--vh-drift, 0px)) rotate(45deg) scale(.7); opacity: 0; }
}

/* 减弱动态：取消位移/缩放与粒子，只保留 120ms 淡入 */
@media (prefers-reduced-motion: reduce) {
  #modal-result.valentine-modal { animation: valentine-mask-in .12s ease; }
  .valentine-card { animation: valentine-mask-in .12s ease; }
  #modal-result .valentine-heart { display: none; }
}
