/* ==========================================================================
   楚河汉界 · 在线中国象棋   古风水墨样式
   ========================================================================== */

:root {
  --paper:      #f6f1e5;
  --paper-2:    #eee5d2;
  --paper-3:    #e4d9c1;
  --ink:        #23201c;
  --ink-2:      #4a443c;
  --ink-3:      #857b6c;
  --line:       #5b4a38;
  --seal:       #a8322a;
  --seal-2:     #c0392b;
  --seal-soft:  rgba(168, 50, 42, .12);
  --gold:       #b08d57;
  --ok:         #4a7a4a;

  --font-kai:  "Kaiti SC", "STKaiti", KaiTi, "楷体", "Noto Serif SC", "Songti SC", serif;
  --font-song: "Songti SC", "STSong", SimSun, "宋体", "Noto Serif SC", serif;
  --font-ui:   "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;

  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(70, 55, 35, .08), 0 4px 12px rgba(70, 55, 35, .07);
  --shadow-md: 0 2px 6px rgba(70, 55, 35, .1), 0 12px 32px rgba(70, 55, 35, .12);
  --shadow-lg: 0 8px 20px rgba(50, 38, 22, .16), 0 30px 70px rgba(50, 38, 22, .2);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 12% -5%, #fffdf6 0%, rgba(255, 253, 246, 0) 62%),
    radial-gradient(900px 620px at 105% 108%, #f2e9d6 0%, rgba(242, 233, 214, 0) 58%),
    linear-gradient(158deg, #f8f4ea 0%, #f1e9d8 46%, #e8ddc6 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 宣纸颗粒 */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: .38;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

/* 水墨晕染 */
.wash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(closest-side, rgba(74, 68, 60, .10), rgba(74, 68, 60, 0) 100%) 4% 22% / 420px 420px no-repeat,
    radial-gradient(closest-side, rgba(74, 68, 60, .07), rgba(74, 68, 60, 0) 100%) 96% 78% / 520px 520px no-repeat,
    radial-gradient(closest-side, rgba(168, 50, 42, .05), rgba(168, 50, 42, 0) 100%) 88% 8% / 300px 300px no-repeat;
  filter: blur(2px);
}

/* ============================ 顶栏 ============================ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px clamp(16px, 3vw, 40px) 16px;
  max-width: 1240px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 14px; }

.seal {
  display: grid;
  place-items: center;
  width: 50px; height: 50px;
  border-radius: 10px;
  background: linear-gradient(150deg, #b8402f, #8f2721);
  color: #fdf6e8;
  font-family: var(--font-kai);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(150, 40, 32, .34), inset 0 1px 0 rgba(255, 255, 255, .28);
  transform: rotate(-3deg);
  user-select: none;
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-kai);
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--ink);
  white-space: nowrap;
}

.brand-text p {
  margin: 3px 0 0;
  font-size: 12px;
  letter-spacing: .22em;
  color: var(--ink-3);
}

.room-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: rgba(255, 253, 246, .74);
  border: 1px solid rgba(120, 100, 70, .22);
  border-radius: 999px;
  padding: 7px 10px 7px 16px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
}

.room-code { font-size: 13px; color: var(--ink-2); letter-spacing: .06em; }
.room-code b {
  font-family: var(--font-ui);
  font-size: 17px;
  letter-spacing: .2em;
  color: var(--seal);
  margin-left: 4px;
}

/* ============================ 布局 ============================ */

.layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(16px, 2.4vw, 32px);
  padding: 0 clamp(16px, 3vw, 40px) 48px;
  max-width: 1240px;
  margin: 0 auto;
}

.board-panel {
  flex: 0 1 auto;
  width: min(100%, 600px, calc((100vh - 196px) * 0.911));
}

.board-frame {
  position: relative;
  border-radius: 18px;
  padding: 0;
  background: linear-gradient(160deg, #fdfaf1, #f4ecda);
  box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(120, 100, 70, .18);
  overflow: hidden;
}

.board-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  pointer-events: none;
  box-shadow: inset 0 0 60px rgba(120, 92, 55, .12);
}

#board {
  display: block;
  width: 100%;
  height: auto;
  touch-action: manipulation;
  font-family: var(--font-kai);
  user-select: none;
  cursor: pointer;
}

