/* 欢乐五子棋 —— 网页版样式
 * 设计语言延续欢乐跳棋（Premium Casual Board Game）：
 *  - 首页/大厅：暖米白 + 极淡圆点纹；对局页：明亮青绿竖条桌面
 *  - 乳白圆角面板、珊瑚主按钮、金色强调、半透明卡片
 *  - 棋盘：SVG 网格（15×15 交叉点、14×14 格、天元与标准星位）+ CSS 渐变棋子
 */
: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;
  --surface: rgba(255, 255, 255, 0.3);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --on-table: #ffffff;
  --table-line: rgba(255, 255, 255, 0.4);
  --gold: #f2b544;
  --coral: #f07b5f;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --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 {
  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; }

/* ---------- 通用控件 ---------- */
.panel {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px 16px;
  text-align: left;
  margin-top: 22px;
}
.field { margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; }
.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #faf7ef;
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
  color: var(--ink);
}
.field input:focus { border-color: var(--accent); background: #fff; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1;
  min-width: 0;
  padding: 9px 6px;
  font-size: 13.5px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #faf7ef;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.btn {
  border: 1.5px solid rgba(59, 55, 43, 0.28);
  background: #f2eee2;
  color: var(--ink);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 14.5px;
  cursor: pointer;
  font-weight: 600;
}
.btn:active { filter: brightness(0.94); }
.btn.primary { background: linear-gradient(135deg, #f48a6e, var(--accent-dark)); color: #fff; font-weight: 700; border: none; }
.btn.big { width: 100%; padding: 14px; font-size: 16px; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); color: #fff; border: none; }
.btn:disabled { opacity: 0.45; cursor: default; }

.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: var(--muted); font-size: 12.5px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- 首页 ---------- */
.home-wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 6vh 16px 40px;
  text-align: center;
}
.home-invalid-notice {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  background: #fffdf6;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(90, 70, 40, 0.14);
  padding: 10px 16px;
  text-align: center;
}
.home-invalid-notice.fade-out { opacity: 0; transition: opacity 0.5s ease; }
.hin-title { font-size: 14px; font-weight: 800; color: #4a4233; }
.hin-text { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.5; }

.logo { font-size: 34px; font-weight: 800; color: #3c5a62; letter-spacing: 1px; margin-bottom: 10px; }
.logo-marbles { display: flex; justify-content: center; gap: 10px; margin-bottom: 6px; }
.marble { width: 34px; height: 34px; border-radius: 50%; box-shadow: 0 3px 7px rgba(0, 0, 0, 0.28), inset 0 2px 3px rgba(255, 255, 255, 0.5); }
.marble.m1 { background: radial-gradient(circle at 32% 30%, #6f6f6f, #2a2a2a 60%, #050505); }
.marble.m2 { background: radial-gradient(circle at 32% 30%, #ffffff, #f1ecdd 60%, #c9c2b0); border: 1px solid #b9b2a2; }

.welcome-back {
  display: inline-block;
  background: #fff8e8;
  border: 1px solid #f0dfae;
  color: #a06a1b;
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  margin: 4px auto 0;
}

.profile-mini { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.profile-avatar-mini { width: 40px; height: 40px; border-radius: 50%; background: #f4f1e7; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; overflow: hidden; flex-shrink: 0; border: 2px solid var(--line); }
.profile-avatar-mini img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.profile-name-mini { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }

.join-row { display: flex; gap: 8px; }
.join-row input {
  flex: 1;
  min-width: 0;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 700;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #faf7ef;
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
}
.join-row input:focus { border-color: var(--accent); background: #fff; }
.join-hint { margin-top: 10px; font-size: 12.5px; color: var(--danger); text-align: center; }

/* ---------- 房间大厅 ---------- */
.lobby-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 14px calc(20px + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lobby-room-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 16px;
}
.lobby-room-summary { text-align: center; }
.lobby-code-line { display: flex; align-items: center; justify-content: center; gap: 8px; }
.room-code-label { color: var(--muted); font-size: 13px; }
.room-code { color: var(--accent-dark); letter-spacing: 2px; font-weight: 800; font-size: 22px; }
.lobby-meta { margin-top: 6px; font-size: 12.5px; color: var(--muted); min-height: 18px; }
.lobby-room-divider { height: 1px; background: var(--line); margin: 12px 0; }
.lobby-invite-actions { display: flex; flex-direction: column; gap: 8px; }
.lobby-invite-primary { border: none; background: linear-gradient(135deg, #f48a6e, var(--accent-dark)); color: #fff; padding: 12px; font-size: 15px; font-weight: 700; }
.lobby-invite-secondary { display: flex; gap: 8px; }
.lobby-invite-weak { flex: 1; background: #f2eee2; border: 1.5px solid var(--line); color: var(--ink); padding: 10px 6px; font-size: 13.5px; }

.lobby-mid { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.lobby-status { text-align: center; font-size: 13px; color: var(--muted); min-height: 20px; }
.lobby-status b { color: var(--accent-dark); }

.seats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.seat-card {
  position: relative;
  background: var(--panel);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.seat-card.empty { opacity: 0.55; }
.seat-card .seat-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f0ece2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  overflow: hidden;
  border: 2px solid var(--line);
}
.seat-card .seat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.seat-info { 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); margin-top: 2px; }
.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;
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 2px 7px;
  font-weight: 700;
  background: var(--muted);
}
.badge.host { background: var(--accent); }
.badge.off { background: var(--muted); }
.badge.black { background: #2b2b2b; }
.badge.white { background: #f5f1e6; color: #5a5140; border: 1px solid #c9c2b0; }

.lobby-host-invite-hint { text-align: center; font-size: 12px; color: var(--muted); }

.lobby-bottom { flex-shrink: 0; }
.lobby-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.lobby-actions.has-split #btn-leave-room { grid-column: auto; }
.lobby-act { padding: 13px 8px; font-size: 15px; font-weight: 700; }
.lobby-act.primary { border: none; }
.lobby-act.ghost { background: transparent; }
.lobby-act.danger-ghost { background: transparent; border: 1.5px solid var(--danger); color: var(--danger); }
.lobby-act .msg-dot { top: 8px; right: 10px; }

/* ---------- 对局（明亮青绿竖条桌面） ---------- */
#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;
}
.game-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 6px calc(8px + env(safe-area-inset-bottom, 0px));
  max-width: 460px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  position: relative;
}
.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;
  white-space: nowrap;
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gt-chip.mine { box-shadow: 0 0 0 2px var(--gold), var(--shadow-sm); }
.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; }

/* 玩家对战 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);
}
.seat-slot {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 12px;
  transition: box-shadow 0.18s ease;
}
.seat-slot.on { box-shadow: inset 0 0 0 2px var(--gold); background: rgba(255, 255, 255, 0.14); }
.slot-avatar-box { position: relative; flex-shrink: 0; width: 40px; height: 40px; }
.slot-avatar {
  width: 34px; height: 34px;
  position: absolute; left: 3px; top: 3px;
  border-radius: 50%;
  background: #f0ece2;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; overflow: hidden;
}
.slot-avatar img { width: 100%; height: 100%; object-fit: cover; }
.slot-frame { width: 40px; height: 40px; object-fit: contain; position: absolute; left: 0; top: 0; pointer-events: none; }
.slot-name { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--on-table); }
.slot-info { flex: 1; min-width: 0; }
.slot-sub { font-size: 11px; color: var(--on-table-soft, rgba(255, 255, 255, 0.88)); }
.slot-sub.warn { color: #ffe08a; }
.slot-color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 3px; }
.slot-color-dot.black { background: #1c1c1c; box-shadow: 0 0 0 1.5px rgba(255,255,255,.7); }
.slot-color-dot.white { background: #fdfdfd; box-shadow: 0 0 0 1.5px rgba(0,0,0,.35); }

/* ---------- 棋盘（SVG 网格 + CSS 棋子） ---------- */
.game-main { flex: 0 1 auto; display: flex; flex-direction: column; align-items: center; min-height: 0; }
.board-box { display: flex; justify-content: center; width: 100%; }
.board-inner {
  position: relative;
  width: min(94vw, 430px, calc(100dvh - 236px));
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.4), transparent 42%),
    linear-gradient(135deg, #edd6a6 0%, #e4c289 52%, #d3a86e 100%);
  border: 1px solid #9c6f3c;
  border-radius: 10px;
  box-shadow:
    0 10px 26px rgba(13, 50, 58, 0.35),
    inset 0 0 0 5px #b98a4e,
    inset 0 0 0 6px #a3763f,
    inset 0 2px 6px rgba(255, 255, 255, 0.35),
    inset 0 -4px 10px rgba(110, 70, 25, 0.28);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
/* 网格层：内缩半格，交点 (0..14) 恰落在网格边缘 */
.board-grid {
  position: absolute;
  inset: calc(100% / 28 + 4px);
}
#board-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#stones { position: absolute; inset: 0; pointer-events: none; }
#ghost { position: absolute; inset: 0; pointer-events: none; }
.stone {
  position: absolute;
  width: 6.3%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.stone.black {
  background: radial-gradient(circle at 33% 28%, #7d7d7d, #2e2e2e 48%, #050505 82%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
}
.stone.white {
  background: radial-gradient(circle at 33% 28%, #ffffff, #f5f1e7 55%, #d6d0c0 92%);
  border: 1px solid #b6af9e;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.32);
}
.stone.ghost { opacity: 0.45; }
.stone .last-dot {
  position: absolute;
  left: 50%; top: 50%;
  width: 24%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #e05252;
  box-shadow: 0 0 4px rgba(224, 82, 82, 0.85);
}

/* 获胜棋子：明显但不刺眼的金色外圈 + 柔光（独立于胜负线开关） */
.stone.win {
  box-shadow:
    0 0 0 2.5px #ffd54a,
    0 0 10px 3px rgba(255, 213, 74, 0.65);
  z-index: 1;
}
.stone.win.white {
  box-shadow:
    0 0 0 2.5px #e3a82e,
    0 0 10px 3px rgba(255, 213, 74, 0.6);
}

/* 胜利线独立覆盖层：位于棋子层之上（DOM 顺序在 #stones 之后），不盖棋盘网格 */
.winline-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
#winline-svg .win-under {
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 0.34;
  stroke-linecap: round;
  fill: none;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.9));
}
#winline-svg .win-top {
  stroke: rgba(255, 213, 74, 0.88);
  stroke-width: 0.22;
  stroke-linecap: round;
  fill: none;
  filter: drop-shadow(0 0 2.5px rgba(255, 213, 74, 0.9));
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  animation: winline-draw 0.7s ease-out forwards;
}
@keyframes winline-draw { to { stroke-dashoffset: 0; } }
/* 减少动态偏好：取消描画动画，保留静态金线与获胜棋子外圈 */
@media (prefers-reduced-motion: reduce) {
  #winline-svg .win-top { animation: none; stroke-dashoffset: 0; }
}

.game-hint {
  flex-shrink: 0;
  margin-top: 8px;
  min-height: 22px;
  font-size: 13px;
  font-weight: 700;
  color: #fff8e0;
  text-shadow: 0 1px 2px rgba(13, 50, 58, 0.35);
  text-align: center;
}

/* 撒花庆祝 */
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; border-radius: 10px; }
.confetti-piece {
  position: absolute;
  top: -6%;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fall 1.7s ease-out forwards;
}
@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(120%) rotate(560deg); }
}

/* ---------- 底部工具栏（顺序：设置 / 对局 / 消息 / 通话，与欢乐跳棋一致） ---------- */
.func-row {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--table-line);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.func-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--on-table);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 2px;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
}
.func-btn .fc-icon { width: 34px; height: 34px; object-fit: contain; pointer-events: none; }
.func-btn:active { background: rgba(255, 255, 255, 0.16); }

/* ---------- 语音通话面板 ---------- */
.voice-panel {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(460px, 100%);
  background: var(--panel);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-lg);
  z-index: 45;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.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: 12px;
  color: #a06a1b;
  background: #fbf3df;
  border-radius: 10px;
  padding: 8px 10px;
  line-height: 1.5;
}
.voice-diag { font-size: 11px; color: var(--muted); word-break: break-all; }

/* 对局内聊天：非文字标签页隐藏历史区（节约空间，与欢乐跳棋一致） */
body.in-game #chat-popup:not(.tab-text) .msg-history { display: none; }
#chat-popup.tab-text .msg-history { display: flex; }

/* ---------- 底部面板（sheet） ---------- */
.sheet-panel {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(460px, 100%);
  max-height: 82vh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-title { font-size: 15px; font-weight: 800; color: #4a4233; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 2px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}
.switch-row:first-of-type { border-top: none; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row .sw {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: #d8d2c0;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.switch-row .sw::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: left 0.15s ease;
}
.switch-row input:checked + .sw { background: #2ca0ad; }
.switch-row input:checked + .sw::after { left: 21px; }
.switch-side { display: inline-flex; align-items: center; gap: 8px; }

.opt-items { display: flex; flex-direction: column; gap: 8px; }
.opt-item { padding: 12px; font-size: 14.5px; font-weight: 700; background: #f2eee2; }
.opt-note { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ---------- 聊天弹窗 ---------- */
.msg-popup {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(460px, 100%);
  height: min(520px, 80vh);
  background: var(--panel);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-lg);
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  flex-shrink: 0;
}
.msg-title { font-size: 15px; font-weight: 800; color: #4a4233; }
.chat-msgs {
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1 1 auto;
  min-height: 0;
}
.chat-msgs.msg-history { flex: 0 0 auto; max-height: 190px; min-height: 0; }.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.sys { color: var(--muted); font-size: 12px; text-align: center; background: transparent; align-self: center; }
.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: inline-block; vertical-align: -13px; object-fit: contain; margin: -8px 0; }

.msg-content { flex: 0 0 auto; display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--line); }
.msg-presets { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
.msg-preset {
  background: #f4f1e7;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--ink);
}
.msg-stickers-wrap {
  padding: 6px 8px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  overflow-y: auto;
  max-height: 220px;
}
.msg-sticker {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 4px 2px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
.msg-sticker img { width: 44px; height: 44px; display: block; object-fit: contain; }
.msg-sticker span { font-size: 10px; color: var(--muted); }
.msg-sticker:active { background: #f1ecdd; }

.chat-input-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); flex-shrink: 0; }
.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-send { border-radius: 14px; padding: 9px 16px; background: var(--coral); color: #fff; border: none; font-weight: 700; }
.msg-tabs { display: flex; gap: 4px; padding: 6px 8px 8px; border-top: 1px solid var(--line); flex-shrink: 0; background: var(--panel); }
.msg-tab { flex: 1; background: transparent; border: none; padding: 4px; cursor: pointer; }
.msg-tab img { width: 100%; max-width: 72px; height: auto; object-fit: contain; opacity: 0.55; }
.msg-tab.on img { opacity: 1; filter: drop-shadow(0 2px 3px rgba(45, 38, 25, 0.28)); }

/* ---------- 弹幕 ---------- */
.danmaku {
  position: fixed;
  top: 16%;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 30;
  overflow: hidden;
  height: 0;
}
.danmaku-item {
  position: absolute;
  white-space: nowrap;
  background: rgba(40, 64, 71, 0.82);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 12.5px;
  animation: danmaku-run 5.2s linear forwards;
}
.danmaku-item .dm-name { font-weight: 800; }
@keyframes danmaku-run {
  from { left: 100%; }
  to { left: -60%; }
}

/* ---------- 请求确认卡 ---------- */
.undo-card {
  position: fixed;
  inset: 0;
  background: rgba(31, 80, 90, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.undo-card-body {
  background: var(--panel);
  border-radius: 16px;
  padding: 22px 20px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 320px;
  width: 100%;
}
.undo-card-text { font-size: 15px; font-weight: 700; line-height: 1.5; margin-bottom: 16px; }
.undo-card-text b { color: var(--accent-dark); }
.undo-card-btns { display: flex; gap: 10px; }
.undo-card-btns .btn { flex: 1; padding: 10px; font-size: 15px; font-weight: 700; }

/* ---------- 弹窗 ---------- */
.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: var(--panel);
  border-radius: 18px;
  padding: 22px 20px;
  width: min(420px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-card h2 { color: #4a4233; margin-bottom: 14px; text-align: center; font-size: 18px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

.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: 84px;
  height: 84px;
  border-radius: 50%;
  background: #f4f1e7;
  border: 2px solid var(--line);
  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 {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--line);
  background: #f4f1e7;
  cursor: pointer;
}
.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; }

.confirm-text { color: var(--ink); font-size: 14px; line-height: 1.8; text-align: center; }
.copy-text {
  width: 100%;
  min-height: 72px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #faf7ef;
  padding: 10px;
  font-size: 15px;
  resize: none;
  outline: none;
  color: var(--ink);
  word-break: break-all;
}

.result-again-line { text-align: center; font-size: 13px; color: var(--muted); margin-top: 10px; min-height: 18px; }
.result-again-line b { color: var(--accent-dark); }
#result-title { font-size: 22px; }

/* ---------- 连接 / 离线 ---------- */
.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: var(--panel);
  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 var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#conn-text { font-size: 13.5px; color: var(--muted); }

.offline-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, rgba(245, 240, 228, 0.94), rgba(217, 205, 178, 0.96));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
  padding: 20px;
}
.offline-card { background: var(--panel); border-radius: 18px; padding: 28px 26px; text-align: center; box-shadow: var(--shadow-lg); width: min(360px, 100%); }
.offline-head { position: relative; width: 76px; height: 76px; margin: 0 auto 6px; }
.offline-cat { width: 76px; height: 76px; object-fit: contain; }
.offline-zzz { position: absolute; top: -8px; right: -14px; font-size: 26px; animation: zzz 2.2s ease-in-out infinite; }
@keyframes zzz { 0%, 100% { transform: translateY(0); opacity: 1; } 50% { transform: translateY(-5px); opacity: 0.6; } }
.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; }
.offline-desc-em { color: var(--accent-dark); font-weight: 700; }

/* ---------- 微信分享指引 ---------- */
#wechat-share-guide {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  background: rgba(20, 40, 44, 0.55);
  z-index: 65;
}
.wsg-arrow {
  position: absolute;
  top: 10px;
  right: 16px;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 22px solid #fff;
  animation: wsg-bounce 1.1s ease-in-out infinite;
}
@keyframes wsg-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
.wsg-card {
  position: absolute;
  top: 46px;
  right: 12px;
  background: #fff;
  border-radius: 14px;
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  width: 220px;
}
.wsg-title { font-size: 16px; font-weight: 800; color: #4a4233; }
.wsg-text { font-size: 13px; color: var(--muted); margin: 6px 0 12px; }
.wsg-ok { width: 100%; }

/* ---------- Toast / 未读点 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: rgba(40, 64, 71, 0.92);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  font-size: 13px;
  z-index: 80;
  max-width: 84vw;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.msg-dot {
  position: absolute;
  top: 4px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 2px var(--panel);
}

/* ---------- 桌面适配 ---------- */
@media (min-width: 760px) {
  .game-wrap { max-width: 520px; }
  .board-inner { width: min(520px, calc(100vh - 236px)); }
  .lobby-wrap { max-width: 560px; }
}
