/* ============================================================
   7鬼523 横屏原型 · 牌桌（V3 定稿收尾版）
   座位固定：你永远在下；2 人对手在上，3 人分居左右，4 人左/上/右。
   两条横带（各占牌桌高度的一半，框体不相交，验收脚本可证）：
     上带 = 对家（信息条在左，出牌朝桌心展开）
     下带 = 左家 / 右家**共用一条横带**：信息条贴两端，牌组向桌心展开
   **自己的已出牌不再占牌桌横带**：它放在底部操作栏左侧的"你"槽位，
   操作栏右侧才是自己的主操作按钮；没出牌时空槽显示简短操作状态。
   结果标签（最大/陪牌·同大/被压过/较弱）挂在各自信息条**下方**，
   因此永远不会压到牌角；分值徽标只写数字，不遮点数。
   比较阶段整块牌桌让给"放大后的中央结果区"。
   ============================================================ */

.table-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}
.stage::before {
  content: '';
  position: absolute;
  inset: 3% 12%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 72%);
  pointer-events: none;
}

/* ------------------------------------------------------------ 两条横带 */

.seat-zone {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 0;
}
/* 上带：对家（2 人局独占整块牌桌，4 人局占上半） */
.seat-zone[data-pos="top"] {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: calc(50% - 1px);
  flex-direction: row;
  justify-content: center;
}
/* 下带：左家 / 右家共用；信息条贴屏边，出牌朝桌心展开 */
.seat-zone[data-pos="left"] {
  top: calc(50% + 1px);
  left: 2px;
  height: calc(50% - 1px);
  flex-direction: row;
  justify-content: flex-start;
}
.seat-zone[data-pos="right"] {
  top: calc(50% + 1px);
  right: 2px;
  height: calc(50% - 1px);
  flex-direction: row-reverse;
  justify-content: flex-start;
}
.stage[data-seats="2"] .seat-zone[data-pos="top"] { top: 0; height: 100%; }
.stage[data-seats="3"] .seat-zone[data-pos="left"],
.stage[data-seats="3"] .seat-zone[data-pos="right"] { top: 0; height: 100%; }

/* 信息条 + 结果标签竖着叠在一起：标签因此绝不会横着挤到牌角上 */
.seat-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}
.seat-zone[data-pos="right"] .seat-col { align-items: flex-end; }

/* ------------------------------------------------------------ 座位信息条 */

.seat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px 2px 3px;
  border-radius: 14px;
  background: rgba(3, 30, 34, 0.72);
  border: 1px solid var(--line);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.seat-pill .sp-main { display: flex; flex-direction: column; gap: 1px; line-height: 1.2; min-width: 0; overflow: hidden; }
