:root {
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  --bg: #f2eee5;
  --bg-elev: #fbf8f1;
  --paper: #f7f2e5;
  --ink: #1e1b17;
  --ink-2: #565049;
  --ink-3: #8d8577;
  --line: rgba(30, 27, 23, 0.12);
  --hair: rgba(30, 27, 23, 0.07);
  --red: #b3362b;
  --red-soft: rgba(179, 54, 43, 0.12);
  --gold: #a67c2e;
  --green: #3e6b4f;
  --board-bg: #f7f2e5;
  --board-glow: rgba(255, 255, 255, 0.42);
  --board-warm: rgba(166, 124, 46, 0.07);
  --board-line: rgba(41, 35, 27, 0.62);
  --piece-bg: #fcf8ee;
  --piece-shadow: rgba(60, 45, 25, 0.22);
  --shadow: 0 18px 50px rgba(40, 32, 20, 0.16);
  --r: 16px;
}

:root[data-theme="dark"] {
  --bg: #12100e;
  --bg-elev: #1d1b17;
  --paper: #1c1a16;
  --ink: #ede7da;
  --ink-2: #a9a193;
  --ink-3: #736c60;
  --line: rgba(237, 231, 218, 0.13);
  --hair: rgba(237, 231, 218, 0.07);
  --red: #e0665a;
  --red-soft: rgba(224, 102, 90, 0.16);
  --gold: #d0a35a;
  --green: #7fb08e;
  --board-bg: #1b1915;
  --board-glow: rgba(255, 255, 255, 0.035);
  --board-warm: rgba(208, 163, 90, 0.03);
  --board-line: rgba(236, 228, 213, 0.46);
  --piece-bg: #26231e;
  --piece-shadow: rgba(0, 0, 0, 0.5);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
input { user-select: text; -webkit-user-select: text; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:disabled { opacity: 0.4; }
h1, h2, h3, h4, p { margin: 0; }
svg { display: block; }
.icon-btn svg, .action-icon svg, .gbtn svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#app { height: 100dvh; overflow: hidden; position: relative; }

.screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: fade 0.28s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- 首页 */
.home-screen {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top) + 12px) 22px calc(env(safe-area-inset-bottom) + 16px);
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 100dvh;
}
.home-screen > .home-head,
.home-screen > .hero,
.home-screen > .actions,
.home-screen > .resume-card { flex: none; }
.home-screen > * { animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.home-screen > *:nth-child(2) { animation-delay: 0.03s; }
.home-screen > *:nth-child(3) { animation-delay: 0.06s; }
.home-screen > *:nth-child(4) { animation-delay: 0.09s; }
.home-screen > *:nth-child(5) { animation-delay: 0.12s; }

.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 22px;
}
.brand { display: flex; align-items: center; gap: 10px; position: relative; }
.brand-seal {
  width: 34px; height: 34px;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 7px;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1;
  box-shadow: inset 0 0 0 2.5px var(--bg), inset 0 0 0 3.5px var(--red-soft);
}
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text b { font-family: var(--serif); font-size: 19px; letter-spacing: 0.16em; font-weight: 600; }
.brand-text small { font-size: 7.5px; letter-spacing: 0.32em; color: var(--ink-3); margin-top: 5px; }
.net-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-3); opacity: 0.45;
  margin-left: 6px;
  transition: 0.3s;
}
.net-dot.on { background: var(--green); opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-2);
  transition: background 0.15s, color 0.15s;
}
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn:active { background: var(--hair); color: var(--ink); }

