/* 欢乐跳棋 —— 网页版样式
 * 设计语言：精品休闲桌游（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%, #aad7d5, #2e7d7b 60%, #1d5452); }

.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: 12px 16px 12px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.lobby-head {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 6px 18px rgba(90,70,40,0.1);
  flex-shrink: 0;
}
.room-code-box { flex: 1; min-width: 0; text-align: left; }
.room-code-label { font-size: 12px; color: var(--muted); }
.room-code { font-size: 36px; font-weight: 800; letter-spacing: 6px; color: var(--accent-dark); line-height: 1.15; }
.lobby-meta { font-size: 12.5px; color: #57503d; margin-top: 4px; line-height: 1.5; }
.lobby-head-btns { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.btn.head-mini {
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 700;
  color: #4a4233;
  border: 1.5px solid var(--line);
  background: #f6f2e7;
  min-width: 88px;
}
.btn.head-mini:active { transform: scale(0.96); }

/* 中间：状态提示 + 座位面板（谁加入了、是否准备），可滚动 */
.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); }

/* 底部：开始游戏（准备）/ +机器人 / 离开 / 聊天 —— 整行宽的大按钮，纵向排列、一样大 */
.lobby-bottom { flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; }
.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.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; }

/* 聊天大按钮（准备界面底部 / 对局界面底部整行，双端统一） */
.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; }
/* 预设头像：座位色圆底 + 动物头像（干净圆形，图片不被遮挡） */
.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; }

/* ---------- 聊天（弹出面板，大厅与对局共用） ---------- */
.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: baseline; gap: 6px; }
.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: 6px; padding: 6px 10px; border-top: 1px solid var(--line); flex-shrink: 0; background: var(--panel); margin-top: auto; height: 50px; }
.chat-input-row input { border: none; background: #f4f1e7; flex: 1; padding: 9px 10px; font-size: 14px; }

.version-tag {
  display: inline-block;
  margin: -6px 0 14px;
  padding: 2px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--muted);
  background: rgba(255, 253, 246, 0.7);
}
/* ---------- 对局（明亮青绿桌面 + 暖金实体棋盘） ---------- */
#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);
}

.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: 1; 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; }
/* PNG 头像框覆盖层：与头像中心严格重合（同盒绝对居中），纯视觉、不挡点击 */
.slot-avatar-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 118%;
  height: 118%;
  object-fit: contain;
  pointer-events: none;
}
.seat-slot.on .slot-avatar-frame { width: 124%; height: 124%; }
.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; }
}

/* 棋盘容器：弹性区域，星盘紧贴玩家区（不留大块顶部空白），
 * 剩余高度自然沉淀在棋盘下方；由 JS 按包围盒贴紧并居中。
 * 柔和悬浮阴影由 CSS drop-shadow 提供（贴合星形轮廓，无黑色晕边）。 */
.board-box {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
.board-inner { position: relative; }
#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 标签 */
.func-row {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  margin: 0 4px;
  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;
}

/* 窄屏（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; }
.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: 10px;
  right: 10px;
  z-index: 5;
  background: rgba(40, 64, 71, 0.95);
  color: #faf7ef;
  font-size: 12.5px;
  line-height: 1.6;
  padding: 10px 12px;
  border-radius: 10px;
  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; }
.opt-item {
  width: 100%;
  text-align: center;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  border: 1.5px solid var(--line);
  background: #f8f4e9;
}
.opt-item:disabled { opacity: 0.45; }

/* ---------- 通用确认框 / 手动复制面板 ---------- */
.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;
}

.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;
  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));
  max-height: min(60vh, 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)); }
/* 消息记录常驻弹窗顶部；内容区固定高度：快捷/猫包/狗包三页切换不抖动 */
.msg-history { height: 120px; flex-shrink: 0; }
.msg-content { height: 170px; display: flex; flex-direction: column; overflow: hidden; }
/* 打字页：消息记录加长（240px + 输入框 50px = 290px，与其他页 120+170 等高），输入框贴底 */
#chat-popup.tab-text .msg-history { height: 240px; }
#chat-popup.tab-text .msg-content { height: auto; flex: 0 0 auto; }
.msg-presets {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 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: 8px 14px;
  font-size: 13px;
  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: 8px 2px;
  padding: 10px;
  border-top: 1px solid var(--line);
  height: 100%;
  overflow-y: auto;
  align-content: start;
}
.msg-sticker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 3px 2px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 10px;
}
.msg-sticker img { width: 52px; height: 52px; display: block; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(45, 38, 25, .15)); }
.msg-sticker span { font-size: 11px; 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); }

.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 {
  background: #f6f3ea;
  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);
}
