:root {
  --bg: #f6efe4;
  --bg2: #efe4d2;
  --card: #fffaf2;
  --ink: #3b2f2a;
  --ink2: #8a7a6e;
  --line: #e7d9c4;
  --accent: #ff7a45;
  --accent2: #ffb84d;
  --green: #3fb67b;
  --red: #ef5350;
  --blue: #4e8cff;
  --sq-light: #f1dfbd;
  --sq-dark: #bf8a5c;
  --shadow: 0 6px 20px rgba(92, 62, 30, .12);
  --shadow-sm: 0 2px 8px rgba(92, 62, 30, .10);
  --radius: 18px;
  --fun: 'ZCOOL KuaiLe', 'PingFang SC', 'Hiragino Sans GB', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1a22; --bg2: #26222c; --card: #2c2733; --ink: #f2e9df; --ink2: #a99e94; --line: #3b3542;
    --sq-light: #d9c39a; --sq-dark: #9a6a43;
    --shadow: 0 6px 20px rgba(0,0,0,.35); --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1d1a22; --bg2: #26222c; --card: #2c2733; --ink: #f2e9df; --ink2: #a99e94; --line: #3b3542;
  --sq-light: #d9c39a; --sq-dark: #9a6a43;
  --shadow: 0 6px 20px rgba(0,0,0,.35); --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(circle at 15% 10%, var(--bg2), transparent 40%), var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; color: var(--ink); }

/* ---------- 通用按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 12px; font-weight: 600; transition: transform .12s, background .15s, box-shadow .15s; white-space: nowrap; }
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; box-shadow: 0 4px 14px rgba(255, 122, 69, .35); }
.btn.big { width: 100%; padding: 13px; font-size: 17px; border-radius: 14px; }
.btn.soft { background: var(--bg2); }
.btn.soft:hover { background: var(--line); }
.btn.soft.waiting { background: #fff1d6; color: #b26b00; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.call { background: var(--green); color: #fff; box-shadow: 0 4px 12px rgba(63, 182, 123, .35); }
.btn:disabled { opacity: .45; pointer-events: none; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; display: inline-grid; place-items: center; font-size: 18px; flex: none; transition: background .15s, transform .12s; }
.icon-btn:hover { background: var(--bg2); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.danger { background: var(--red); color: #fff; }
.icon-btn.muted { background: var(--line); filter: grayscale(1); }

/* ---------- 登录 ---------- */
.screen#login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); background: var(--card); border-radius: 28px; padding: 32px 24px 24px; box-shadow: var(--shadow); text-align: center; }
.logo { width: 84px; height: 84px; margin: 0 auto 8px; border-radius: 26px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 8px 20px rgba(255, 122, 69, .35); }
.logo-piece { font-size: 54px; color: #fff; animation: hop 1.6s ease-in-out infinite; display: inline-block; }
@keyframes hop { 0%, 100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-8px) rotate(-8deg); } 60% { transform: translateY(0) rotate(6deg); } }
.title { font-family: var(--fun); font-weight: 400; font-size: 34px; margin: 6px 0 0; letter-spacing: 2px; }
.sub { color: var(--ink2); margin: 2px 0 18px; }
.acc-pick { display: flex; gap: 12px; margin-bottom: 16px; }
.acc { flex: 1; padding: 14px 8px 10px; border-radius: 18px; background: var(--bg2); border: 2px solid transparent; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: border-color .15s, transform .15s; }
.acc:hover { transform: translateY(-2px); }
.acc.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.acc-ava { font-size: 42px; line-height: 1; }
.acc-id { font-weight: 600; color: var(--ink2); font-size: 13px; }
#loginForm { display: flex; flex-direction: column; gap: 10px; }
#loginForm input { padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); outline: none; font-size: 16px; }
#loginForm input:focus { border-color: var(--accent); }
.err { color: var(--red); min-height: 1.5em; margin: 0; font-size: 14px; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); height: 60px; }
.brand { font-family: var(--fun); font-size: 22px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo-mini { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); font-size: 22px; }
.tag { font-family: inherit; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bg2); color: var(--ink2); font-family: system-ui; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.callbar { display: flex; align-items: center; gap: 6px; padding: 3px 4px 3px 12px; border-radius: 99px; background: var(--card); box-shadow: var(--shadow-sm); font-variant-numeric: tabular-nums; font-weight: 600; }
.call-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- 布局 ---------- */
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 10px; }
.panel-title { font-weight: 700; font-size: 13px; color: var(--ink2); display: flex; justify-content: space-between; align-items: center; padding: 0 4px 6px; }
.status { font-weight: 600; color: var(--accent); }

