/* ========== 基础 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* 兼容层：历史上组件直接用这些名字。
   现在统一指向 themes.css 的主题令牌，换肤即整站生效。
   同名变量（--bg / --primary / --line）由 themes.css 的 [data-theme] 覆盖，
   这里的值只作「主题表未加载」时的兜底。 */
:root {
  --bg: var(--surface);
  --ink: var(--text, var(--text));
  --ink-2: var(--text-2, var(--text-2));
  --ink-3: var(--text-3, var(--text-3));
  --primary: var(--primary);
  --primary-dark: var(--primary-hover, var(--primary));
  --gold: var(--accent, var(--accent));
  --card: var(--surface, #ffffff);
  --card-2: var(--surface-2, var(--surface));
  --line: var(--line);
  --line-strong: var(--line-strong, var(--line-strong));
  --header: var(--header-bg, var(--text));
  --header-2: var(--header-bg-2, var(--text));
  --header-fg: var(--header-fg, #f3e7d3);
  --green: var(--success, var(--success));
  --red: var(--danger, var(--primary));
  --radius: var(--radius-md, 14px);
  --shadow: var(--shadow-md, 0 8px 28px rgba(var(--shadow-color), .1));
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; cursor: pointer; border: none; }
input { font-family: inherit; }

/* ========== 顶部导航 ========== */
.site-header {
  background: linear-gradient(135deg, var(--header), var(--header-2));
  color: var(--header-fg);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .25);
}
.header-inner {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--primary), var(--primary-hover));
  /* 关键：文字色固定用「主色对比色」，否则在赛博霓虹主题下
     会继承 --header-fg（同为青色），导致青字青底、logo 看不见。
     primary-contrast 是每个主题都配好的、压在主色上的可读色。 */
  color: var(--primary-contrast);
  display: grid;
  place-items: center;
  font-family: KaiTi, STKaiti, serif;
  font-size: 22px;
  font-weight: bold;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
.brand-name { font-size: 18px; font-weight: 600; letter-spacing: 1px; }

.nav-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.game-nav {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  scroll-behavior: smooth;
  padding: 3px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .3) transparent;
}
/* 被截断的部分保留可见细滚动条，避免用户误以为“显示不全” */
.game-nav::-webkit-scrollbar { height: 6px; }
.game-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .28);
  border-radius: 3px;
}
.game-nav::-webkit-scrollbar-track { background: transparent; }

/* 左右滚动箭头：仅在可滚动且未到边界时出现 */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 26px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: rgba(var(--shadow-color), .88);
  color: var(--header-fg);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.nav-arrow:hover { background: var(--primary); color: var(--primary-contrast); }
.nav-arrow:active { transform: translateY(-50%) scale(.94); }
.nav-arrow-left { left: 0; }
.nav-arrow-right { right: 0; }
.nav-wrap.can-left .nav-arrow-left { display: flex; }
.nav-wrap.can-right .nav-arrow-right { display: flex; }
/* 箭头出现时给导航两端留白，避免遮挡首个/末个游戏项 */
.nav-wrap.can-left .game-nav { padding-left: 30px; }
.nav-wrap.can-right .game-nav { padding-right: 30px; }

.nav-item {
  position: relative;
  flex: 0 0 auto;          /* 禁止压缩：放不下时换行/滚动，而不是把按钮挤变形 */
  background: transparent;
  color: var(--header-fg-2);
  font-size: 14px;
  padding: 7px 10px;
  border-radius: 9px;
  white-space: nowrap;
  transition: all .18s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-item:hover { color: var(--header-fg); background: rgba(255, 255, 255, .08); }
.nav-item.active {
  color: var(--primary-contrast);
  background: linear-gradient(145deg, var(--primary), var(--primary-hover));
  box-shadow: 0 3px 10px var(--ring);
}

/* ========== 视图切换 ========== */
.site-main { max-width: 1180px; margin: 0 auto; padding: 26px 18px 60px; }
.view { display: none; }
.view.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ========== 首页大厅 ========== */
.hero { text-align: center; padding: 18px 0 30px; }
.hero-title {
  font-family: KaiTi, STKaiti, serif;
  font-size: 42px;
  letter-spacing: 8px;
  color: var(--primary);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .06);
}
.hero-sub { margin-top: 10px; color: var(--ink-2); font-size: 15px; letter-spacing: 1px; }

/* ========== 一级首页：三个占满屏幕的大方框（参考小程序三宫格） ==========
 * 设计要点（对齐微信小游戏中心 / 主流小程序的启动页）：
 *   1. 手机上一屏刚好三块，拇指可达、无横向滚动；
 *   2. 每块用「大圆角 + 主色渐变 + 大图标」制造点击暗示；
 *   3. 全部用主题变量，切主题自动跟随。
 * 桌面端则把三块横排并限制最大宽度，避免出现过宽的巨型方块。 */
.mode-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 0 auto;
  max-width: 900px;
}
.mode-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  /* 手机上接近方形：视口高度按 100svh 分配，减去标题与安全区 */
  aspect-ratio: 1 / 1;
  min-height: 150px;
  padding: 18px 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  transition: transform .16s ease, box-shadow .16s ease;
}
/* 顶部彩条：点一下就知道「这是个可点的入口」 */
.mode-tile::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: var(--tile-accent, var(--primary));
}
.mode-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.mode-tile:active { transform: scale(.97); }
.mt-icon {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: KaiTi, STKaiti, serif;
  font-size: 30px;
  color: #fff;
  background: linear-gradient(145deg, var(--tile-accent, var(--primary)), var(--tile-accent-2, var(--primary-hover)));
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, .32), 0 6px 16px rgba(0, 0, 0, .16);
  flex: none;
}
.mt-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 2px;
}
.mt-desc {
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: .5px;
  text-align: center;
  line-height: 1.5;
  padding: 0 2px;
}
/* 角标：说明该模式有多少棋种可玩 */
.mt-count {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  color: var(--ink-2);
  background: var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  letter-spacing: .5px;
}
/* 三块各自的强调色，用 --tile-accent 覆盖。
 * --success 在木色主题偏灰绿，直接用会发闷，这里叠加 saturate 提亮并压深末端 */
.mode-tile.t-online { --tile-accent: var(--primary); --tile-accent-2: var(--primary-hover); }
.mode-tile.t-local  { --tile-accent: var(--success); --tile-accent-2: var(--primary); }
.mode-tile.t-ai     { --tile-accent: var(--info);    --tile-accent-2: var(--info-hover); }
.mode-tile.t-local .mt-icon { filter: saturate(1.45) brightness(1.06); }

/* ========== 二级页：选择棋类 ========== */
.view-pick.active { display: flex; flex-direction: column; }
.pick-head {
  position: relative;
  text-align: center;
  padding: 4px 0 18px;
}
.pick-title { font-size: 22px; color: var(--ink); letter-spacing: 3px; }
.pick-sub { margin-top: 6px; font-size: 13px; color: var(--ink-2); letter-spacing: .5px; }
.pick-back {
  position: absolute;
  left: 0;
  top: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.pick-back:active { transform: scale(.94); }
/* 三级页顶部的玩法切换标签 */
.mode-switch {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
.ms-btn {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
  letter-spacing: 1px;
  transition: all .15s ease;
}
.ms-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.ms-btn:disabled { opacity: .4; cursor: not-allowed; }
/* 棋类网格：手机 3 列 / 平板 4 列 / 桌面 5 列 */
.pick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-bottom: 24px;
}
.pick-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 6px;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .14s ease;
}
.pick-cell:active { transform: scale(.95); }
.pc-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: KaiTi, STKaiti, serif;
  font-size: 22px;
  color: #fff;
  background: linear-gradient(145deg, var(--primary), var(--primary-hover));
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, .28);
  flex: none;
}
.pc-name { font-size: 13px; color: var(--ink); letter-spacing: .5px; text-align: center; line-height: 1.3; }

/* 手机：三块改为纵向平铺，每块横向铺满，占满一屏 */
@media (max-width: 560px) {
  .hero { padding: 10px 0 16px; }
  .hero-title { font-size: 30px; letter-spacing: 5px; }
  .hero-sub { font-size: 13px; margin-top: 6px; }
  .mode-tiles {
    grid-template-columns: 1fr;      /* 纵向三块，每块占满屏宽 */
    gap: 14px;
    max-width: none;
    /* 三块平分首屏剩余高度：减去标题区与底部 Tab，避免下半屏大片留白 */
    min-height: calc(100svh - 230px);
    grid-auto-rows: 1fr;
  }
  .mode-tile {
    aspect-ratio: auto;
    min-height: 104px;
    flex-direction: row;           /* 横向：图标在左，文字在右，更省竖向空间 */
    justify-content: flex-start;
    gap: 16px;
    padding: 20px 18px;
    border-radius: 18px;
    text-align: left;
  }
  .mt-icon { width: 58px; height: 58px; font-size: 28px; }
  .mt-title { font-size: 19px; }
  .mt-desc { text-align: left; font-size: 12px; }
  .mt-count { top: 50%; transform: translateY(-50%); right: 14px; }
  .pick-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .pick-title { font-size: 19px; }
}
/* 矮屏（iPhone SE 等）：三块不强制平分高度，避免每块被压得太扁 */
@media (max-width: 560px) and (max-height: 700px) {
  .mode-tiles { min-height: 0; grid-auto-rows: auto; }
  .mode-tile { min-height: 92px; }
}
@media (min-width: 900px) {
  .pick-grid { grid-template-columns: repeat(5, 1fr); }
}
/* 桌面端三块横排，但限制高度避免巨型方块 */
@media (min-width: 561px) {
  .mode-tile { aspect-ratio: auto; height: 190px; }
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 8px;
}
.mode-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px 26px;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.mode-card:hover { transform: translateY(-3px); transition: transform .2s; }
.mode-card .mode-icon.ai-icon {
  background: linear-gradient(145deg, var(--info), var(--info-hover));
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, .3), 0 4px 10px rgba(63, 95, 176, .32);
}
.mode-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: KaiTi, STKaiti, serif;
  font-size: 26px;
  color: #fff;
  background: linear-gradient(145deg, #d9a347, #b97a1d);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, .3), 0 4px 10px rgba(185, 122, 29, .3);
}
.mode-card h2 { font-size: 19px; }
.mode-card p { font-size: 13.5px; color: var(--ink-2); line-height: 1.7; min-height: 44px; }

.field { width: 100%; }
.field input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
  background: var(--surface);
}
.field input:focus { border-color: var(--gold); }

.btn {
  padding: 10px 22px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  transition: transform .14s ease, box-shadow .14s ease, background .15s, filter .15s, color .15s;
  border: 1px solid var(--line);
  cursor: pointer;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.14); filter: none; }
.btn:active { transform: translateY(0) scale(.96); }
.btn:focus-visible { outline: 2.5px solid var(--gold); outline-offset: 2px; }
.btn-primary {
  background: linear-gradient(145deg, var(--primary), var(--primary-hover));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px var(--ring);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px var(--ring); }
.btn-primary:active { transform: translateY(0) scale(.96); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,.05); }
.btn-small { padding: 7px 14px; font-size: 13.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.mode-card .btn { width: 100%; margin-top: 2px; }

/* 按钮 loading 态（spinner + 隐藏文字） */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; opacity: 1 !important; }
.btn.is-loading::after {
  content: ''; position: absolute; top: 50%; left: 50%; width: 16px; height: 16px;
  margin: -8px 0 0 -8px; border: 2px solid rgba(255,255,255,.55); border-top-color: #fff;
  border-radius: 50%; animation: btnSpin .7s linear infinite;
}
.btn.is-loading.is-dark::after { border-color: rgba(0,0,0,.2); border-top-color: var(--ink); }
@keyframes btnSpin { to { transform: rotate(360deg); } }

/* 错误抖动 */
.btn.is-error, .shaker { animation: shakeX .4s ease; }
@keyframes shakeX { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-6px)} 40%,80%{transform:translateX(6px)} }

