:root {
  --bg: #14161c;
  --panel: #1d212b;
  --panel2: #262b38;
  --line: #333a4a;
  --text: #e9edf5;
  --dim: #98a1b3;
  --accent: #4f8cff;
  --accent2: #2bd39a;
  --danger: #ff5f6d;
  --wood: #e3b778;
  --wood2: #d8a75f;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 680px; margin: 0 auto; padding: 12px 12px 40px; }

/* ---------- 通用 ---------- */
.hd { display: flex; align-items: center; padding: 6px 2px 14px; }
.hd > * + * { margin-left: 10px; }
.hd h1 { font-size: 17px; margin: 0; font-weight: 600; flex: 1; }
.back {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 10px; padding: 7px 11px; font-size: 13px; cursor: pointer;
}
.back:active { transform: scale(.97); }
.btn {
  border: 0; border-radius: 11px; padding: 11px 14px; font-size: 14px; font-weight: 600;
  background: var(--panel2); color: var(--text); cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(180deg, #5b95ff, #3d7bf0); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: transparent; border: 1px solid rgba(255,95,109,.5); color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: default; }
.row { display: flex; flex-wrap: wrap; margin: 0 -4px; }
.row > * { margin: 0 4px 8px; }
.chip {
  display: inline-flex; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; font-size: 12px; color: var(--dim);
}
.chip > * + * { margin-left: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent2); }
.dot.off { background: #7a5560; }

/* ---------- 大厅 ---------- */
.hero { text-align: center; padding: 22px 0 8px; }
.hero h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: 2px; }
.hero p { margin: 0; color: var(--dim); font-size: 13px; }
.cards { display: block; margin-top: 18px; }
/* 说明：旧版卡片的 flex 横排布局已废弃，改为纵向卡片，内部由
   .ctop / .cinfo / .chips / .cbtns 组成（见文件后半部分）。
.join-box { margin-top: 20px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px; }
.join-box h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.join-box input, .chat input, .name-input {
  background: #12151c; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 15px; width: 100%; outline: none;
}
.name-input { letter-spacing: .5px; }
.join-box input { text-transform: uppercase; letter-spacing: 3px; font-weight: 700; }
.join-box input:focus, .chat input:focus { border-color: var(--accent); }
.tip { font-size: 12px; color: var(--dim); margin-top: 10px; line-height: 1.6; }

/* ---------- 对局 ---------- */
.bar { display: flex; align-items: center; margin-bottom: 10px; }
.bar > * + * { margin-left: 8px; }
.code-chip { cursor: pointer; font-weight: 700; color: var(--text); letter-spacing: 1px; }
.status {
  text-align: center; padding: 11px; border-radius: 12px; font-size: 15px; font-weight: 600;
  background: var(--panel); border: 1px solid var(--line); margin-bottom: 10px;
}
.status.myturn { border-color: rgba(43,211,154,.55); background: rgba(43,211,154,.10); color: #8ff0cb; }
.status.over { border-color: rgba(255,95,109,.45); background: rgba(255,95,109,.10); }
.seats { display: flex; margin-bottom: 10px; }
.seats > * + * { margin-left: 8px; }
.seat {
  flex: 1; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 11px; font-size: 13px; min-width: 0;
}
.seat.active { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(79,140,255,.35) inset; }
.seat .nm { display: flex; align-items: center; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .cl { font-size: 11px; color: var(--dim); margin-top: 3px; }
.seat .nm .dot { margin-right: 6px; }
.seat .nm .avatar { margin-right: 6px; }
.board-wrap { display: flex; justify-content: center; }
canvas { display: block; border-radius: 14px; touch-action: manipulation; }
.controls { display: flex; flex-wrap: wrap; margin: 12px -4px 0; }
.controls > * { margin: 0 4px 8px; }
.controls .btn { flex: 1; min-width: 86px; }
.chat { margin-top: 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; }
.chat-list { height: 168px; overflow-y: auto; padding: 10px 12px; font-size: 13px; line-height: 1.7; }
.chat-list .who { color: var(--accent); font-weight: 600; }
.chat-list .sys { color: var(--dim); font-style: italic; }
.chat-form { display: flex; padding: 9px; border-top: 1px solid var(--line); }
.chat-form > * + * { margin-left: 8px; }
.chat-form input { flex: 1; }
.chat-form button { border: 0; border-radius: 10px; padding: 0 16px; background: var(--accent);
  color: #fff; font-weight: 600; cursor: pointer; }
.loading { text-align: center; padding: 60px 0; color: var(--dim); }
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 20px);
  background: rgba(20,22,28,.96); border: 1px solid var(--line); color: #fff;
  padding: 11px 16px; border-radius: 12px; font-size: 14px; max-width: 88vw;
  opacity: 0; pointer-events: none; transition: .22s; z-index: 99; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 进入棋室时的慢网络提示（弱网下给用户一个解释，避免误判为"打不开"） */
.ld-hint { margin-top: 10px; font-size: 12px; color: var(--dim); min-height: 16px; }

/* ---------- 扫雷（单人）工具条 ---------- */
.mine-bar { display: flex; align-items: center; flex-wrap: wrap; margin: 0 -4px 10px; }
.mine-bar > * { margin: 0 4px 8px; }
.mine-bar .mb-item {
  font-size: 14px; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 74px;
}
.mine-bar .mb-item b { color: var(--accent); font-size: 16px; }

/* ---------------------------------------------------------------
   手机点按优化：去掉浏览器的"双击缩放"判定。
   不加这条，移动端每次点击要等约 300ms 才触发 click —— 落子会有明显卡顿感。
   --------------------------------------------------------------- */
canvas#board, .btn, .seg, .qbtn, .av, .avatar-btn, .chat-hd, .ctop {
  touch-action: manipulation;
}

/* ---------- 访问统计 ---------- */
.stats-line {
  text-align: center; color: var(--dim); font-size: 12px; line-height: 1.8;
  margin: 14px 0 6px; padding: 10px 8px; border-top: 1px solid var(--line);
  word-break: break-all;
}

/* ---------- 大厅游戏卡（手机优先：大点按区、不依赖 hover） ---------- */
/* 类名用 .seg（旧文件里已有 .chip 是房间号药丸标签，不能撞名） */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.ctop { display: flex; align-items: center; margin-bottom: 10px; }
.ctop .ico { font-size: 26px; line-height: 1; margin-right: 10px; }

/* 难度卡：跟游戏卡区分开（它是"设置"，不是"一个游戏"） */
.diffcard { border-color: rgba(79, 140, 255, .38); }
.diffcard .ctop .ico { font-size: 22px; }
.cinfo i { min-height: 16px; }
/* 卡片上的补充说明（例如围棋人机棋力有限） */
.card-note {
  font-size: 11px; color: #e8b04b; background: rgba(232, 176, 75, .12);
  border-radius: 8px; padding: 5px 9px; margin-bottom: 10px;
}
.cinfo { display: flex; flex-direction: column; min-width: 0; }
.cinfo b { font-size: 16px; }
.cinfo i { font-style: normal; color: var(--dim); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; margin: 0 -4px 8px; }
.seg {
  flex: 1 1 0; min-width: 52px; min-height: 40px; margin: 0 4px 8px; padding: 8px 6px;
  border-radius: 10px; background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); font-size: 13px; cursor: pointer;
}
.seg.on { background: var(--accent); border-color: var(--accent); color: #10121a; font-weight: 600; }
.seg:active { transform: scale(.96); }
/* 注意：这里的行内布局刻意【不用 flex 的 gap】——
   微信 X5 内核约等于 Chrome 66~77，而 gap 要 Chrome 84+，在微信里会失效导致元素挤在一起。
   统一改用 margin 方案，全内核可用。 */
.cbtns { display: flex; margin: 0 -5px; }
.cbtns .btn { flex: 1; min-height: 46px; margin: 0 5px; }
.btn.small { min-height: 44px; min-width: 52px; padding: 0 12px; }

/* ---------- 身份：头像与昵称（游客也能自己选） ---------- */
.identity { border-color: var(--accent); }
.idrow { display: flex; align-items: center; margin-bottom: 10px; }
.idrow > * { margin-right: 10px; }
.idrow > *:last-child { margin-right: 0; }
.avatar-btn {
  width: 54px; height: 54px; flex: 0 0 54px; border-radius: 50%;
  background: var(--panel2); border: 2px solid var(--accent);
  font-size: 27px; line-height: 1; padding: 0; cursor: pointer;
}
.avatar-btn:active { transform: scale(.94); }
/* 头像网格：用固定像素尺寸，不用 aspect-ratio（那个要 Chrome 88+，微信里不支持） */
.avgrid { display: flex; flex-wrap: wrap; margin: 0 -3px 6px; }
.av {
  width: 38px; height: 38px; margin: 0 3px 7px; border-radius: 50%;
  background: var(--panel2); border: 1px solid var(--line);
  font-size: 20px; line-height: 1; padding: 0; cursor: pointer;
}
.av.on { border-color: var(--accent); background: rgba(79, 140, 255, .22); }
.av:active { transform: scale(.92); }
/* 座位与聊天里显示的小头像 */
.avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; background: var(--panel2);
  display: inline-block; text-align: center; line-height: 30px; font-size: 17px;
  vertical-align: middle;
}

/* ---------- 悔棋提示条（对方请求时出现） ---------- */
.undo-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255, 193, 7, .14); border: 1px solid rgba(255, 193, 7, .45);
  border-radius: 12px; padding: 10px 12px; margin-top: 10px; font-size: 13px;
}
.undo-bar > * + * { margin-left: 8px; }
.undo-bar span { flex: 1; }