.hero {
  padding: 8px 2px 22px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.hero-top { display: flex; align-items: baseline; justify-content: space-between; }
.hero-title {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.08em;
  color: var(--ink);
}
.hero-games { font-size: 11px; color: var(--ink-3); letter-spacing: 0.04em; }
.hero-name-inline {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  margin-left: 8px;
  font-weight: 400;
}
.hero-rating {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 10px 0 6px;
  font-family: var(--serif);
}
.hero-rating .num {
  font-size: clamp(56px, 17vw, 74px);
  line-height: 0.95;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.hero-rating .unit { font-size: 13px; color: var(--ink-3); font-family: var(--sans); }
.hero-meta {
  display: flex;
  gap: 18px;
  font-size: 11.5px;
  color: var(--ink-3);
  margin: 12px 0 16px;
}
.hero-meta b { color: var(--ink-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.track {
  height: 3px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.track i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--red), color-mix(in srgb, var(--red) 55%, var(--gold)));
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.track.small { height: 2px; margin-top: 8px; }
.track-note { margin-top: 9px; font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.02em; }

.resume-card {
  width: 100%;
  margin-top: 18px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 14px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  box-shadow: 0 10px 24px rgba(30, 27, 23, 0.18);
}
.resume-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: blink 1.6s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.resume-text { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.resume-text b { font-size: 13.5px; font-weight: 600; }
.resume-text small { font-size: 10.5px; opacity: 0.6; }
.resume-card .chev { color: inherit; opacity: 0.5; }

.actions {
  margin-top: 26px;
}
.action-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 17px 2px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  transition: background 0.16s;
}
.action-row:active { background: var(--hair); }
.action-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--hair);
  display: grid; place-items: center;
  color: var(--ink-2);
  flex: none;
}
.action-icon svg { width: 18px; height: 18px; }
.action-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.action-text b { font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }
.action-text small { font-size: 11px; color: var(--ink-3); }
.chev { font-size: 18px; color: var(--ink-3); font-family: var(--sans); }

.home-recent { margin-top: 26px; flex: none; }
.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
.sec-head .label { font-size: 10px; letter-spacing: 0.14em; color: var(--ink-3); }
.home-recent-row { padding: 11px 2px; }
.empty-recent {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 2px 8px;
  color: var(--ink-3);
}
.empty-mark {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink-3);
  flex: none;
}
.empty-recent b { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.empty-recent small { display: block; font-size: 10px; margin-top: 3px; color: var(--ink-3); }
.recent { display: flex; align-items: center; gap: 10px; }
.recent .label { font-size: 10px; letter-spacing: 0.14em; color: var(--ink-3); }
.dots { display: flex; gap: 6px; align-items: center; min-height: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: block; }
.dot.win { background: var(--red); }
.dot.loss { border: 1px solid var(--ink-3); }
.dot.draw { background: var(--ink-3); }
.muted { color: var(--ink-3); font-size: 11px; }
.link {
  font-size: 11px;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.link span { opacity: 0.6; }
.link.tiny { font-size: 10px; font-weight: 400; }
.home-version {
  text-align: center;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--ink-3);
  opacity: 0.6;
  padding: 26px 0 4px;
  margin-top: auto;
}

/* ------------------------------------------------------------- 对局 */
.game-screen {
  overflow: hidden;
  padding: 0;
}
.game-head {
  flex: none;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  padding-top: max(0px, env(safe-area-inset-top));
  height: calc(46px + env(safe-area-inset-top));
}
.game-title { text-align: center; line-height: 1.15; }
.game-title b { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: 0.04em; }
.game-title small { display: block; font-size: 9.5px; color: var(--ink-3); margin-top: 2px; letter-spacing: 0.08em; }
.game-head .icon-btn { width: 38px; height: 38px; }

.player {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  min-height: 60px;
  transition: opacity 0.2s;
}
.player.opp { padding-top: 0; }
.player.me { padding-bottom: 8px; }
.player .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1;
  border: 1px solid currentColor;
  flex: none;
  background: color-mix(in srgb, currentColor 5%, transparent);
  transition: box-shadow 0.2s;
}
.avatar.red { color: var(--red); }
.avatar.black { color: var(--ink); }
.player.active .avatar { box-shadow: 0 0 0 3px var(--red-soft); }
.pinfo { flex: 1; min-width: 0; }
.pname { display: flex; align-items: baseline; gap: 7px; }
.pname b {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}
.ptitle { font-size: 9.5px; color: var(--ink-3); white-space: nowrap; letter-spacing: 0.02em; }
.captured {
  height: 13px;
  display: flex;
  gap: 2px;
  align-items: center;
  margin-top: 2px;
  font-family: var(--serif);
  font-size: 10px;
  color: var(--ink-3);
  overflow: hidden;
}
.captured i { font-style: normal; opacity: 0.85; }
.clock { text-align: right; display: flex; flex-direction: column; gap: 1px; min-width: 58px; flex: none; }
.clock b {
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.1;
  color: var(--ink-2);
}
.clock small { font-size: 8.5px; color: var(--ink-3); letter-spacing: 0.12em; }
.player.active .clock b { color: var(--ink); }
.clock.low b { color: var(--red); }

