/* ════════════════════════════════════════════════���═════════════
   云山对弈 · 五子棋
   极简黑金，与摄影站点同一套设计语言
   ══════════════════════════════════════════════════════════════ */

:root {
  --bg: #050505;
  --ink: #f5f4f1;
  --ink-dim: #a09d97;
  --ink-faint: #6a6862;
  --gold: #c9a558;
  --line: rgba(245, 244, 241, 0.11);
  /* 下面几个以前**只被使用、从未定义**，导致 8 处声明静默失效：
     border: 1px solid var(--gold-line) 整条失效 → 元素根本没有边框
     （.dm--me 的金框、.ask 确认条的边框都因此丢失）；
     border-color: var(--gold-line) 失效 → 回退成 currentColor。
     这里补齐，别再依赖「碰巧看起来还行」的退化表现。 */
  --gold-line: rgba(201, 165, 88, 0.38);   /* 金色描边 */
  --gold-soft: rgba(201, 165, 88, 0.09);   /* 金色淡底 */
  --line-2: rgba(245, 244, 241, 0.2);      /* 比 --line 更明显的一条线 */
  --wood: #d9b978;          /* 棋盘木色 */
  --wood-line: rgba(90, 62, 26, 0.55);
  --font-display: "NSSC FS", "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-ui: "Manrope", system-ui, -apple-system, "PingFang SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);   /* 同 --ease，独立命名以免别处引用落空 */
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