/* ========== 等待页 ========== */
.waiting-box {
  max-width: 520px;
  margin: 30px auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 38px 34px 30px;
  text-align: center;
}
.waiting-box h2 { font-size: 20px; margin-bottom: 22px; }
.room-code {
  font-size: 54px;
  font-weight: 700;
  letter-spacing: 12px;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 2px dashed #e0c387;
  border-radius: 12px;
  padding: 10px 0 10px 12px;
  margin-bottom: 8px;
}
.wait-tip { color: var(--ink-2); font-size: 14px; margin-bottom: 18px; }
.invite-link { display: flex; gap: 8px; margin-bottom: 26px; }
.invite-link input {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink-2);
  min-width: 0;
}
.wait-players { text-align: left; margin-bottom: 20px; }
.wait-seat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 15px;
}
.seat-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.seat-dot.red { background: var(--primary); }
.seat-dot.black { background: #3a3a3a; }
.seat-dot.yellow { background: var(--accent); }
.seat-dot.green { background: #3f8f5a; }
.seat-dot.purple { background: #7d5ba6; }
.seat-dot.blue { background: #3a72b8; }
.seat-dot.orange { background: #d97a26; }
.seat-dot.cyan { background: #2f9aa8; }
.seat-dot.pink { background: #c75b8a; }
.seat-dot.brown { background: #8a6242; }
.seat-dot.lime { background: #7aa32b; }
.seat-dot.teal { background: #2b8078; }
.seat-state { margin-left: auto; font-size: 12.5px; color: var(--ink-2); }
.seat-state.ready { color: var(--green); }
.seat-state.ok { color: var(--green); font-weight: 600; }

/* 4 人以上社交局的座位列表（狼人杀 6-12 / 三国杀 3-8） */
.wait-seat-list { margin-top: 10px; }
.wait-seat-list .wait-seat { padding: 9px 12px; font-size: 14px; margin-bottom: 6px; }
.wait-seat-list .wait-seat.on { border-color: rgba(63, 143, 90, .5); background: #f4fbf6; }
.wait-seat-list .wsl-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 560px) {
  .wait-seat-list { display: grid !important; grid-template-columns: 1fr 1fr; gap: 6px; }
  .wait-seat-list .wait-seat { margin-bottom: 0; font-size: 13px; padding: 8px 10px; }
}
.wait-loading { color: var(--ink-2); font-size: 13.5px; margin-bottom: 18px; }

/* ========== 好友约战总大厅 ========== */
.roomlobby-box {
  max-width: 660px;
  margin: 30px auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 30px 26px;
  text-align: center;
}
.roomlobby-box h2 { font-size: 20px; margin-bottom: 18px; }
.rl-grid-title { margin: 2px 0 12px; font-size: 15px; color: var(--ink); text-align: left; }
.game-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.game-tile {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 14px 6px 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s, transform .15s, box-shadow .15s;
}
.game-tile:hover { border-color: var(--primary); background: var(--surface); transform: translateY(-1px); }
.game-tile .tile-icon {
  width: 42px; height: 42px;
  margin: 0 auto 7px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--primary), var(--primary-hover));
  color: var(--primary-contrast);
  font-size: 20px;
  font-weight: 700;
}
.game-tile .tile-name { font-size: 13.5px; color: var(--ink); }
.game-tile.selected {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 2px rgba(201, 74, 50, .18);
}
.game-tile.selected .tile-name::after { content: ' · 待开局'; color: var(--primary); font-size: 12px; }
/* 人数未满的棋种：可见但置灰，点击后服务端会给出补人提示 */
.game-tile.dim { opacity: .5; }
.game-tile.dim:hover { border-color: var(--line); background: var(--surface); transform: none; }
.game-tile .tile-need { margin-top: 4px; font-size: 11.5px; color: var(--ink-2); }
@media (max-width: 560px) {
  .game-grid { grid-template-columns: repeat(3, 1fr); }
  .roomlobby-box { padding: 20px 14px 16px; margin: 18px auto; }
  .roomlobby-box h2 { font-size: 17px; margin-bottom: 12px; }
  .game-grid { gap: 8px; margin-bottom: 10px; }
  .game-tile { padding: 10px 4px 9px; border-radius: 10px; }
  .game-tile .tile-icon { width: 34px; height: 34px; font-size: 17px; margin-bottom: 5px; }
  .game-tile .tile-name { font-size: 12.5px; }
}

/* ===== 手机端紧凑化（大厅首屏）===== */
@media (max-width: 560px) {
  /* 首屏标题与副标题再收一档，减少占位 */
  .hero { padding: 4px 0 10px; }
  .hero-title { font-size: 25px; letter-spacing: 3px; }
  .hero-sub { font-size: 12px; margin-top: 4px; }
  /* 模式卡改横向紧凑头部：图标左、标题右、说明通栏、按钮/选项通栏
     —— 替代原「全部纵向居中堆叠」，单卡高度约省 1/4~1/3 */
  .mode-card {
    display: grid;
    grid-template-columns: 44px 1fr;
    grid-template-areas:
      "icon title"
      "desc desc"
      "btn  btn"
      "opts opts";
    gap: 5px 12px;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    text-align: left;
  }
  .mode-card .mode-icon,
  .mode-icon { grid-area: icon; width: 44px; height: 44px; font-size: 20px; }
  .mode-card h2 { grid-area: title; font-size: 16.5px; margin: 0; justify-self: start; }
  .mode-card p { grid-area: desc; font-size: 12px; line-height: 1.5; margin: 0; min-height: 0; }
  .mode-card .btn { grid-area: btn; }
  .mode-card .lobby-options { grid-area: opts; gap: 7px; }
  /* 输入框与按钮略降高度（仍 ≥44px 保触控） */
  .field input, .invite-link input { min-height: 42px; padding: 9px 12px; }
  .btn { min-height: 44px; padding: 9px 18px; }
  /* 约战大厅卡片内边距 */
  .mode-cards { gap: 10px; }
}

/* ========== 对局页 ========== */
.game-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.game-bar-info { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.mode-badge {
  background: linear-gradient(145deg, var(--primary), var(--primary-hover));
  color: var(--primary-contrast);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12.5px;
}
.mode-badge.local { background: linear-gradient(145deg, #4f8a57, #35683c); }
.mode-badge.spec { background: linear-gradient(145deg, #6c6a8f, #4a4870); }
.mode-badge.ai { background: linear-gradient(145deg, var(--info), var(--info-hover)); }
.spectators-box {
  background: #faf7ee;
  border: 1px dashed #c9b98a;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: #6b5a32;
  line-height: 1.5;
}
.spec-title { font-weight: 600; margin-right: 6px; }
.spec-names { color: #8a7540; }
.room-no { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.conn-state { font-size: 13px; color: var(--ink-2); }
.conn-state.offline { color: #c62828; font-weight: 600; }
.conn-state.online { color: var(--green); }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
}
.board-wrap {
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .6);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
#boardCanvas {
  border-radius: 8px;
  touch-action: none;            /* 拖动落子时禁止页面滚动抢占手势 */
  cursor: grab;                  /* 提示可拖拽棋子 */
  box-shadow: 0 6px 18px rgba(80, 50, 20, .18);
}
.turn-banner {
  align-self: stretch;
  text-align: center;
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 600;
  padding: 9px;
  border-radius: 10px;
  background: #f6ecda;
  color: var(--ink);
  letter-spacing: 2px;
}
.turn-banner.red { background: #fae7e2; color: var(--primary); }
.turn-banner.black { background: #ececec; color: #222; }
.turn-banner.wait { background: #f3f3f3; color: var(--ink-2); font-weight: 400; letter-spacing: 0; }
.turn-banner.thinking { background: linear-gradient(145deg, #e6edff, #d4e0ff); color: var(--info); font-weight: 600; letter-spacing: 1px; animation: aiThinkingPulse 1.1s ease-in-out infinite; }
@keyframes aiThinkingPulse { 0%, 100% { opacity: 1; } 50% { opacity: .62; } }

.side-panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.players-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#rowBlack { order: 1; }
.vs-divider { order: 2; }
#rowRed { order: 3; }
.players-card.flipped #rowRed { order: 1; }
.players-card.flipped #rowBlack { order: 3; }
.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}
.player-row.active { background: #fbf3e2; }
.player-row.lost { opacity: .55; }
.p-piece {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: KaiTi, STKaiti, serif;
  font-size: 22px;
  font-weight: bold;
  background: radial-gradient(circle at 35% 30%, #fff7e3, #e3c68d);
  border: 1.5px solid #b08a4e;
  flex-shrink: 0;
}
.p-piece.red { color: var(--primary); }
.p-piece.black { color: #262626; }
.p-piece.white {
  color: #1a1a1a;
  background: radial-gradient(circle at 35% 30%, #ffffff, #d8d8d8);
  border-color: #9a9a9a;
}
.p-piece.yellow { color: #7a5a00; background: radial-gradient(circle at 35% 30%, #ffe98a, #e0b82f); border-color: #b8901a; }
.p-piece.blue { color: #123a73; background: radial-gradient(circle at 35% 30%, #9fc4f5, #3f74c4); border-color: #2c5699; }
.p-piece.green { color: #14502a; background: radial-gradient(circle at 35% 30%, #a6e0b2, #3da05f); border-color: #2b7a45; }

.lobby-options { width: 100%; display: flex; flex-direction: column; gap: 10px; }
#cardCreate .local-only { display: none; } /* 联机建房固定双人，隐藏仅本机有效的选项（如飞行棋人数） */
.action-row + .action-row { margin-top: 8px; }
.p-meta { min-width: 0; flex: 1; }
.p-name { font-size: 15.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-status { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.p-tag { font-size: 12px; color: var(--primary); font-weight: 600; flex-shrink: 0; }
.vs-divider {
  text-align: center;
  font-size: 12px;
  color: #a7926a;
  letter-spacing: 4px;
  padding: 6px 0;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
  background: var(--surface);
}

.action-row { display: flex; gap: 8px; }
.action-row .btn { flex: 1; }

.chat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-title {
  padding: 11px 15px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.chat-log {
  height: 200px;
  overflow-y: auto;
  padding: 10px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13.5px;
}
.chat-msg { line-height: 1.5; word-break: break-all; }
.chat-msg .chat-name { color: var(--primary); font-weight: 600; margin-right: 4px; }
.chat-msg.me .chat-name { color: var(--green); }
.chat-msg.system { color: var(--ink-2); font-size: 12.5px; text-align: center; }
.chat-input { display: flex; gap: 6px; padding: 9px; border-top: 1px solid var(--line); }
.chat-input input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 13.5px;
  outline: none;
  background: var(--surface);
}
.chat-input input:focus { border-color: var(--gold); }

/* ========== 敬请期待 ========== */
.view-soon { display: none; }
.view-soon.active { display: flex; }
.soon-box {
  margin: 70px auto;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 54px 36px;
  max-width: 480px;
}
.soon-icon {
  font-size: 58px;
  color: var(--gold);
  margin-bottom: 14px;
  font-family: KaiTi, serif;
}
.soon-box h2 { font-size: 26px; margin-bottom: 12px; letter-spacing: 3px; }
.soon-box p { color: var(--ink-2); margin-bottom: 24px; line-height: 1.8; }

/* ========== Toast & Modal ========== */
.toast-wrap {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none; /* 让 toast 不遮挡其下按钮（toast 自身仍可点击关闭） */
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--header-bg);
  color: var(--header-fg);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  animation: toastIn .25s ease;
  max-width: 86vw;
  text-align: center;
}
.toast.success { background: rgba(46, 125, 50, .95); }
.toast.error { background: rgba(198, 40, 40, .95); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(30, 22, 12, .5);
  display: grid;
  place-items: center;
  z-index: 900;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, visibility .2s ease, backdrop-filter .2s ease;
  -webkit-backdrop-filter: blur(0);
  backdrop-filter: blur(0);
}
.modal-mask.show { opacity: 1; visibility: visible; pointer-events: auto; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 30px 30px 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  animation: modalIn .22s ease;
  max-height: 85vh;
  overflow-y: auto;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.modal h2 { font-size: 22px; margin-bottom: 12px; }
.modal p { color: var(--ink-2); font-size: 14.5px; line-height: 1.7; margin-bottom: 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions .btn { flex: 1; max-width: 150px; }

/* ========== 局时 / 难度 / 执子选择 ========== */
.field select.time-select,
.field select.opt-select,
.field select.ai-side,
.field select.ai-level {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%238a7450' stroke-width='1.8' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.field select.time-select:focus { border-color: var(--gold); }
.wait-time { font-size: 13.5px; color: var(--ink-2); margin-bottom: 6px; }

/* ========== 声音按钮 ========== */
.sound-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .08);
  font-size: 18px;
  cursor: pointer;
  transition: background .15s, transform .15s;
  display: grid;
  place-items: center;
}
.sound-btn:hover { background: rgba(255, 255, 255, .18); }
.sound-btn:active { transform: scale(.92); }
.sound-btn.muted { opacity: .55; }

/* 对局页侧栏抽屉开关：桌面隐藏，仅手机显示（见 ≤560 媒体查询） */
.panel-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 10px;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--primary), var(--primary-hover));
  color: var(--primary-contrast);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  box-shadow: 0 4px 14px var(--ring);
  cursor: pointer;
}
.panel-toggle:active { transform: scale(.98); }
.panel-toggle .pt-chev { transition: transform .2s ease; }
.view-game.show-panel .panel-toggle .pt-chev { transform: rotate(180deg); }

/* ========== 手机端重构组件（桌面全部隐藏，由 ≤720px 媒体查询启用） ========== */

/* 顶栏操作区容器：桌面行为与原来一致（flex 直接子项） */
.header-actions { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }

/* 当前棋种胶囊：桌面隐藏，手机端替代 13 个平铺按钮 */
.game-picker-trigger {
  display: none;
  align-items: center;
  gap: 5px;
  max-width: 42vw;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .26);
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.game-picker-trigger:active { transform: scale(.97); }
.gp-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-caret { font-size: 11px; opacity: .8; flex-shrink: 0; }

/* 游戏选择抽屉：默认隐藏（桌面完全不用） */
.game-sheet { display: none; }
.gs-mask {
  position: fixed; inset: 0; z-index: 998;
  background: rgba(30, 22, 12, .5);
  opacity: 0; transition: opacity .22s ease;
}
.game-sheet.show .gs-mask { opacity: 1; }
.gs-panel {
  position: fixed; left: 0; right: 0; top: 0; z-index: 999;
  background: linear-gradient(160deg, var(--text), var(--text));
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  padding: 8px 14px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(-100%);
  transition: transform .26s cubic-bezier(.32, .72, 0, 1);
  max-height: 82vh; overflow-y: auto;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .45);
}
.game-sheet.show .gs-panel { transform: none; }
.gs-grip { width: 38px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.3); margin: 4px auto 10px; }
.gs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.gs-title { color: var(--surface-2); font-size: 16px; font-weight: 600; letter-spacing: 2px; }
.gs-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255, 255, 255, .12); color: var(--surface-2); font-size: 15px;
  display: grid; place-items: center; cursor: pointer;
}
.gs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gs-item {
  padding: 13px 6px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .06);
  color: var(--surface-2);
  font-size: 13.5px;
  text-align: center;
  cursor: pointer;
  transition: transform .12s, background .15s;
  min-height: 46px;
}
.gs-item:active { transform: scale(.95); }
.gs-item.active {
  background: linear-gradient(145deg, var(--primary), var(--primary-hover));
  border-color: transparent;
  box-shadow: 0 3px 10px var(--ring);
  font-weight: 600;
}

/* 对局页「更多工具」按钮：桌面隐藏 */
.tools-more {
  display: none;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, .12);
  background: transparent;
  color: var(--ink);
  font-size: 20px; line-height: 1;
  cursor: pointer;
}

/* 侧栏抽屉抓手 / 遮罩：桌面隐藏 */
.panel-grip { display: none; }
.panel-scrim {
  position: fixed; inset: 0; z-index: 798;
  background: rgba(30, 22, 12, .45);
  opacity: 0; transition: opacity .24s ease;
}
.view-game.show-panel .panel-scrim { opacity: 1; }

/* 对局页固定底部操作条：桌面隐藏 */
.game-dock { display: none; }

/* 全局底部 Tab 栏：桌面隐藏 */
.tabbar { display: none; }

/* ========== 对局时钟 ========== */
.p-clock {
  flex-shrink: 0;
  min-width: 68px;
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  padding: 5px 10px;
  border-radius: 8px;
  background: #f4ede0;
  border: 1.5px solid var(--line);
  color: #5c4a30;
  transition: all .2s;
}
.player-row.active .p-clock {
  border-color: var(--gold);
  background: #fff8e8;
  box-shadow: 0 0 0 2px rgba(201, 154, 70, .18);
}
.p-clock.warn {
  color: #c7771a;
  border-color: #e0a24b;
}
.p-clock.danger {
  color: #fff;
  background: #c93b26;
  border-color: var(--primary);
  animation: clock-blink 1s ease-in-out infinite;
}
@keyframes clock-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

/* ========== 响应式 ========== */
@media (max-width: 900px) {
  .mode-cards { grid-template-columns: 1fr; max-width: 460px; margin-left: auto; margin-right: auto; }
  .game-layout { grid-template-columns: 1fr; }
  .side-panel { order: 2; }
  .chat-log { height: 160px; }
}

@media (max-width: 720px) {
  /* ============ 手机端整体骨架 ============
     布局重排：顶栏压成单行胶囊 + 棋种抽屉；底部固定 Tab 栏（拇指热区）；
     对局页棋盘占满剩余高度，工具收进「更多」，侧栏改为底部抽屉。 */

  /* ---- 顶栏：单行，只留品牌 + 当前棋种 + 图标操作 ---- */
  .header-inner {
    flex-wrap: nowrap;
    height: 54px;
    min-height: 54px;
    padding: 0 10px;
    gap: 8px;
  }
  .brand { order: 1; flex: 0 0 auto; }
  .brand-name { display: none; }
  .brand-mark { width: 32px; height: 32px; font-size: 18px; }

  /* 13 个棋种不再平铺：顶栏隐藏横向导航，改由胶囊触发抽屉 */
  .nav-wrap { display: none; }
  .game-picker-trigger { display: flex; order: 2; flex: 1 1 auto; min-width: 0; justify-content: center; }
  .header-actions { order: 3; gap: 6px; }
  /* 启用棋种抽屉容器（基础样式为 display:none，桌面不渲染） */
  .game-sheet { display: block; }
  .game-sheet[hidden] { display: none; }

  /* 顶栏文字按钮图标化：只留符号，避免中文挤压 */
  .header-actions .header-btn {
    width: 38px; height: 38px;
    padding: 0; border-radius: 10px;
    display: grid; place-items: center;
    font-size: 0;                 /* 隐藏中文，仅留 ::after 图标 */
    border-color: rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
    position: relative;           /* 供「我的」头像图标定位用 */
  }
  .header-actions .header-btn::after { font-size: 17px; line-height: 1; }
  #btnRecords::after { content: '\1F4CB'; }   /* 战绩 */
  #btnRanking::after { content: '\1F3C6'; }  /* 排行 */
  #btnRules::after { content: '\1F4D6'; }    /* 规则（书本） */
  /* 「我的」用 CSS 绘制头像，避免 emoji 在部分设备缺字形显示成方框 */
  #btnProfile::after {
    content: '';
    width: 15px; height: 15px;
    border-radius: 50%;
    border: 1.6px solid currentColor;
    position: relative;
  }
  #btnProfile::before {
    content: '';
    position: absolute;
    left: 50%; top: 54%;
    width: 8px; height: 5px;
    transform: translateX(-50%);
    border-radius: 5px 5px 0 0;
    background: currentColor;
  }
  .header-btn.signed { border-color: var(--header-accent); color: var(--header-accent); }
  .sound-btn { width: 38px; height: 38px; padding: 0; font-size: 17px; }

  /* 主内容：底部留出 Tab 栏高度 + 安全区 */
  .site-main { padding: 12px 10px calc(74px + env(safe-area-inset-bottom)); }
  .hero { padding: 6px 0 14px; }
  .hero-title { font-size: 28px; letter-spacing: 4px; }
  .hero-sub { font-size: 12.5px; letter-spacing: 0; margin-top: 6px; }

  /* ---- 底部固定 Tab 栏 ---- */
  .tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 700;
    background: rgba(44, 36, 24, .97);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, .1);
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
    box-shadow: 0 -3px 16px rgba(0, 0, 0, .22);
  }
  .tab-item {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 4px 2px;
    background: transparent; color: var(--line-strong);
    font-size: 10.5px;
    border-radius: 10px;
    min-height: 48px;
    cursor: pointer;
    transition: color .15s, background .15s;
  }
  .tab-ico { font-size: 19px; line-height: 1.1; }
  /* 「我的」图标同样用 CSS 绘制，规避 emoji 缺字形 */
  .tab-ico-user {
    position: relative;
    width: 17px; height: 17px;
    border-radius: 50%;
    border: 1.6px solid currentColor;
  }
  .tab-ico-user::after {
    content: '';
    position: absolute; left: 50%; top: 55%;
    width: 9px; height: 5.5px;
    transform: translateX(-50%);
    border-radius: 5px 5px 0 0;
    background: currentColor;
  }
  .tab-item.active { color: var(--primary-contrast); background: var(--primary); }
  .tab-item:active { transform: scale(.94); }
  /* 对局页隐藏 Tab 栏，把竖向空间全留给棋盘 */
  body.in-game .tabbar { display: none; }

  /* ---- 大厅：卡片单列紧凑 ---- */
  .mode-cards { grid-template-columns: 1fr; gap: 12px; }
  .mode-card { padding: 16px 14px; gap: 9px; }
  .mode-icon { width: 46px; height: 46px; font-size: 21px; }
  .mode-card h2 { font-size: 17px; }
  .mode-card p { font-size: 12.5px; min-height: 0; line-height: 1.6; }
  .lobby-options { gap: 8px; }
  /* 输入框 16px：避免 iOS 聚焦自动放大页面 */
  .field input, .invite-link input { font-size: 16px; min-height: 44px; }
  .btn { min-height: 46px; }

  /* 主按钮提到选项区之前：狼人杀/三国杀卡片含人数+规则下拉，
     按钮原本被推到首屏之外（实测 top 832 > 视口 844），用户点不到。
     用 order 重排：图标 → 标题 → 说明 → 主按钮 → 选项，不改 HTML/JS 契约。 */
  .mode-card .mode-icon { order: 0; }
  .mode-card h2 { order: 0; }
  .mode-card p { order: 0; }
  .mode-card .btn { order: 1; }
  .mode-card .lobby-options { order: 2; }

  /* ---- 对局页：棋盘占满 + 固定底部操作条 ---- */
  .game-bar { margin-bottom: 8px; gap: 6px; }
  .game-bar-info { gap: 6px; font-size: 12px; }
  .mode-badge { font-size: 11px; padding: 3px 9px; }
  .btn-small { padding: 8px 12px; font-size: 13px; min-height: 40px; }
  /* 桌面三个工具按钮在手机端收进「更多」 */
  .game-bar-tools { display: none; }
  .tools-more { display: grid; place-items: center; }
  .view-game.tools-open .game-bar-tools {
    display: flex;
    position: absolute; right: 10px; top: 46px; z-index: 60;
    flex-direction: column; gap: 6px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px;
    box-shadow: var(--shadow);
  }

  .game-layout {
    grid-template-columns: 1fr;
    gap: 10px;
    /* 棋盘区撑满视口剩余高度，棋盘垂直居中吃掉多余留白 */
    min-height: calc(100dvh - 190px - env(safe-area-inset-bottom));
    align-content: center;
  }
  .board-wrap { padding: 6px; border-radius: 10px; justify-content: center; }
  .turn-banner { font-size: 13px; padding: 5px 7px; margin-bottom: 6px; border-radius: 8px; }

  /* 侧栏抽屉：从底部滑出，覆盖棋盘，不占文档流 */
  .panel-toggle { display: none; }
  .view-game .side-panel {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 799;
    max-height: 76dvh;
    overflow-y: auto;
    background: var(--bg);
    border-top-left-radius: 18px; border-top-right-radius: 18px;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .3);
    padding: 0 12px calc(16px + env(safe-area-inset-bottom));
    gap: 12px;
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.32, .72, 0, 1);
    order: 3;
  }
  .view-game.show-panel .side-panel { transform: none; }
  .panel-scrim { display: block; }
  .panel-grip {
    display: block;
    position: sticky; top: 0; z-index: 2;
    width: 100%; height: 22px;
    background: var(--bg);
    display: grid; place-items: center;
  }
  .panel-grip::after {
    content: ''; width: 40px; height: 4px; border-radius: 2px;
    background: rgba(0, 0, 0, .18);
  }
  .panel-scrim[hidden] { display: none; }

  /* 固定底部操作条：拇指热区 */
  .game-dock {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 750;
    gap: 8px;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -3px 16px rgba(var(--shadow-color), .12);
  }
  .dock-btn {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    min-height: 50px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 11px; font-weight: 600;
    cursor: pointer;
    transition: transform .12s, background .15s;
  }
  .dock-btn:active { transform: scale(.95); }
  .dk-ico { font-size: 17px; line-height: 1; }
  .dock-primary {
    background: linear-gradient(145deg, var(--primary), var(--primary-hover));
    border-color: transparent; color: var(--primary-contrast);
    box-shadow: 0 3px 10px var(--ring);
  }
  /* 对局页隐藏 Tab 栏后，底部空间由操作条占据 */
  body.in-game .site-main { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }

  /* 抽屉内元素紧凑化 */
  .player-row { padding: 9px 12px; gap: 9px; }
  .p-piece { width: 34px; height: 34px; font-size: 18px; }
  .p-name { font-size: 13.5px; }
  .p-status { font-size: 11.5px; }
  .p-clock { font-size: 15px !important; padding: 3px 8px !important; }
  .side-panel { gap: 10px; }
  .action-row { gap: 8px; }
  .action-row .btn, .action-row button { min-height: 44px; padding: 9px 6px; font-size: 14px; white-space: nowrap; }
  .chat-log { height: 130px; font-size: 13px; }
  .chat-input { padding: 8px; }
  .chat-input input { font-size: 16px; min-height: 44px; padding: 9px 12px; }
  .chat-input .btn { min-height: 44px; padding: 8px 14px; }

  /* ---- 等待页 / 约战大厅 ---- */
  .room-code { font-size: 38px; letter-spacing: 6px; }
  .waiting-box, .roomlobby-box { padding: 22px 16px 18px; margin: 14px auto; }
  .wait-seat { font-size: 13.5px; }
  .game-grid { grid-template-columns: repeat(3, 1fr); }

  /* ---- 弹层：窄屏贴边全屏，表单更好填 ---- */
  .modal-mask { padding: 0; }
  .modal {
    max-width: none; width: 100%; height: 100%;
    max-height: none; border-radius: 0;
    padding: calc(22px + env(safe-area-inset-top)) 18px calc(22px + env(safe-area-inset-bottom));
  }
  .modal h2 { font-size: 19px; }
  .modal p { font-size: 14px; margin-bottom: 18px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 45%; max-width: none; min-height: 46px; }
  .field-input { font-size: 16px; }

  /* 敬请期待 */
  .soon-box { margin: 30px auto; padding: 34px 20px; }
  .soon-icon { font-size: 44px; }
  .soon-box h2 { font-size: 21px; letter-spacing: 2px; }
}

/* 斗地主样式见文件末尾完整区块 */


/* ==================== 斗地主（真实扑克风） ==================== */
.player-row.won { background: #e8f6e4; box-shadow: inset 3px 0 0 #3da05f; }

.board-wrap.ddz-wrap {
  padding: 10px;
  border-radius: 12px;
  min-height: 580px;
  background:
    radial-gradient(ellipse 90% 70% at 50% 42%, rgba(255,255,255,.10), transparent 60%),
    radial-gradient(ellipse at center, #15653f 0%, #0c4a2d 55%, #07331f 100%);
  box-shadow: inset 0 0 60px rgba(0,0,0,.45);
}
.ddz-root {
  position: relative; width: 100%; height: 580px;
  display: flex; flex-direction: column;
  color: #f3f7f3; font-size: 14px;
}

/* ---------- 顶部：两名对手 ---------- */
.ddz-top { display: flex; justify-content: space-between; align-items: flex-start; padding: 2px 14px 0; position: relative; min-height: 158px; }
.ddz-opponent { width: 210px; text-align: center; }
.ddz-opp-name {
  display: inline-block; font-weight: bold; font-size: 13.5px; letter-spacing: .5px;
  background: rgba(0,0,0,.32); padding: 3px 14px; border-radius: 20px;
  border: 1px solid rgba(255,255,255,.18); margin-bottom: 3px;
}
.ddz-opp-count { font-size: 12px; opacity: .9; margin-bottom: 2px; }
.ddz-hand-back { position: relative; height: 66px; margin: 4px auto 0; width: 150px; }
.ddz-play-area { min-height: 64px; margin-top: 2px; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; }

/* 牌背：白边 + 深红菱格 + 中心徽章 */
.ddz-card-back {
  position: absolute; top: 0; width: 30px; height: 44px;
  border-radius: 5px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,238,170,.28) 0 22%, transparent 24%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.10) 0 3px, transparent 3px 7px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.10) 0 3px, transparent 3px 7px),
    linear-gradient(140deg, #c62838 0%, #961524 55%, #7c0f1c 100%);
  background-color: #a41b2a;
  border: 2px solid #f4efe3;
  box-shadow: 0 2px 4px rgba(0,0,0,.45), inset 0 0 0 1px rgba(0,0,0,.25);
}
.ddz-card-back::before {
  content: ''; position: absolute; inset: 4px;
  border: 1px solid rgba(255,238,170,.65); border-radius: 3px;
}
.ddz-card-back::after {
  content: '★'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #f3d577; font-size: 12px; text-shadow: 0 1px 1px rgba(0,0,0,.5);
}

/* ---------- 底牌 ---------- */
.ddz-bottom-cards {
  position: absolute; top: 4px; left: 50%; transform: translateX(-50%);
  font-size: 12px; display: flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,.28); padding: 4px 10px; border-radius: 10px;
}
.ddz-bottom-label { opacity: .9; }

/* ---------- 中央出牌区 ---------- */
.ddz-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 4px 0; min-height: 130px; }
.ddz-last-play { text-align: center; min-height: 96px; }
.ddz-last-meta { font-size: 12px; opacity: .85; margin-bottom: 4px; letter-spacing: .5px; }
.ddz-last-cards { display: flex; justify-content: center; }

/* 「不要」小标签：桌面牌保留期间，标记选择不要的各家 */
.ddz-pass-chips { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: 22px; margin-top: 4px; }
.ddz-pass-chip {
  display: inline-block; background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.28); color: #ffe8c9;
  padding: 2px 12px; border-radius: 12px; font-size: 12px; letter-spacing: .5px;
  animation: ddz-fade .2s ease both;
}

/* 棋盘中央操作栏：出牌 / 不要 / 提示（大号触控按钮 + 快捷键提示） */
.ddz-act-bar { display: flex; justify-content: center; align-items: center; gap: 12px; min-height: 52px; }
.ddz-act-btn {
  position: relative; min-width: 104px; min-height: 48px;
  border: none; border-radius: 12px; cursor: pointer;
  font-size: 17px; font-weight: bold; letter-spacing: 2px; color: #fff;
  padding: 8px 18px; box-shadow: 0 3px 10px rgba(0,0,0,.35);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
}
.ddz-act-btn:active { transform: translateY(2px); box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.ddz-act-btn b {
  display: block; margin-top: 1px; font-size: 10.5px; font-weight: normal;
  letter-spacing: .5px; opacity: .75;
}
.ddz-act-btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.ddz-act-play { background: linear-gradient(135deg, #f5b73e, #d98a16); color: #3a2200; }
.ddz-act-play b { color: rgba(58,34,0,.75); }
.ddz-act-pass { background: linear-gradient(135deg, #7d828f, #5b5f6b); }
.ddz-act-hint { background: linear-gradient(135deg, #4f8a57, #376b3f); }

/* ---------- 叫分 ---------- */
.ddz-bid-bar { background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.15); border-radius: 12px; padding: 12px 22px; text-align: center; }
.ddz-bid-title { margin-bottom: 8px; font-weight: bold; }
.ddz-bid-btns { display: flex; gap: 8px; justify-content: center; margin-bottom: 7px; }
.ddz-bid-log { font-size: 12px; opacity: .85; }

/* ---------- 底部自己 ---------- */
.ddz-bottom { padding: 6px 12px 2px; }
.ddz-me-info { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.ddz-me-name { font-weight: bold; font-size: 14px; }
.ddz-me-count { font-size: 12px; opacity: .85; }
.ddz-role-tag { padding: 1px 9px; border-radius: 10px; font-size: 12px; letter-spacing: 1px; }
.ddz-role-tag.landlord { background: linear-gradient(135deg,#f6d365,#e0a82e); color: #4a2f00; font-weight: bold; }
.ddz-role-tag.peasant { background: linear-gradient(135deg,#5b9bd5,#3a6ea5); color: #fff; }
.ddz-my-hand { display: flex; justify-content: center; align-items: flex-start; flex-wrap: nowrap; min-height: 92px; padding-top: 4px; }

/* ---------- 真实扑克牌 ---------- */
.ddz-card {
  position: relative; display: inline-block; flex: 0 0 auto;
  border-radius: 6px; overflow: hidden;
  background:
    linear-gradient(160deg, #ffffff 0%, #fbf9f3 52%, #efeade 100%);
  border: 1px solid #b7b1a1;
  box-shadow:
    0 2px 5px rgba(0,0,0,.40),
    inset 0 0 0 1px rgba(255,255,255,.85),
    inset 0 0 14px rgba(120,105,70,.10);
  cursor: pointer; user-select: none;
  transition: transform .14s ease, box-shadow .14s ease;
}
.ddz-card.red { color: #c8223a; }
.ddz-card.black { color: #1d1d1d; }
.ddz-card.ddz-lg { width: 58px; height: 82px; }
.ddz-card.ddz-sm { width: 36px; height: 52px; cursor: default; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.ddz-card.ddz-play { width: 54px; height: 76px; margin-right: 3px; }

/* 角标（左上 + 右下旋转对称） */
.ddz-corner {
  position: absolute; display: flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1; width: 15px;
}
.ddz-corner b {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 700; font-size: 14px; letter-spacing: -.5px;
}
.ddz-corner i { font-style: normal; font-size: 11px; margin-top: 1px; }
.ddz-corner-tl { top: 3px; left: 2.5px; }
.ddz-corner-br { bottom: 3px; right: 2.5px; transform: rotate(180deg); }
.ddz-card.ddz-sm .ddz-corner { width: 10px; }
.ddz-card.ddz-sm .ddz-corner b { font-size: 9.5px; }
.ddz-card.ddz-sm .ddz-corner i { font-size: 7.5px; margin-top: 0; }
.ddz-card.ddz-play .ddz-corner b { font-size: 13px; }
.ddz-card.ddz-play .ddz-corner i { font-size: 10px; }

/* 数字点数（pips） */
.ddz-pips { position: absolute; inset: 15px 7px 15px; }
.ddz-pip {
  position: absolute; left: var(--x); top: var(--y);
  transform: translate(-50%,-50%);
  font-size: 15px; line-height: 1; font-family: 'Segoe UI Symbol', sans-serif;
}
.ddz-pip.inv { transform: translate(-50%,-50%) rotate(180deg); }
.ddz-card.ddz-sm .ddz-pips { inset: 10px 4px; }
.ddz-card.ddz-sm .ddz-pip { font-size: 9.5px; }
.ddz-card.ddz-play .ddz-pip { font-size: 14px; }

/* A：中央大花色 */
.ddz-center-suit {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  font-size: 36px; line-height: 1;
}
.ddz-card.ddz-sm .ddz-center-suit { font-size: 21px; }
.ddz-card.ddz-play .ddz-center-suit { font-size: 32px; }

/* 人头牌 J/Q/K：描金画框 + 大字母 + 花色水印 */
.ddz-face {
  position: absolute; inset: 10px 7px;
  border: 1.5px solid currentColor; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(0,0,0,.035), rgba(0,0,0,0));
}
.ddz-face::before {
  content: ''; position: absolute; inset: 2.5px;
  border: 1px solid currentColor; opacity: .35; border-radius: 2px;
}
.ddz-face-bg { position: absolute; font-size: 40px; opacity: .13; font-style: normal; line-height: 1; }
.ddz-face b {
  font-family: Georgia, 'Times New Roman', serif; font-style: italic;
  font-size: 28px; line-height: 1; position: relative;
  text-shadow: 0 1px 0 rgba(255,255,255,.6);
}
.ddz-face i { position: absolute; bottom: 6px; font-style: normal; font-size: 12px; }
.ddz-card.ddz-sm .ddz-face { inset: 7px 5px; }
.ddz-card.ddz-sm .ddz-face-bg { font-size: 23px; }
.ddz-card.ddz-sm .ddz-face b { font-size: 16px; }
.ddz-card.ddz-sm .ddz-face i { font-size: 7.5px; bottom: 3px; }
.ddz-card.ddz-play .ddz-face-bg { font-size: 36px; }
.ddz-card.ddz-play .ddz-face b { font-size: 25px; }

/* 王牌 */
.ddz-card.joker-red { color: #c8223a; }
.ddz-card.joker-black { color: #24325c; }
.ddz-jcorner { position: absolute; top: 3px; left: 1px; width: 16px; text-align: center; line-height: 1; }
.ddz-jcorner-br { transform: rotate(180deg); bottom: 3px; top: auto; right: 1px; left: auto; }
.ddz-jcorner b { display: block; font-family: Georgia, serif; font-size: 7.5px; font-weight: 700; letter-spacing: -.2px; }
.ddz-jcorner i { font-style: normal; font-size: 9px; }
.ddz-joker-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.ddz-joker-star { font-style: normal; font-size: 15px; line-height: 1; }
.ddz-joker-center b {
  font-family: Georgia, 'STKaiti', '楷体', serif; font-size: 30px; line-height: 1;
}
.ddz-joker-center small { font-family: Georgia, serif; font-size: 6.5px; letter-spacing: 1px; }
.joker-red .ddz-joker-star { color: #e0a92e; }
.joker-red .ddz-jcorner i { color: #e0a92e; }
.joker-black .ddz-joker-star { color: #3d5597; }
.joker-black .ddz-jcorner i { color: #3d5597; }
.ddz-card.ddz-sm .ddz-jcorner b { font-size: 5px; }
.ddz-card.ddz-sm .ddz-jcorner i { font-size: 6px; }
.ddz-card.ddz-sm .ddz-joker-center b { font-size: 18px; }
.ddz-card.ddz-sm .ddz-joker-star { font-size: 9px; }
.ddz-card.ddz-sm .ddz-joker-center small { font-size: 4.5px; }

/* 手牌交互 */
.ddz-my-hand .ddz-card:hover { transform: translateY(-7px); box-shadow: 0 8px 14px rgba(0,0,0,.5); z-index: 6; }
.ddz-card.selected {
  transform: translateY(-16px);
  box-shadow: 0 10px 18px rgba(0,0,0,.5), 0 0 0 2px #f6c945, 0 0 12px rgba(246,201,69,.75);
  z-index: 8;
}
.ddz-my-hand .ddz-card.selected:hover { transform: translateY(-16px); }

/* 地主底牌金框 */
.ddz-card.landlord-card {
  box-shadow: 0 2px 5px rgba(0,0,0,.4), 0 0 0 1.5px #e8b730, 0 0 8px rgba(232,183,48,.65);
}

/* 出牌弹出动画 */
.ddz-last-cards .ddz-card { animation: ddz-pop .22s cubic-bezier(.2,.9,.35,1.3) both; }
@keyframes ddz-pop {
  from { transform: translateY(16px) scale(.75); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes ddz-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 发牌动画（仅新一局） */
.ddz-card.deal-in { animation: ddz-deal .26s ease both; }
@keyframes ddz-deal {
  from { transform: translateY(-46px) rotate(-8deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------- 手机 ---------- */
@media (max-width: 620px) {
  .board-wrap.ddz-wrap { min-height: 530px; padding: 6px; }
  .ddz-root { height: 530px; font-size: 13px; }
  .ddz-top { min-height: 126px; padding: 0 6px; }
  .ddz-opponent { width: 128px; }
  .ddz-hand-back { width: 112px; height: 52px; }
  .ddz-card-back { width: 23px; height: 34px; }
  .ddz-card-back::after { font-size: 9px; }
  .ddz-card.ddz-lg { width: 46px; height: 66px; }
  .ddz-card.ddz-play { width: 42px; height: 60px; }
  .ddz-card.ddz-sm { width: 29px; height: 42px; }
  .ddz-corner b { font-size: 11.5px; }
  .ddz-corner i { font-size: 9px; }
  .ddz-pip { font-size: 12px; }
  .ddz-center-suit { font-size: 28px; }
  .ddz-face b { font-size: 21px; }
  .ddz-face-bg { font-size: 30px; }
  .ddz-face i { font-size: 9px; }
  .ddz-joker-center b { font-size: 23px; }
  .ddz-my-hand { min-height: 76px; }
  .ddz-center { gap: 6px; min-height: 104px; }
  .ddz-act-bar { gap: 8px; min-height: 46px; }
  .ddz-act-btn { min-width: 78px; min-height: 44px; font-size: 15px; padding: 6px 10px; letter-spacing: 1px; }
  .ddz-card.selected { transform: translateY(-12px); }
}

/* 底牌区牌背（静态排列） */
.ddz-bottom-back { position: static; display: inline-block; width: 26px; height: 38px; margin: 0 1px; }
.ddz-bottom-back::after { font-size: 10px; }
@media (max-width: 620px) {
  .ddz-bottom-back { width: 21px; height: 31px; }
}

/* ==================== 局势编码弹层 ==================== */
.code-desc { font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.code-box {
  width: 100%;
  box-sizing: border-box;
  margin: 10px 0 4px;
  padding: 10px 12px;
  border: 1.5px solid var(--line, var(--line-strong));
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink, #333);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
  resize: none;
  min-height: 88px;
}
.code-box:focus { outline: none; border-color: var(--primary, #b48b52); }

/* ==================== 棋盘截图预览弹层 ==================== */
.shot-modal { max-width: 560px; }
.shot-preview {
  margin: 12px 0 4px;
  padding: 10px;
  max-height: 58vh;
  overflow: auto;
  background: #f3efe6;
  border: 1.5px solid var(--line, var(--line-strong));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  -webkit-overflow-scrolling: touch;
}
.shot-preview img {
  max-width: 100%;
  max-height: 54vh;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(var(--shadow-color), .16);
  background: #fff;
}
.shot-empty { color: var(--ink-2, #6b5d48); font-size: 13px; text-align: center; padding: 18px 10px; }
.shot-loading { color: var(--ink-2, #6b5d48); font-size: 13px; text-align: center; padding: 18px 10px; }
@media (max-width: 620px) {
  .shot-modal .modal-actions { flex-wrap: wrap; gap: 8px; }
  .shot-modal .modal-actions .btn { flex: 1 1 44%; min-height: 40px; }
}

/* ==================== 斗地主 特效与音效 ==================== */

/* 特效层（覆盖全桌，不拦截点击） */
.ddz-fx { position: absolute; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }

/* 中央印章：炸弹 / 王炸 / 飞机 / 地主 */
.ddz-fx-stamp {
  position: absolute; left: 50%; top: 40%;
  transform: translate(-50%,-50%) scale(2.4);
  font-family: KaiTi, STKaiti, 'Microsoft YaHei', serif;
  font-size: 58px; font-weight: 900; letter-spacing: 10px;
  padding: 10px 26px 14px 36px;
  border-radius: 18px; white-space: nowrap;
  opacity: 0;
  animation: ddz-stamp 1.05s cubic-bezier(.2,.9,.3,1) forwards;
}
.ddz-fx-stamp.fx-bomb {
  color: #fff3e8;
  background: radial-gradient(circle at 50% 42%, rgba(255,110,50,.96), rgba(200,30,20,.92) 60%, rgba(120,10,10,.9));
  border: 3px solid #ffb46a;
  text-shadow: 0 0 18px rgba(255,120,40,.95), 0 3px 0 rgba(90,10,0,.6);
  box-shadow: 0 0 46px rgba(255,90,30,.55), inset 0 0 24px rgba(255,180,90,.35);
}
.ddz-fx-stamp.fx-rocket {
  color: #fff8dc;
  background: radial-gradient(circle at 50% 42%, rgba(255,214,90,.96), rgba(232,160,30,.94) 60%, rgba(150,90,8,.92));
  border: 3px solid #ffe9a8;
  text-shadow: 0 0 20px rgba(255,220,120,1), 0 3px 0 rgba(110,60,0,.6);
  box-shadow: 0 0 54px rgba(255,200,70,.65), inset 0 0 26px rgba(255,240,170,.4);
}
.ddz-fx-stamp.fx-plane {
  color: #eaf6ff;
  background: radial-gradient(circle at 50% 42%, rgba(90,162,232,.95), rgba(40,100,190,.93) 60%, rgba(16,52,110,.92));
  border: 3px solid #a8d4ff;
  text-shadow: 0 0 16px rgba(140,200,255,.9), 0 3px 0 rgba(0,30,80,.55);
  box-shadow: 0 0 42px rgba(80,150,235,.5), inset 0 0 22px rgba(170,215,255,.35);
  font-size: 46px;
}
.ddz-fx-stamp.fx-landlord {
  color: #4a2f00;
  background: linear-gradient(160deg, #ffe9a8, #f2c14e 55%, #d99a24);
  border: 3px solid #fff3cc;
  text-shadow: 0 1px 0 rgba(255,255,255,.55);
  box-shadow: 0 0 38px rgba(240,190,70,.55);
  font-size: 44px; letter-spacing: 8px;
}
@keyframes ddz-stamp {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(2.4); }
  16% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  72% { opacity: 1; transform: translate(-50%,-52%) scale(1.04); }
  100% { opacity: 0; transform: translate(-50%,-56%) scale(1.08); }
}

/* 炸弹冲击波双环 */
.ddz-shock {
  position: absolute; left: 50%; top: 40%; width: 60px; height: 60px;
  margin: -30px 0 0 -30px; border-radius: 50%;
  border: 5px solid rgba(255,130,60,.85);
  animation: ddz-shock .75s cubic-bezier(.15,.6,.4,1) forwards;
}
.ddz-shock.d2 { border-color: rgba(255,210,110,.7); border-width: 3px; animation-delay: .12s; }
@keyframes ddz-shock {
  0% { transform: scale(.35); opacity: 1; }
  100% { transform: scale(10); opacity: 0; }
}

/* 王炸放射火花 */
.ddz-spark {
  position: absolute; left: 50%; top: 40%; width: 7px; height: 22px;
  margin: -11px 0 0 -3.5px; border-radius: 4px;
  background: linear-gradient(180deg, #fff4c2, #f2b93c);
  transform: rotate(var(--a, 0deg)) translateY(-34px);
  opacity: 0;
  animation: ddz-spark .9s ease-out var(--dl, 0s) forwards;
}
@keyframes ddz-spark {
  0% { opacity: 0; transform: rotate(var(--a,0deg)) translateY(-20px) scaleY(.5); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a,0deg)) translateY(-120px) scaleY(1.25); }
}

/* 炸弹/王炸震屏 */
.ddz-root.ddz-shake { animation: ddz-shake .55s linear; }
@keyframes ddz-shake {
  0%, 100% { transform: none; }
  10% { transform: translate(-8px, 4px) rotate(-.5deg); }
  22% { transform: translate(7px, -5px) rotate(.4deg); }
  34% { transform: translate(-6px, 3px) rotate(-.3deg); }
  46% { transform: translate(5px, -3px) rotate(.25deg); }
  58% { transform: translate(-4px, 2px); }
  70% { transform: translate(3px, -2px); }
  82% { transform: translate(-2px, 1px); }
  92% { transform: translate(1px, 0); }
}

/* 胜利彩带 */
.ddz-confetti { position: absolute; inset: 0; overflow: hidden; }
.ddz-confetti i {
  position: absolute; top: -18px; left: var(--x, 50%);
  width: var(--w, 9px); height: calc(var(--w, 9px) * 1.7);
  background: var(--c, #f6c945);
  border-radius: 2px;
  animation: ddz-fall var(--d, 2.6s) linear var(--dl, 0s) forwards;
  opacity: .95;
}
@keyframes ddz-fall {
  0% { transform: translateY(0) rotate(var(--r, 0deg)); }
  100% { transform: translateY(660px) rotate(540deg); opacity: .1; }
}

/* 出牌方向飞入（西家左入 / 东家右入 / 南家下入） */
@keyframes ddz-from-left { from { transform: translateX(-120px) translateY(8px) rotate(-9deg) scale(.7); opacity: 0; } }
@keyframes ddz-from-right { from { transform: translateX(120px) translateY(8px) rotate(9deg) scale(.7); opacity: 0; } }
.ddz-last-cards .ddz-card.anim-from-left { animation-name: ddz-from-left; animation-duration: .34s; }
.ddz-last-cards .ddz-card.anim-from-right { animation-name: ddz-from-right; animation-duration: .34s; }

@media (max-width: 620px) {
  .ddz-fx-stamp { font-size: 38px; letter-spacing: 6px; padding: 8px 18px 10px 24px; }
  .ddz-fx-stamp.fx-plane { font-size: 32px; }
  .ddz-fx-stamp.fx-landlord { font-size: 30px; }
}

/* ================= 打娘子补充样式 ================= */
.dnz-bottom { padding: 6px 12px 2px; }
.dnz-me { text-align: center; }
.dnz-act-hint-txt { font-size: 13px; opacity: .85; }

/* 手牌按同点数张数微亮色区分：单张=蓝 / 对子=绿 / 炸弹(≥3张)=橙 */
/* :not(.selected) 保证选中时的金色上浮光效不被覆盖 */
/* 水平滑动交给 pointer 事件做滑选，垂直仍可滚动页面 */
.ddz-my-hand { touch-action: pan-y; }
.ddz-card.dnz-grp-single:not(.selected) {
  border-color: rgba(96,165,250,.55);
  box-shadow:
    0 2px 5px rgba(0,0,0,.40),
    inset 0 0 0 1px rgba(255,255,255,.85),
    inset 0 0 14px rgba(59,130,246,.10),
    inset 0 3px 0 0 rgba(96,165,250,.7),
    0 0 5px rgba(96,165,250,.22);
}
.ddz-card.dnz-grp-pair:not(.selected) {
  border-color: rgba(52,211,153,.6);
  box-shadow:
    0 2px 5px rgba(0,0,0,.40),
    inset 0 0 0 1px rgba(255,255,255,.85),
    inset 0 0 14px rgba(16,185,129,.12),
    inset 0 3px 0 0 rgba(52,211,153,.75),
    0 0 6px rgba(52,211,153,.28);
}
.ddz-card.dnz-grp-bomb:not(.selected) {
  border-color: rgba(251,146,60,.78);
  box-shadow:
    0 2px 5px rgba(0,0,0,.40),
    inset 0 0 0 1px rgba(255,255,255,.85),
    inset 0 0 16px rgba(249,115,22,.16),
    inset 0 3px 0 0 rgba(251,146,60,.9),
    0 0 9px rgba(251,146,60,.42);
}
@media (max-width: 620px) {
  .dnz-bottom { padding: 4px 6px 2px; }
  .ddz-card.dnz-grp-bomb:not(.selected) { box-shadow: 0 2px 4px rgba(0,0,0,.4), inset 0 3px 0 0 rgba(251,146,60,.9), 0 0 5px rgba(251,146,60,.3); }
}

/* ==================== 小鱼端锅 ==================== */
.board-wrap.dg-wrap {
  padding: 10px;
  border-radius: 12px;
  min-height: 580px;
  background:
    radial-gradient(ellipse 90% 70% at 50% 42%, rgba(255,255,255,.10), transparent 60%),
    radial-gradient(ellipse at center, #175c3c 0%, #0d452b 55%, #072e1c 100%);
  box-shadow: inset 0 0 60px rgba(0,0,0,.45);
}

/* 顶部对手：flex 均分自适应（5 人手机也不溢出），筹码徽章 + 庄标记 + 当前操作金边 */
.dg-top { flex: 0 0 auto; justify-content: center; gap: 10px; }
.dg-opponent { flex: 1 1 0; min-width: 0; max-width: 190px; text-align: center; }
.dg-opp-head { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; }
.dg-opp-head .ddz-opp-name { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dg-opp-chips {
  font-size: 12px; font-weight: bold; color: #ffe3a1;
  background: rgba(0,0,0,.32); border: 1px solid rgba(240,196,96,.4);
  padding: 2px 8px; border-radius: 12px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.dg-opp-mark { height: 18px; margin-top: 2px; font-size: 12px; font-weight: bold; color: #f6c945; }
.dg-opponent.dg-active { border-radius: 12px; box-shadow: 0 0 0 1px rgba(246,201,69,.55), 0 0 22px rgba(246,201,69,.22); }
.dg-opponent.dg-out { opacity: .38; filter: grayscale(.8); }
.dg-opponent .ddz-hand-back { width: 104px; margin: 4px auto 0; }

/* 中央三列正常文档流：牌堆 | 锅+牌河 | 牌桌（互不重叠）
   注意：基类 .ddz-center 是 flex-direction:column，这里必须显式改回 row，
   否则三列会纵向堆叠溢出，把行动栏压到底部手牌上 */
.dg-center {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: row; align-items: stretch; justify-content: center;
  gap: 22px; padding: 2px 16px;
}
.dg-wall {
  flex: 0 0 auto; width: 84px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.dg-wall-stack {
  width: 48px; height: 70px; border-radius: 7px; position: relative;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,238,170,.28) 0 22%, transparent 24%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.10) 0 3px, transparent 3px 7px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.10) 0 3px, transparent 3px 7px),
    linear-gradient(140deg, #c62838 0%, #961524 55%, #7c0f1c 100%);
  border: 2px solid #f4efe3;
  box-shadow: 3px 3px 0 rgba(0,0,0,.25), 0 4px 8px rgba(0,0,0,.4);
}
.dg-wall-stack::after {
  content: '★'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #f3d577; font-size: 19px;
}
.dg-wall-count { font-size: 12px; opacity: .85; white-space: nowrap; }

/* 锅 + 牌河 独立列 */
.dg-side {
  flex: 0 0 auto; width: 112px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.dg-pot { display: flex; justify-content: center; }
.dg-pot-body {
  position: relative;
  width: 92px; min-height: 74px; margin-top: 9px; border-radius: 0 0 46px 46px / 0 0 28px 28px;
  background: linear-gradient(180deg, #6b4a25 0%, #4a3115 45%, #2f1e0b 100%);
  border: 3px solid #d8a84e; border-top: none;
  box-shadow: inset 0 -10px 18px rgba(0,0,0,.45), 0 6px 14px rgba(0,0,0,.4), 0 0 18px rgba(216,168,78,.25);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 9px 8px 11px; gap: 2px;
}
.dg-pot-body::before {
  content: ''; position: absolute; top: -5px; left: -3px; width: 98px; height: 12px; border-radius: 50%;
  background: linear-gradient(180deg, #efcf86, #b9842c);
  border: 2px solid #f3da96;
}
.dg-pot-amt { font-size: 25px; font-weight: 900; color: #ffe9b0; text-shadow: 0 2px 3px rgba(0,0,0,.6); line-height: 1.1; }
.dg-pot-label { font-size: 10.5px; color: #e8c98a; opacity: .9; text-align: center; line-height: 1.3; }

/* 牌河：sm 牌 36 宽，固定 3 列；最多 6 张 2 行，超高由 JS 截断 */
.dg-graveyard {
  width: 112px; min-height: 40px;
  display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 2px;
}
.dg-graveyard .ddz-card { margin: 0 !important; }

/* 牌桌列：弃牌槽 + 提示 + 行动按钮 */
.dg-table {
  flex: 1 1 auto; min-width: 0; max-width: 720px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}

/* 待处理弃牌 */
.dg-discard-slot { min-height: 100px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.dg-discard-meta { font-size: 12px; opacity: .88; letter-spacing: .5px; text-align: center; }
.dg-discard-card { display: inline-block; border-radius: 8px; padding: 3px; }
.dg-discard-card.dg-can-hu {
  box-shadow: 0 0 0 2px #f6c945, 0 0 24px rgba(246,201,69,.65);
  animation: dg-glow 1.1s ease-out;
}
@keyframes dg-glow {
  0% { box-shadow: 0 0 0 2px rgba(246,201,69,0), 0 0 0 rgba(246,201,69,0); }
  35% { box-shadow: 0 0 0 3px #f6c945, 0 0 34px rgba(246,201,69,.85); }
  100% { box-shadow: 0 0 0 2px rgba(246,201,69,.85), 0 0 18px rgba(246,201,69,.4); }
}
.dg-discard-empty { width: 56px; height: 78px; border: 2px dashed rgba(255,255,255,.18); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.35); font-size: 13px; }

.dg-banner { max-width: 100%; font-size: 14px; font-weight: bold; letter-spacing: 1px; color: #ffe9c0; min-height: 20px; text-align: center; }
.dg-act-bar { flex-wrap: wrap; }

/* 主行动按钮统一金色 */
.ddz-act-btn.dg-primary {
  background: linear-gradient(135deg, #ffd768, #e8a72c 60%, #d18e16);
  color: #3a2200;
}
.ddz-act-btn.dg-primary b { color: rgba(58,34,0,.75); }
.ddz-act-btn.dg-act-duan {
  background: linear-gradient(135deg, #ff7a5e, #e23822 60%, #b21c0c);
  color: #fff6e8;
  box-shadow: 0 0 20px rgba(240,70,40,.5), 0 3px 10px rgba(0,0,0,.4);
}

/* 底部自己 */
.dg-bottom { flex: 0 0 auto; padding: 6px 12px 2px; }
.dg-me { text-align: center; }
.dg-me-info { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 4px; }
.dg-me-chips {
  font-size: 13px; font-weight: bold; color: #ffe3a1;
  background: rgba(0,0,0,.32); border: 1px solid rgba(240,196,96,.4);
  padding: 2px 12px; border-radius: 12px; white-space: nowrap;
}
.dg-me-count { font-size: 12px; opacity: .8; white-space: nowrap; }
.dg-my-hand { display: flex; justify-content: center; gap: 12px; min-height: 88px; align-items: flex-start; padding-top: 8px; }
.dg-my-hand .ddz-card { margin: 0 !important; }

/* 局结算面板（挂在 dg-root 下，覆盖全桌） */
.dg-settle {
  position: absolute; inset: 0; z-index: 40; display: none;
  align-items: center; justify-content: center;
  background: rgba(4,20,12,.55); border-radius: 12px;
}
.dg-settle.show { display: flex; animation: ddz-fade .18s ease both; }
.dg-st-box {
  min-width: 250px; max-width: 92%;
  background: linear-gradient(170deg, rgba(30,52,36,.97), rgba(12,28,18,.97));
  border: 2px solid rgba(240,196,96,.65); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.55), 0 0 30px rgba(240,196,96,.18);
  padding: 18px 22px 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.dg-st-box b { font-size: 24px; color: #ffe9b0; letter-spacing: 2px; }
.dg-st-box b.dg-st-duan { color: #ffb38f; text-shadow: 0 0 18px rgba(255,120,60,.8); }
.dg-st-box small { font-size: 13px; opacity: .9; line-height: 1.5; }
.dg-st-amt { color: #ffd768; font-weight: bold; font-size: 14px !important; }
.dg-st-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 4px 0 6px; }
.dg-st-chip {
  font-size: 12.5px; padding: 3px 12px; border-radius: 14px;
  background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.18);
}
.dg-st-chip.win { color: #4a2f00; background: linear-gradient(135deg, #ffe9a8, #f2c14e); border-color: #fff3cc; font-weight: bold; }
.dg-st-chip.out { opacity: .5; text-decoration: line-through; }
.dg-final { border-color: rgba(246,201,69,.9); box-shadow: 0 12px 44px rgba(0,0,0,.6), 0 0 46px rgba(246,201,69,.28); }

/* 胡牌 / 端锅 特效 */
.ddz-fx-stamp.fx-hu {
  color: #fff8d6;
  background: radial-gradient(circle at 50% 42%, rgba(255,214,90,.96), rgba(226,150,30,.93) 60%, rgba(150,90,8,.92));
  border: 3px solid #ffefb4;
  text-shadow: 0 0 20px rgba(255,224,130,.95), 0 3px 0 rgba(110,60,0,.6);
  box-shadow: 0 0 50px rgba(255,205,80,.6), inset 0 0 24px rgba(255,240,170,.4);
}
.ddz-fx-stamp.fx-duan {
  color: #fff1e4;
  background: radial-gradient(circle at 50% 42%, rgba(255,140,70,.97), rgba(216,50,24,.94) 60%, rgba(130,16,6,.93));
  border: 3px solid #ffd0a0;
  text-shadow: 0 0 22px rgba(255,150,80,.95), 0 3px 0 rgba(90,10,0,.65);
  box-shadow: 0 0 62px rgba(255,90,40,.7), inset 0 0 26px rgba(255,200,140,.45);
  font-size: 64px;
}
.dg-spark {
  position: absolute; left: 50%; top: 42%; width: 7px; height: 24px;
  margin: -12px 0 0 -3.5px; border-radius: 4px;
  background: linear-gradient(180deg, #fff6d2, #ffb13d);
  opacity: 0;
  animation: dg-spark 1.15s ease-out var(--dl, 0s) forwards;
  transform: rotate(var(--a, 0deg)) translateY(-30px);
}
@keyframes dg-spark {
  0% { opacity: 0; transform: rotate(var(--a,0deg)) translateY(-16px) scaleY(.5); }
  22% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a,0deg)) translateY(-132px) scaleY(1.3); }
}

@media (max-width: 620px) {
  .board-wrap.dg-wrap { min-height: 530px; padding: 8px; }
  .dg-root { height: 530px; font-size: 13px; }
  /* 顶部对手：卡内竖排，4 家也放得下 */
  .dg-top { gap: 6px; padding: 0 4px; }
  .dg-opponent { max-width: none; }
  .dg-opp-head { flex-direction: column; gap: 2px; }
  .dg-opp-head .ddz-opp-name { padding: 2px 6px; font-size: 11px; letter-spacing: 0; }
  .dg-opp-chips { font-size: 10px; padding: 1px 6px; }
  .dg-opp-mark { height: 14px; font-size: 11px; }
  .dg-opponent .ddz-hand-back { width: 66px; height: 46px; margin-top: 3px; }
  /* 三列紧凑 */
  .dg-center { gap: 8px; padding: 2px 6px; align-items: center; }
  .dg-wall { width: 46px; gap: 5px; }
  .dg-wall-stack { width: 38px; height: 56px; }
  .dg-wall-stack::after { font-size: 15px; }
  .dg-wall-count { font-size: 11px; }
  .dg-side { width: 60px; gap: 6px; }
  .dg-pot-body { width: 52px; min-height: 48px; margin-top: 6px; padding: 8px 4px; }
  .dg-pot-body::before { top: -5px; left: -3px; width: 58px; height: 10px; }
  .dg-pot-amt { font-size: 18px; }
  .dg-pot-label { font-size: 9px; line-height: 1.2; }
  .dg-graveyard { width: 60px; min-height: 0; }
  .dg-table { gap: 6px; }
  .dg-discard-slot { min-height: 74px; }
  .dg-discard-empty { width: 44px; height: 62px; font-size: 11px; }
  .dg-discard-meta { font-size: 11px; }
  .dg-banner { font-size: 12px; letter-spacing: 0; }
  .dg-act-bar { gap: 8px; }
  .dg-act-bar .ddz-act-btn { min-width: 72px; min-height: 40px; font-size: 14px; padding: 6px 10px; }
  .ddz-fx-stamp.fx-duan { font-size: 42px; }
  .dg-my-hand { gap: 8px; min-height: 76px; }
}

/* ================= 身份 & 战绩（数据层 · 云端降级） ================= */
.header-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .28);
  color: var(--header-fg);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: background .15s, border-color .15s;
}
.header-btn:hover { background: rgba(255, 255, 255, .16); }
.header-btn.signed { border-color: var(--header-accent); color: var(--header-accent); }
.modal-wide { max-width: 460px; }
.field-input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 18px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 15px;
  text-align: center;
}
.rec-stats { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.rec-stat {
  background: var(--surface); border-radius: 10px; padding: 8px 12px;
  font-size: 12.5px; color: var(--text-2); min-width: 56px;
}
.rec-stat b { display: block; font-size: 18px; color: var(--text); }
.rec-stat.win b { color: var(--primary); }
.rec-stat.lose b { color: var(--success); }
.rec-list { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; text-align: left; }
.rec-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 10px; font-size: 13px;
  border-bottom: 1px solid var(--surface-2); color: var(--text-2);
}
.rec-item .rec-res {
  width: 22px; height: 22px; line-height: 22px; text-align: center;
  border-radius: 50%; font-size: 12px; color: #fff; background: var(--text-3); flex: 0 0 auto;
}
.rec-item .rec-game { font-weight: 600; }
.rec-item .rec-mode { color: var(--text-2); font-size: 12px; }
.rec-item .rec-time { margin-left: auto; color: #a89a86; font-size: 11.5px; }
.rec-empty { color: var(--text-2); }
.login-tip { font-size: 13.5px; color: var(--ink-2); margin-bottom: 14px; }
.field-error { color: var(--primary); font-size: 12.5px; margin: -8px 0 12px; }
.code-row { display: flex; gap: 8px; align-items: stretch; }
.code-row .field-input { flex: 1; margin-bottom: 18px; }
.code-btn {
  flex: 0 0 auto; min-width: 108px; padding: 0 12px; white-space: nowrap;
  border: 1px solid var(--line, #ddd); border-radius: 10px; background: var(--surface); color: var(--text-2);
}
.code-btn:disabled { opacity: .6; cursor: default; }

/* ================= 胜率预测 ================= */
.winrate-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 12px;
}
.winrate-card .wr-title {
  font-size: 13px; font-weight: 700; color: var(--text-2); letter-spacing: .04em;
  margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
}
.winrate-card .wr-title::before { content: "\1F4CA"; font-size: 14px; }
.wr-rows { display: flex; flex-direction: column; gap: 9px; }
.wr-row { display: flex; flex-direction: column; gap: 4px; }
.wr-row-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; }
.wr-name { color: var(--text-2); font-weight: 600; }
.wr-pct { color: #2b241a; font-weight: 700; font-variant-numeric: tabular-nums; }
.wr-track { height: 8px; border-radius: 999px; background: #e7ddca; overflow: hidden; }
.wr-fill { height: 100%; border-radius: 999px; transition: width .35s ease; background: #888; }
.wr-fill.red { background: var(--primary); }
.wr-fill.black { background: #3a3a3a; }
.wr-fill.white { background: var(--line); }
.wr-fill.yellow { background: var(--accent); }
.wr-fill.green { background: var(--success); }

/* 横幅下方：各方占比进度条 */
.winrate-bar {
  display: flex; height: 10px; border-radius: 999px; overflow: hidden;
  margin: 6px 2px 2px; background: #eee; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.winrate-bar .wrb-seg { height: 100%; transition: width .35s ease; background: #888; }
.winrate-bar .wrb-seg.red { background: var(--primary); }
.winrate-bar .wrb-seg.black { background: #3a3a3a; }
.winrate-bar .wrb-seg.white { background: var(--line); }
.winrate-bar .wrb-seg.yellow { background: var(--accent); }
.winrate-bar .wrb-seg.green { background: var(--success); }
.winrate-bar .wrb-seg.blue { background: var(--info); }
.wr-fill.blue { background: var(--info); }

/* 侧边栏：重复局面提示（三次重复判和规则） */
.rep-card {
  background: #f3f7f3; border: 1px solid #d7e6d7; border-radius: 14px;
  padding: 10px 14px; margin-bottom: 12px;
}
.rep-card .rep-title {
  font-size: 13px; font-weight: 700; color: #3f6b46; letter-spacing: .04em;
  margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.rep-card .rep-title::before { content: "\267B"; font-size: 14px; }
.rep-card.warn { background: #fdf3e7; border-color: #f0c98a; }
.rep-card.warn .rep-title { color: var(--warning); }
.rep-card .rep-text { font-size: 12.5px; color: #37423a; font-variant-numeric: tabular-nums; }
.rep-card .rep-text b { color: #1f2b24; }

/* ============ 增强反馈：toast 类型化 / spinner / 骨架屏 ============ */
.toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--text); color: var(--surface);
  padding: 11px 16px 13px 14px;
  border-radius: 12px; font-size: 14px; line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
  animation: toastIn .26s cubic-bezier(.2,.9,.3,1) both;
  max-width: 88vw; min-width: 132px;
  pointer-events: auto; cursor: pointer;
  overflow: hidden; position: relative; text-align: left;
}
.toast-out { animation: toastOut .24s ease forwards !important; }
@keyframes toastIn { from { opacity:0; transform: translateY(-12px) scale(.98);} to {opacity:1; transform:none;} }
@keyframes toastOut { to { opacity:0; transform: translateY(-8px) scale(.98);} }

.toast-ico {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  color: #fff; background: rgba(255,255,255,.28);
}
.toast-msg { flex: 1 1 auto; }
.toast-bar {
  position: absolute; left:0; bottom:0; height:3px; width:100%;
  background: rgba(255,255,255,.65); transform-origin: left;
  animation: toastBar var(--toast-ttl,2600ms) linear forwards;
}
@keyframes toastBar { from { transform: scaleX(1);} to { transform: scaleX(0);} }


/* 通用加载圈 */
.spinner {
  width: 22px; height: 22px; display: inline-block; vertical-align: middle;
  border: 2.5px solid rgba(0,0,0,.15); border-top-color: var(--primary);
  border-radius: 50%; animation: btnSpin .7s linear infinite;
}
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }

/* 骨架屏（战绩 / 排行榜 / 复盘加载占位） */
.skeleton {
  background: linear-gradient(90deg,#ece1c9 25%,var(--surface-2) 37%,#ece1c9 63%);
  background-size: 400% 100%; animation: shimmer 1.2s ease infinite; border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.rec-skel-row { display:flex; align-items:center; gap:10px; padding:11px 6px; border-bottom:1px solid #f0eada; }
.rec-skel-row .sk-dot { width:26px; height:26px; border-radius:50%; flex:0 0 auto; }
.rec-skel-row .sk-line { height:12px; border-radius:6px; flex:1; }
.rec-skel-row .sk-line.s2 { flex:0 0 70px; }
.rank-skel-row { display:flex; align-items:center; gap:12px; padding:12px 10px; border-bottom:1px solid #f1ebdd; }
.rank-skel-row .sk-rank { width:26px; height:22px; border-radius:6px; flex:0 0 auto; }
.rank-skel-row .sk-av { width:30px; height:30px; border-radius:50%; flex:0 0 auto; }
.rank-skel-row .sk-line { height:12px; border-radius:6px; flex:1; }
.rank-skel-row .sk-line.s2 { flex:0 0 64px; }

/* 登录弹窗：微信扫码登录按钮 + 分隔线 */
.btn-wechat {
  width: 100%; background: #09bb07; color: #fff; border: none;
  font-weight: 600; letter-spacing: .04em;
}
.btn-wechat:hover { background: #0a9e08; }
.btn-wechat:disabled { opacity: .6; cursor: default; }
.divider {
  display: flex; align-items: center; text-align: center;
  color: #a99e8c; font-size: 12px; margin: 12px 0 4px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: #e5e0d4; }
.divider span { padding: 0 10px; }

/* ================= 多方式登录 / 绑定手机号 ================= */
.oauth-row { display: flex; gap: 8px; margin-bottom: 4px; }
.oauth-row .btn { flex: 1; }
.btn-text { background: transparent; color: var(--text-2); border: none; box-shadow: none; padding: 6px 4px; }
.btn-text:hover { background: transparent; text-decoration: underline; }

/* ================= 战绩多 Tab ================= */
.rec-tabs { display: flex; gap: 6px; margin: 4px 0 14px; border-bottom: 1px solid var(--line); }
.rec-tab {
  flex: 1; padding: 8px 4px; border: none; background: transparent; cursor: pointer;
  font-size: 13px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.rec-tab:hover { color: #5a4d3a; }
.rec-tab.active { color: var(--text); font-weight: 700; border-bottom-color: var(--primary); }
.rec-content { text-align: left; }
.rec-sub { font-size: 13px; color: var(--text-2); margin: 12px 0 8px; font-weight: 600; }
.rec-bygame { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bg-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface); border-radius: 10px; font-size: 13px; }
.bg-item .bg-name { font-weight: 600; color: var(--text); }
.bg-item .bg-num { color: var(--text-2); }
.bg-item .bg-rate { margin-left: auto; color: var(--success); font-weight: 600; }
.bg-table, .rank-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; }
.bg-table th, .bg-table td, .rank-table th, .rank-table td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--surface-2); }
.bg-table th, .rank-table th { color: var(--text-2); font-weight: 600; }
.bg-table td:first-child, .rank-table td:first-child { text-align: left; }
.rank-table tr.rank-me { background: #fff7e6; }
.rank-table tr.rank-me td { font-weight: 600; color: var(--warning); }
.rec-replay { flex: 0 0 auto; padding: 4px 10px; font-size: 12px; }
.rec-noreplay { margin-left: auto; color: var(--text-3); font-size: 11.5px; }

/* ================= 复盘 ================= */
.replay-layout { display: flex; gap: 14px; align-items: flex-start; }
.replay-board { flex: 1; min-width: 0; display: flex; justify-content: center; }
.replay-board canvas { width: 100%; max-width: 360px; height: auto; background: #f7f1e3; border-radius: 12px; }
.replay-side { width: 180px; flex: 0 0 180px; display: flex; flex-direction: column; gap: 10px; }
.replay-ctrl { display: flex; align-items: center; gap: 4px; justify-content: center; }
.rp-step { font-size: 12.5px; color: var(--text-2); min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }
.replay-moves { flex: 1; max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 6px; }
.rm-head { font-size: 12px; color: var(--text-2); padding: 2px 4px 6px; }
.rm-item { font-size: 12.5px; padding: 5px 8px; border-radius: 6px; cursor: pointer; font-variant-numeric: tabular-nums; }
.rm-item.rm-r { background: var(--ring); }
.rm-item.rm-b { background: rgba(46,125,50,.06); }
.rm-item:hover { filter: brightness(.97); }
.rm-item.rm-cur { outline: 2px solid var(--primary); font-weight: 700; }

@media (max-width: 560px) {
  .replay-layout { flex-direction: column; }
  .replay-side { width: 100%; flex: none; }
  .replay-moves { max-height: 180px; }
}

/* ===== 胜率预测 v2：可信度标签 + 局面解读 ===== */
.wr-conf {
  margin-top: 9px;
  font-size: 11.5px;
  line-height: 1.5;
  padding: 4px 8px;
  border-radius: 6px;
  text-align: center;
  border: 1px solid transparent;
}
.wr-note {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.55;
  color: #6b4a2a;
  background: rgba(232, 163, 61, .1);
  border-left: 3px solid rgba(232, 163, 61, .75);
  padding: 5px 9px;
  border-radius: 0 6px 6px 0;
}

/* ==========================================================
       社交游戏：狼人杀 / 三国杀
       两者都不走棋盘画布，用自绘的环形座位 + 操作面板
   ========================================================== */

/* ---------- 公共骨架 ---------- */
.ww-wrap, .sgs-wrap { position: relative; }
.ww-root, .sgs-root {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 8px;
  animation: wwFadeIn .28s ease;
}
@keyframes wwFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 阶段横幅 ---------- */
.ww-banner, .sgs-banner {
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  letter-spacing: .5px;
  border: 1.5px solid var(--line);
  background: #fdfbf6;
  color: var(--ink);
  transition: background .25s, border-color .25s, color .25s;
}
.ww-banner.night, .sgs-banner.night {
  background: linear-gradient(135deg, #2c3e60, #1a2536);
  border-color: #1a2536; color: #e8eef7;
}
.ww-banner.day, .sgs-banner.red { background: #fdf3e2; border-color: #e8c98a; color: #8a5a12; }
.ww-banner.vote, .sgs-banner.wait { background: #eef4fb; border-color: #b8cee8; color: #2b5580; }
.ww-banner.good, .sgs-banner.good { background: #eef8f0; border-color: #9ccfa8; color: #1f6b3a; }
.ww-banner.bad, .sgs-banner.bad { background: #fdeeec; border-color: #e2a89f; color: #9c2f22; }
.ww-banner.mine, .sgs-banner.mine { box-shadow: 0 0 0 2px rgba(201, 74, 50, .22); }

/* ---------- 环形座位通用 ---------- */
.ww-ring, .sgs-ring {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 6px;
}
.ww-seat, .sgs-seat {
  position: relative;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s, opacity .2s;
  min-width: 0;
}
.ww-seat:hover, .sgs-seat:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, .08); }
.ww-seat.me, .sgs-seat.me { border-color: var(--primary); background: #fff8f2; }
.ww-seat.speaking, .sgs-seat.turn { border-color: #d9a520; background: #fdf3e2; box-shadow: 0 0 0 2px rgba(217, 165, 32, .25); }
.ww-seat.picked, .sgs-seat.picked { border-color: #c0392b; background: #fdeeec; box-shadow: 0 0 0 3px rgba(192, 57, 43, .28); }
.ww-seat.dead, .sgs-seat.dead { opacity: .45; filter: grayscale(.85); cursor: default; }
.ww-seat.dead:hover, .sgs-seat.dead:hover { transform: none; box-shadow: none; }

/* 狼人杀座位 */
.ww-avatar {
  width: 40px; height: 40px;
  margin: 0 auto 6px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #7f8c8d, #5d6d7e);
  color: #fff; font-size: 14px; font-weight: 700;
}
.ww-seat.me .ww-avatar { background: linear-gradient(145deg, #c94a32, #a92d19); }
.ww-seat.dead .ww-avatar { background: #95a5a6; }
.ww-seat-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.ww-seat-state { margin-top: 3px; font-size: 11.5px; color: var(--ink-2); }

/* ---------- 狼人杀中心与面板 ---------- */
.ww-center { text-align: center; padding: 4px 0; }
.ww-round { font-size: 13px; color: var(--ink-2); }
.ww-hint { margin-top: 4px; font-size: 12.5px; color: var(--ink-2); min-height: 18px; }

.ww-panel { display: flex; flex-direction: column; gap: 10px; }

/* 身份卡（点击翻面） */
.ww-role-card { perspective: 1000px; cursor: pointer; }
.ww-role-inner {
  position: relative;
  min-height: 128px;
  transition: transform .45s cubic-bezier(.4, .2, .2, 1);
  transform-style: preserve-3d;
}
.ww-role-card.flipped .ww-role-inner { transform: rotateY(180deg); }
.ww-role-back, .ww-role-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  padding: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
}
.ww-role-back {
  background: repeating-linear-gradient(45deg, #f3ece0, #f3ece0 10px, #ece2d2 10px, #ece2d2 20px);
}
.ww-role-back-title { font-size: 17px; font-weight: 700; color: #8a6a3a; letter-spacing: 2px; }
.ww-role-back-tip { font-size: 12.5px; color: #9a8258; }
.ww-role-face { transform: rotateY(180deg); background: #fff; }
.ww-role-hidden { font-size: 13.5px; color: var(--ink-2); }
.ww-role-icon {
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 24px;
}
.ww-role-name { font-size: 19px; font-weight: 700; }
.ww-role-camp {
  font-size: 11.5px; padding: 2px 10px; border-radius: 999px;
  background: #f0ece4; color: #6b5c47;
}
.ww-role-desc { font-size: 12.5px; color: var(--ink-2); line-height: 1.6; text-align: center; }
.ww-mates, .ww-potions {
  font-size: 12.5px; color: #9c2f22; background: rgba(192, 57, 43, .08);
  padding: 3px 10px; border-radius: 6px;
}
.ww-role-toggle { font-size: 11px; color: #b0a894; }

.ww-actions, .ww-extra, .sgs-actions {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fdfbf6;
}
.ww-act-title, .sgs-act-title { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.ww-act-note, .sgs-act-note { font-size: 13.5px; color: var(--ink-2); }
.ww-pick, .sgs-pick { font-size: 13.5px; color: var(--ink-2); }
.ww-pick b, .sgs-pick b { color: var(--primary); font-size: 15px; }
.ww-btns, .sgs-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.ww-witch-opts { display: flex; gap: 16px; font-size: 13.5px; }
.ww-witch-opts label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.ww-extra-item { font-size: 13px; color: var(--ink-2); padding: 4px 0; }
.ww-extra-item b { color: var(--ink); }

/* ---------- 事件日志 ---------- */
.ww-log, .sgs-log {
  max-height: 168px;
  overflow-y: auto;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fbf8f2;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.75;
}
.ww-log-line, .sgs-log-line { color: var(--ink-2); }
.ww-log-round, .sgs-log-round {
  display: inline-block;
  min-width: 30px;
  margin-right: 7px;
  font-size: 11px;
  color: #a99a80;
}

/* ---------- 三国杀 ---------- */
.sgs-top { display: flex; flex-direction: column; gap: 8px; }
.sgs-pile { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--ink-2); }
.sgs-pile-item b { color: var(--ink); font-size: 14px; }
.sgs-pile-top { color: #a99a80; }
.sgs-table {
  padding: 8px;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 40%, #fdf8ec, #f3ead6);
  border: 1.5px solid #e3d5b8;
}
.sgs-ring { grid-template-columns: repeat(4, 1fr); }
.sgs-seat-name { font-size: 13px; font-weight: 600; }
.sgs-hp { margin: 5px 0; font-size: 13px; color: #c0392b; letter-spacing: 1px; }
.sgs-hp-num { margin-left: 4px; font-size: 11.5px; color: var(--ink-2); letter-spacing: 0; }
.sgs-seat-tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; min-height: 18px; }
.sgs-tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 4px;
  background: #efe9dc; color: #7a6a52;
}
.sgs-tag.turn { background: rgba(217, 165, 32, .2); color: #8a5a12; }
.sgs-tag.judge { background: rgba(192, 57, 43, .12); color: #9c2f22; }
.sgs-tag.chain { background: rgba(47, 154, 168, .16); color: #1f6b74; }
.sgs-tag.dead { background: #e8e4dc; color: #8a8378; }
.sgs-tag.role { background: transparent; font-weight: 700; }
.sgs-handcount { margin-top: 4px; font-size: 11.5px; color: var(--ink-2); }

/* 响应条 */
.sgs-resp {
  padding: 12px 14px;
  border: 1.5px solid #c94a32;
  border-radius: 12px;
  background: #fff4f0;
  animation: sgsPulse 1.4s ease-in-out infinite;
}
@keyframes sgsPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 74, 50, .3); }
  50% { box-shadow: 0 0 0 6px rgba(201, 74, 50, 0); }
}
.sgs-resp-title { font-size: 14px; margin-bottom: 9px; }
.sgs-resp-cardname { color: #9c2f22; font-size: 17px; }
.sgs-resp-cards { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.sgs-resp-none { font-size: 12.5px; color: var(--ink-2); }
.sgs-resp-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.sgs-mini-card {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 4px 9px;
  border: 1.5px solid #d8c9a8;
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
}

/* 我方信息 + 手牌 */
.sgs-bottom { display: flex; flex-direction: column; gap: 10px; }
.sgs-me { display: flex; align-items: center; gap: 12px; }
.sgs-me-role {
  padding: 7px 16px;
  border-radius: 9px;
  color: #fff; font-size: 15px; font-weight: 700;
}
.sgs-me-info { font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
.sgs-me-line { white-space: nowrap; }

.sgs-hand {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px;
  min-height: 84px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fdfaf3, #f5eee0);
}
.sgs-hand-empty { color: var(--ink-2); font-size: 13px; align-self: center; width: 100%; text-align: center; }
.sgs-card {
  position: relative;
  width: 62px; height: 84px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  border: 1.5px solid #d8c9a8;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  transition: transform .14s, box-shadow .14s, border-color .14s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .07);
}
.sgs-card:hover { transform: translateY(-4px); box-shadow: 0 6px 14px rgba(0, 0, 0, .12); }
.sgs-card.sel { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(201, 74, 50, .3); transform: translateY(-6px); }
.sgs-card.dis { opacity: .42; cursor: not-allowed; }
.sgs-card.dis:hover { transform: none; box-shadow: 0 1px 3px rgba(0, 0, 0, .07); }
.sgs-card-suit { font-size: 15px; font-style: normal; }
.sgs-card-rank { font-size: 21px; line-height: 1; }
.sgs-card-name {
  position: absolute; bottom: 4px; left: 0; right: 0;
  font-size: 10px; color: var(--ink-2); text-align: center;
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .ww-ring, .sgs-ring { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .ww-avatar { width: 34px; height: 34px; font-size: 12.5px; }
  .sgs-card { width: 54px; height: 74px; }
  .sgs-card-rank { font-size: 18px; }
}
@media (max-width: 460px) {
  .ww-ring, .sgs-ring { grid-template-columns: repeat(2, 1fr); }
  .sgs-me { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* ================= 管理后台独立页面（admin.html） =================
 * 全部配色基于设计令牌（见 themes.css），切换 data-theme 即可整体换肤。
 * 所有规则限定在 .admin-page 下，不会污染对局页。后续加功能：新增 .adm-tab + .adm-panel 即可。 */
.admin-page { background: var(--bg); min-height: 100vh; color: var(--text); }
.adm-wrapper { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }
/* 首页低调管理入口角标（指向独立页 /admin） */
.adm-entry {
  position: fixed; right: 12px; bottom: 12px; z-index: 60;
  font-size: 12px; line-height: 1; color: var(--text-3); text-decoration: none;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; backdrop-filter: blur(2px);
  transition: color .15s, border-color .15s;
}
.adm-entry:hover { color: var(--primary); border-color: var(--primary); }
/* 管理页自诊断红条 */
.adm-fatal {
  margin: 14px 0 0; padding: 12px 14px; border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 38%, transparent);
  color: var(--danger); font-size: 13.5px; line-height: 1.6;
}
.adm-fatal code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; color: var(--danger); }
.adm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 4px 14px; border-bottom: 1px solid var(--line);
}
.adm-brand { display: flex; align-items: center; gap: 10px; }
.adm-mark {
  width: 38px; height: 38px; border-radius: var(--radius-md); background: var(--primary); color: var(--primary-contrast);
  display: grid; place-items: center; font-size: 20px; font-weight: 700;
}
.adm-title { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: .04em; }
.adm-header-right { display: flex; align-items: center; gap: 12px; }
.adm-user { font-size: 13px; color: var(--text-3); }
.adm-btn {
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: var(--radius-md); padding: 9px 18px; font-size: 14px; cursor: pointer;
  transition: all var(--t-fast);
}
.adm-btn:disabled { opacity: .55; cursor: default; }
.adm-btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.adm-btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.adm-btn-ghost { background: transparent; }

.adm-card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 32px 28px; margin-top: 28px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line);
}
.adm-h1 { font-size: 24px; color: var(--text); margin-bottom: 8px; }
.adm-h2 { font-size: 20px; color: var(--text); margin: 4px 0 10px; }
.adm-sub { color: var(--text-2); font-size: 14.5px; margin-bottom: 20px; }
.adm-input {
  width: 100%; padding: 12px 14px; margin-bottom: 8px;
  border: 1.5px solid var(--line); border-radius: var(--radius-md); font-size: 15px;
  background: var(--surface-2); color: var(--text);
}
.adm-input::placeholder { color: var(--text-3); }
.adm-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.adm-error { color: var(--danger); font-size: 13px; margin: 2px 0 12px; }
.adm-tip { color: var(--text-3); font-size: 12.5px; margin-top: 16px; line-height: 1.7; }
.adm-tip code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; color: var(--text-2); }

.adm-main { margin-top: 24px; }
.adm-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.adm-tab {
  flex: 0 0 auto; padding: 10px 16px; border: none; background: transparent; cursor: pointer;
  font-size: 14.5px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--t-fast);
}
.adm-tab:hover { color: var(--text); }
.adm-tab.active { color: var(--text); font-weight: 700; border-bottom-color: var(--primary); }

.adm-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.adm-stat {
  flex: 1 1 70px; min-width: 70px; text-align: center;
  background: var(--surface-2); border-radius: var(--radius-md); padding: 10px 6px; font-size: 12px; color: var(--text-2);
}
.adm-stat b { display: block; font-size: 20px; color: var(--text); font-variant-numeric: tabular-nums; }
.adm-stat.warn b { color: var(--warning); }
.adm-stat.live b { color: var(--success); }

.adm-toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.adm-toolbar .adm-btn { flex: 1; }

.adm-list {
  max-height: 52vh; overflow-y: auto; border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 6px; min-height: 60px; background: var(--surface);
}
.adm-list:empty::after {
  content: '当前没有开启的房间'; display: block; text-align: center;
  color: var(--text-3); font-size: 13px; padding: 24px 0;
}
.adm-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 6px 10px; padding: 10px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--text-2);
}
.adm-item:last-child { border-bottom: none; }
.adm-item.is-empty { background: var(--surface-2); border-radius: var(--radius-md); }
.ai-code {
  grid-column: 1; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: .06em;
}
.ai-game { grid-column: 2; color: var(--text-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ai-badge {
  font-size: 11px; padding: 1px 6px; border-radius: 8px;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.ai-badge.playing { background: color-mix(in srgb, var(--success) 16%, var(--surface)); color: var(--success); }
.ai-badge.waiting { background: color-mix(in srgb, var(--warning) 16%, var(--surface)); color: var(--warning); }
.ai-badge.ended { background: var(--surface-2); color: var(--text-3); }
.ai-badge.vacant { background: color-mix(in srgb, var(--danger) 16%, var(--surface)); color: var(--danger); }
.ai-seats { grid-column: 1 / -1; color: var(--text-3); font-size: 12px; }
.ai-idle { grid-column: 1 / -1; color: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ai-close {
  grid-column: 3; grid-row: 1; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); border-radius: var(--radius-sm); padding: 4px 12px; font-size: 12px; cursor: pointer; white-space: nowrap;
  transition: all var(--t-fast);
}
.ai-close:hover { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); border-color: var(--danger); color: var(--danger); }
.ai-close:disabled { opacity: .5; cursor: default; }
.adm-hint { font-size: 12px; color: var(--text-3); text-align: center; margin: 12px 0 0; }

.adm-label { display: block; font-size: 12.5px; color: var(--text-2); margin: 10px 0 4px; }

/* ---- 主题切换器（显示当前主题，点击切换） ---- */
.theme-switcher { position: fixed; left: 14px; bottom: 14px; z-index: 70; font-family: var(--font-ui); }
.theme-btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 9px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--text); background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-md); transition: border-color var(--t-fast), transform var(--t-fast);
}
.theme-btn:hover { border-color: var(--primary); transform: translateY(-1px); }
.theme-btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.theme-btn .sw-dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.15) inset; }
.theme-btn .sw-caret { opacity: .55; font-size: 10px; margin-left: 2px; }
.theme-menu {
  position: absolute; bottom: calc(100% + 10px); left: 0; min-width: 196px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 8px; display: none; backdrop-filter: blur(var(--glass-blur));
}
.theme-menu.open { display: block; }
.theme-menu-hint { font-size: 11px; color: var(--text-3); padding: 2px 10px 8px; }
.theme-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border: none; background: transparent; cursor: pointer;
  color: var(--text); border-radius: var(--radius-md); font-size: 13.5px; font-family: var(--font-ui);
}
.theme-opt:hover { background: var(--surface-2); }
.theme-opt[aria-checked="true"] { font-weight: 700; }
.theme-opt[aria-checked="true"]::after { content: '✓'; margin-left: auto; color: var(--primary); }
.theme-opt .sw-dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 1px rgba(0,0,0,.15) inset; }

/* 玻璃 / 霓虹主题专属质感 */
[data-theme="glass"] .adm-card,
[data-theme="glass"] .adm-list,
[data-theme="glass"] .adm-fatal {
  backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--shadow-md);
}
[data-theme="cyber"] .adm-card,
[data-theme="cyber"] .adm-list { box-shadow: var(--shadow-md); }
[data-theme="cyber"] .adm-mark { box-shadow: 0 0 18px -2px var(--primary); }
[data-theme="cyber"] .adm-stat.live b { text-shadow: 0 0 10px color-mix(in srgb, var(--success) 60%, transparent); }

@media (max-width: 560px) {
  /* 收紧留白：手机端更紧凑 */
  .adm-wrapper { padding: 0 12px 88px; }          /* 底部留出切换器空间 */
  .adm-header { padding: 12px 2px 10px; gap: 8px; }
  .adm-mark { width: 32px; height: 32px; font-size: 17px; border-radius: 9px; }
  .adm-title { font-size: 17px; }
  .adm-user { font-size: 12px; }
  .adm-btn { padding: 8px 14px; font-size: 13.5px; border-radius: 9px; }
  .adm-header-right .adm-btn-ghost { padding: 6px 12px; font-size: 12.5px; }

  /* 登录卡片：减小内外边距与标题字号 */
  .adm-card { padding: 22px 18px; margin-top: 18px; border-radius: var(--radius-md); }
  .adm-h1 { font-size: 20px; margin-bottom: 4px; }
  .adm-h2 { font-size: 17px; }
  .adm-sub { font-size: 13.5px; margin-bottom: 14px; }
  .adm-input { padding: 10px 12px; font-size: 15px; }
  .adm-tip { font-size: 11.5px; margin-top: 12px; }

  /* 标签页更紧凑 */
  .adm-tabs { gap: 2px; margin-bottom: 12px; }
  .adm-tab { padding: 9px 12px; font-size: 14px; }

  /* 统计：改为 5 等分单行，不再换行成两行 */
  .adm-stats { gap: 6px; margin-bottom: 12px; }
  .adm-stat {
    flex: 1 1 0; min-width: 0; padding: 8px 2px; font-size: 11px;
    border-radius: 9px; overflow: hidden;
  }
  .adm-stat b { font-size: 17px; }
  .adm-stat span { font-size: 11px; }

  .adm-toolbar { gap: 8px; margin-bottom: 12px; }
  .adm-list { max-height: 44vh; border-radius: var(--radius-md); }
  .adm-item { padding: 9px; gap: 4px 8px; font-size: 12.5px; }
  .ai-code { font-size: 14px; }
  .adm-hint { font-size: 11px; margin-top: 10px; }

  /* 切换器缩小，避免遮挡内容 */
  .theme-btn { padding: 7px 11px; font-size: 12px; }
  .theme-menu { min-width: 172px; }
  .theme-opt { padding: 7px 9px; font-size: 13px; }
}

/* ============================================================
   主题质感增强层
   换肤不只是换色：渐变背景、毛玻璃、霓虹发光、字体气质
   ============================================================ */

/* 1) 渐变背景：玻璃/霓虹等主题带氛围底纹（无渐变时为 none） */
html[data-theme] body {
  background-image: var(--bg-grad, none);
  background-attachment: fixed;
}

/* 2) 毛玻璃：液态玻璃主题下，卡片与弹层真正"透光" */
[data-theme="glass"] .mode-card,
[data-theme="glass"] .waiting-box,
[data-theme="glass"] .roomlobby-box,
[data-theme="glass"] .players-card,
[data-theme="glass"] .chat-card,
[data-theme="glass"] .side-panel,
[data-theme="glass"] .lobby-options,
[data-theme="glass"] .spectators-box,
[data-theme="glass"] .soon-box,
[data-theme="glass"] .modal,
[data-theme="glass"] .code-box,
[data-theme="glass"] .shot-modal,
[data-theme="glass"] .game-sheet,
[data-theme="glass"] .gs-panel {
  background: color-mix(in srgb, var(--surface) calc(var(--surface-alpha) * 100%), transparent);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid rgba(255, 255, 255, .35);
}
/* 玻璃态下顶栏也半透，整体更通透 */
[data-theme="glass"] .site-header {
  background: color-mix(in srgb, var(--header-bg) 78%, transparent);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
}

/* 3) 霓虹：赛博主题给主色元素加发光描边 */
[data-theme="cyber"] .mode-card,
[data-theme="cyber"] .waiting-box,
[data-theme="cyber"] .roomlobby-box,
[data-theme="cyber"] .players-card,
[data-theme="cyber"] .modal {
  box-shadow: 0 0 0 1px var(--line), var(--shadow-md);
}
[data-theme="cyber"] .btn-primary,
[data-theme="cyber"] .nav-item.active,
[data-theme="cyber"] .brand-mark {
  text-shadow: 0 0 10px color-mix(in srgb, var(--primary) 70%, transparent);
}
[data-theme="cyber"] .primary,
[data-theme="cyber"] .btn-primary { box-shadow: 0 0 18px -2px var(--ring), var(--shadow-md); }

/* 4) 字体气质：古风用衬线标题，现代/赛博用无衬线 */
.brand-name,
.mode-card .mc-title,
.hero-title,
.adm-title {
  font-family: var(--font-display, inherit);
}

/* ==================================================================
 * 响应式「可点击性」兜底（不同宽高比下按钮点不开的根因修复）
 * ------------------------------------------------------------------
 * 问题：管理入口 .adm-entry（z-index 60）与主题切换器 .theme-switcher
 *       （z-index 70）都是 position:fixed + bottom 贴底。而手机端底部
 *       被 Tab 栏（z-index 700）或对局操作条 .game-dock（750）占满，
 *       两者层高更低且与它们的高度重叠 → 在 ≤720px 下永久被盖住，
 *       「管理后台」「主题切换」两个按钮完全点不到。
 * 修复：在手机断点把它们抬到底栏之上，并提到底栏之上（< 遮罩 798）。
 * ================================================================== */

/* 桌面/平板：维持贴底，但补足 44px 触控安全尺寸 */
.adm-entry {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
}
.theme-btn {
  min-height: 38px;
  padding: 8px 14px;
}

@media (max-width: 720px) {
  /* 抬到底部 Tab 栏 / 对局操作条之上；两者实测高度约 60–66px */
  .adm-entry,
  .theme-switcher {
    bottom: calc(70px + env(safe-area-inset-bottom));
    z-index: 780;
  }
  .adm-entry { right: 10px; }
  .theme-switcher { left: 10px; }
  /* 横向两侧都贴边时，避免两者在极窄屏（≤360px）上互相重叠 */
  .theme-switcher { max-width: calc(100vw - 130px); }
  .theme-btn { max-width: 100%; padding: 8px 11px; font-size: 12px; }
  .theme-btn #themeName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* 棋种横向滚动箭头：26px 宽低于 32px 触控下限，加宽并加大命中区 */
.nav-arrow { width: 32px; height: 40px; }
.nav-wrap.can-left .game-nav { padding-left: 36px; }
.nav-wrap.can-right .game-nav { padding-right: 36px; }

/* 横向滚动容器末尾给右箭头让位。
   不能直接依赖 .game-nav 的 padding-right：flex + overflow-x 的滚动容器
   滚到尽头时尾部内边距常常不被保留，最后一项会被右箭头压住一部分，
   看着能点、点右半边却没反应。这里补一个真实占位盒子，滚动容器一定会算它。 */
.game-nav::after { content: ''; flex: 0 0 4px; }
.nav-wrap.can-right .game-nav::after { flex-basis: 40px; }
.nav-wrap.can-left .game-nav::before { content: ''; flex: 0 0 0; }

/* 超矮视口（横屏手机，可视高度 ≤ 430px）：压缩纵向留白，保证主操作不出屏 */
@media (max-height: 430px) and (max-width: 900px) {
  .site-main { padding-top: 8px; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .hero { padding: 2px 0 8px; }
  .hero-title { font-size: 22px; letter-spacing: 2px; }
  .hero-sub { display: none; }
  .adm-entry,
  .theme-switcher { bottom: calc(62px + env(safe-area-inset-bottom)); }
}

/* 窄屏抽屉 / 弹层：按钮不再被挤出视口 */
@media (max-width: 400px) {
  .modal-actions { flex-wrap: wrap; gap: 8px; }
  .modal-actions .btn { flex: 1 1 100%; max-width: none; min-height: 44px; }
}

/* ================= 版本号显示 =================
   版本号唯一来源是 package.json，由服务端注入到页面。
   页脚放在 .site-main 内部（不是 fixed），所以手机端 Tab 栏、
   对局页操作条都不会压住它 —— 这点延续本次适配修复的排查结论。 */
.app-footer {
  margin: 26px 0 4px;
  text-align: center;
  line-height: 1.6;
}
.app-ver {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-3, var(--ink-2, #9a8f80));
  opacity: 0.9;
  user-select: all;
  -webkit-user-select: all;
}

/* 管理后台顶栏版本号 */
.adm-ver {
  margin-right: 10px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-3, var(--ink-2, #9a8f80));
  opacity: 0.85;
  user-select: all;
  -webkit-user-select: all;
}

/* 对局页（全屏沉浸）里页脚不参与布局争抢，缩到最小 */
body.in-game .app-footer { margin: 10px 0 0; }

/* ==================================================================
 * 规则说明弹窗 + 对局侧栏「谁大谁小」图表
 * ------------------------------------------------------------------
 * 规则弹窗用主题令牌（--surface / --text），在木色与赛博霓虹等主题下
 * 都保持可读；侧栏 rank-card 复用同一套 rank 图表样式，窄栏自动压缩。
 * ================================================================== */
.rules-modal {
  max-width: 880px;
  width: 100%;
  padding: 0;
  text-align: left;
  background: var(--surface, #fff);
  color: var(--text, #2c2418);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 86vh;
}
.rules-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line, #e3d7c2);
}
.rules-head h2 { font-size: 20px; margin: 0; color: var(--text, #2c2418); }
.rules-close {
  border: none; background: transparent; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--text-2, #6b5c47);
  width: 34px; height: 34px; border-radius: 8px;
}
.rules-close:hover { background: var(--surface-2, #f3ead8); }
.rules-body { display: flex; min-height: 0; flex: 1; }
.rules-list {
  flex: 0 0 168px;
  border-right: 1px solid var(--line, #e3d7c2);
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rules-item {
  display: flex; align-items: center; gap: 10px;
  border: none; background: transparent; cursor: pointer;
  padding: 9px 10px; border-radius: 9px;
  font-size: 14px; color: var(--text-2, #6b5c47);
  text-align: left; min-height: 38px;
}
.rules-item:hover { background: var(--surface-2, #f3ead8); }
.rules-item.active { background: var(--primary, #c0392b); color: var(--primary-contrast, #fff); font-weight: 600; }
.rules-item .ri-icon {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: rgba(127,127,127,.18);
}
.rules-item.active .ri-icon { background: rgba(255,255,255,.22); }
.rules-content {
  flex: 1; overflow-y: auto; padding: 18px 22px 22px;
  min-width: 0;
}
.rules-loading, .rules-empty { color: var(--text-3, #a2937e); padding: 20px 0; }
.rules-head-card {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1px dashed var(--line-strong, #d8c8ac);
}
.rules-badge {
  flex: 0 0 46px; width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center; font-size: 24px; font-weight: 700;
  background: linear-gradient(145deg, var(--primary, #c0392b), var(--primary-hover, #a93226));
  color: var(--primary-contrast, #fff);
}
.rules-name { font-size: 19px; font-weight: 700; color: var(--text, #2c2418); }
.rules-summary { font-size: 13.5px; color: var(--text-2, #6b5c47); margin-top: 2px; }
.rules-section { margin-bottom: 16px; }
.rules-section h3 {
  font-size: 15px; margin: 0 0 7px; color: var(--primary, #c0392b);
  font-weight: 600;
}
.rules-section p { font-size: 14px; line-height: 1.75; color: var(--text, #2c2418); margin: 0 0 6px; }
.rules-section ul { margin: 0; padding-left: 20px; }
.rules-section li { font-size: 13.5px; line-height: 1.7; color: var(--text-2, #6b5c47); margin-bottom: 3px; }

/* ---- 谁大谁小：等级图表（弹窗内 + 侧栏卡片共用） ---- */
.rank-card {
  background: var(--surface-2, #f3ead8);
  border: 1px solid var(--line, #e3d7c2);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.rank-card-title {
  font-size: 13.5px; font-weight: 700; color: var(--text, #2c2418);
  margin-bottom: 8px;
}
.rank-chart { /* 容器，弹窗内与侧栏共用 */ }
.rank-title {
  font-size: 14px; font-weight: 700; color: var(--text, #2c2418);
  margin: 4px 0 6px;
}
.rank-note {
  font-size: 12px; line-height: 1.6; color: var(--text-2, #6b5c47);
  margin-bottom: 10px;
}
.rank-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; border-top: 1px dashed var(--line, #e3d7c2);
}
.rank-row:first-of-type { border-top: none; }
.rank-badge {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 7px;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
  color: #fff;
}
.rank-badge.rk-num { background: var(--primary, #c0392b); }
.rank-badge.rk-special { background: var(--accent, #b8860b); }
.rank-name { font-size: 14px; font-weight: 600; color: var(--text, #2c2418); }
.rank-row-note { font-size: 11.5px; color: var(--text-3, #a2937e); margin-left: auto; text-align: right; }

/* 侧栏更窄时：说明文字换行到下一行，避免挤压徽标 */
.rank-card .rank-row-note { flex-basis: 100%; margin-left: 34px; text-align: left; }

@media (max-width: 720px) {
  .rules-modal { max-width: none; width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .rules-body { flex-direction: column; }
  .rules-list {
    flex: 0 0 auto; flex-direction: row; border-right: none;
    border-bottom: 1px solid var(--line, #e3d7c2);
    overflow-x: auto; overflow-y: hidden; padding: 8px;
  }
  .rules-item { flex: 0 0 auto; white-space: nowrap; }
  .rules-content { padding: 16px; }
}