.board-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.board-status {
  position: absolute;
  left: 18px;
  right: 18px;
  top: max(2px, calc(50% - var(--board-h, 0px) / 2 - 27px));
  height: 22px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  z-index: 3;
  pointer-events: none;
}
.turn-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ink-3);
  flex: none;
  transition: background 0.2s;
}
.turn-dot.mine { background: var(--red); animation: blink 1.7s infinite; }
.turn-dot.thinking { background: var(--gold); animation: blink 1s infinite; }
.turn-dot.over { background: var(--ink-3); animation: none; }
.last-notation {
  margin-left: auto;
  font-size: 10px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.board-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px 4px;
}
.board-host {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-actions {
  flex: none;
  display: flex;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
}
.gbtn {
  flex: 1;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink-2);
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: background 0.15s;
  position: relative;
}
.gbtn + .gbtn::before {
  content: "";
  position: absolute;
  left: 0; top: 15px; bottom: 15px;
  width: 1px;
  background: var(--hair);
}
.gbtn svg { width: 18px; height: 18px; stroke-width: 1.5; }
.gbtn:active { background: var(--hair); }

/* ------------------------------------------------------------- 棋盘 */
.xq-board {
  position: relative;
  width: 340px;
  height: 377px;
  border-radius: 10px;
  background:
    radial-gradient(120% 80% at 18% 0%, var(--board-glow), transparent 62%),
    radial-gradient(90% 70% at 100% 100%, var(--board-warm), transparent 60%),
    var(--board-bg);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 10px 30px rgba(40, 32, 20, 0.13),
    0 2px 6px rgba(40, 32, 20, 0.06);
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
:root[data-theme="dark"] .xq-board {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 14px 36px rgba(0, 0, 0, 0.45);
}
.xq-grid, .xq-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--board-line);
  pointer-events: none;
}
.xq-overlay { overflow: visible; }
.xq-grid text.river-text {
  font-family: var(--serif);
  font-size: 0.42px;
  fill: var(--board-line);
  opacity: 0.72;
  letter-spacing: 0.12em;
}
.last-line {
  stroke: var(--red);
  stroke-width: 0.03;
  opacity: 0.42;
  stroke-dasharray: 0.13 0.11;
  stroke-linecap: round;
}
.last-dot { fill: var(--red); opacity: 0.45; }
.last-dot-end { opacity: 0.7; }
.xq-marks, .xq-pieces { position: absolute; inset: 0; pointer-events: none; }

.xq-piece {
  position: absolute;
  width: 10.1%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: calc(var(--bw, 340px) * 0.057);
  font-weight: 600;
  line-height: 1;
  padding-top: 0.04em;
  background: var(--piece-bg);
  border: 1px solid currentColor;
  box-shadow:
    0 1px 2px var(--piece-shadow),
    0 4px 8px rgba(40, 30, 15, 0.06);
  will-change: left, top, transform;
  transition:
    left 0.2s cubic-bezier(0.22, 0.8, 0.25, 1),
    top 0.2s cubic-bezier(0.22, 0.8, 0.25, 1),
    transform 0.12s ease,
    box-shadow 0.15s ease,
    opacity 0.16s ease;
  z-index: 2;
}
.xq-piece::before {
  content: "";
  position: absolute;
  inset: 4.5%;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.34;
  pointer-events: none;
}
.xq-piece span { position: relative; z-index: 1; transform: translateY(-1%); }
.xq-piece.red { color: var(--red); }
.xq-piece.black { color: var(--ink); }
.xq-piece.selected {
  transform: translate(-50%, -50%) scale(1.07);
  box-shadow: 0 0 0 4px var(--red-soft), 0 3px 10px rgba(40, 30, 15, 0.22);
  z-index: 6;
}
.xq-piece.dragging {
  transition: none;
  z-index: 12;
  box-shadow: 0 12px 24px rgba(30, 20, 10, 0.3);
}
.xq-piece.captured { opacity: 0; transform: translate(-50%, -50%) scale(0.55); }
.xq-piece.no-anim { transition: none !important; }
.xq-piece.in-check { animation: checkPulse 1.05s ease-in-out infinite; }
@keyframes checkPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--red-soft), 0 2px 8px rgba(0, 0, 0, 0.16); }
  50% { box-shadow: 0 0 0 6px var(--red-soft), 0 2px 8px rgba(0, 0, 0, 0.16); }
}
.xq-board.is-locked .xq-piece { cursor: default; }