body {
  min-height: 100svh;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, #101012 0%, #08080a 55%, #050505 100%);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.wrap {
  width: 100%;
  /* 放大到40rem：手机上棋盘更大更好落子 */
  max-width: 40rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* ── 顶部 ── */
.hd {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.hd__back {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--ink-dim);
  flex: none;
  transition: color .25s var(--ease), border-color .25s var(--ease);
}
.hd__back:hover { color: var(--gold); border-color: rgba(201,165,88,.4); }

.hd__title {
  flex: 1;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: .18em;
  text-align: center;
  color: var(--ink);
  /* 标题和版本号上藏着两个双击彩蛋，触发点**不做任何视觉标记**
     （不加下划线、不换色、不改光标）—— 看得见就不叫彩蛋了。
     这两条只是为了不让双击时冒出文字选中的高亮、以及手机上的双击缩放，
     外观上没有任何变化。 */
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* 版本号：一眼确认加载的是不是最新文件 */
.hd__ver {
  flex: none;
  font-family: var(--font-mono);
  font-size: .5rem;
  letter-spacing: .1em;
  color: var(--ink-faint);
  opacity: .55;
  padding: .15rem .3rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  user-select: none;
  /* 这儿也藏着一个双击彩蛋，同样不加任何视觉提示。
     只补上「手机双击不要缩放」，外观不变。 */
  touch-action: manipulation;
}

/* 版本号 + 全站计数叠成一列，挂在标题右侧 */
.hd__meta {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .18rem;
}

/* 全站累计完成的对局数。字号压到很小 —— 它是「顺便看一眼」的信息，
   不该和标题抢注意力，但数字给金色，扫一眼就能找到。 */
.hd__stat {
  font-family: var(--font-mono);
  font-size: .5rem;
  letter-spacing: .04em;
  color: var(--ink-faint);
  opacity: .8;
  white-space: nowrap;
  user-select: none;
}
.hd__stat b {
  font-weight: 400;
  color: var(--gold);
  font-variant-numeric: tabular-nums;   /* 等宽数字，变化时宽度不跳 */
}
.hd__stat b.is-bump { animation: score-bump .6s var(--ease); }

.hd__reset {
  flex: none;
  padding: .42rem .9rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: .75rem;
  letter-spacing: .1em;
  color: var(--ink-dim);
  transition: color .25s var(--ease), border-color .25s var(--ease);
}
.hd__reset:hover { color: var(--gold); border-color: rgba(201,165,88,.4); }
.hd__reset:disabled { opacity: .4; cursor: wait; }

/* ── 房间栏 ── */
.room {
  position: relative;      /* 人机标记 .room__badge 绝对定位要用 */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .7rem .9rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255,255,255,.014);
}

.room__side {
  display: flex;
  align-items: center;
  gap: .45rem;
  min-width: 0;
  flex: 1;
}
.room__side--r { justify-content: flex-end; }

.room__stone {
  width: 15px; height: 15px;
  border-radius: 50%;
  flex: none;
  transition: box-shadow .4s var(--ease);
}
.room__stone--b { background: radial-gradient(circle at 32% 28%, #4a4a4a, #0d0d0d 70%); }
.room__stone--w { background: radial-gradient(circle at 32% 28%, #fff, #cfcbc4 70%); }

/* 当前轮次高亮 */
.room__side.is-turn .room__stone {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--gold),
              0 0 14px rgba(201,165,88,.55);
}

.room__name {
  font-size: .8125rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 5.5rem;
}

.room__tag {
  font-family: var(--font-mono);
  font-size: .5625rem;
  letter-spacing: .14em;
  color: var(--ink-faint);
  padding: .15rem .38rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  white-space: nowrap;
}
.room__side.is-turn .room__tag { color: var(--gold); border-color: rgba(201,165,88,.35); }

.room__score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .18rem;
  flex: none;
}
.room__label {
  font-family: var(--font-mono);
  font-size: .5rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* 计分板：弈秋 n : n 褚嬴
   数字给金色和略大的字号，名字压小压暗 —— 一眼先看到比分，
   再看清是谁领先，不需要读懂就能扫到。 */
.score {
  display: flex;
  align-items: baseline;
  gap: .3rem;
  font-variant-numeric: tabular-nums;   /* 等宽数字，比分变化时不会左右跳 */
}
.score__who {
  font-family: var(--font-display);
  font-size: .625rem;
  letter-spacing: .06em;
  color: var(--ink-faint);
  max-width: 3.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.score__n {
  font-family: var(--font-mono);
  font-size: .9375rem;
  line-height: 1;
  color: var(--gold);
  min-width: .8rem;
  text-align: center;
}
.score__c {
  font-size: .75rem;
  color: var(--ink-faint);
  opacity: .6;
}
/* 比分刚刚变化时轻轻亮一下，让人注意到「这局算进去了」 */
.score__n.is-bump { animation: score-bump .6s var(--ease); }
@keyframes score-bump {
  0%   { transform: scale(1);    color: var(--gold); }
  35%  { transform: scale(1.45); color: #f0d79a; }
  100% { transform: scale(1);    color: var(--gold); }
}

/* 房间已满：两个人的名字都占上了，来晚的人只能看到提示 */
.room.is-full .room__name { color: var(--ink-faint); }

@media (max-width: 420px) {
  .score__who { max-width: 2.4rem; font-size: .5625rem; }
  .score__n { font-size: .8125rem; }
  .room__side .room__name { max-width: 3.6rem; font-size: .8125rem; }
}

/* ── 棋盘 ── */
.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6),
              0 0 0 1px rgba(201,165,88,.14);
  background: var(--wood);
}

/* 棋盘线层：与网格严格同框（inset:0），
   线画在 viewBox 的 0.5 / 1.5 / … 处，即每格中心 —— 棋子正好落在交点上。
   棋盘四周的留白由坐标范围 0.5~14.5 自然产生，不需要额外 padding。 */
.grid-lines {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.grid-lines line {
  stroke: var(--wood-line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
/* 星位点 */
.grid-lines circle {
  fill: var(--wood-line);
}

/* 外框加粗一点，视觉上把棋盘"框住" */
.grid-lines rect {
  fill: none;
  stroke: rgba(90, 62, 26, 0.85);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.board {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* 棋子 */
.piece {
  position: relative;
  z-index: 2;
  width: 82%;
  height: 82%;
  border-radius: 50%;
  transform: scale(0);
  animation: drop .38s var(--ease) forwards;
  box-shadow: 0 2px 5px rgba(0,0,0,.42);
  pointer-events: none;
}
@keyframes drop {
  0%   { transform: scale(.35); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.piece--b { background: radial-gradient(circle at 34% 28%, #565656, #0a0a0a 68%); }
.piece--w {
  background: radial-gradient(circle at 34% 28%, #fff, #d6d2ca 68%);
}

/* 最后落子：多层金色标记（外环 + 内环 + 光晕 + 呼吸） */
.piece--last::before,
.piece--last::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

/* 外层靶心环 */
.piece--last::before {
  inset: -26%;
  border: 2px solid var(--gold);
  box-shadow: 0 0 12px rgba(201, 165, 88, .95),
              0 0 26px rgba(201, 165, 88, .55),
              inset 0 0 8px rgba(201, 165, 88, .35);
  animation: last-ring 1.5s var(--ease) infinite;
}

/* 内层实心光点 */
.piece--last::after {
  inset: -12%;
  background: radial-gradient(circle,
              rgba(255, 233, 176, .95) 0%,
              rgba(201, 165, 88, .55) 45%,
              rgba(201, 165, 88, 0) 72%);
  animation: last-core 1.5s var(--ease) infinite;
}

@keyframes last-ring {
  0%, 100% { transform: scale(.92); opacity: .95; }
  50%      { transform: scale(1.18); opacity: .35; }
}
@keyframes last-core {
  0%, 100% { transform: scale(1);    opacity: .9; }
  50%      { transform: scale(1.45); opacity: .3; }
}

/* 白子上的金色标记也要看得见：加一圈深色描边压住白底 */
.piece--w.piece--last { box-shadow: 0 0 0 1px rgba(90,62,26,.5), 0 2px 5px rgba(0,0,0,.42); }

/* 可落子提示（轮到本人） */
.cell.can-play::after {
  content: "";
  position: absolute;
  z-index: 1;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: rgba(90, 60, 20, .32);
  opacity: 0;
  transition: opacity .2s var(--ease);
}
.cell.can-play:hover::after { opacity: 1; }

.board.is-locked .cell { cursor: default; }
.board.is-locked .cell.can-play::after { display: none; }

/* ── 待确认的落子（两次点击落子的第一次）──
   半透明幽灵棋子 + 金圈 + 缓慢呼吸，明确表达「还没落下，可以改」。
   纯本地状态，从不写云端，所以对方完全看不到。
   用 inset:9% 而不是 width/height —— 格子是 grid 容器，
   绝对定位用 inset 自动居中，不用再管对齐。 */
.cell.is-armed::before {
  content: "";
  position: absolute;
  inset: 9%;
  z-index: 2;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #5c5c5c, #0a0a0a 68%);
  box-shadow: 0 0 0 1.5px var(--gold),
              0 0 16px rgba(201, 165, 88, .55),
              inset 0 -2px 5px rgba(0, 0, 0, .6);
  animation: arm-breathe 1.4s var(--ease) infinite;
  pointer-events: none;
}
.cell.is-armed--w::before {
  background: radial-gradient(circle at 34% 28%, #fff, #d8d4cc 68%);
  box-shadow: 0 0 0 1.5px var(--gold),
              0 0 16px rgba(201, 165, 88, .5),
              inset 0 -2px 4px rgba(140, 132, 116, .5);
}
@keyframes arm-breathe {
  0%, 100% { opacity: .40; transform: scale(1); }
  50%      { opacity: .62; transform: scale(1.06); }
}
/* 瞄准中的格子不再显示悬停小点，免得两个提示打架 */
.cell.is-armed.can-play::after { display: none; }

/* ── 胜利连线 ── */
.winline {
  position: absolute;
  /* 与棋盘线、网格三者严格同框 */
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  overflow: visible;
  transition: opacity .45s var(--ease);
}
.winline.on { opacity: 1; }
.winline line {
  stroke: var(--gold);
  stroke-width: .18;
  stroke-linecap: round;
  filter: drop-shadow(0 0 5px rgba(201,165,88,.8));
}

/* ── 旧地址提示 ──
   只在 App 发布域名上出现（那个域名被微信内置浏览器拦掉，分享出去打不开）。
   刻意做得像一条「通知」而不是「错误」：它不是故障，只是地址该换了。 */
.legacy {
  margin: -.35rem 0 -.3rem;
  padding: .55rem .8rem;
  border: 1px solid var(--gold-line);
  border-radius: 4px;
  background: rgba(201, 165, 88, .08);
  color: var(--ink-dim);
  font-size: .75rem;
  line-height: 1.6;
  text-align: center;
}
.legacy b {
  font-weight: 400;
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: .95em;
  word-break: break-all;
}

/* ── 实时胜率条 ──
   贴在棋盘和提示行之间。设计上有两点是刻意的：
   1. 底色用**白子色**打底、黑方从左边往右填充 ——
      这样 50% 是一道正中间的分界，领先方多少一目了然，
      比两个独立的进度条更容易读。
   2. 数字用等宽字形，百分比跳动时宽度不抖。 */
.rate {
  /* 外层 .wrap 是 gap: 1.1rem 的竖向 flex，胜率条只有 6px 高 + 一行小字，
     上下各留满 1.1rem 会显得散。用负 margin 吃掉一半，收到 .55rem。
     负 margin 在这里安全：它只影响自身，不影响兄弟元素的间距计算。 */
  margin: -.5rem 0 -.45rem;
  width: 100%;
}

.rate__track {
  position: relative;
  height: 6px;
  border-radius: 99px;
  overflow: hidden;
  background: #efe7d6;                 /* 白子色打底 */
  box-shadow: inset 0 1px 2px rgba(90, 60, 20, .28);
}

.rate__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 50%;
  border-radius: 99px 0 0 99px;
  background: linear-gradient(90deg, #17150f, #3c3527);
  transition: width .45s var(--ease);
}

.rate__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  margin: .3rem 0 0;
  font-size: .625rem;
  color: var(--ink-faint);
  letter-spacing: .06em;
}
.rate__side b {
  margin-left: .28em;
  font-family: var(--font-mono);
  font-weight: 400;
  font-variant-numeric: tabular-nums;   /* 数字变化时宽度不跳 */
  color: var(--ink-dim);
}
.rate__side--b b { color: #cbb488; }    /* 黑方那侧数字偏暖，和棋子呼应 */
.rate__side--w b { color: #f2ece0; }

.rate__verdict {
  font-family: var(--font-display);
  font-size: .6875rem;
  color: var(--ink-dim);
}

/* 领先方超过八成时，把结论染成金色 —— 数字之外再给一次提示 */
.rate.is-lead .rate__verdict { color: var(--gold); }
.rate.is-even .rate__verdict { color: var(--ink-faint); }

/* ── 状态提示 ── */
.hint {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: .06em;
  color: var(--ink-dim);
  min-height: 1.7em;
  line-height: 1.7;
}
.hint b { color: var(--gold); font-weight: 400; }
.hint .win { color: var(--gold); }
.hint__again {
  display: block;
  margin-top: .15rem;
  font-family: var(--font-ui);
  font-style: normal;
  font-size: .6875rem;
  letter-spacing: .08em;
  color: var(--ink-faint);
}

/* ── 邀请按钮 ── */
.invite {
  padding: .7rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: .8125rem;
  letter-spacing: .14em;
  color: var(--ink-dim);
  transition: color .25s var(--ease), border-color .25s var(--ease),
              background .25s var(--ease);
}
.invite:hover {
  color: var(--gold);
  border-color: rgba(201,165,88,.42);
  background: rgba(201,165,88,.07);
}
.invite.done {
  color: #7fbf7f;
  border-color: rgba(127,191,127,.4);
}

/* ── 移动端 ── */
@media (max-width: 420px) {
  .wrap { gap: .85rem; }
  .hd__title { font-size: 1.125rem; letter-spacing: .14em; }
  .room { padding: .55rem .65rem; }
  .room__name { max-width: 3.8rem; font-size: .75rem; }
  .hint { font-size: .9375rem; }
}

/* ══════════════════════════════════════════════════════
   弹幕层
   ══════════════════════════════════════════════════════ */

/* 弹幕容器覆盖在棋盘上，但不拦截点击 */
.play-area {
  position: relative;
  width: 100%;
}

.danmaku {
  position: absolute;
  /* 只覆盖棋盘中部横带，避开顶栏与底部信息 */
  top: 8%;
  left: 0; right: 0;
  height: 84%;
  /* 必须**高于面板遮罩**（.tool-scrim = 6）、低于面板本身（9）。
     遮罩带 backdrop-filter: blur()，弹幕若压在它下面会被一起糊掉 ——
     打开聊天面板时对方说的话就完全看不清了。 */
  z-index: 7;
  pointer-events: none;
  overflow: hidden;
}

.dm {
  position: absolute;
  left: 100%;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: clamp(0.9375rem, 3.6vw, 1.375rem);
  line-height: 1;
  padding: .34em .8em;
  border-radius: 99px;
  background: rgba(5, 5, 5, 0.78);
  color: #fff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .6);
  will-change: transform;
  animation: dm-fly var(--dur, 4.2s) linear forwards;
  /* 描边保证在浅色木纹上也清晰 */
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
}

/* 己方弹幕用金色描边，一眼分清是谁发的 */
.dm--me {
  color: var(--gold);
  border: 1px solid var(--gold-line);
  background: rgba(20, 16, 8, .82);
}

/* 观战者/对手 */
.dm--other {
  color: #f0efe9;
  border: 1px solid rgba(255, 255, 255, .14);
}

/* 底部大号弹幕（重要的话走大号） */
.dm--big {
  font-size: clamp(1.125rem, 4.4vw, 1.75rem);
  padding: .38em 1em;
}

/* ── 彩蛋弹幕 ──
   只有双击标题里的「云」或者右下角版本号才会出现。
   速度刻意放慢（--dur 由 JS 设成 9 秒）：这两句都比普通弹幕长，
   飞太快根本看不清，彩蛋就白留了。
   配色分两种：摸头=红，晚安=蓝。 */
.dm--egg {
  font-size: clamp(1rem, 3.9vw, 1.4375rem);
  padding: .42em 1.05em;
  letter-spacing: .04em;
}
.dm--egg-pat {
  color: #ffd7d7;
  border: 1px solid rgba(255, 108, 108, .78);
  background: linear-gradient(180deg, rgba(102, 18, 18, .96), rgba(54, 8, 8, .96));
  box-shadow: 0 8px 30px rgba(190, 34, 34, .48);
}
.dm--egg-night {
  color: #dbe8ff;
  border: 1px solid rgba(118, 164, 255, .74);
  background: linear-gradient(180deg, rgba(14, 30, 70, .96), rgba(8, 14, 34, .96));
  box-shadow: 0 8px 30px rgba(54, 94, 205, .45);
}
/* 「天元 + 四角」摆出来时的彩蛋：用站点的金调，和局面本身就是一体的 */
.dm--egg-neat {
  color: #f6e6bf;
  border: 1px solid var(--gold-line);
  background: linear-gradient(180deg, rgba(44, 34, 12, .96), rgba(18, 15, 8, .96));
  box-shadow: 0 8px 30px rgba(201, 165, 88, .42);
}

@keyframes dm-fly {
  0%   { transform: translateX(0); opacity: 0; }
  6%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { transform: translateX(calc(-100vw - 100%)); opacity: 0; }
}

/* ══════════════════════════════════════════════════════
   快捷短语栏
   ══════════════════════════════════════════════════════ */

.fx {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
  border-radius: 6px;
}

/* ══════════════════════════════════════════════════════════
   落子特效：云雾散开
   做法：一团柔边雾气在落点凝聚 → 向外推开扩张 → 同时变淡消散。
   关键是**不能有硬边**——用radial-gradient 的柔和衰减 +
   blur() 制造雾气质感，靠多层不同速度/大小的雾团叠出层次。
   ══════════════════════════════════════════════════════════ */

/* 单团雾：radial-gradient 天然柔边，越靠外越透明。
   尺寸/时长/起始透明度全部写死在这一处，三层雾靠不同数值错开层次：
   内层 .95s 起步小 → 中层 1.25s 主体 → 外层 1.5s 推得最远。 */
.fx__mist {
  position: absolute;
  width: 96px; height: 96px;
  margin: -48px 0 0 -48px;
  border-radius: 50%;
  transform: scale(.3);
  filter: blur(7px);
  animation: fx-mist 1.25s cubic-bezier(.16, 1, .3, 1) forwards;
  will-change: transform, opacity;
  /* 黑子落子：暖金色云雾 */
  background: radial-gradient(circle at 50% 50%,
    rgba(201, 165, 88, .62) 0%,
    rgba(201, 165, 88, .38) 26%,
    rgba(201, 165, 88, .16) 48%,
    rgba(201, 165, 88, .05) 68%,
    rgba(201, 165, 88, 0) 82%);
}

/* 白子落子：银白色云雾，和黑子一眼可分 */
.fx__mist--w {
  background: radial-gradient(circle at 50% 50%,
    rgba(248, 247, 244, .70) 0%,
    rgba(240, 240, 235, .42) 26%,
    rgba(232, 233, 229, .19) 48%,
    rgba(226, 229, 229, .07) 68%,
    rgba(226, 229, 229, 0) 82%);
}

@keyframes fx-mist {
  0%   { transform: scale(.28); opacity: 0; }
  14%  { opacity: .95; }
  38%  { transform: scale(1.02); opacity: .72; }
  100% { transform: scale(2.45); opacity: 0; }
}

/* 内层雾：起步更小、扩张更慢，和外层错峰 → 雾气有厚度 */
.fx__mist--in {
  width: 62px; height: 62px;
  margin: -31px 0 0 -31px;
  filter: blur(5px);
  animation-duration: .95s;
}

/* 外层雾：起步就大一些、推得更远，形成「散开」的边缘 */
.fx__mist--out {
  width: 132px; height: 132px;
  margin: -66px 0 0 -66px;
  filter: blur(12px);
  animation-duration: 1.5s;
  opacity: 0;
}

/* 贴地的那一缕薄雾：紧贴棋盘面横向铺开，像烟贴着桌面走 */
.fx__haze {
  position: absolute;
  width: 150px; height: 150px;
  margin: -75px 0 0 -75px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 50%,
    rgba(201, 165, 88, 0) 52%,
    rgba(201, 165, 88, .16) 66%,
    rgba(201, 165, 88, .07) 79%,
    rgba(201, 165, 88, 0) 92%);
  filter: blur(9px);
  transform: scale(.4);
  animation: fx-haze 1.35s cubic-bezier(.22, .7, .3, 1) forwards;
  will-change: transform, opacity;
}
.fx__haze--w {
  background: radial-gradient(ellipse at 50% 50%,
    rgba(245, 244, 241, 0) 52%,
    rgba(242, 242, 238, .18) 66%,
    rgba(238, 240, 240, .08) 79%,
    rgba(238, 240, 240, 0) 92%);
}
@keyframes fx-haze {
  0%   { transform: scale(.35) scaleY(.5);  opacity: 0; }
  20%  { opacity: .9; }
  100% { transform: scale(2.2) scaleY(.85); opacity: 0; }
}

/* 雾中悬浮的微粒：极小的亮点在雾里飘散，加一点「有东西在动」的生气 */
.fx__mote {
  position: absolute;
  width: 3px; height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  background: rgba(255, 238, 198, .9);
  filter: blur(.6px);
  animation: fx-mote 1.15s cubic-bezier(.3, .6, .4, 1) forwards;
  will-change: transform, opacity;
}
.fx__mote--w { background: rgba(255, 255, 255, .9); }
@keyframes fx-mote {
  0%   { transform: translate(0, 0) scale(.4); opacity: 0; }
  22%  { opacity: .85; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ── 胜利演出：撒金粉 ──
   从连珠那几颗子附近向上炸开，到最高点后飘落、旋转、缩小、消失。
   每个粒子的方向/距离/时长/延迟/大小都由 JS 写成 CSS 变量，
   这里只负责「怎么动」—— 所以 46 个粒子共用一条动画，浏览器能批量合成。
   注意棋盘是浅木色，纯金粉会糊在底色里，所以内核提亮到接近白色，
   再加一道极浅的投影把边缘托出来。 */
.gold {
  position: absolute;
  width: var(--sz, 3px);
  height: var(--sz, 3px);
  margin: calc(var(--sz, 3px) / -2) 0 0 calc(var(--sz, 3px) / -2);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%,
    #ffffff 0%, #fff3cf 34%, #eccb7c 66%, rgba(200, 160, 80, 0) 100%);
  box-shadow: 0 1px 2px rgba(96, 64, 20, .45);
  will-change: transform, opacity;
  animation: gold-fly var(--dur, 1.5s) cubic-bezier(.24, .6, .34, 1)
             var(--delay, 0s) forwards;
}

/* 约三成做成四角星，撒出来才有「金粉」那种一闪一闪的感觉
   （圆点旋转看不出来，星形一转就亮一下） */
.gold--star {
  border-radius: 0;
  background: #fdf0cd;
  clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%,
                     50% 100%, 39% 61%, 0% 50%, 39% 39%);
}

@keyframes gold-fly {
  0%   { transform: translate(0, 0) rotate(0deg) scale(.2); opacity: 0; }
  10%  { opacity: 1; }
  /* 52% 是最高点，之后被 --fall 拽着往下落 */
  52%  { transform: translate(var(--dx, 0), var(--dy, -60px))
                   rotate(calc(var(--rot, 180deg) * .55)) scale(1);
         opacity: 1; }
  100% { transform: translate(calc(var(--dx, 0px) * 1.12),
                              calc(var(--dy, -60px) + var(--fall, 45px)))
                   rotate(var(--rot, 180deg)) scale(.25);
         opacity: 0; }
}

/* 落点中心的一点余烬光：雾散后留一线暖光，暗示「气」散尽 */
.fx__ember {
  position: absolute;
  width: 42px; height: 42px;
  margin: -21px 0 0 -21px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 244, 214, .9) 0%,
    rgba(201, 165, 88, .45) 30%,
    rgba(201, 165, 88, 0) 68%);
  animation: fx-ember .62s var(--ease) forwards;
}
/* 白子：冷白余烬，避免白子落下时闪出一团暖光，看着像黑子 */
.fx__ember--w {
  background: radial-gradient(circle,
    rgba(255, 255, 255, .92) 0%,
    rgba(232, 236, 238, .46) 30%,
    rgba(226, 229, 229, 0) 68%);
}
@keyframes fx-ember {
  0%   { transform: scale(.25); opacity: 1; }
  100% { transform: scale(1.55); opacity: 0; }
}

/* 落子瞬间棋盘极轻微的一沉。
   原版 translateY(-2px) + scale(1.006) 的抖动幅度太大，
   云雾是柔和的，棋盘跟着明显晃会很突兀。改成几乎察觉不到的呼吸感。 */
.board-wrap.is-hit { animation: board-hit .5s cubic-bezier(.2, .7, .3, 1); }
@keyframes board-hit {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  40%  { transform: translate3d(0, -1px, 0) scale(1.002); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}

/* 棋子落下：柔和沉入，与云雾的节奏一致。
   原来是 45% 处 scale(1.16) 的明显回弹，节奏太"弹"，
   和云雾的散开不搭，改为「稍过一点再缓缓压实」。 */
.piece.is-new { animation: drop-fancy .5s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes drop-fancy {
  0%   { transform: scale(.5) translateY(-5%); opacity: 0; }
  38%  { transform: scale(1.04) translateY(0);opacity: 1; }
  62%  { transform: scale(.985);                opacity: 1; }
  100% { transform: scale(1);                   opacity: 1; }
}

/* 上一手定位辅助线 */
.lastmark {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}
.lastmark line {
  stroke: var(--gold);
  stroke-width: 1;
  stroke-dasharray: 3 4;
  stroke-linecap: round;
  opacity: .5;
  vector-effect: non-scaling-stroke;
  animation: mark-draw .5s var(--ease) both;
}
.lastmark circle {
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  opacity: .55;
  animation: mark-draw .5s var(--ease) both;
}
@keyframes mark-draw {
  from { opacity: 0; stroke-dashoffset: 14; }
  to   { opacity: .5; stroke-dashoffset: 0; }
}

/* 减少动效偏好：关掉所有动画 */
@media (prefers-reduced-motion: reduce) {
  .fx, .board-wrap.is-hit { display: none; }
  .piece--last::before,
  .piece--last::after,
  .lastmark line,
  .lastmark circle { animation: none; }
  /* 瞄准中的幽灵棋子：保留可见，但不再呼吸，免得晃眼 */
  .cell.is-armed::before { animation: none; opacity: .55; }
}

.quick {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.quick__btn {
  flex: 1 1 auto;
  min-width: 4.4rem;
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  font-family: var(--font-display);
  font-size: .8125rem;
  color: var(--ink-dim);
  white-space: nowrap;
  transition: color .25s var(--ease),
              border-color .25s var(--ease),
              background .25s var(--ease),
              transform .25s var(--ease);
}

.quick__btn:hover,
.quick__btn:focus-visible {
  color: var(--gold);
  border-color: var(--gold-line);
  background: rgba(201, 165, 88, .08);
  transform: translateY(-1px);
}

.quick__btn:active { transform: translateY(0) scale(.97); }

/* 冷却中的按钮变暗，防止刷屏 */
.quick__btn.is-cooling {
  opacity: .35;
  pointer-events: none;
}

/* ── 自定义消息输入框：接在快捷消息下方 ──
   和面板融为一体：不加亮底色，靠一条分隔线 + 细边框，
   焦点时才亮起金边，避免在暗色面板里显得像另一个「盒子」。 */
.compose {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-top: .6rem;
  padding-top: .7rem;
  border-top: 1px solid var(--line);
}

.compose__input {
  flex: 1 1 auto;
  /* min-width:0 必须有：input 有默认固有宽度，
     不加这一行在窄屏上会把 flex 容器撑破。 */
  min-width: 0;
  height: 2.3rem;
  padding: 0 .8rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(245, 244, 241, .05);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: .8125rem;
  transition: border-color .25s var(--ease),
              background .25s var(--ease);
}
.compose__input::placeholder { color: var(--ink-faint); }
.compose__input:focus {
  outline: none;
  border-color: var(--gold-line);
  background: var(--gold-soft);
}

.compose__send {
  flex: 0 0 auto;
  width: 2.3rem;
  height: 2.3rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold-line);
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  cursor: pointer;
  transition: background .25s var(--ease), transform .25s var(--ease);
}
.compose__send:hover { background: rgba(201, 165, 88, .2); }
.compose__send:active { transform: scale(.92); }

@media (max-width: 420px) {
  .compose__input { height: 2.5rem; font-size: .875rem; }  /* 手机上手指点得准一些 */
  .compose__send { width: 2.5rem; height: 2.5rem; }
}

@media (max-width: 420px) {
  .quick { gap: .3rem; }
  .quick__btn {
    min-width: 0;
    flex: 1 1 28%;
    padding: .45rem .3rem;
    font-size: .75rem;
  }
}

/* ══════════════════════════════════════════════════════
   工具面板：折叠式对局操作
   ══════════════════════════════════════════════════════ */

.tools {
  position: relative;
  display: flex;
  justify-content: center;
  gap: .5rem;
}

.tools__btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: .875rem;
  letter-spacing: .1em;
  color: var(--ink-dim);
  background: rgba(255, 255, 255, .015);
  transition: color .25s var(--ease),
              border-color .25s var(--ease),
              background .25s var(--ease);
}
.tools__btn:hover {
  color: var(--gold);
  border-color: var(--gold-line);
  background: rgba(201, 165, 88, .06);
}
.tools__btn[aria-expanded="true"] {
  color: var(--gold);
  border-color: var(--gold-line);
  background: rgba(201, 165, 88, .1);
}
.tools__btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.tools__btn svg { transition: transform .35s var(--ease); }

/* 遮罩：压暗棋盘区域、模糊背后的内容，让面板浮起来。
   层级链（从下到上）不能乱：
     棋盘各层 0–3 → 落子特效 5 → 本遮罩 6 → 弹幕 7 → 面板 9
   弹幕夹在遮罩与面板之间，所以打开聊天时它依然清晰可读。 */
.tool-scrim {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: rgba(3, 3, 3, .55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade .3s var(--ease);
}
.tool-scrim[hidden] { display: none; }

/* 面板 */
.tool-panel {
  position: absolute;
  left: 50%;
  bottom: calc(100% + .6rem);
  transform: translateX(-50%);
  z-index: 9;
  width: min(26rem, calc(100vw - 2rem));
  /* 两个面板宽度不同，各自贴合对应按钮 */
  --panel-w: min(24rem, calc(100vw - 2rem));
  padding: .9rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(12, 12, 14, .97);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .7);
  animation: panel-in .38s var(--ease) both;
}
.tool-panel[hidden] { display: none; }

@keyframes panel-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(.98); }
}

.tool-panel__sec + .tool-panel__sec {
  margin-top: .9rem;
  padding-top: .9rem;
  border-top: 1px solid var(--line);
}

.tool-panel__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  font-family: var(--font-mono);
  font-size: .625rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: .6rem;
}
.tool-panel__label em {
  font-style: normal;
  letter-spacing: .08em;
  text-transform: none;
  font-size: .625rem;
  color: rgba(201, 165, 88, .7);
}

/* 对战模式：三选一（双人 / 人机简单 / 人机困难） */
.modes { display: flex; gap: .4rem; }

/* 人机风格那一排：四个两字选项，单独一排、字号略小，
   视觉上做成「主选项的下级」，不要和上面那排平起平坐。 */
.modes--sub {
  margin-top: .4rem;
  gap: .3rem;
}
.modes--sub .mode {
  padding: .42rem .15rem;
  font-size: .71875rem;
  border-radius: 4px;      /* 圆角改小：从属关系更明显 */
  letter-spacing: .02em;
}
/* 展开时轻轻落下，避免突然出现 */
.modes--sub:not([hidden]) { animation: submenu-in .22s var(--ease); }
@keyframes submenu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mode {
  flex: 1;
  padding: .5rem .3rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: .75rem;
  letter-spacing: .04em;
  white-space: nowrap;
  color: var(--ink-dim);
  background: rgba(255, 255, 255, .014);
  transition: color .25s var(--ease),
              border-color .25s var(--ease),
              background .25s var(--ease);
}
.mode:hover { color: var(--gold); border-color: var(--gold-line); }
/* 当前模式：实心金，一眼看出正在用哪个 */
.mode.is-on {
  color: #14110a;
  border-color: transparent;
  background: linear-gradient(180deg, #e2c47f 0%, var(--gold) 100%);
  box-shadow: 0 2px 12px rgba(201, 165, 88, .38);
}

/* 人机对战时，房间栏右上角挂一枚小标记，免得忘了对手是 AI */
.room__badge {
  position: absolute;
  top: -.45rem; right: .55rem;
  padding: .06rem .38rem;
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: .5rem;
  letter-spacing: .1em;
  color: #14110a;
  background: var(--gold);
}
.room__badge[hidden] { display: none; }

/* 三个操作按钮 */
.acts { display: flex; gap: .4rem; }

.act {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .18rem;
  padding: .65rem .3rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255, 255, 255, .014);
  transition: color .25s var(--ease),
              border-color .25s var(--ease),
              background .25s var(--ease),
              transform .25s var(--ease);
}
.act:hover {
  color: var(--gold);
  border-color: var(--gold-line);
  background: rgba(201, 165, 88, .08);
  transform: translateY(-2px);
}
.act:active { transform: translateY(0); }

.act__name {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: .06em;
  color: var(--ink);
}
.act__note {
  font-size: .5625rem;
  color: var(--ink-faint);
  line-height: 1.3;
  text-align: center;
}

/* 已有待处理请求时，操作按钮置灰 */
.act.is-busy,
.act:disabled {
  opacity: .35;
  pointer-events: none;
}

/* 条件不满足：置灰但**仍可点击**，点了会给出一句原因说明。
   不能用 pointer-events:none —— 那正是「点了没反应」的观感来源。 */
.act.is-off {
  opacity: .42;
  cursor: not-allowed;
  filter: saturate(.4);
}
.act.is-off:hover {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 255, 255, .014);
  transform: none;
}
.act.is-off .act__note { color: var(--gold); opacity: .75; }

/* ══════════════════════════════════════════════════════
   待确认条
   ══════════════════════════════════════════════════════ */

.ask {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
  padding: .7rem .9rem;
  border: 1px solid var(--gold-line);
  border-radius: 3px;
  background: rgba(201, 165, 88, .09);
  animation: ask-in .45s var(--ease-out) both;
}
.ask[hidden] { display: none; }

@keyframes ask-in {
  from { opacity: 0; transform: translateY(8px); }
}

.ask__text {
  font-family: var(--font-display);
  font-size: .9375rem;
  color: var(--ink);
  line-height: 1.5;
}
.ask__text b { color: var(--gold); font-weight: 400; }

.ask__acts { display: flex; gap: .4rem; flex: none; }

.ask__btn {
  padding: .45rem 1rem;
  border-radius: 99px;
  font-size: .8125rem;
  letter-spacing: .08em;
  transition: all .25s var(--ease);
}
.ask__btn--yes {
  border: 1px solid var(--gold);
  background: var(--gold);
  color: #1a1408;
}
.ask__btn--yes:hover { filter: brightness(1.12); }
.ask__btn--no {
  border: 1px solid var(--line-2);
  color: var(--ink-dim);
}
.ask__btn--no:hover { color: var(--ink); border-color: var(--ink-faint); }

/* 我发出的请求：等待对方 */
.ask-wait {
  text-align: center;
  font-size: .8125rem;
  color: var(--ink-faint);
  padding: .7rem;
  border: 1px dashed var(--line);
  border-radius: 3px;
  animation: fade .3s var(--ease);
}
.ask-wait[hidden] { display: none; }
.ask-wait b { color: var(--gold); font-weight: 400; }

/* 弹幕里也提示结果 */
.dm--sys {
  color: var(--ink-faint);
  border: 1px dashed var(--line-2);
  background: rgba(5, 5, 5, .7);
  font-size: .8125rem;
}

/* 局终贺词：也是系统说的，但比普通系统提示隆重得多 ——
   金色描边 + 深底 + 一圈暖光，像题在棋盘边上的一句词。
   字距拉开一点，读起来更像一句话而不是一条通知。 */
.dm--verse {
  color: #f3dda8;
  border: 1px solid var(--gold-line);
  background: linear-gradient(180deg, rgba(30, 23, 10, .95), rgba(14, 12, 8, .95));
  font-size: clamp(1rem, 3.9vw, 1.5rem);
  letter-spacing: .06em;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .72),
              0 0 24px rgba(201, 165, 88, .3);
}

@media (max-width: 420px) {
  .tool-panel { width: calc(100vw - 1.5rem); }
  .act__note { display: none; }
  .act__name { font-size: .9375rem; }
  .tools__btn { padding: .55rem 1.25rem; }
  .ask { padding: .6rem .7rem; }
  .ask__text { font-size: .875rem; }
}


/* ══════════════════════════════════════════════════════
   两个独立面板的对齐
   ══════════════════════════════════════════════════════ */

/* 聊天面板：锚在左侧按钮上方 */
.tool-panel--chat {
  left: 0;
  transform: none;
  width: min(21rem, calc(100vw - 2rem));
}
@keyframes panel-in-left {
  from { opacity: 0; transform: translateX(-10px) scale(.98); }
}
.tool-panel--chat { animation-name: panel-in-left; }

/* 对局面板：锚在右侧按钮上方 */
.tool-panel:not(.tool-panel--chat) {
  left: auto;
  right: 0;
  transform: none;
  animation-name: panel-in-right;
}
@keyframes panel-in-right {
  from { opacity: 0; transform: translateX(10px) scale(.98); }
}

/* 聊天按钮微调：视觉上与对局区分 */
.tools__btn--chat svg { opacity: .95; }

/* 面板内的快捷消息改为两行网格，撑满面板 */
.tool-panel--chat .quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .35rem;
}
.tool-panel--chat .quick__btn {
  min-width: 0;
  padding: .5rem .2rem;
  font-size: .75rem;
}

@media (max-width: 420px) {
  .tool-panel--chat .quick { grid-template-columns: repeat(3, 1fr); }
}