/* ---------- 玩家卡片 ---------- */
.player { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm); position: relative; min-height: 66px; transition: box-shadow .2s; }
.player.turn { box-shadow: 0 0 0 2.5px var(--accent), var(--shadow-sm); }
.ava { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; background: var(--bg2); flex: none; position: relative; overflow: visible; transition: box-shadow .1s; background-size: cover; background-position: center; }
.ava.xl { width: 92px; height: 92px; font-size: 56px; margin: 6px auto; }
.ava.me { cursor: pointer; }
.ava.me::after { content: '✏️'; position: absolute; right: -4px; bottom: -4px; font-size: 13px; background: var(--card); border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.ava .dot { position: absolute; right: 0; top: 1px; width: 13px; height: 13px; border-radius: 50%; border: 2.5px solid var(--card); background: #bbb; }
.ava .dot.on { background: var(--green); }
.ava.speaking { box-shadow: 0 0 0 3px var(--green), 0 0 16px 4px rgba(63, 182, 123, .55); }
.ava.hit { animation: hit .5s; }
@keyframes hit { 0%, 100% { transform: none; } 20% { transform: translateX(-6px) rotate(-8deg); } 40% { transform: translateX(6px) rotate(6deg); } 60% { transform: translateX(-4px) rotate(-4deg); } 80% { transform: translateX(3px); } }
.pinfo { flex: 1; min-width: 0; }
.pname { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.pname .side-chip { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid #8a7a6e; flex: none; }
.pname .side-chip.w { background: #fff; }
.pname .side-chip.b { background: #222; }
.pname .me-tag { font-size: 11px; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); padding: 0 6px; border-radius: 99px; }
.caps { font-size: 13px; color: var(--ink2); min-height: 20px; letter-spacing: -2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.caps b { letter-spacing: 0; margin-left: 6px; color: var(--ink); font-weight: 700; }
.thinking { font-size: 12px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.thinking::after { content: '…'; animation: dots 1.2s steps(3) infinite; display: inline-block; width: 1em; overflow: hidden; vertical-align: bottom; }
.bubble { position: absolute; left: 58px; bottom: calc(100% - 6px); z-index: 30; background: var(--ink); color: var(--card); padding: 7px 12px; border-radius: 14px 14px 14px 4px; font-weight: 600; max-width: 240px; box-shadow: var(--shadow); animation: pop .3s cubic-bezier(.3, 1.6, .5, 1) both; pointer-events: none; }
#pTop .bubble { bottom: auto; top: calc(100% - 6px); border-radius: 4px 14px 14px 14px; }
.bubble.big { font-size: 40px; background: transparent; box-shadow: none; padding: 0; line-height: 1; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }

/* ---------- 棋盘 ---------- */
.board-shell { position: relative; width: 100%; aspect-ratio: 1; border-radius: 14px; box-shadow: var(--shadow); padding: 0; }
.board { width: 100%; height: 100%; border-radius: 12px; overflow: hidden; }
.board.cg-wrap { width: 100%; height: 100%; }
cg-board { background-color: var(--sq-light); background-image: repeating-conic-gradient(var(--sq-dark) 0 25%, var(--sq-light) 0 50%); background-size: 25% 25%; }
cg-board square.move-dest { background: radial-gradient(rgba(40, 30, 20, .28) 20%, transparent 22%); }
cg-board square.move-dest:hover { background: rgba(255, 122, 69, .35); }
cg-board square.oc.move-dest { background: radial-gradient(transparent 0%, transparent 78%, rgba(40, 30, 20, .3) 80%); }
cg-board square.last-move { background-color: rgba(255, 196, 60, .42); }
cg-board square.selected { background-color: rgba(255, 122, 69, .5); }
cg-board square.check { background: radial-gradient(ellipse at center, rgba(255, 0, 0, 1) 0%, rgba(231, 0, 0, 1) 25%, rgba(169, 0, 0, 0) 89%, rgba(158, 0, 0, 0) 100%); }
cg-board square.premove-dest { background: radial-gradient(rgba(78, 140, 255, .4) 20%, transparent 22%); }
coords { font-weight: 700; font-size: clamp(10px, calc(var(--S, 400px) / 62), 15px) !important; }
coords.ranks coord:nth-child(odd), coords.files coord:nth-child(even) { color: var(--sq-light); }
coords.ranks coord:nth-child(even), coords.files coord:nth-child(odd) { color: var(--sq-dark); }
.orientation-black coords.ranks coord:nth-child(odd), .orientation-black coords.files coord:nth-child(even) { color: var(--sq-dark); }
.orientation-black coords.ranks coord:nth-child(even), .orientation-black coords.files coord:nth-child(odd) { color: var(--sq-light); }

.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; overflow: visible; }
.promo { position: absolute; inset: 0; z-index: 25; background: rgba(30, 20, 10, .45); display: grid; place-items: center; border-radius: 12px; }
.promo-box { background: var(--card); padding: 14px; border-radius: 18px; display: flex; gap: 8px; box-shadow: var(--shadow); }
.promo-box button { width: 64px; height: 64px; border-radius: 14px; background: var(--bg2); background-size: 80%; background-repeat: no-repeat; background-position: center; }
.promo-box button:hover { background-color: var(--line); }
.over { position: absolute; inset: 0; z-index: 24; display: grid; place-items: center; background: rgba(30, 20, 10, .35); border-radius: 12px; backdrop-filter: blur(1.5px); }
.over-card { background: var(--card); padding: 22px 28px; border-radius: 22px; text-align: center; box-shadow: var(--shadow); animation: pop .4s cubic-bezier(.3, 1.6, .5, 1) both; }
.over-emoji { font-size: 60px; line-height: 1.1; }
.over-title { font-family: var(--fun); font-size: 30px; margin: 4px 0; }
.over-sub { color: var(--ink2); margin-bottom: 14px; }
.over-card .row { justify-content: center; }

/* ---------- 侧栏 ---------- */
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.actions .btn { padding: 9px 4px; font-size: 13.5px; }
.request { position: fixed; z-index: 60; top: 68px; left: 0; right: 0; margin: 0 auto; width: min(440px, calc(100vw - 24px)); box-shadow: var(--shadow) !important; background: #fff6e3; color: #6b4a12; border-radius: var(--radius); padding: 12px 14px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-sm); animation: pop .3s both; border: 1.5px solid #ffd58a; }
.request .rq-text { flex: 1; font-weight: 600; }
.request .btn { padding: 7px 12px; }
.btn.yes { background: var(--green); color: #fff; }
.btn.no { background: #fff; color: var(--ink); border: 1px solid #f0d9a8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .request { background: #3a3020; color: #ffd98a; border-color: #5c4a20; } :root:not([data-theme="light"]) .btn.no { background: transparent; color: inherit; } }

.tabs { display: flex; gap: 4px; margin-bottom: 8px; background: var(--bg2); padding: 3px; border-radius: 12px; }
.tab { flex: 1; padding: 5px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--ink2); }
.tab.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.tray { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.tray.phrases { grid-template-columns: 1fr 1fr; }
.emo { font-size: 26px; height: 44px; border-radius: 12px; display: grid; place-items: center; transition: transform .12s, background .12s; }
.emo:hover { background: var(--bg2); transform: scale(1.12) rotate(-6deg); }
.emo:active { transform: scale(.85); }
.emo.cool { opacity: .4; pointer-events: none; }
.phrase { font-size: 12.5px; text-align: left; padding: 6px 9px; border-radius: 10px; background: var(--bg2); line-height: 1.35; font-weight: 500; }
.phrase:hover { background: var(--line); }

.moves { flex: none; }
.move-list { margin: 0; padding: 0 4px; list-style: none; display: flex; flex-wrap: wrap; gap: 2px 4px; max-height: 76px; overflow-y: auto; font-size: 13px; font-variant-numeric: tabular-nums; }
.move-list li { display: flex; gap: 3px; }
.move-list .n { color: var(--ink2); }
.move-list .m { padding: 0 4px; border-radius: 5px; font-weight: 600; }
.move-list .m.last { background: var(--accent); color: #fff; }
.move-list .empty { color: var(--ink2); }

.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0; position: relative; }
.msgs { flex: 1; overflow-y: auto; padding: 12px 12px 4px; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .ava { width: 30px; height: 30px; font-size: 18px; }
.msg .body { background: var(--bg2); padding: 7px 11px; border-radius: 16px 16px 16px 5px; word-break: break-word; }
.msg.mine .body { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-radius: 16px 16px 5px 16px; }
.msg.emoji .body { background: none !important; font-size: 40px; padding: 0; line-height: 1.1; }
.msg.system { align-self: center; max-width: 100%; font-size: 12px; color: var(--ink2); background: var(--bg2); padding: 3px 12px; border-radius: 99px; }
.voice { display: flex; align-items: center; gap: 8px; min-width: 70px; cursor: pointer; user-select: none; }
.voice .bars { display: flex; align-items: center; gap: 2px; height: 18px; }
.voice .bars i { width: 3px; border-radius: 2px; background: currentColor; opacity: .75; }
.voice.playing .bars i { animation: eq .6s ease-in-out infinite alternate; }
.voice.playing .bars i:nth-child(2n) { animation-delay: .2s; }
.voice.playing .bars i:nth-child(3n) { animation-delay: .4s; }
@keyframes eq { to { transform: scaleY(.3); } }
.voice .dur { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.msg-time { align-self: center; font-size: 11px; color: var(--ink2); }

.chat-input { display: flex; align-items: center; gap: 4px; padding: 8px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 12px; border: 0; background: var(--bg2); outline: none; font-size: 15px; }
.icon-btn.send { background: var(--accent); color: #fff; font-size: 16px; }
.icon-btn.mic { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.icon-btn.mic.rec { background: var(--red); transform: scale(1.12); }
.emoji-pop { position: absolute; bottom: 56px; left: 8px; right: 8px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 200px; overflow-y: auto; z-index: 10; border: 1px solid var(--line); }
.emoji-pop button { font-size: 24px; height: 38px; border-radius: 8px; }
.emoji-pop button:hover { background: var(--bg2); }

/* ---------- 录音 ---------- */
.rec-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; pointer-events: none; }
.rec-box { background: rgba(20, 15, 10, .82); color: #fff; padding: 22px 28px; border-radius: 22px; text-align: center; min-width: 170px; }
.rec-box.cancel { background: rgba(200, 40, 40, .9); }
.rec-wave { display: flex; justify-content: center; gap: 4px; height: 34px; align-items: center; }
.rec-wave i { width: 5px; height: 100%; background: #fff; border-radius: 3px; animation: eq .5s ease-in-out infinite alternate; }
.rec-wave i:nth-child(2) { animation-delay: .15s; } .rec-wave i:nth-child(3) { animation-delay: .3s; } .rec-wave i:nth-child(4) { animation-delay: .1s; } .rec-wave i:nth-child(5) { animation-delay: .25s; }
#recTime { font-size: 26px; font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
#recHint { font-size: 13px; opacity: .8; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(20, 15, 10, .45); padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal-card { background: var(--card); border-radius: 26px; padding: 22px; width: min(360px, 100%); text-align: center; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; animation: pop .3s cubic-bezier(.3, 1.5, .5, 1) both; }
.modal-card h3 { margin: 0; font-family: var(--fun); font-weight: 400; font-size: 24px; }
.modal-card input { padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); outline: none; text-align: center; font-size: 16px; }
.modal-card .row, .row { display: flex; gap: 10px; }
.modal-card .row .btn { flex: 1; }
.ava-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; max-height: 170px; overflow-y: auto; }
.ava-grid button { font-size: 28px; height: 46px; border-radius: 12px; }
.ava-grid button:hover, .ava-grid button.on { background: var(--bg2); }
.ava-grid button.on { box-shadow: inset 0 0 0 2px var(--accent); }
.upload { cursor: pointer; }
.ring .row { justify-content: center; gap: 48px; margin-top: 8px; }
.in-name { font-size: 22px; font-weight: 700; }
.in-sub { color: var(--ink2); }
.round-btn { width: 64px; height: 64px; border-radius: 50%; font-size: 28px; color: #fff; box-shadow: var(--shadow); transition: transform .12s; }
.round-btn:active { transform: scale(.9); }
.round-btn.red { background: var(--red); }
.round-btn.green { background: var(--green); animation: wobble 1s infinite; }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(63, 182, 123, .6); } 100% { box-shadow: 0 0 0 26px rgba(63, 182, 123, 0); } }

.toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 100; background: var(--ink); color: var(--card); padding: 9px 18px; border-radius: 99px; font-weight: 600; box-shadow: var(--shadow); animation: pop .25s both; max-width: calc(100vw - 32px); text-align: center; }

/* ---------- 特效 ---------- */
.fly { position: fixed; z-index: 70; font-size: 46px; line-height: 1; pointer-events: none; will-change: transform; left: 0; top: 0; }
.splat { position: fixed; z-index: 69; pointer-events: none; font-size: 64px; line-height: 1; left: 0; top: 0; }
.rain { position: fixed; top: -60px; z-index: 75; pointer-events: none; font-size: 30px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(calc(100vh + 120px)) rotate(540deg); } }
body.shake { animation: shake .55s; }
@keyframes shake { 0%, 100% { transform: none; } 15% { transform: translate(-10px, 6px) rotate(-1deg); } 30% { transform: translate(9px, -7px) rotate(1deg); } 45% { transform: translate(-7px, -4px); } 60% { transform: translate(6px, 5px); } 75% { transform: translate(-3px, 2px); } }
.flash { position: fixed; inset: 0; z-index: 68; pointer-events: none; background: radial-gradient(circle, rgba(255, 220, 120, .8), rgba(255, 120, 40, .2) 50%, transparent 70%); animation: flash .6s forwards; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

/* ---------- 窄屏 ---------- */
@media (max-width: 700px) {
  .btn.call span { display: none; }
  .btn.call { padding: 9px 12px; }
  .brand { font-size: 19px; }
  .topbar { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 380px) { .tag { display: none; } }

/* ---------- 实木棋盘 / 棋子 ---------- */
:root, :root[data-theme="dark"] { --sq-light: #f0d4a3; --sq-dark: #6e4122; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sq-light: #f0d4a3; --sq-dark: #6e4122; } }
body.wood .board-shell {
  padding: 3.6%;
  border-radius: 16px;
  background: var(--frame-img) center / cover, #3a1a0a;
  box-shadow:
    inset 0 1.5px 0 rgba(255, 214, 170, .35),
    inset 0 0 0 1px rgba(0, 0, 0, .55),
    inset 0 -5px 10px rgba(0, 0, 0, .45),
    inset 0 5px 12px rgba(255, 200, 150, .08),
    0 22px 44px rgba(40, 20, 5, .42),
    0 4px 10px rgba(0, 0, 0, .28);
}
body.wood .board {
  border-radius: 3px;
  box-shadow: 0 0 0 2px rgba(18, 8, 0, .85), 0 0 0 3.5px rgba(214, 170, 110, .35), 0 0 0 5px rgba(18, 8, 0, .5);
}
body.wood cg-board { background-image: var(--board-img); background-size: 100% 100%; background-color: #a8743f; }
body.wood cg-board piece { filter: drop-shadow(0 2.5px 1.5px rgba(25, 10, 0, .5)) drop-shadow(0 0 1px rgba(0, 0, 0, .35)); }
body.wood cg-board piece.dragging { filter: drop-shadow(0 14px 8px rgba(25, 10, 0, .4)); }
body.wood cg-board square.last-move { background-color: rgba(255, 210, 90, .38); }
body.wood cg-board square.move-dest { background: radial-gradient(rgba(30, 14, 4, .38) 19%, transparent 21%); }
body.wood coords { text-shadow: 0 1px 0 rgba(0, 0, 0, .15); }
body.wood .promo, body.wood .over { border-radius: 16px; }
.caps .cap { display: inline-block; width: 20px; height: 20px; margin-right: -5px; background-size: contain; background-repeat: no-repeat; vertical-align: -4px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .3)); }

/* ---------- 布局：棋盘优先 ---------- */
.layout { --S: calc(100vw - 24px); display: grid; gap: 10px; padding: 0 12px 12px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "opp" "board" "me" "actions" "emotes" "moves" "chat"; }
.layout > * { min-width: 0; }
.board-shell { grid-area: board; width: var(--S); height: var(--S); justify-self: center; }
#pTop { grid-area: opp; } #pBottom { grid-area: me; }
.actions { grid-area: actions; } .emotes { grid-area: emotes; } .moves { grid-area: moves; } .chat { grid-area: chat; height: 62vh; min-height: 360px; }
.player { min-height: 60px; }
@media (max-width: 599px) { body.wood .board-shell { padding: 2.6%; } }

/* 竖屏平板：棋盘几乎占满宽度；操作按钮并进自己的卡片，表情和聊天在下方分两栏 */
@media (min-width: 600px) and (max-aspect-ratio: 1/1) {
  .layout { --S: min(calc(100vw - 32px), calc(100dvh - 476px)); width: calc(var(--S) + 32px); padding: 0 16px 16px; gap: 12px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    grid-template-areas: "opp opp" "board board" "me me" "emotes chat" "moves chat"; }
  .player { min-height: 54px; padding: 6px 12px; }
  .player .ava { width: 44px; height: 44px; font-size: 26px; }
  .actions { grid-area: me; justify-self: end; align-self: center; z-index: 2; display: flex; gap: 6px; background: none; box-shadow: none; padding: 0 10px 0 0; }
  .actions .btn { padding: 9px 12px; }
  #pBottom .thinking { display: none; }
  .chat { height: auto; min-height: 220px; }
  .move-list { max-height: 120px; }
}

/* 电脑 / 横屏平板：棋盘占满整个高度，玩家卡片和功能都在右侧栏 */
@media (min-width: 640px) and (min-aspect-ratio: 1/1) {
  :root { --side: clamp(290px, 27vw, 380px); --Sw: min(calc(100dvh - 72px), calc(100vw - var(--side) - 44px)); }
  .layout { --S: var(--Sw); height: calc(100dvh - 60px); width: auto; padding: 0 16px 12px; gap: 10px 14px; justify-content: center;
    grid-template-columns: var(--S) var(--side);
    grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "board opp" "board actions" "board emotes" "board moves" "board chat" "board me"; }
  .board-shell { align-self: start; }
  .chat { height: auto; min-height: 0; }
  .tray.phrases { max-height: 150px; overflow-y: auto; }
  .move-list { max-height: 64px; }
  #pTop .bubble { top: calc(100% - 6px); }
  .request { top: 60px; left: auto; right: max(16px, calc((100vw - var(--Sw) - var(--side) - 14px) / 2)); width: var(--side); margin: 0; }
}
@media (min-width: 640px) and (min-aspect-ratio: 1/1) and (max-height: 620px) {
  .moves { display: none; }
  .emotes .tabs { margin-bottom: 4px; }
  .emo { height: 38px; font-size: 22px; }
}

/* 触屏设备（平板、手机）：按钮更大、更好点 */
@media (pointer: coarse) {
  .emo { height: 50px; font-size: 30px; }
  .actions .btn { padding: 12px 4px; font-size: 15px; }
  .icon-btn { width: 44px; height: 44px; }
  .tab { padding: 8px 5px; font-size: 14px; }
  .phrase { padding: 9px 10px; font-size: 14px; }
  .chat-input input { padding: 11px 12px; font-size: 16px; }
}