.xq-dot {
  position: absolute;
  width: 2.5%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.24;
  z-index: 1;
}
.xq-dot.capture {
  width: 9.6%;
  background: transparent;
  border: 1.5px solid var(--red);
  opacity: 0.65;
  box-sizing: border-box;
}

/* ------------------------------------------------------------- 弹层 */
.sheet-layer, .modal-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  background: rgba(20, 18, 15, 0.38);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.sheet-layer { align-items: flex-end; }
.modal-layer { align-items: center; justify-content: center; padding: 22px; }
.sheet-layer.in, .modal-layer.in { opacity: 1; }
.sheet-layer { opacity: 0; }
.sheet-layer.in { opacity: 1; }
.sheet {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  max-height: 86dvh;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.2, 1);
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.2);
}
.sheet-layer.in .sheet { transform: translateY(0); }
.sheet-grab {
  width: 38px; height: 4px;
  border-radius: 4px;
  background: var(--line);
  margin: 2px auto 6px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 14px;
}
.sheet-head h3 { font-size: 17px; font-weight: 600; letter-spacing: 0.02em; }
.sheet-head .icon-btn { width: 32px; height: 32px; font-size: 22px; font-weight: 300; line-height: 1; }
.sheet-body { padding-bottom: 4px; }
.sheet-note { font-size: 12px; color: var(--ink-3); line-height: 1.6; margin: 0 0 14px; }
.sheet-note b { color: var(--ink-2); font-weight: 600; }
.sheet-fine { font-size: 10px; color: var(--ink-3); opacity: 0.85; margin-top: 14px; line-height: 1.5; }

.modal {
  width: 100%;
  max-width: 340px;
  background: var(--bg-elev);
  border-radius: 24px;
  padding: 26px 24px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  transform: translateY(10px) scale(0.985);
  transition: transform 0.26s cubic-bezier(0.2, 0.9, 0.2, 1);
}
.modal-layer.in .modal { transform: none; }
.modal h3 { font-family: var(--serif); font-size: 23px; font-weight: 600; letter-spacing: 0.06em; }
.modal-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 9px; line-height: 1.6; }
.modal-kicker {
  font-size: 9.5px;
  letter-spacing: 0.24em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}
.modal-actions .btn { flex: 1; }
.modal-fine { font-size: 10px; color: var(--ink-3); margin-top: 14px; }

.btn {
  height: 46px;
  border-radius: 13px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  transition: transform 0.12s, opacity 0.15s, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.ghost { background: var(--hair); color: var(--ink-2); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.block { width: 100%; margin-top: 4px; }
.modal-actions .btn.primary, .modal .btn.primary { background: var(--ink); color: var(--bg); }

/* 结果 */
.result-modal { padding-top: 24px; }
.result-glyph {
  width: 84px; height: 84px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 42px;
  line-height: 1;
  border: 1px solid currentColor;
  position: relative;
}
.result-glyph::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.35;
}
.result-modal.win .result-glyph { color: var(--red); }
.result-modal.loss .result-glyph { color: var(--ink-2); }
.result-modal.draw .result-glyph { color: var(--gold); }
.result-modal h2 { font-family: var(--serif); font-size: 25px; letter-spacing: 0.08em; }
.delta-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  margin: 18px 0 4px;
}
.delta-line.unrated { font-size: 11.5px; color: var(--ink-3); justify-content: center; }
.delta {
  font-size: 27px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: var(--sans);
}
.delta.up { color: var(--red); }
.delta.down { color: var(--ink-2); }
.delta.flat { color: var(--ink-3); }
.rating-shift { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rating-shift i { font-style: normal; opacity: 0.5; margin: 0 2px; }
.result-level { margin-top: 16px; text-align: left; }
.result-level-top {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--ink-3);
}
.result-level-top span:first-child { color: var(--ink-2); font-weight: 500; }
.promo {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--gold) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
  text-align: left;
  animation: promoIn 0.5s 0.1s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}