/* ---------- SVG 棋盘 ---------- */

.bd-line   { stroke: var(--line); stroke-width: 1.1; opacity: .76; }
.bd-edge   { stroke-width: 1.9; opacity: .88; }
.bd-palace { opacity: .66; }
.bd-mark   { stroke: var(--line); stroke-width: 1.1; opacity: .68; }
.bd-frame-outer { stroke: #4a3b2c; stroke-width: 2.4; opacity: .82; }

.river-char { font-family: var(--font-kai); font-size: 30px; fill: #4a3b2c; opacity: .40; }
.coord      { font-family: var(--font-song); font-size: 13px; fill: #6b5a44; opacity: .48; }

/* ---------- 棋子 ---------- */

.piece {
  cursor: pointer;
  transition: transform .24s cubic-bezier(.34, .08, .2, 1), opacity .26s ease;
  filter: drop-shadow(0 2px 3px rgba(70, 52, 28, .26));
}
.piece.is-dead { opacity: 0; pointer-events: none; }

.pc-bg   { stroke-width: 2.2; }
.pc-ring { fill: none; stroke-width: 1; opacity: .5; }
.pc-char { font-family: var(--font-kai); font-size: 31px; font-weight: 700; }

.piece.is-red .pc-bg   { stroke: #a8322a; }
.piece.is-red .pc-ring { stroke: #c98d7d; }
.piece.is-red .pc-char { fill: #a8322a; }

.piece.is-black .pc-bg   { stroke: #2f2b28; }
.piece.is-black .pc-ring { stroke: #948c7f; }
.piece.is-black .pc-char { fill: #23201c; }

.piece:hover { filter: drop-shadow(0 4px 7px rgba(70, 52, 28, .34)); }

.piece.is-selected .pc-bg { stroke-width: 3.4; }
.piece.is-selected .pc-char { fill: #c0392b; }
.piece.is-selected { filter: drop-shadow(0 0 10px rgba(168, 50, 42, .45)); }

/* ---------- 提示层 ---------- */

.hint-last {
  fill: rgba(168, 50, 42, .07);
  stroke: rgba(168, 50, 42, .34);
  stroke-width: 1.4;
  stroke-dasharray: 5 4;
}

.hint-sel {
  fill: none;
  stroke: var(--seal);
  stroke-width: 2;
  opacity: .72;
  stroke-dasharray: 6 5;
  animation: march 12s linear infinite;
}
@keyframes march { to { stroke-dashoffset: -220; } }

.hint-dot { fill: var(--seal); opacity: .46; }

.hint-cap {
  fill: none;
  stroke: var(--seal);
  stroke-width: 2.6;
  opacity: .7;
  stroke-dasharray: 5 4;
}

.hint-check {
  fill: none;
  stroke: #c0392b;
  stroke-width: 3;
  opacity: .9;
  animation: pulse 1.05s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .28; transform: scale(.94); }
  50%      { opacity: .92; transform: scale(1.04); }
}

/* ============================ 侧栏 ============================ */

.side {
  flex: 0 0 336px;
  width: 336px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius);
  background: rgba(255, 253, 246, .82);
  border: 1px solid rgba(120, 100, 70, .2);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .3s, border-color .3s, transform .3s;
}

.player-card.active {
  border-color: rgba(168, 50, 42, .5);
  box-shadow: 0 0 0 3px var(--seal-soft), var(--shadow-sm);
  transform: translateY(-1px);
}

.pl-avatar {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  font-family: var(--font-kai);
  font-size: 21px;
  font-weight: 700;
  background: linear-gradient(150deg, #fffdf6, #efe6d2);
  box-shadow: inset 0 0 0 1.5px rgba(120, 100, 70, .3);
}

.player-card.red .pl-avatar   { color: var(--seal); box-shadow: inset 0 0 0 1.6px rgba(168, 50, 42, .55); }
.player-card.black .pl-avatar { color: #23201c;    box-shadow: inset 0 0 0 1.6px rgba(45, 42, 38, .55); }

.pl-info { flex: 1; min-width: 0; }

.pl-name {
  font-family: var(--font-kai);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-tag { font-size: 11px; color: var(--ink-3); margin-top: 1px; height: 14px; }

.pl-clock {
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--ink-2);
  transition: color .3s;
}
.pl-clock.low { color: var(--seal-2); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: .35; } }

.status-bar {
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(74, 68, 60, .05), rgba(74, 68, 60, .02));
  border: 1px dashed rgba(120, 100, 70, .28);
}

.status-text {
  font-family: var(--font-kai);
  font-size: 15.5px;
  letter-spacing: .1em;
  color: var(--ink-2);
}
.status-text.check   { color: var(--seal-2); font-weight: 700; animation: blink 1s step-end infinite; }
.status-text.over    { color: var(--seal); font-weight: 700; letter-spacing: .18em; }
.status-text.waiting { color: var(--ink-3); }

/* ---------- 棋谱 ---------- */

.panel {
  border-radius: var(--radius);
  background: rgba(255, 253, 246, .82);
  border: 1px solid rgba(120, 100, 70, .2);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  font-family: var(--font-kai);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--ink-2);
  border-bottom: 1px solid rgba(120, 100, 70, .16);
  background: linear-gradient(180deg, rgba(120, 100, 70, .06), transparent);
}
.panel-sub { font-family: var(--font-ui); font-size: 11px; letter-spacing: .1em; color: var(--ink-3); font-weight: 400; }

.moves-list {
  height: 168px;
  overflow-y: auto;
  padding: 6px 8px 8px;
  scrollbar-width: thin;
}

.mv-row {
  display: grid;
  grid-template-columns: 30px 1fr 1fr;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 7px;
  font-family: var(--font-kai);
  font-size: 15px;
}
.mv-row:nth-child(odd) { background: rgba(120, 100, 70, .045); }
.mv-row.latest { background: var(--seal-soft); box-shadow: inset 0 0 0 1px rgba(168, 50, 42, .2); }
.mv-no  { font-family: var(--font-ui); font-size: 11px; color: var(--ink-3); text-align: right; padding-right: 4px; }
.mv-r   { color: var(--seal); font-weight: 700; letter-spacing: .04em; }
.mv-b   { color: #23201c; font-weight: 700; letter-spacing: .04em; }
.mv-empty { padding: 26px 0; text-align: center; font-size: 13px; color: var(--ink-3); letter-spacing: .14em; }

/* ---------- 操作按钮 ---------- */

.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.act {
  padding: 10px 6px;
  border-radius: 10px;
  font-family: var(--font-kai);
  font-size: 15px;
  letter-spacing: .1em;
  color: var(--ink-2);
  background: rgba(255, 253, 246, .86);
  border: 1px solid rgba(120, 100, 70, .26);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .14s, box-shadow .2s, background .2s, color .2s;
}
.act:hover { background: #fffdf6; color: var(--seal); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.act:active { transform: translateY(0); }
.act.wide { grid-column: 1 / -1; font-size: 14px; padding: 8px; }
.act.off { color: var(--ink-3); background: rgba(120, 100, 70, .07); }

/* ---------- 聊天 ---------- */

.chat-panel { display: flex; flex-direction: column; }

.chat-log {
  height: 116px;
  overflow-y: auto;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.65;
  scrollbar-width: thin;
}

.chat-item { margin-bottom: 2px; word-break: break-word; }
.chat-item b { font-weight: 600; margin-right: 6px; }
.chat-item.red b   { color: var(--seal); }
.chat-item.black b { color: #33302b; }
.chat-item span { color: var(--ink-2); }

.chat-input {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid rgba(120, 100, 70, .16);
}

.chat-input input {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid rgba(120, 100, 70, .24);
  background: rgba(255, 255, 255, .7);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
.chat-input input:focus { border-color: rgba(168, 50, 42, .5); box-shadow: 0 0 0 3px var(--seal-soft); }

.chat-input button {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(150deg, #b8402f, #93291f);
  color: #fdf6e8;
  font-family: var(--font-kai);
  font-size: 14px;
  letter-spacing: .1em;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(150, 40, 32, .28);
}
.chat-input button:hover { filter: brightness(1.06); }

/* ============================ 通用按钮 ============================ */

.btn {
  padding: 12px 18px;
  border-radius: 11px;
  font-family: var(--font-kai);
  font-size: 16px;
  letter-spacing: .12em;
  color: var(--ink-2);
  background: rgba(255, 253, 246, .9);
  border: 1px solid rgba(120, 100, 70, .3);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .15s, box-shadow .22s, background .22s, color .22s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); color: var(--seal); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn.primary {
  background: linear-gradient(150deg, #b8402f, #8f2721);
  color: #fdf6e8;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(150, 40, 32, .3), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn.primary:hover { color: #fff; filter: brightness(1.07); }

.btn.ghost { background: transparent; box-shadow: none; color: var(--ink-3); }
.btn.ghost:hover { background: rgba(255, 253, 246, .7); }
.btn.wide { width: 100%; }

.mini {
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink-2);
  background: rgba(255, 255, 255, .68);
  border: 1px solid rgba(120, 100, 70, .22);
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.mini:hover { background: #fff; color: var(--seal); border-color: rgba(168, 50, 42, .4); }
.mini.ghost { background: transparent; color: var(--ink-3); }

/* ============================ 覆盖层 ============================ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: radial-gradient(900px 620px at 50% 40%, rgba(246, 241, 229, .86), rgba(226, 214, 190, .92));
  backdrop-filter: blur(7px);
}
.overlay.show { display: flex; animation: fadeIn .3s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.card {
  position: relative;
  width: min(100%, 420px);
  padding: 38px 32px 30px;
  border-radius: 20px;
  text-align: center;
  background:
    radial-gradient(700px 380px at 50% -18%, #fffdf6, rgba(255, 253, 246, 0) 70%),
    linear-gradient(165deg, #fdfaf2, #f2ead8);
  border: 1px solid rgba(120, 100, 70, .24);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255, 255, 255, .6);
  animation: cardIn .4s cubic-bezier(.2, .9, .3, 1);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.card-seal {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%) rotate(-4deg);
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 9px;
  background: linear-gradient(150deg, #b8402f, #8f2721);
  color: #fdf6e8;
  font-family: var(--font-kai);
  font-size: 27px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(150, 40, 32, .36), inset 0 1px 0 rgba(255, 255, 255, .26);
  z-index: 2;
}

.card h2 {
  margin: 4px 0 6px;
  font-family: var(--font-kai);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: .2em;
  color: var(--ink);
}

.card-sub { margin: 0 0 22px; font-size: 12.5px; letter-spacing: .12em; color: var(--ink-3); }

.field { display: block; text-align: left; margin-bottom: 14px; }
.field > span {
  display: block;
  font-family: var(--font-kai);
  font-size: 13px;
  letter-spacing: .14em;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.field input, .field select, .join-row input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid rgba(120, 100, 70, .28);
  background: rgba(255, 255, 255, .74);
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .join-row input:focus {
  border-color: rgba(168, 50, 42, .55);
  box-shadow: 0 0 0 3px var(--seal-soft);
}
.join-row input { letter-spacing: .3em; text-transform: uppercase; font-weight: 600; text-align: center; }

.lobby-grid { display: grid; gap: 11px; margin-top: 4px; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.join-row .btn { padding: 11px 20px; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 14px;
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: .2em;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(120, 100, 70, .3), transparent);
}

.hint {
  margin: 18px 0 0;
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--ink-3);
  text-align: left;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(120, 100, 70, .05);
  border-left: 3px solid rgba(168, 50, 42, .3);
}

/* 连接失败提示 */
.conn-error {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 10px;
  text-align: left;
  background: rgba(168, 50, 42, .07);
  border: 1px solid rgba(168, 50, 42, .28);
  animation: cardIn .3s ease;
}
.conn-error b {
  font-family: var(--font-kai);
  font-size: 15px;
  letter-spacing: .1em;
  color: var(--seal);
}
.conn-error span {
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--ink-2);
}
.conn-error code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(120, 100, 70, .12);
  color: var(--ink);
}
.conn-error strong { color: var(--seal); font-weight: 600; }

.conn-fix {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
  margin-top: 4px;
}
.conn-fix input {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(168, 50, 42, .3);
  background: rgba(255, 255, 255, .8);
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink);
  outline: none;
}
.conn-fix input:focus { border-color: rgba(168, 50, 42, .6); box-shadow: 0 0 0 3px var(--seal-soft); }
.conn-fix .btn { padding: 8px 12px; font-size: 13px; letter-spacing: .06em; }

.hint code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(120, 100, 70, .1);
}

.server-hint {
  margin: 8px 0 0;
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.6;
  text-align: left;
  word-break: break-all;
  color: var(--ink-2);
  background: rgba(176, 141, 87, .12);
  border: 1px dashed rgba(176, 141, 87, .45);
}

.big-code {
  font-family: var(--font-ui);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: .3em;
  text-indent: .3em;
  color: var(--seal);
  margin: 8px 0 22px;
  text-shadow: 0 2px 12px rgba(168, 50, 42, .18);
}

.wait-actions { display: grid; gap: 10px; }

.over-title { font-size: 34px; letter-spacing: .26em; }
.over-title.red   { color: var(--seal); }
.over-title.black { color: #23201c; }

.waiting-dots { display: flex; justify-content: center; gap: 7px; margin-top: 22px; }
.waiting-dots i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(168, 50, 42, .55);
  animation: bounce 1.25s ease-in-out infinite;
}
.waiting-dots i:nth-child(2) { animation-delay: .18s; }
.waiting-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40%           { transform: translateY(-7px); opacity: 1; }
}

/* ============================ 询问框 / Toast ============================ */

.ask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(60, 48, 30, .28);
  backdrop-filter: blur(3px);
  animation: fadeIn .22s ease;
}
.ask[hidden] { display: none; }

.ask-inner {
  width: min(100%, 330px);
  padding: 26px 24px 20px;
  border-radius: 16px;
  text-align: center;
  background: linear-gradient(165deg, #fdfaf2, #f2ead8);
  border: 1px solid rgba(120, 100, 70, .24);
  box-shadow: var(--shadow-lg);
}
.ask-inner p {
  margin: 0 0 20px;
  font-family: var(--font-kai);
  font-size: 17px;
  letter-spacing: .08em;
  color: var(--ink);
}
.ask-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 42px;
  z-index: 90;
  transform: translate(-50%, 20px);
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 13.5px;
  letter-spacing: .06em;
  color: #fdf6e8;
  background: rgba(45, 40, 34, .9);
  box-shadow: 0 8px 26px rgba(40, 30, 18, .3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .26s, transform .26s;
  max-width: 84vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================ 响应式 ============================ */

@media (max-width: 940px) {
  .layout { flex-direction: column; align-items: center; }
  .board-panel { width: min(100%, 560px); }
  .side { width: min(100%, 560px); flex: 0 0 auto; }
  .moves-list { height: 138px; }
  .topbar { padding-top: 14px; }
}

@media (max-width: 660px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .room-bar { justify-content: center; border-radius: 14px; padding: 8px 10px; }
}

@media (max-width: 520px) {
  .brand-text h1 { font-size: 21px; letter-spacing: .12em; }
  .brand-text p { font-size: 10.5px; letter-spacing: .16em; }
  .seal { width: 42px; height: 42px; font-size: 25px; }
  .card { padding: 32px 22px 24px; }
  .pl-clock { font-size: 18px; }
  .big-code { font-size: 36px; }
  .room-bar { border-radius: 14px; padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