/* ---------- 聊天（手机优先：折叠 + 快捷短语 + 时间戳 + 未读） ---------- */
.chat { border-radius: 14px; overflow: hidden; }
.chat-hd {
  display: flex; align-items: center; padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--line); -webkit-user-select: none; user-select: none;
}
.chat-title { font-size: 13px; font-weight: 600; }
.chat-badge {
  margin-left: 8px; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: #10121a; font-size: 11px;
  font-weight: 600; text-align: center;
}
.chat-toggle { margin-left: auto; font-size: 12px; color: var(--dim); }
.chat-list { -webkit-overflow-scrolling: touch; }
.chat-list .msg { display: flex; align-items: flex-start; margin-bottom: 8px; }
.chat-list .msg .avatar {
  width: 26px; height: 26px; flex: 0 0 26px; line-height: 26px;
  font-size: 15px; margin-right: 8px;
}
.msg-body { flex: 1; min-width: 0; }
.msg-body .who { color: var(--accent2); font-size: 12px; margin-right: 6px; }
.msg-body .time { color: var(--dim); font-size: 11px; }
.msg-body .txt { display: block; word-break: break-word; color: var(--text); }

/* 快捷短语 */
.quick { display: flex; flex-wrap: wrap; padding: 8px 8px 2px; border-top: 1px solid var(--line); }
.qbtn {
  margin: 0 4px 6px; padding: 7px 11px; border-radius: 999px; font-size: 12px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
.qbtn:active { background: var(--accent); color: #10121a; }

/* 输入行：手机上按钮和输入框都要够大 */
.chat-form input { min-height: 42px; font-size: 15px; }
.chat-form button { min-height: 42px; min-width: 64px; font-size: 14px; }

/* ---------- 启动占位与错误兜底（避免白屏） ---------- */
.boot { text-align: center; padding: 70px 0; color: var(--dim); font-size: 14px; }
.boot-error {
  margin: 24px auto; max-width: 520px; background: #241a1f; border: 1px solid rgba(255,95,109,.45);
  border-radius: 14px; padding: 16px; color: #ffd9dd; font-size: 14px; line-height: 1.7;
}
.boot-error b { display: block; margin-bottom: 8px; color: #ff8f99; font-size: 15px; }
.boot-error .be-detail {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
  background: #1a1216; border-radius: 8px; padding: 8px 10px; margin-bottom: 10px;
  word-break: break-all; color: #ffc9cf;
}
.boot-error .be-tip { color: var(--dim); font-size: 13px; }
.boot-error .be-url { margin-top: 8px; font-size: 12px; color: var(--dim); word-break: break-all; }
@media (min-width: 560px) { .hero h2 { font-size: 32px; } }
