/* ============================================================
 * index.css — 补丁样式（仅覆盖雀王 CSS 的少量调整）
 * 规则：
 *   1. 不覆盖雀王 core class（tile、hand、seat、board 等）
 *   2. 只做：透明度、间距、定位微调、中心面板、按钮、结果弹窗
 * ============================================================ */

/* /* ---- 布局标记（调试用） ---- */ */
/* #hand-0, #hand-1, #hand-2, #hand-3 { outline: 2px solid #ff4444; outline-offset: 2px; } */
/* #river-0, #river-1, #river-2, #river-3 { outline: 2px solid #4488ff; outline-offset: 2px; } */
/* #melds-0, #melds-1, #melds-2, #melds-3 { outline: 2px solid #44ff44; outline-offset: 2px; } */
/* .board__center { outline: 2px solid #ffcc00; outline-offset: 2px; } */
/* #label-0, #label-1, #label-2, #label-3 { outline: 2px dashed #ff88ff; outline-offset: 2px; } */

/* ---- 全局 ---- */
html, body {
  width: 100%; height: 100%;
  margin: 0; padding: 0; background: #0c0a08; overflow: hidden;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

/* 手机旋转后始终以实际可视区域为基准，完整缩放并居中固定舞台。 */
.viewport {
  top: var(--vp-top, 0px) !important;
  left: var(--vp-left, 0px) !important;
  width: var(--vp-w, 100vw) !important;
  height: var(--vp-h, 100dvh) !important;
}
.stage {
  transform-origin: center center !important;
  top: var(--stage-center-y, 50%) !important;
}

.mobile-shell { display: none; }

/* ---- 顶栏：无背景条，按钮浮在桌面上 ---- */
.stage-header {
  padding: 8px 16px; background: none; border-bottom: none;
}

/* ---- 桌面底色（兜底） ---- */
.table-felt {
  background: radial-gradient(ellipse at center, #2d5d3f 0%, #1f4430 55%, #143221 100%) !important;
}

/* ---- 按钮 ---- */
.qw-btn {
  padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 600;
  background: rgba(20,30,25,0.6); color: #e8e0c8;
  border: 1px solid rgba(212,175,55,0.4); cursor: pointer; transition: all .15s;
}
.qw-btn:hover { background: rgba(35,50,40,0.85); border-color: rgba(212,175,55,0.7); }
.qw-btn:disabled { opacity: .4; cursor: not-allowed; }
.qw-btn--primary {
  background: linear-gradient(180deg, #b8862a, #8a6018);
  border-color: #d4af37; color: #fff;
}
.qw-btn--primary:hover { background: linear-gradient(180deg, #d4a043, #a8761e); }
.online-room-badge {
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(212,175,55,0.42);
  background: rgba(12,20,15,0.72);
  color: #f0d98a;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

/* ---- 顶栏消息 ---- */
#msg { font-size: 13px; color: #f0d98a; min-width: 200px; text-align: right; }

/* ---- 两侧信息面板 ---- */
.side-panel {
  position: absolute;
  z-index: 15;
  top: 72px;
  width: 230px;
  max-height: 230px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(12, 20, 15, 0.78);
  border: 1px solid rgba(212,175,55,0.34);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  color: #e8e0c8;
  pointer-events: auto;
}
.side-panel--history { left: 14px; }
.side-panel--log { right: 14px; }
.side-panel__title {
  color: #f0d98a;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
.side-panel__list {
  max-height: 188px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.side-panel__empty {
  color: #9fb8a6;
  font-size: 12px;
}
.history-item {
  width: 100%;
  border: 1px solid rgba(212,175,55,0.22);
  border-radius: 6px;
  background: rgba(30,44,34,0.78);
  color: #f5e8bc;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  padding: 5px 7px;
  cursor: pointer;
}
.history-item:hover { border-color: rgba(255,215,107,0.7); filter: brightness(1.1); }
.log-item {
  color: #d7e8d9;
  font-size: 11px;
  line-height: 1.35;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* ---- 中心面板 ---- */
.center-inner { color: #f0d98a; text-align: center; line-height: 1.6; }
.center-round {
  font-size: 16px; font-weight: 700; color: #ffe9a8;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
}
.center-wall { font-size: 14px; color: #cfe8d4; margin-top: 2px; }
.center-turn { font-size: 12px; color: #b8d4be; margin-top: 2px; }
.center-dice { font-size: 20px; color: #fff; margin-top: 4px; letter-spacing: 3px; }

/* 风向指示 */
.center-side { color: #cfe8d4; font-size: 13px; font-weight: 600; }
.center-side__wind {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  background: rgba(20,30,25,0.5); border: 1px solid rgba(212,175,55,0.3);
}
.center-side.is-active .center-side__wind {
  background: rgba(212,175,55,0.35); border-color: #d4af37;
  color: #fff; box-shadow: 0 0 12px rgba(212,175,55,0.6);
}

/* 中心区补充定位 */
.board__center {
  display: flex; align-items: center; justify-content: center;
}
.center {
  position: relative; width: 240px; height: 240px;
  display: flex; align-items: center; justify-content: center;
}
.center-inner { position: relative; inset: auto; }

/* DEBUG: 方位词标记 */
.center-side { justify-content: center !important; gap: 0 !important; }
.center-side__wind { width: auto !important; height: auto !important; padding: 2px 4px !important; line-height: 1 !important; }

/* ---- 对手标签 ---- */
.seat-label--overlay-top, .seat-label--overlay-left, .seat-label--overlay-right {
  position: absolute; padding: 6px 10px; border-radius: 8px;
  background: rgba(15,22,18,0.85); border: 1px solid rgba(212,175,55,0.4);
  color: #f0d98a; font-size: 12px; font-weight: 600; text-align: center;
  backdrop-filter: blur(4px); box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  pointer-events: auto;
  cursor: pointer;
}
.seat-label--overlay-top { top: 72px; left: 50%; transform: translateX(-50%); }
.seat-label--overlay-left { left: 24px; top: 50%; transform: translateY(-50%); }
.seat-label--overlay-right { right: 24px; top: 50%; transform: translateY(-50%); }
.seat-label--overlay-top.is-turn,
.seat-label--overlay-left.is-turn,
.seat-label--overlay-right.is-turn {
  border-color: #ffd76b; box-shadow: 0 0 16px rgba(255,215,107,0.7);
}
.seat-label__name { display: block; color: #fff; font-size: 13px; }
.seat-label__sub { display: block; color: #9fb8a6; font-size: 10px; margin-top: 1px; }

/* ---- 自家标签 + 底部布局 ---- */
.seat-bottom-fixed .seat-label {
  padding: 6px 12px; border-radius: 8px;
  background: rgba(15,22,18,0.85); border: 1px solid rgba(212,175,55,0.5);
  color: #f0d98a; font-size: 13px; font-weight: 600;
}
.seat-bottom-fixed .seat-label.is-turn {
  border-color: #ffd76b; box-shadow: 0 0 16px rgba(255,215,107,0.7);
}

/* ---- 浮层定位 ---- */
.stage-overlays { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.seat-bottom-fixed {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 30; pointer-events: auto; width: auto;
}
.seat-bottom-fixed .seat { display: block; }
.seat-bottom-fixed .seat-body {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.seat-bottom-fixed .seat-bottom-row {
  display: flex; align-items: flex-end; justify-content: center; gap: 12px;
}
.seat-bottom-fixed .melds { margin: 0; }
.self-hand-flare-wrap { display: block; }
.seat-bottom-fixed .hand { justify-content: center; }

/* ---- 河牌：上听牌标记 ---- */
.river-ting-slot {
  width: 52px;
  height: 40px;
  flex: 0 0 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}
.river-row--has-ting {
  gap: 6px;
}
.river-ting-slot--seat0,
.river-ting-slot--seat2 {
  width: 52px;
  flex-basis: 52px;
}
.river-ting-slot--seat1,
.river-ting-slot--seat3 {
  width: 52px;
  flex-basis: 52px;
}
.river-tile--ting {
  z-index: 2;
}
.river-tile--latest {
  box-shadow: 0 0 0 2px #c92a2a, 0 4px 10px rgba(0,0,0,0.45);
  z-index: 3;
}
.river-tile--claimed-ting {
  opacity: 0.38;
  filter: grayscale(0.65) blur(0.35px);
  border: 1px dashed rgba(235,235,220,0.55);
  box-shadow: inset 0 0 8px rgba(0,0,0,0.28);
}

/* === 副露：保留雀王 owner 方向与杠牌叠放，只调整四家落位 === */
.melds--owner-0,
.melds--owner-1,
.melds--owner-2,
.melds--owner-3 {
  flex-wrap: nowrap;
  gap: 6px;
  overflow: visible;
}

.seat-bottom-row > .melds {
  flex-direction: row-reverse;
  align-items: flex-end;
  min-width: 132px;
}

.seat--top .melds {
  margin-top: -5px;
  transform: translateY(-30px);
}

.seat--left > .seat-body {
  flex-direction: column-reverse;
}

.seat--right > .seat-body {
  flex-direction: column;
}

.seat--left .melds {
  transform: translate(-48px, 18px);
}

.seat--right .melds {
  transform: translate(48px, -18px);
}

.meld,
.meld__stack {
  overflow: visible;
}

/* === 左右家副露牌 === */
.meld.meld--owner-1 .tile--side-meld,
.meld.meld--owner-3 .tile--side-meld {
  overflow: visible;
}

/* 去掉所有窄边伪元素 */
.meld.meld--owner-1 .tile--side-meld::before,
.meld.meld--owner-1 .tile--side-meld::after,
.meld.meld--owner-3 .tile--side-meld::before,
.meld.meld--owner-3 .tile--side-meld::after {
  content: none;
}

/* 被碰/杠的牌：完全绿色牌背 */
.meld.meld--owner-1 .tile--side-meld.tile--back .tile__face,
.meld.meld--owner-3 .tile--side-meld.tile--back .tile__face {
  background: #2c5e3f !important;
}

/* 左家横牌翻转面朝方向 */
.meld.meld--owner-1 .tile--side-meld.tile--horiz .tile__face {
  transform: translate(-50%, -50%) rotate(90deg);
}
/* 右家横牌翻转面朝方向 */
.meld.meld--owner-3 .tile--side-meld.tile--horiz .tile__face {
  transform: translate(-50%, -50%) rotate(-90deg);
}

/* 碰牌：被碰那张向对应玩家方向移位 */
.meld--owner-1.meld--pon > .tile--side-meld.tile--back {
  transform: translateX(-12px);
}
.meld--owner-2.meld--pon > .tile--back {
  transform: translateY(-12px);
}
.meld--owner-3.meld--pon > .tile--side-meld.tile--back {
  transform: translateX(12px);
}
/* 明杠：被杠那张同样移位 */
.meld--owner-1.meld--kong > .tile--side-meld.tile--back {
  transform: translateX(-12px);
}
.meld--owner-2.meld--kong > .tile--back {
  transform: translateY(-12px);
}
.meld--owner-3.meld--kong > .tile--side-meld.tile--back {
  transform: translateX(12px);
}

/* ---- 操作按钮 ---- */
.seat-action-slot {
  display: flex; gap: 8px; justify-content: center; min-height: 36px; margin-bottom: 4px;
}
.act-btn {
  padding: 5px 16px; border-radius: 6px; font-size: 13px; font-weight: 700;
  cursor: pointer; border: 1px solid; transition: all .15s;
}
.act-btn--hu { background: linear-gradient(180deg,#c0392b,#8b1f15); border-color:#ff6b5a; color:#fff; }
.act-btn--gang { background: linear-gradient(180deg,#6c3483,#4a235a); border-color:#bb8fce; color:#fff; }
.act-btn--pon { background: linear-gradient(180deg,#1e8449,#145a32); border-color:#58d68d; color:#fff; }
.act-btn--pass { background: rgba(60,60,60,0.8); border-color:#888; color:#ccc; }
.act-btn:hover { transform: translateY(-1px); filter: brightness(1.15); }
.online-discard-prompt {
  padding: 5px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255,215,107,0.62);
  background: rgba(15,22,18,0.86);
  color: #ffe9a8;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,0.42), inset 0 1px rgba(255,255,255,0.08);
}

/* ---- 选中/高亮 ---- */
.tile.is-selected {
  transform: translateY(-14px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.5), 0 0 0 2px #ffd76b;
}

.ting-preview {
  position: absolute;
  right: 150px;
  bottom: 96px;
  z-index: 42;
  min-width: 160px;
  max-width: 300px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,215,107,0.58);
  background: rgba(12,20,15,0.9);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  color: #f6e7b5;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
}
.ting-preview.show {
  opacity: 1;
  transform: translateY(0);
}
.ting-preview__title {
  font-size: 12px;
  font-weight: 800;
  color: #ffd76b;
  margin-bottom: 6px;
}
.ting-preview__tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}
.ting-preview__item {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ting-preview__item em {
  position: absolute;
  right: -7px;
  bottom: -6px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: #c92a2a;
  color: #fff;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  line-height: 15px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.45);
}
.tile--ting-choice {
  z-index: 5;
  transform: translateY(-14px) translateZ(0);
  filter: drop-shadow(0 0 8px rgba(217,182,91,0.55)) drop-shadow(0 8px 14px rgba(0,0,0,0.45));
}
.tile--ting-choice .tile__face {
  box-shadow: 0 0 0 1.5px #ffd76b, 0 6px 10px rgba(0,0,0,0.38);
}
.hand--locked-ting .tile--clickable:hover {
  transform: translateZ(0);
}
.hand--locked-ting .tile--locked {
  cursor: default;
}
/* 上听选牌模式：非可听牌虚化，禁止悬浮上浮 */
.hand--pending-ting .tile--locked,
.hand--pending-ting .tile--locked:hover {
  opacity: 0.35;
  cursor: default;
  filter: grayscale(0.5);
  pointer-events: none;
  transform: translateY(0) !important;
}
.hand--locked-ting .tile--ting-hover:hover,
.hand--locked-ting .tile--ting-hover:focus {
  transform: translateY(-14px) translateZ(0);
  filter: drop-shadow(0 0 8px rgba(217,182,91,0.55)) drop-shadow(0 8px 14px rgba(0,0,0,0.45));
}

/* ---- 胜负浮层 ---- */
.result-overlay {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.65); z-index: 100; backdrop-filter: blur(3px);
}
.result-overlay.show { display: flex; }
.result-box {
  background: linear-gradient(180deg, rgba(30,40,32,0.98), rgba(20,28,22,0.98));
  border: 2px solid #d4af37; border-radius: 12px; padding: 28px 48px;
  text-align: center; box-shadow: 0 0 40px rgba(212,175,55,0.4);
}
.result-title {
  font-size: 32px; font-weight: 800; color: #ffd76b; margin-bottom: 10px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}
.result-detail { color: #e8e0c8; font-size: 15px; line-height: 1.8; }
.result-fan { color: #f0d98a; font-size: 13px; margin-top: 8px; }
.result-scoreboard {
  margin-top: 14px;
  min-width: 430px;
  max-width: 640px;
  color: #e8e0c8;
  font-size: 12px;
  text-align: left;
}
.score-section {
  padding: 8px 0;
  border-top: 1px solid rgba(212,175,55,0.22);
}
.history-hand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 8px;
}
.history-hand--full {
  align-items: flex-start;
}
.history-hand__name {
  flex: 0 0 70px;
  color: #f0d98a;
  font-weight: 700;
}
.history-hand__tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
}
.history-tile {
  width: 24px;
  height: 34px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.history-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.history-meld {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 5px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(212,175,55,0.18);
}
.history-meld em,
.history-empty {
  color: #9fb8a6;
  font-size: 10px;
  font-style: normal;
  margin-left: 3px;
}
.history-hand__meld-sep {
  color: #f0d98a;
  font-size: 11px;
  margin: 0 5px 0 9px;
}
.score-calc,
.payment-line {
  line-height: 1.55;
}
.score-rank {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(212,175,55,0.22);
}
.score-row {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
}

.history-detail-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
  background: rgba(0,0,0,0.55);
  pointer-events: auto;
}
.history-detail-overlay.show { display: flex; }
.history-detail-box {
  position: relative;
  width: min(680px, 86vw);
  max-height: 70vh;
  overflow: hidden;
  padding: 22px 26px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(28,40,31,0.98), rgba(14,22,17,0.98));
  border: 1px solid rgba(212,175,55,0.62);
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  color: #e8e0c8;
}
.history-detail-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(212,175,55,0.45);
  background: rgba(0,0,0,0.25);
  color: #f0d98a;
  cursor: pointer;
}
.history-detail-title {
  color: #ffd76b;
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 12px;
}

/* ---- 对家手牌位置微调（不被 header 挡） ---- */
.seat--top { transform: translateY(-100px) !important; }

/* ---- 桌面中心骰子展示 ---- */
.center-dice-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 260px;
  min-height: 200px;
  padding: 16px;
  background: rgba(10, 18, 13, 0.88);
  border-radius: 10px;
  border: 2px solid rgba(212, 175, 55, 0.5);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
.dice-disp-grid {
  display: grid;
  grid-template-columns: 110px 110px;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
}
.dice-disp-grid--single {
  grid-template-columns: 200px;
}
.dice-disp-slot {
  background: rgba(20, 30, 25, 0.85);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 8px;
  padding: 10px 10px 8px;
  text-align: center;
}
.dice-disp-slot.is-dealer {
  border-color: #ffd76b;
  box-shadow: 0 0 12px rgba(255, 215, 107, 0.50);
}
.dice-disp-name {
  display: block;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.dice-disp-dots {
  display: block;
  color: #f0d98a;
  font-size: 22px;
}
.dice-disp-btn {
  margin-top: 10px;
  padding: 8px 32px;
  font-size: 15px;
}

/* ---- 牌墙 ---- */
.cell { position: relative; }
.wall {
  position: absolute; /* border: 1px dashed rgba(212,175,55,0.35); */
  border-radius: 4px; pointer-events: none; overflow: visible;
  display: flex; gap: 2px; align-items: flex-end;
}
.wall--top    { bottom: 20px; left: 50%; transform: translateX(-50%); width: 380px; height: 55px; }
.wall--left   { right: -80px; top: 50%; transform: translateY(-50%); width: 60px; height: 280px; flex-direction: column; }
.wall--right  { left: -80px; top: 50%; transform: translateY(-50%); width: 60px; height: 280px; flex-direction: column; }
.wall--bottom { bottom: 150px; left: 50%; transform: translateX(-50%); width: 460px; height: 92px; }

.wall-tile { flex-shrink:0; }
.wall-tile .wt-face {
  background:linear-gradient(180deg,#45835E,#2E6348);
  border:1px solid #5aa374; border-bottom:none; border-radius:3px 3px 0 0;
  box-shadow:0 2px 6px rgba(0,0,0,.4),inset 0 1px 0 rgba(255,255,255,.08);
}
.wall-tile .wt-edge {
  border:1px solid #5aa374; border-top:none; border-radius:0 0 3px 3px;
  box-shadow:0 1px 3px rgba(0,0,0,.3);
}

.wall--bottom .wall-tile .wt-face { width:44px; height:74px; border-top:2px solid #6ab884; }
.wall--bottom .wall-tile .wt-edge {
  width:44px; height:18px;
  background: repeating-linear-gradient(to bottom,
    #2E6348 0px,#2E6348 3px,#d4e8d8 3px,#d4e8d8 6px,
    #2E6348 6px,#2E6348 9px,#d4e8d8 9px,#d4e8d8 12px,
    #2E6348 12px,#2E6348 15px,#d4e8d8 15px,#d4e8d8 18px);
}
.wall--top .wall-tile .wt-face { width:35px; height:40px; border-top:1px solid #6ab884; }
.wall--top .wall-tile .wt-edge {
  width:35px; height:12px;
  background: repeating-linear-gradient(to bottom,
    #2E6348 0px,#2E6348 2px,#d4e8d8 2px,#d4e8d8 4px,
    #2E6348 4px,#2E6348 6px,#d4e8d8 6px,#d4e8d8 8px,
    #2E6348 8px,#2E6348 10px,#d4e8d8 10px,#d4e8d8 12px);
}
.wall--left .wall-tile, .wall--right .wall-tile { display:flex; flex-direction:row; align-items:stretch; }
.wall--left .wall-tile .wt-face, .wall--right .wall-tile .wt-face {
  width:42px; height:25px;
  background:linear-gradient(90deg,#45835E,#2E6348);
  border:1px solid #5aa374; border-right:none; border-radius:3px 0 0 3px;
  box-shadow:0 2px 4px rgba(0,0,0,.3);
}
.wall--left .wall-tile .wt-edge, .wall--right .wall-tile .wt-edge {
  width:18px; height:25px;
  background: repeating-linear-gradient(to right,
    #2E6348 0px,#2E6348 3px,#d4e8d8 3px,#d4e8d8 6px,
    #2E6348 6px,#2E6348 9px,#d4e8d8 9px,#d4e8d8 12px,
    #2E6348 12px,#2E6348 15px,#d4e8d8 15px,#d4e8d8 18px);
  border:1px solid #5aa374; border-left:none; border-radius:0 3px 3px 0;
  box-shadow:0 1px 3px rgba(0,0,0,.3);
}

/* ---- 四家待摸牌墙：单张可控的横置盖牌 ----
 * 视觉方向元数据在 game/render.js 的 WALL_SEAT_VISUAL_META 中维护。
 * CSS 只负责每个 seat 的旋转、白边和三层偏移，不再在这里推导摸牌顺序。
 */
.wall-pending-probe {
  --pending-rotate: 180deg;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  pointer-events: none;
}

.wall-pending-probe--seat1,
.wall-pending-probe--seat3 {
  transform: translateY(-2px);
}

.wall-pending-probe--seat0,
.wall-pending-probe--seat2 {
  flex-direction: row;
  transform: translateX(-2px);
  gap: 2px;
}

.wall-pending-probe--seat0 {
  --pending-rotate: 90deg;
}

.wall-pending-probe--seat1 {
  --pending-rotate: 0deg;
}

.wall-pending-probe--seat2 {
  --pending-rotate: 90deg;
}

.wall-pending-probe--seat3 {
  --pending-rotate: 180deg;
}

.wall-pending-probe__slot {
  position: relative;
  width: 66px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.wall-pending-probe--seat0 .wall-pending-probe__slot,
.wall-pending-probe--seat2 .wall-pending-probe__slot {
  width: 43px;
  height: 70px;
}

.wall-pending-probe__layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.wall-pending-probe__layer--0 {
  transform: translate(0, 7px);
}

.wall-pending-probe__layer--1 {
  transform: translate(2px, 0);
}

.wall-pending-probe__layer--2 {
  transform: translate(4px, -7px);
}

.wall-pending-probe--seat0 .wall-pending-probe__layer--1,
.wall-pending-probe--seat2 .wall-pending-probe__layer--1 {
  transform: translate(0, 0);
}

.wall-pending-probe--seat0 .wall-pending-probe__layer--2,
.wall-pending-probe--seat2 .wall-pending-probe__layer--2 {
  transform: translate(0, -7px);
}

.wall-pending-probe--seat1 .wall-pending-probe__layer--0 {
  transform: translate(0, 7px);
}

.wall-pending-probe--seat1 .wall-pending-probe__layer--1 {
  transform: translate(-2px, 0);
}

.wall-pending-probe--seat1 .wall-pending-probe__layer--2 {
  transform: translate(-4px, -7px);
}

.pending-horizontal-tile {
  position: relative;
  width: 118px;
  height: 76px;
  overflow: hidden;
  border-radius: 7px 9px 9px 7px;
  background: #fafaf2;
  transform: rotate(var(--pending-rotate)) scale(0.56);
  box-shadow:
    rgba(12,35,22,.68) 0 0 0 .5px,
    rgba(255,255,247,.80) 0 1.2px 2px -1px inset,
    rgba(104,99,72,.18) 0 -5px 7px -5px inset,
    rgba(0,0,0,.32) 0 8px 12px;
}

.pending-horizontal-tile__layer,
.pending-horizontal-tile__seam {
  position: absolute;
  pointer-events: none;
}

.pending-horizontal-tile__cream {
  inset: 0;
  border-radius: inherit;
  background: #fafaf2;
  box-shadow:
    rgba(255,255,255,.68) 0 1.5px 2px -1px inset,
    rgba(136,124,88,.22) 0 -8px 9px -7px inset;
}

.pending-horizontal-tile__cream::before,
.pending-horizontal-tile__transition::before,
.pending-horizontal-tile__green::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.pending-horizontal-tile__cream::before {
  background:
    radial-gradient(18px 16px at 0% 0%, rgba(255,255,255,.56), transparent 72%),
    linear-gradient(180deg, rgba(255,255,255,.40), transparent 15%, transparent 78%, rgba(104,99,72,.10)),
    linear-gradient(90deg, rgba(255,255,255,.18), transparent 15%, transparent 84%, rgba(255,255,246,.22) 96%, rgba(132,121,86,.06));
}

.pending-horizontal-tile__transition {
  left: 0;
  bottom: 0;
  z-index: 2;
  width: calc(100% - 5px);
  height: calc(100% - 7px);
  border-radius: 6px 8px 8px 7px;
  background: #6b8a72;
  box-shadow:
    rgba(18,43,27,.50) 0 0 0 .5px,
    rgba(255,244,210,.54) 0 1px 2px -1px inset,
    rgba(255,244,210,.30) -1px 0 3px -2px inset,
    rgba(18,43,27,.28) 1.5px 0 4px -3px inset,
    rgba(18,43,27,.32) 0 -6px 8px -6px inset;
}

.wall-pending-probe--seat1 .pending-horizontal-tile__transition {
  top: 0;
  bottom: auto;
}

.wall-pending-probe--seat0 .pending-horizontal-tile__transition,
.wall-pending-probe--seat2 .pending-horizontal-tile__transition {
  width: calc(100% - 5px);
  height: 100%;
}

.wall-pending-probe--seat3 .pending-horizontal-tile__transition {
  box-shadow:
    rgba(18,43,27,.50) 0 0 0 .5px,
    rgba(255,244,210,.54) 0 -1px 2px -1px inset,
    rgba(255,244,210,.30) 1px 0 3px -2px inset,
    rgba(18,43,27,.28) -1.5px 0 4px -3px inset,
    rgba(18,43,27,.32) 0 6px 8px -6px inset;
}

.wall-pending-probe--seat3 .pending-horizontal-tile__transition::before {
  background:
    radial-gradient(18px 16px at 100% 100%, rgba(13,38,24,.30), transparent 70%),
    radial-gradient(12px 52px at 100% 50%, rgba(13,38,24,.24), transparent 72%),
    radial-gradient(10px 34px at 0% 50%, rgba(255,244,210,.14), transparent 74%),
    linear-gradient(180deg, rgba(13,38,24,.26), transparent 28%, transparent 82%, rgba(255,244,210,.24)),
    linear-gradient(90deg, rgba(13,38,24,.08), rgba(255,244,210,.12) 14%, transparent 30%, transparent 84%, rgba(13,38,24,.24) 96%, rgba(13,38,24,.10));
}

.pending-horizontal-tile__transition::before {
  background:
    radial-gradient(18px 16px at 0% 0%, rgba(255,244,210,.44), transparent 70%),
    radial-gradient(12px 52px at 0% 50%, rgba(255,244,210,.22), transparent 72%),
    radial-gradient(10px 34px at 100% 50%, rgba(255,244,210,.16), transparent 74%),
    linear-gradient(180deg, rgba(255,244,210,.28), transparent 17%, transparent 70%, rgba(13,38,24,.26)),
    linear-gradient(90deg, rgba(255,244,210,.30), rgba(255,244,210,.15) 12%, transparent 30%, transparent 84%, rgba(255,244,210,.13) 96%, rgba(13,38,24,.05));
}

.pending-horizontal-tile__green {
  left: 0;
  bottom: 0;
  z-index: 3;
  width: calc(100% - 10px);
  height: calc(100% - 13px);
  border-radius: 5px 7px 7px 6px;
  background: #2c5e3f;
  box-shadow:
    rgba(12,35,22,.48) 0 0 0 .5px,
    rgba(255,244,210,.23) 0 1.2px 2px -1px inset,
    rgba(255,244,210,.14) -1px 0 3px -2px inset,
    rgba(12,35,22,.30) 1.5px 0 4px -3px inset,
    rgba(12,35,22,.34) 0 -7px 8px -7px inset,
    rgba(0,0,0,.12) 2px 4px 7px;
}

.wall-pending-probe--seat1 .pending-horizontal-tile__green {
  top: 0;
  bottom: auto;
}

.wall-pending-probe--seat0 .pending-horizontal-tile__green,
.wall-pending-probe--seat2 .pending-horizontal-tile__green {
  width: calc(100% - 10px);
  height: 100%;
}

.wall-pending-probe--seat3 .pending-horizontal-tile__green {
  box-shadow:
    rgba(12,35,22,.48) 0 0 0 .5px,
    rgba(255,244,210,.23) 0 -1.2px 2px -1px inset,
    rgba(255,244,210,.14) 1px 0 3px -2px inset,
    rgba(12,35,22,.30) -1.5px 0 4px -3px inset,
    rgba(12,35,22,.34) 0 7px 8px -7px inset,
    rgba(0,0,0,.12) -2px -4px 7px;
}

.pending-horizontal-tile__green::before {
  background:
    radial-gradient(20px 16px at 0% 0%, rgba(255,244,210,.20), transparent 68%),
    radial-gradient(12px 62px at 0% 49%, rgba(255,244,210,.18), transparent 72%),
    radial-gradient(9px 38px at 100% 46%, rgba(255,244,210,.12), transparent 74%),
    radial-gradient(32px 24px at 100% 100%, rgba(13,38,24,.09), transparent 70%),
    linear-gradient(180deg, rgba(255,244,210,.10), transparent 19%, transparent 70%, rgba(13,38,24,.26)),
    linear-gradient(90deg, rgba(255,244,210,.16), rgba(255,244,210,.05) 13%, transparent 31%, transparent 85%, rgba(255,244,210,.09) 96%, rgba(13,38,24,.05));
}

.pending-horizontal-tile__green::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 12px;
  left: 5px;
  height: 1px;
  border-radius: 999px;
  background: rgba(18,70,46,.30);
  box-shadow:
    0 22px 0 rgba(18,70,46,.22),
    0 44px 0 rgba(18,70,46,.18);
}

.wall-pending-probe--seat1 .pending-horizontal-tile__green::after {
  top: 12px;
  bottom: auto;
}

.wall-pending-probe--seat3 .pending-horizontal-tile__green::after {
  top: 12px;
  bottom: auto;
}

.pending-horizontal-tile__seam {
  left: 0;
  right: 10px;
  top: 13px;
  z-index: 4;
  height: 1px;
  background-image: linear-gradient(rgba(255,248,220,.42), rgba(255,248,220,.42) 45%, rgba(12,35,22,.70) 55%, rgba(12,35,22,.70));
  mask-image: linear-gradient(90deg, rgba(0,0,0,0), rgb(0,0,0) 8%, rgb(0,0,0) 90%, rgba(0,0,0,0));
}

.wall-pending-probe--seat1 .pending-horizontal-tile__seam {
  top: auto;
  bottom: 13px;
}

.wall-pending-probe--seat0 .pending-horizontal-tile__seam,
.wall-pending-probe--seat2 .pending-horizontal-tile__seam {
  top: 0;
  right: 10px;
  bottom: 0;
  left: auto;
  width: 1px;
  height: auto;
  background-image: linear-gradient(90deg, rgba(255,248,220,.42), rgba(255,248,220,.42) 45%, rgba(12,35,22,.70) 55%, rgba(12,35,22,.70));
  mask-image: linear-gradient(180deg, rgba(0,0,0,0), rgb(0,0,0) 8%, rgb(0,0,0) 90%, rgba(0,0,0,0));
}

.wall-pending-probe--seat3 .pending-horizontal-tile__seam {
  top: 13px;
  bottom: auto;
}

/* 右上角消息栏隐藏 */
#msg { display: none; }
.score-round { color: #9fb8a6; font-size: 11px; margin-left: 8px; }

/* ---- 设置面板 ---- */
.settings-gear {
  padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 600;
  background: rgba(20,30,25,0.6); color: #e8e0c8;
  border: 1px solid rgba(212,175,55,0.4); cursor: pointer; transition: all .15s;
}
.settings-gear:hover {
  background: rgba(35,50,40,0.85); border-color: rgba(212,175,55,0.7);
}
.settings-panel {
  display: none;
  position: absolute;
  top: 72px;
  left: 14px;
  width: 320px;
  max-height: 480px;
  z-index: 50;
  background: rgba(12, 20, 15, 0.92);
  border: 1px solid rgba(212, 175, 55, 0.5);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.55);
  color: #e8e0c8;
  overflow: hidden;
  flex-direction: column;
}
.settings-panel.show {
  display: flex;
}
.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(212,175,55,0.22);
  font-weight: 700;
  color: #ffd76b;
}
.settings-close {
  background: none;
  border: none;
  color: #9fb8a6;
  font-size: 16px;
  cursor: pointer;
}
.settings-close:hover { color: #ff6b5a; }
.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(212,175,55,0.15);
  padding: 0 8px;
}
.settings-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #9fb8a6;
  font-size: 12px;
  padding: 8px 4px;
  cursor: pointer;
  transition: all .15s;
}
.settings-tab.active {
  color: #ffd76b;
  border-bottom-color: #d4af37;
}
.settings-tab:hover { color: #e8e0c8; }
.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
}
.config-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 12px;
}
.config-item span {
  color: #d7e8d9;
}
.config-item input {
  width: 60px;
  padding: 2px 6px;
  border: 1px solid rgba(212,175,55,0.35);
  border-radius: 4px;
  background: rgba(20,30,25,0.7);
  color: #f0d98a;
  font-size: 12px;
  text-align: center;
}
.config-item input:focus {
  outline: none;
  border-color: #d4af37;
}
.settings-footer {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(212,175,55,0.22);
  justify-content: flex-end;
}

/* ---- 联机按钮 ---- */
.online-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.online-status {
  font-size: 11px;
  color: #9fb8a6;
  margin-left: 4px;
}

/* ---- 转分弹窗 ---- */
.transfer-popup-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,0.5); display: flex;
  align-items: center; justify-content: center;
}
.transfer-popup {
  background: rgba(15,25,20,0.95); border: 1px solid rgba(212,175,55,0.5);
  border-radius: 10px; padding: 20px 24px; min-width: 280px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.transfer-popup__title { color: #f0d98a; font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.transfer-popup__body { display: flex; flex-direction: column; gap: 10px; }
.transfer-popup__label { color: #d7e8d9; font-size: 13px; }
.transfer-popup__input {
  background: rgba(20,30,25,0.8); border: 1px solid rgba(212,175,55,0.4);
  border-radius: 6px; padding: 8px 12px; color: #e8e0c8; font-size: 15px; outline: none;
}
.transfer-popup__input:focus { border-color: rgba(212,175,55,0.8); }

/* ---- 联机大厅 ---- */
.online-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5,10,8,0.92); display: flex;
  align-items: center; justify-content: center;
}
.online-lobby { width: 360px; }
.online-title { color: #f0d98a; font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 20px; }
.online-btn {
  display: block; width: 100%; padding: 12px; border: 1px solid rgba(212,175,55,0.4);
  border-radius: 8px; background: rgba(20,30,25,0.8); color: #d7e8d9;
  font-size: 15px; cursor: pointer; transition: all 0.2s; margin-bottom: 10px;
}
.online-btn:hover { border-color: rgba(212,175,55,0.8); background: rgba(30,40,35,0.9); }
.online-btn--primary { background: rgba(212,175,55,0.2); color: #f0d98a; font-weight: 600; }
.online-btn--primary:hover { background: rgba(212,175,55,0.35); }
.online-btn--small { display: inline; width: auto; padding: 6px 14px; font-size: 13px; }
.online-or { text-align: center; color: #6a8075; margin: 6px 0; font-size: 13px; }
.online-input {
  display: block; width: 100%; padding: 10px; background: rgba(15,25,20,0.9);
  border: 1px solid rgba(212,175,55,0.3); border-radius: 6px;
  color: #e8e0c8; font-size: 15px; outline: none; margin-bottom: 10px; box-sizing: border-box;
}
.online-input:focus { border-color: rgba(212,175,55,0.7); }
.online-name-row { margin-top: 10px; }
.online-name-row label { color: #9fb8a6; font-size: 13px; display: block; margin-bottom: 4px; }
.online-input--name { margin-top: 0; }
.online-error { color: #e06050; font-size: 13px; min-height: 18px; margin-top: 4px; text-align: center; }

/* 房间内 */
.online-room-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; color: #d7e8d9; font-size: 14px; }
.online-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.online-slot {
  background: rgba(15,25,20,0.8); border: 1px dashed rgba(212,175,55,0.3);
  border-radius: 10px; padding: 16px 12px; text-align: center; cursor: pointer;
  transition: all 0.2s; min-height: 60px; display: flex; flex-direction: column; justify-content: center;
}
.online-slot:hover { border-color: rgba(212,175,55,0.6); background: rgba(25,35,30,0.9); }
.online-slot--taken { border-style: solid; cursor: default; border-color: rgba(212,175,55,0.5); }
.online-slot--taken:hover { background: rgba(15,25,20,0.8); }
.online-slot--me { border-color: rgba(212,175,55,0.9); background: rgba(212,175,55,0.1); }
.online-slot-num { color: #6a8075; font-size: 12px; }
.online-slot-name { color: #e8e0c8; font-size: 15px; font-weight: 600; }
.online-slot .online-slot-add { color: #6a8075; font-size: 12px; margin-top: 4px; }
.online-slot--taken .online-slot-add { display: none; }
.online-status { text-align: center; color: #9fb8a6; font-size: 13px; margin-top: 8px; }
.transfer-popup__btns { display: flex; gap: 10px; margin-top: 6px; }
.transfer-popup__error { color: #e06050; font-size: 12px; min-height: 16px; }

/* ===== 旁观 / toast 提示（需求 9.1 / 9.4） ===== */
.online-btn--ghost { background: transparent; border: 1px dashed rgba(212,175,55,0.6); color: #e8d9a0; }
.online-btn--ghost:hover { background: rgba(212,175,55,0.12); }

/* 旁观者看牌时固定在右上角的「选座加入」按钮 */
.online-spectate-join {
  position: fixed;
  top: 10px;
  right: 16px;
  z-index: 50;
}

.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  min-width: 180px;
  max-width: 80vw;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: rgba(40, 48, 44, 0.94);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.toast--show { opacity: 1; transform: translateY(0); }
.toast--info { background: rgba(46, 110, 90, 0.95); }
.toast--success { background: rgba(46, 130, 70, 0.95); }
.toast--warn { background: rgba(180, 120, 30, 0.96); }
.toast--error { background: rgba(180, 60, 50, 0.96); }

/* ---- 设置：顶层菜单（计分配置 / 音量） ---- */
.settings-scopes {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(212,175,55,0.15);
  padding: 0 8px;
}
.settings-scope {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #9fb8a6;
  font-size: 12px;
  padding: 8px 4px;
  cursor: pointer;
  transition: all .15s;
}
.settings-scope.active {
  color: #ffd76b;
  border-bottom-color: #d4af37;
}
.settings-scope:hover { color: #e8e0c8; }

/* 音量面板 */
.audio-panel { display: flex; flex-direction: column; gap: 14px; padding: 4px 0; }
.audio-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.audio-label { width: 36px; color: #d7e8d9; }
.audio-row input[type="range"] { flex: 1; accent-color: #d4af37; cursor: pointer; }
.audio-val { width: 30px; text-align: right; color: #f0d98a; }
.audio-switch { position: relative; display: inline-block; width: 42px; height: 22px; }
.audio-switch input { display: none; }
.audio-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: rgba(255,255,255,0.18); border-radius: 22px; transition: .2s;
}
.audio-slider::before {
  content: ""; position: absolute; height: 16px; width: 16px;
  left: 3px; top: 3px; background: #e8e0c8; border-radius: 50%; transition: .2s;
}
.audio-switch input:checked + .audio-slider { background: #d4af37; }
.audio-switch input:checked + .audio-slider::before { transform: translateX(20px); }

/* 操作设置 */
.controls-panel { padding: 6px 0; }
.controls-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.controls-label { color: #d7e8d9; font-size: 13px; white-space: nowrap; }
.controls-segment {
  display: inline-flex;
  padding: 2px;
  border: 1px solid rgba(212,175,55,0.34);
  border-radius: 6px;
  background: rgba(10,18,13,0.72);
}
.controls-segment button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #9fb8a6;
  font-size: 12px;
  cursor: pointer;
}
.controls-segment button.active { background: rgba(212,175,55,0.25); color: #ffe48a; }

/* ===== 横屏移动端：牌桌缩放，操作层保持真实触控尺寸 ===== */
@media (orientation: landscape) and (max-height: 720px) and (pointer: coarse) {
  .stage-header,
  .side-panel,
  #ting-preview,
  #action-slot {
    display: none !important;
  }

  .mobile-shell {
    position: absolute;
    inset: 0;
    z-index: 180;
    display: block;
    pointer-events: none;
    color: #e8e0c8;
  }

  .mobile-toolbar {
    position: absolute;
    top: max(5px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    left: max(8px, env(safe-area-inset-left));
    height: 40px;
    display: flex;
    align-items: center;
    gap: 7px;
    pointer-events: auto;
  }

  .mobile-icon-btn,
  .mobile-edge-btn,
  .mobile-drawer__close {
    border: 1px solid rgba(212, 175, 55, 0.48);
    background: rgba(10, 20, 14, 0.88);
    color: #f4dc94;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.36);
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-icon-btn {
    width: 42px;
    height: 40px;
    border-radius: 6px;
    font-size: 21px;
    line-height: 1;
  }

  .mobile-toolbar__identity {
    flex: 0 0 min(180px, 25vw);
    width: min(180px, 25vw);
    min-width: 0;
    height: 40px;
    padding: 4px 10px;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 6px;
    background: rgba(10, 20, 14, 0.82);
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
  }

  #mobile-fullscreen { margin-left: auto; }

  .mobile-room-badge {
    color: #f4dc94;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.05;
    white-space: nowrap;
  }

  .mobile-self {
    color: #bcd2c0;
    font-size: 10px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-status {
    position: absolute;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(9px, env(safe-area-inset-bottom));
    z-index: 211;
    max-width: min(320px, 46vw);
    min-height: 40px;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid rgba(212, 175, 55, 0.24);
    border-radius: 6px;
    background: rgba(10, 20, 14, 0.78);
    color: #f2dda0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 100ms ease;
    pointer-events: none;
  }

  .mobile-shell:has(.mobile-action-dock:not(:empty)) .mobile-status { opacity: 1; }

  .mobile-edge-btn {
    position: absolute;
    top: 50%;
    z-index: 205;
    width: 34px;
    height: 52px;
    padding: 0;
    transform: translateY(-50%);
    font-size: 14px;
    font-weight: 700;
    pointer-events: auto;
  }

  .mobile-edge-btn--left {
    left: max(0px, env(safe-area-inset-left));
    border-left: 0;
    border-radius: 0 6px 6px 0;
  }

  .mobile-edge-btn--right {
    right: max(0px, env(safe-area-inset-right));
    border-right: 0;
    border-radius: 6px 0 0 6px;
  }

  .mobile-drawer-scrim {
    position: absolute;
    inset: 0;
    z-index: 210;
    display: none;
    background: rgba(2, 7, 4, 0.5);
    pointer-events: auto;
  }

  .mobile-drawer-scrim.show { display: block; }

  .mobile-drawer {
    position: absolute;
    top: max(50px, calc(env(safe-area-inset-top) + 46px));
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 220;
    width: min(340px, 46vw);
    border: 1px solid rgba(212, 175, 55, 0.45);
    background: rgba(9, 18, 12, 0.97);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
    transition: transform 180ms ease-out;
    pointer-events: auto;
    overflow: hidden;
  }

  .mobile-drawer--left {
    left: max(0px, env(safe-area-inset-left));
    border-left: 0;
    border-radius: 0 7px 7px 0;
    transform: translateX(-105%);
  }

  .mobile-drawer--right {
    right: max(0px, env(safe-area-inset-right));
    border-right: 0;
    border-radius: 7px 0 0 7px;
    transform: translateX(105%);
  }

  .mobile-drawer.show { transform: translateX(0); }

  .mobile-drawer__header {
    height: 44px;
    padding: 0 8px 0 14px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.22);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #f4dc94;
    font-size: 14px;
  }

  .mobile-drawer__close {
    width: 38px;
    height: 34px;
    border-radius: 5px;
    font-size: 22px;
    line-height: 1;
  }

  .mobile-drawer__content {
    height: calc(100% - 44px);
    padding: 9px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-drawer .history-item {
    min-height: 42px;
    padding: 8px 9px;
    font-size: 12px;
  }

  .mobile-drawer .log-item {
    padding: 7px 4px;
    font-size: 12px;
  }

  .mobile-action-dock {
    position: absolute;
    top: auto;
    right: auto;
    bottom: max(78px, calc(env(safe-area-inset-bottom) + 74px));
    left: 50%;
    z-index: 212;
    min-height: 40px;
    max-width: calc(100vw - max(24px, env(safe-area-inset-left)) - max(24px, env(safe-area-inset-right)));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
    transform: translateX(-50%);
    pointer-events: none;
  }

  .mobile-action-dock:empty { display: none; }

  .mobile-action-dock .act-btn {
    min-width: 54px;
    height: 40px;
    padding: 0 15px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 700;
    pointer-events: auto;
    touch-action: manipulation;
  }

  .mobile-action-dock .act-btn--gang,
  .mobile-action-dock .act-btn--angang,
  .mobile-action-dock .act-btn--addgang {
    background: linear-gradient(180deg, #6c3483, #4a235a);
    border-color: #bb8fce;
    color: #fff;
  }

  .mobile-action-dock .act-btn--ting {
    background: linear-gradient(180deg, #b8862a, #7a5315);
    border-color: #f0c75e;
    color: #fff;
  }

  .mobile-action-dock .online-discard-prompt {
    min-height: 40px;
    padding: 0 18px;
    border: 1px solid rgba(255, 215, 107, 0.58);
    border-radius: 6px;
    background: rgba(10, 20, 14, 0.9);
    display: flex;
    align-items: center;
    color: #ffe48a;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
  }

  .mobile-ting-preview {
    position: absolute;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(60px, calc(env(safe-area-inset-bottom) + 56px));
    z-index: 209;
    max-width: min(540px, 72vw);
    padding: 8px 10px;
    border: 1px solid rgba(212, 175, 55, 0.55);
    border-radius: 7px;
    background: rgba(9, 18, 12, 0.95);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.46);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 120ms ease, transform 120ms ease;
    pointer-events: none;
  }

  .mobile-ting-preview.show {
    opacity: 1;
    transform: translateY(0);
  }

  .mobile-ting-preview .ting-preview__title { margin-bottom: 5px; }
  .mobile-ting-preview .ting-preview__tiles { flex-wrap: nowrap; }
  .tile--touch-preview { outline: 3px solid #ffd76b; outline-offset: 2px; }
  html[data-discard-mode="drag"] #hand-0 .tile--clickable { touch-action: none; }
  html[data-discard-mode="drag"],
  html[data-discard-mode="drag"] body,
  html[data-discard-mode="drag"] .viewport { overscroll-behavior: none; }
  #hand-0 .tile.is-selected { transform: translateY(-8px); }
  #hand-0 .tile--dragging {
    transform: translateY(var(--drag-shift, 0px)) !important;
    transition: none !important;
    z-index: 90;
  }
  #hand-0 .tile--drag-ready {
    filter: drop-shadow(0 0 7px rgba(255,215,107,.8)) drop-shadow(0 10px 14px rgba(0,0,0,.5));
    outline: 2px solid #ffd76b;
    outline-offset: 2px;
  }

  .settings-panel {
    position: absolute;
    top: max(8px, env(safe-area-inset-top));
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 50%;
    width: min(440px, calc(100vw - 24px));
    max-height: none;
    transform: translateX(-50%);
    z-index: 280;
  }

  .settings-tab,
  .settings-scope { min-height: 42px; font-size: 13px; }
  .settings-close { width: 40px; height: 36px; font-size: 22px; }
  .config-item { min-height: 36px; font-size: 13px; }

  .result-overlay,
  .history-detail-overlay {
    z-index: 300;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    box-sizing: border-box;
  }

  .result-box,
  .history-detail-box {
    width: min(720px, calc(100vw - 28px));
    max-width: none;
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    box-sizing: border-box;
  }

  .result-box { padding: 14px 20px; }
  .result-title { font-size: 23px; }
  .history-detail-box { padding: 14px 18px; }
  .history-detail-close { min-width: 42px; min-height: 42px; }

  .transfer-popup-overlay { z-index: 320; }
  .transfer-popup { max-height: calc(100dvh - 20px); overflow-y: auto; }

  .online-overlay {
    padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    box-sizing: border-box;
  }

  .online-lobby {
    width: min(680px, calc(100vw - 24px));
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
  }

  .online-menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    align-items: end;
  }

  .online-title { grid-column: 1 / -1; margin-bottom: 2px; font-size: 20px; }
  .online-or { display: none; }
  .online-menu .online-btn,
  .online-menu .online-input { min-height: 44px; margin: 0; }
  #online-btn-create { grid-column: 1; grid-row: 2; }
  #online-room-input { grid-column: 2; grid-row: 2; }
  #online-btn-spectate { grid-column: 1; grid-row: 3; }
  #online-btn-join { grid-column: 2; grid-row: 3; }
  .online-name-row { grid-column: 1 / -1; margin-top: 0; }
  .online-name-row label { display: inline-block; margin: 0 8px 0 0; }
  .online-input--name { display: inline-block; width: calc(100% - 86px); }
  .online-error { grid-column: 1 / -1; margin: 0; min-height: 16px; }
  .online-room { padding: 0 4px; }
  .online-room-header { margin-bottom: 8px; }
  .online-slots { gap: 8px; margin-bottom: 8px; }
  .online-slot { min-height: 48px; padding: 8px 10px; }

  /* 宽度优先的移动牌桌：按 1600 逻辑宽度铺满，纵向只裁木质边缘。 */
  .cell--top { transform: none; }
  .seat--top { transform: translateY(calc(var(--mobile-crop-y, 82px) - 102px)) !important; }
  .seat-label--overlay-top { top: calc(var(--mobile-crop-y, 82px) + 22px); }
  .seat-bottom-fixed { bottom: calc(var(--mobile-crop-y, 82px) + 8px); }
  .hand--top {
    transform: translateY(-20px) translateZ(20px) rotateX(-18deg) scale(.86) !important;
    transform-origin: center bottom;
  }
  .wall--top {
    transform: translateX(-50%) translateY(35px) scale(.86);
    transform-origin: center center;
  }
  .board__river--top {
    transform: translateY(33px) scale(.86);
    transform-origin: center center;
  }
  .board__river--bottom {
    transform: translateY(-33px) scale(.86);
    transform-origin: center center;
  }
  .wall--bottom {
    bottom: calc(var(--mobile-crop-y, 82px) + 99px);
    transform: translateX(-50%) scale(.86);
    transform-origin: center bottom;
  }
  #hand-0 {
    transform: scale(.86);
    transform-origin: center bottom;
  }

  /* 历史和记录常驻在桌面两侧，不再使用抽屉入口。 */
  .mobile-edge-btn,
  .mobile-drawer-scrim { display: none !important; }

  .mobile-drawer,
  .mobile-drawer.show {
    top: max(52px, calc(env(safe-area-inset-top) + 47px));
    bottom: auto;
    width: min(190px, 21vw);
    height: 66px;
    border-radius: 6px;
    transform: none;
    background: rgba(9, 18, 12, 0.84);
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.38);
    transition: height 160ms ease-out, background 160ms ease-out;
  }

  .mobile-drawer--left {
    left: max(8px, env(safe-area-inset-left));
    border-left: 1px solid rgba(212, 175, 55, 0.42);
  }

  .mobile-drawer--right {
    right: max(8px, env(safe-area-inset-right));
    border-right: 1px solid rgba(212, 175, 55, 0.42);
  }

  .mobile-drawer__header {
    height: 30px;
    padding: 0 9px;
    font-size: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-drawer__header::after {
    content: "⌄";
    color: #f0d98a;
    font-size: 15px;
    line-height: 1;
  }

  .mobile-drawer__close { display: none; }

  .mobile-drawer__content {
    height: calc(100% - 30px);
    padding: 5px 6px;
    gap: 4px;
    overflow: hidden;
  }

  .mobile-drawer.is-expanded {
    height: min(170px, calc(100dvh - 112px));
    background: rgba(9, 18, 12, 0.96);
  }

  .mobile-drawer.is-expanded .mobile-drawer__header::after { content: "⌃"; }
  .mobile-drawer.is-expanded .mobile-drawer__content { overflow-y: auto; }

  .mobile-drawer:not(.is-expanded) .history-item:not(:first-child),
  .mobile-drawer:not(.is-expanded) .log-item:not(:last-child) {
    display: none;
  }

  .mobile-drawer .history-item {
    min-height: 34px;
    padding: 5px 6px;
    font-size: 10px;
    line-height: 1.3;
  }

  .mobile-drawer .log-item {
    padding: 4px 2px;
    font-size: 10px;
    line-height: 1.3;
  }

  /* ?layoutdebug=1：只用于手机布局重叠检查。 */
  .layout-debug #hand-0,
  .layout-debug #hand-1,
  .layout-debug #hand-2,
  .layout-debug #hand-3 { outline: 1px solid #39e75f !important; outline-offset: 1px; }

  .layout-debug #wall-0,
  .layout-debug #wall-1,
  .layout-debug #wall-2,
  .layout-debug #wall-3 { outline: 1px solid #29a8ff !important; outline-offset: 1px; }

  .layout-debug #river-0,
  .layout-debug #river-1,
  .layout-debug #river-2,
  .layout-debug #river-3 { outline: 1px solid #ff4b4b !important; outline-offset: 1px; }

  .layout-debug #melds-0,
  .layout-debug #melds-1,
  .layout-debug #melds-2,
  .layout-debug #melds-3 { outline: 1px solid #c45cff !important; outline-offset: 1px; }

  .layout-debug #label-0,
  .layout-debug #label-1,
  .layout-debug #label-2,
  .layout-debug #label-3 { outline: 1px solid #ffe047 !important; outline-offset: 1px; }

  .layout-debug #mobile-history-drawer { outline: 1px solid #27e0e0 !important; outline-offset: 1px; }
  .layout-debug #mobile-log-drawer { outline: 1px solid #ff65b5 !important; outline-offset: 1px; }
  .layout-debug #mobile-status { outline: 1px solid #fff !important; outline-offset: 1px; }
  .layout-debug .board__center { outline: 1px dashed #ff9f32 !important; outline-offset: 1px; }
}