.seat-pill .sp-name { display: flex; align-items: center; gap: 4px; min-width: 0; }
/* 昵称横向显示：绝不逐字换行，超长用省略号 */
.seat-pill .nm {
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 6.5em;
}
.seat-pill .sub {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seat-pill .tm {
  font-weight: 800;
  color: #ffe6a8;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  min-width: 34px;
  text-align: right;
  white-space: nowrap;
}
.seat-pill .tm.warn { color: #ff9d94; }
.seat-pill .tm.over { color: #ffb347; }
.seat-pill.active {
  border-color: rgba(247, 195, 61, 0.9);
  background: rgba(247, 195, 61, 0.22);
  box-shadow: 0 0 0 1px rgba(247, 195, 61, 0.35);
}
.seat-pill.winner {
  border-color: rgba(123, 255, 207, 0.9);
  background: rgba(79, 211, 154, 0.22);
  box-shadow: 0 0 0 1px rgba(123, 255, 207, 0.4);
}
.seat-pill.draw { border-color: rgba(111, 196, 255, 0.9); }

/* ------------------------------------------------------------ 出牌区 */

.play-zone {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 0;
  padding: 1px 3px;
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
}
.play-zone[data-empty="1"] { border-style: none; padding: 0; }
.play-zone[data-active="1"] { border-color: rgba(247, 195, 61, 0.6); background: rgba(247, 195, 61, 0.08); }
.play-zone .pz-cards { display: flex; align-items: center; }
.play-zone .pz-cards .pc + .pc { margin-left: calc(-1 * var(--play-card-overlap)); }
.play-zone .pz-group { display: flex; align-items: center; gap: 4px; min-width: 0; }

/* 出牌标签：牌桌与历史弹层共用同一套样式 */
.pz-tag {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.16);
  flex: 0 0 auto;
}
.pz-tag.best { background: rgba(79, 211, 154, 0.32); color: #ccffe9; }
.pz-tag.companion { background: rgba(247, 195, 61, 0.28); color: #ffe9b8; }
.pz-tag.beaten { background: rgba(255, 255, 255, 0.16); color: #ffd9a1; }
.pz-tag.weaker { background: rgba(255, 255, 255, 0.14); color: var(--text-dim); }
.play-zone[data-owner="winner"] .pc { box-shadow: 0 0 0 2px rgba(123, 255, 207, 0.9), 0 2px 6px rgba(0, 0, 0, 0.4); }

/* 历史弹层里的一句话结果 */
.round-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 12px;
  background: rgba(3, 30, 34, 0.55);
  border: 1px solid rgba(123, 255, 207, 0.4);
  font-size: 13px;
}
.round-panel .rp-main { font-weight: 700; color: #ccffe9; white-space: nowrap; }
.round-panel .rp-sub { color: var(--text-dim); font-size: 12px; }

/* 出牌用的牌面：640 档 42×60 / 844 档 46×66（设计目标，按渲染尺寸验收） */
.pc.play {
  width: var(--play-card-w);
  height: var(--play-card-h);
  border-radius: 6px;
}
/* 分值徽标只写数字，宽度小到不会碰到左上角的点数 */
.pc.play .pc-pts,
.pc.cmp .pc-pts { font-size: 8px; padding: 0 2px; border-radius: 5px; }

/* ------------------------------------------------------------ 中央区 */

.center-cell {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
}
.deal-note {
  font-size: 13px;
  font-weight: 700;
  color: #ffe6a8;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(3, 30, 34, 0.72);
  border: 1px solid rgba(247, 195, 61, 0.45);
  white-space: nowrap;
}

/* 比较阶段：整块牌桌让给放大的中央结果区（座位信息条与出牌区让位隐藏） */
.stage[data-mode="compare"] .seat-zone { visibility: hidden; }
.compare-panel {
  position: absolute;
  inset: 1px 6px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(3, 34, 38, 0.94), rgba(2, 24, 28, 0.96));
  border: 2px solid rgba(247, 195, 61, 0.55);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.compare-panel .cp-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffe6a8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.compare-entries { display: flex; align-items: center; justify-content: center; gap: 10px; max-width: 100%; }
.compare-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  border-radius: 10px;
  border: 1px solid transparent;
  min-width: 0;
}
.compare-entry .ce-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.compare-entry .ce-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 5em;
}
.compare-entry .ce-tag { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.compare-entry.win { background: rgba(247, 195, 61, 0.22); border-color: rgba(247, 195, 61, 0.8); }
.compare-entry.win .ce-tag { color: #ffe9b8; font-weight: 700; }
.compare-entry.out { opacity: 0.45; }
.compare-note {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ------------------------------------------------------------ 操作区（含"你"的已出牌槽位） */

/* 操作栏永远压在牌桌之上：出牌飞行动画（translateY 46px）会短暂伸进操作栏高度，
   如果不给操作栏建立更高的层级，动画中的牌会盖住"托管"这类按钮、抢走点击 */
.table-actions {
  position: relative;
  z-index: 6;
  padding: 2px 8px;
  gap: 6px;
}

/* 左侧预留槽位：固定"你"标签 + （自己的牌组 或 简短操作状态） */
.table-actions .me-slot {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.table-actions[data-me="played"] .me-slot { flex: 0 0 auto; }
.table-actions .me-chip {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 7px;
  background: rgba(247, 195, 61, 0.25);
  color: #ffe6a8;
  white-space: nowrap;
}
.table-actions .me-status {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  line-height: 1.2;
}
.table-actions[data-me="played"] .me-status { display: none; }
.table-actions .status-main { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-actions .status-sub { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 自己的牌组：放在操作栏里，比桌面出牌略小，但保留点数与花色 */
.table-actions .me-play { display: none; align-items: center; gap: 4px; min-width: 0; }
.table-actions[data-me="played"] .me-play { display: flex; }
.table-actions .me-play .pc.play {
  width: var(--my-play-card-w);
  height: var(--my-play-card-h);
  border-radius: 5px;
}
.table-actions .me-play .pz-cards .pc + .pc { margin-left: calc(-1 * var(--my-play-card-overlap)); }
.table-actions .me-play .pc-pts { font-size: 8px; padding: 0 1px; }
/* 操作栏里的牌组不描边、不内缩：牌高就是槽位高，操作栏不会被撑高 */
.table-actions .me-slot .play-zone { border: none; padding: 0; cursor: zoom-in; }
.table-actions .me-slot .play-zone[data-empty="1"] { cursor: default; }

/* ------------------------------------------------------------ V4：操作栏增量
   选牌合法性摘要 table-select-note / 清空选择 table-clear / 代管说明 table-custody-note
   都待在操作栏这一条里，不新增行高，也不侵占主按钮热区。 */

.table-actions .me-slot { min-width: 0; }
.table-actions .me-status .status-main { max-width: 18em; }
/* 已经出过牌时保留"在等谁/为什么等"，只把第二行收起来（等待界面必须回答三件事，§7） */
.table-actions[data-me="played"] .me-slot { flex: 0 1 auto; }
.table-actions[data-me="played"] .me-status { display: flex; }
.table-actions[data-me="played"] .me-status .status-sub { display: none; }

.table-actions .select-note {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 44%;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
}
.table-actions .select-note[data-state="ok"] {
  color: #ccffe9;
  border-color: rgba(123, 255, 207, 0.5);
  background: rgba(79, 211, 154, 0.18);
}
.table-actions .select-note[data-state="bad"] {
  color: #ffe9b8;
  border-color: rgba(247, 195, 61, 0.55);
  background: rgba(247, 195, 61, 0.16);
}
.table-actions .select-note[hidden] { display: none; }
.table-actions .btn[hidden] { display: none; }
.table-actions .custody-note {
  flex: 0 0 auto;
  font-size: 12.5px;
  font-weight: 700;
  color: #ffe9b8;
  white-space: nowrap;
}
.table-actions .custody-note[hidden] { display: none; }

/* ------------------------------------------------------------ V4：上一轮回看面板 */

.prev-meta {
  font-size: 12.5px;
  font-weight: 700;
  color: #ffe6a8;
  background: rgba(247, 195, 61, 0.14);
  border: 1px solid rgba(247, 195, 61, 0.36);
  border-radius: 10px;
  padding: 5px 8px;
}
.prev-list { display: flex; flex-direction: column; gap: 6px; }
.prev-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  min-width: 0;
}
.prev-row.win { border-color: rgba(123, 255, 207, 0.55); background: rgba(79, 211, 154, 0.14); }
.prev-row .prev-who { display: flex; align-items: center; gap: 5px; min-width: 0; flex: 0 1 auto; }
.prev-row .prev-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 6em;
}
.prev-row .prev-cards { display: flex; align-items: center; gap: 2px; flex: 1 1 auto; justify-content: flex-end; }
.prev-row .prev-cards .pc + .pc { margin-left: -14px; }
.prev-row .pz-tag { flex: 0 0 auto; }

/* ------------------------------------------------------------ V4：房主管理菜单里的代管行 */

.custody-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  flex-wrap: wrap;
}
.custody-row .cr-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------ V4：观众视角
   观众没有"你"：底部的"你"槽位与手牌区不渲染，全部座位按固定基准画在牌桌上。
   只有观众会看到这套网格（玩家仍是已审核的两条横带布局）。 */

.table-screen.is-spectator .hand { display: none; }
.table-screen.is-spectator .stage[data-spectate="1"] {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 3px 5px;
  overflow: hidden;
}
.table-screen.is-spectator .stage[data-spectate="1"] .seat-zone {
  position: static;
  transform: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.table-screen.is-spectator .stage[data-spectate="1"] .seat-col,
.table-screen.is-spectator .stage[data-spectate="1"] .seat-zone[data-pos="right"] .seat-col {
  align-items: center;
}
.table-screen.is-spectator .stage[data-spectate="1"] .seat-pill { max-width: 100%; }
.table-screen.is-spectator .stage[data-spectate="1"] .play-zone { justify-content: center; max-width: 100%; }

/* 倒计时永远贴右边：自己的牌组占住左侧槽位时，空出来的宽度不能把倒计时丢在中间 */
.table-actions .timer-box { display: flex; flex-direction: column; align-items: flex-end; min-width: 62px; margin-left: auto; }
.table-actions .timer-big { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.table-actions .timer-big.warn { color: #ff9d94; }
.table-actions .timer-big.over { color: #ffb347; }
.table-actions .timer-sub { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.table-actions .btn { flex: 0 0 auto; }

/* 出牌飞行动画：从手牌位置落到本家出牌区 */
@keyframes playOut {
  from { transform: translateY(46px) scale(0.86); opacity: 0.35; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes dealIn {
  from { transform: translateY(-26px) scale(0.8); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes scoreFly {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-22px) scale(1.16); opacity: 0; }
}
.pc.animate-play { animation: playOut 0.22s ease-out; }
.pc.animate-deal { animation: dealIn 0.26s ease-out backwards; }
.score-pop {
  position: absolute;
  font-size: 15px;
  font-weight: 800;
  color: #ffe9b8;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  animation: scoreFly 0.6s ease-out forwards;
  pointer-events: none;
}

/* 本家牌组的大牌查看面板 */
.myplay-grid { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.myplay-meta { font-size: 13px; color: var(--text-dim); }

/* ------------------------------------------------------------ 结算 */

.settle-screen { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.settle-grid {
  flex: 1 1 auto;
  display: grid;
  gap: 6px;
  padding: 6px 10px;
  min-height: 0;
  align-content: center;
}
.settle-grid[data-seats="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settle-grid[data-seats="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settle-grid[data-seats="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.settle-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 6px;
  border-radius: 12px;
  background: rgba(3, 34, 38, 0.6);
  border: 1px solid var(--line);
}
.settle-card.win { border-color: rgba(247, 195, 61, 0.8); background: rgba(247, 195, 61, 0.14); }
.settle-card .st-name { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.settle-card .st-score { font-size: 20px; font-weight: 800; color: #ffe9b8; font-variant-numeric: tabular-nums; }
.settle-card .st-sub { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.settle-card .st-rank { font-size: 12px; font-weight: 700; color: #ccffe9; }

/* 历史里的牌组 */
.history-trick { border: 1px dashed rgba(255, 255, 255, 0.18); border-radius: 8px; padding: 4px 6px; margin-top: 4px; }
.history-trick .ht-head { font-size: 12px; color: #ffe6a8; margin-bottom: 3px; }

/* ------------------------------------------------------------ 尺寸分档
   高度预算（640×360）：顶栏 44 + 状态条 22 + 牌桌 122 + 操作区 56 + 手牌 116 = 360
   高度预算（844×390）：顶栏 46 + 状态条 22 + 牌桌 140 + 操作区 58 + 手牌 124 = 390
   牌桌两条横带各占一半：640 档 61px（出牌 42×60），844 档 70px（出牌 46×66）。 */

/* 640×360 */
html[data-hband="xs"] {
  --topbar-h: 44px;
  --notice-h: 21px;
  --action-h: 56px;
  --hand-h: 116px;
  --card-w: 70px;
  --card-h: 102px;
  --card-overlap: 22px;
  --play-card-w: 42px;
  --play-card-h: 60px;
  --play-card-overlap: 24px;
  --my-play-card-w: 36px;
  --my-play-card-h: 52px;
  --my-play-card-overlap: 18px;
}
/* 844×390 */
html[data-hband="short"] {
  --topbar-h: 46px;
  --notice-h: 22px;
  --action-h: 58px;
  --hand-h: 124px;
  --card-w: 76px;
  --card-h: 110px;
  --card-overlap: 24px;
  --play-card-w: 46px;
  --play-card-h: 66px;
  --play-card-overlap: 26px;
  --my-play-card-w: 36px;
  --my-play-card-h: 52px;
  --my-play-card-overlap: 18px;
}
html[data-hband="mid"] {
  --topbar-h: 50px;
  --notice-h: 26px;
  --action-h: 62px;
  --hand-h: 126px;
  --card-w: 78px;
  --card-h: 114px;
  --card-overlap: 24px;
  --play-card-w: 44px;
  --play-card-h: 62px;
  --play-card-overlap: 24px;
  --my-play-card-w: 38px;
  --my-play-card-h: 56px;
  --my-play-card-overlap: 19px;
}
html[data-hband="tall"] {
  --topbar-h: 54px;
  --notice-h: 28px;
  --action-h: 66px;
  --hand-h: 134px;
  --card-w: 84px;
  --card-h: 122px;
  --card-overlap: 26px;
  --play-card-w: 46px;
  --play-card-h: 66px;
  --play-card-overlap: 26px;
  --my-play-card-w: 40px;
  --my-play-card-h: 58px;
  --my-play-card-overlap: 20px;
}

/* 紧凑横屏（640×360 / 844×390）：抠出每一像素给牌桌，但不缩小文字与牌面 */
html[data-hband="xs"][data-viewport="landscape"] .topbar,
html[data-hband="short"][data-viewport="landscape"] .topbar { padding: 0 6px; gap: 4px; }
html[data-hband="xs"][data-viewport="landscape"] .stage,
html[data-hband="short"][data-viewport="landscape"] .stage { padding: 0 2px; }
html[data-hband="xs"][data-viewport="landscape"] .compare-panel,
html[data-hband="short"][data-viewport="landscape"] .compare-panel { padding: 4px 8px; gap: 4px; }

/* 竖屏：只有竖屏回退页与大厅/创建/等待页生效（见 proto.css） */
html[data-viewport="portrait"] .settle-grid { align-content: center; }
html[data-viewport="portrait"] .field-grid { grid-template-columns: 1fr; }
html[data-viewport="portrait"] .seats-row[data-seats="3"],
html[data-viewport="portrait"] .seats-row[data-seats="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html[data-viewport="portrait"] .seats-row[data-seats="1"] { grid-template-columns: minmax(0, 1fr); }