@keyframes promoIn { from { opacity: 0; transform: scale(0.9) translateY(6px); } to { opacity: 1; transform: none; } }
.promo-seal {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  color: var(--gold);
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 18px;
  flex: none;
}
.promo b { display: block; font-size: 12px; color: var(--gold); letter-spacing: 0.06em; }
.promo small { display: block; font-size: 9.5px; color: var(--ink-3); margin-top: 2px; }
.demote { font-size: 10px; color: var(--ink-3); margin-top: 10px; }

/* 搜索 */
.search-layer { background: rgba(18, 16, 13, 0.72); }
.search-card { text-align: center; color: #f4efe4; }
.search-card h3 { font-family: var(--serif); font-size: 22px; letter-spacing: 0.16em; margin-top: 24px; }
.search-card p { font-size: 11px; opacity: 0.55; margin-top: 8px; letter-spacing: 0.04em; }
.search-elapsed {
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  margin: 18px 0 26px;
  opacity: 0.9;
}
.search-card .btn.ghost { background: rgba(255, 255, 255, 0.1); color: #f4efe4; }
.radar {
  width: 92px; height: 92px;
  margin: 0 auto;
  border-radius: 50%;
  border: 1px solid rgba(244, 239, 228, 0.16);
  position: relative;
  display: grid;
  place-items: center;
}
.radar::before, .radar::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid rgba(244, 239, 228, 0.4);
  animation: radar 2.2s ease-out infinite;
}
.radar::after { animation-delay: 1.1s; }
@keyframes radar {
  0% { transform: scale(0.55); opacity: 0.9; }
  100% { transform: scale(1.55); opacity: 0; }
}
.radar b {
  font-family: var(--serif);
  font-size: 30px;
  color: rgba(244, 239, 228, 0.9);
  font-weight: 500;
}
.radar i {
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--red);
  opacity: 0.8;
}
.radar i:nth-child(1) { top: 12px; right: 16px; }
.radar i:nth-child(2) { bottom: 16px; left: 13px; }

/* 房间 */
.room-modal h3 { margin-bottom: 4px; }
.code-display {
  font-family: var(--sans);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: 0.22em;
  padding: 16px 0 6px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.waiting-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  margin: -2px 0 4px;
}
.waiting-line i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--gold);
  animation: blink 1.3s infinite;
}

/* 机器人列表 */
.bot-list { display: flex; flex-direction: column; }
.bot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.bot-row:last-child { border-bottom: 0; }
.bot-row:active { background: var(--hair); }
.bot-orb {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.bot-info { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bot-info b { font-size: 13.5px; font-weight: 600; }
.bot-info small { font-size: 10px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-rating { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bot-rating small { font-size: 9px; color: var(--ink-3); margin-left: 1px; }

/* 在线 */
.tc-row { display: flex; gap: 8px; margin-bottom: 16px; }
.tc {
  flex: 1;
  padding: 12px 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  transition: 0.15s;
}
.tc b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tc span { font-size: 9.5px; color: var(--ink-3); }
.tc.selected { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.tc.selected span { color: color-mix(in srgb, var(--bg) 65%, transparent); }
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 14px;
  color: var(--ink-3);
  font-size: 10px;
  letter-spacing: 0.08em;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.friend-actions { display: flex; flex-direction: column; gap: 10px; }
.join-box { display: flex; gap: 8px; }
.join-box input {
  flex: 1;
  min-width: 0;
  height: 46px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  padding: 0 14px;
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.join-box input::placeholder { letter-spacing: 0.04em; color: var(--ink-3); font-size: 12px; }
.join-box .btn { flex: none; }

/* 战绩 */
.stats-hero { display: flex; gap: 8px; padding: 4px 0 12px; }
.stats-hero > div {
  flex: 1;
  background: var(--bg-elev);
  border-radius: 14px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--hair);
}
.stats-hero b { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stats-hero span { font-size: 9.5px; color: var(--ink-3); letter-spacing: 0.06em; }
.spark { height: 64px; margin: 4px 0 2px; }
.spark svg { width: 100%; height: 100%; }
.spark-line { fill: none; stroke: var(--red); stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; opacity: 0.85; }
.spark-area { fill: var(--red); opacity: 0.07; }
.record-line { font-size: 10.5px; color: var(--ink-3); text-align: center; padding: 6px 0 2px; }
.sec-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  margin: 24px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ladder { border-top: 1px solid var(--line); }
.ladder-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--hair);
  font-size: 11.5px;
  color: var(--ink-3);
}
.ladder-row.current { color: var(--ink); background: var(--red-soft); margin: 0 -8px; padding: 7px 10px; border-radius: 8px; border-bottom-color: transparent; }
.ladder-name { flex: 1; }
.ladder-row.current .ladder-name { font-weight: 600; color: var(--red); }
.ladder-min { font-variant-numeric: tabular-nums; opacity: 0.75; }
.ladder-badge { font-size: 8.5px; padding: 2px 6px; border-radius: 999px; background: var(--red); color: #fff; }
.leaderboard { border-top: 1px solid var(--line); }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--hair); }
.lb-rank { width: 18px; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.lb-name { flex: 1; font-size: 12px; display: flex; flex-direction: column; gap: 1px; }
.lb-name small { font-size: 9px; color: var(--ink-3); }
.lb-score { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.lb-row.me .lb-name { color: var(--red); }
.empty { font-size: 11px; color: var(--ink-3); text-align: center; padding: 16px 0; }
.recent-list { border-top: 1px solid var(--line); }
.recent-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--hair); }
.res {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 11px;
  flex: none;
}
.res.win { background: var(--red-soft); color: var(--red); }
.res.loss { background: var(--hair); color: var(--ink-3); }
.res.draw { background: color-mix(in srgb, var(--gold) 12%, transparent); color: var(--gold); }
.recent-opp { flex: 1; display: flex; flex-direction: column; gap: 1px; font-size: 11.5px; }
.recent-opp b { font-weight: 500; }
.recent-opp small { font-size: 9px; color: var(--ink-3); }
.recent-delta { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.recent-delta.up { color: var(--red); }
.recent-delta.down { color: var(--ink-2); }

/* 设置 */
.field { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 6px 0 16px; border-bottom: 1px solid var(--line); }
.field span { font-size: 13px; }
.field input {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink);
  font-size: 14px;
  text-align: right;
  padding: 4px 0;
  width: 140px;
  outline: none;
}
.setting-list { margin-top: 4px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--hair);
  font-size: 13px;
}
.switch {
  width: 44px; height: 26px;
  border-radius: 999px;
  background: var(--line);
  padding: 3px;
  transition: background 0.2s;
  position: relative;
}
.switch i {
  display: block;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--bg-elev);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.2, 1);
}
.switch.on { background: var(--ink); }
.switch.on i { transform: translateX(18px); background: var(--bg); }
.about { padding: 18px 0 4px; font-size: 10.5px; color: var(--ink-3); line-height: 1.7; }
.about p + p { margin-top: 8px; }

/* 棋谱 / 菜单 */
.move-head { display: flex; gap: 10px; font-size: 9px; color: var(--ink-3); letter-spacing: 0.1em; padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.move-head span { flex: 1; }
.move-head span:first-child { flex: 0 0 34px; }
.move-row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--hair); font-size: 12.5px; }
.move-row .move-no { width: 24px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.move-row span:not(.move-no) { flex: 1; font-family: var(--serif); }
.menu-list { display: flex; flex-direction: column; }
.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  text-align: left;
}
.menu-row.danger { color: var(--red); }
.menu-row .chev { font-size: 17px; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 82px);
  transform: translate(-50%, 14px);
  background: rgba(28, 25, 21, 0.94);
  color: #f6f1e6;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.3;
  opacity: 0;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 200;
  pointer-events: none;
  max-width: 82vw;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 横屏 / 桌面 */
@media (orientation: landscape) and (max-height: 620px) {
  .game-screen {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-rows: auto 1fr auto;
    height: 100dvh;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .game-head { grid-column: 1 / 3; grid-row: 1; height: calc(42px + env(safe-area-inset-top)); }
  .board-area { grid-column: 1; grid-row: 2 / 4; padding: 0 6px 6px; }
  .player.opp { grid-column: 2; grid-row: 2; align-self: start; padding: 8px 14px 0; }
  .player.me { grid-column: 2; grid-row: 2; align-self: end; padding: 0 14px 8px; }
  .game-actions { grid-column: 2; grid-row: 3; }
  .board-stage { padding: 0 6px 4px; }
  .game-screen .board-status { padding: 0 12px; }
}
@media (min-width: 700px) and (min-height: 700px) {
  .game-screen { max-width: 560px; margin: 0 auto; width: 100%; }
}
.board-stage.tight .board-status { display: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
