/* ==========================================================================
   斗地主 · 薄片 —— 玩家视角牌桌（POV）
   在 style.css 之后加载：只覆盖「布局 / 牌桌 / 座位 / 手牌区 / 侧栏」，
   卡牌、按钮、浮层、动画等基础样式仍沿用 style.css，避免回归。
   ========================================================================== */

/* ------------------------------------------------------------------ 变量 */
:root {
  --card-w: 78px;
  --card-h: 110px;
  --mini-w: 46px;
  --mini-h: 65px;
  --topbar-h: 56px;
  /* 手牌区高度由 app.js 用 ResizeObserver 实测后写回；这里只是首帧兜底 */
  --dock-h: 236px;
  /* 左上 / 右上两个座位：半身坐姿，尺寸按 42vh 缩放，宽度跟随立绘比例 */
  --cat-h: clamp(300px, 42vh, 430px);
  --cat-w: calc(var(--cat-h) * 0.68);
  --cat-top: 8px;
  --seat-edge: 0px;
  --rail-w: 356px;
}

html,
body {
  height: 100%;
}

body {
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(40, 170, 100, 0.22), transparent 55%),
    linear-gradient(180deg, #062b18 0%, #03180d 62%, #010b06 100%);
  background-attachment: fixed;
}

/* ------------------------------------------------------------------ 外壳 */
.app {
  max-width: none;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  gap: 0;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------ 顶栏 */
.topbar {
  position: relative;
  z-index: 60;
  flex: 0 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  flex-wrap: nowrap;
  padding: 6px 16px;
  border: none;
  border-bottom: 1px solid rgba(246, 216, 124, 0.16);
  border-radius: 0;
  background: linear-gradient(180deg, rgba(3, 22, 12, 0.98), rgba(2, 16, 9, 0.88));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
}

.topbar .brand {
  flex: 0 0 auto;
}

.topbar .stats {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
  gap: 7px;
}

.topbar .stat {
  white-space: nowrap;
}

.topbar .top-actions {
  flex: 0 0 auto;
  margin-left: auto;
}

.rail-btn {
  border-color: rgba(147, 197, 253, 0.32);
  color: #d8ecff;
  background: rgba(96, 165, 250, 0.1);
}

.rail-btn.active {
  border-color: var(--gold);
  color: var(--gold-2);
  background: rgba(246, 216, 124, 0.16);
  box-shadow: 0 0 16px rgba(246, 216, 124, 0.22);
}

.phase-pill.idle {
  color: #bfe3ff;
  border-color: rgba(147, 197, 253, 0.45);
  background: rgba(96, 165, 250, 0.12);
}

/* ------------------------------------------------------------------ 舞台 / 牌桌 */
.table-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(30, 120, 70, 0.22), transparent 62%),
    linear-gradient(180deg, #062b18 0%, #03170d 70%, #020d07 100%);
}

#table.table-felt {
  position: absolute;
  inset: 0;
  min-height: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

#table.table-felt::after {
  display: none;
}

/* 中央绿色绒面椭圆牌桌：占据主视觉，上方给两个角落座位留出空间 */
.table-oval {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(94%, 1640px);
  height: min(72%, 740px);
  border-radius: 50%;
  border: 2px solid rgba(246, 216, 124, 0.26);
  background:
    radial-gradient(ellipse at 50% 36%, #33ad68 0%, #229050 34%, #146a3e 62%, #0a4527 84%, #06301b 100%);
  box-shadow:
    inset 0 0 170px rgba(0, 0, 0, 0.55),
    inset 0 0 0 14px rgba(0, 0, 0, 0.16),
    inset 0 2px 0 rgba(255, 255, 255, 0.06),
    0 30px 80px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 0;
}

.table-oval::after {
  content: "";
  position: absolute;
  inset: 24px 34px;
  border-radius: 50%;
  border: 1px dashed rgba(246, 216, 124, 0.14);
}

.felt-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(ellipse at 50% 46%, transparent 42%, rgba(0, 10, 5, 0.55) 100%),
    radial-gradient(ellipse at 50% 118%, rgba(0, 0, 0, 0.5), transparent 55%);
}

/* 桌心淡淡的四种花色水印，空桌时不至于太空 */
.felt-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 34px;
  font-size: 76px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.055);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  user-select: none;
}

.felt-mark .red {
  color: rgba(255, 120, 120, 0.06);
}

/* 待机 / 收牌时的桌沿渐变：让立绘下半身像被桌沿挡住，而不是硬切 */
.table-stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--dock-h) + 96px);
  z-index: 14;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: linear-gradient(180deg,
    rgba(2, 16, 9, 0) 0%,
    rgba(2, 16, 9, 0.58) 34%,
    rgba(2, 14, 8, 0.93) 70%,
    #020d07 100%);
}

.table-stage.idle::after {
  opacity: 1;
}

/* ------------------------------------------------------------------ 左上 / 右上猫娘座位 */
#seat-1,
#seat-2 {
  position: absolute;
  top: var(--cat-top);
  bottom: auto;
  width: var(--cat-w);
  height: var(--cat-h);
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
  z-index: 6;
  pointer-events: none;
  transition: none;
}

#seat-2 {
  left: var(--seat-edge);
  right: auto;
}

#seat-1 {
  right: var(--seat-edge);
  left: auto;
}

.seat-panel.active::before {
  display: none !important;
}

.cat-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.cat-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 20px 28px rgba(0, 0, 0, 0.45));
  user-select: none;
  -webkit-user-drag: none;
  transition: filter 0.25s ease;
  /* 底部渐隐：半身像的腰/手臂自然融进桌沿，而不是硬切 */
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 92%, rgba(0, 0, 0, 0) 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 92%, rgba(0, 0, 0, 0) 100%);
}

/* 左上座位面朝右偏下、右上座位面朝左偏下：轻微向桌心倾斜 */
#seat-2 .cat-img {
  transform: rotate(3.5deg);
  transform-origin: 50% 96%;
}

#seat-1 .cat-img {
  transform: rotate(-3.5deg);
  transform-origin: 50% 96%;
}

.cat-wrap.img-missing .cat-img {
  display: none;
}

.cat-aura {
  position: absolute;
  left: 50%;
  bottom: -2%;
  width: 88%;
  height: 62%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 70%, rgba(246, 216, 124, 0.2), rgba(120, 255, 190, 0.08) 46%, transparent 72%);
  filter: blur(10px);
  z-index: -1;
  pointer-events: none;
}

.cat-crown {
  position: absolute;
  top: 1%;
  right: 9%;
  font-size: 26px;
  line-height: 1;
  display: none;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.seat-panel.landlord .cat-crown {
  display: block;
  animation: crownFloat 2.6s ease-in-out infinite;
}

@keyframes crownFloat {
  0%, 100% { transform: translateY(0) rotate(-7deg); }
  50% { transform: translateY(-5px) rotate(5deg); }
}

/* 立绘缺失时的可爱占位（服务端图片就位后自动隐藏） */
.cat-fallback {
  display: none;
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 64%;
  height: 76%;
  align-items: center;
  justify-content: center;
  border-radius: 48% 48% 26% 26% / 36% 36% 20% 20%;
  background: radial-gradient(ellipse at 50% 26%, #ffe7f1, #f6c2d8 52%, #d895b6 100%);
  box-shadow: inset 0 -20px 36px rgba(120, 40, 80, 0.22), 0 20px 44px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.cat-wrap:not(.img-ok) .cat-fallback {
  display: flex;
}

.cat-fallback::before,
.cat-fallback::after {
  content: "";
  position: absolute;
  top: -8%;
  width: 26%;
  height: 24%;
  background: linear-gradient(180deg, #ffe7f1, #eaa8c6);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.cat-fallback::before {
  left: 6%;
  transform: rotate(-10deg);
}

.cat-fallback::after {
  right: 6%;
  transform: rotate(10deg);
}

.cat-fallback-face {
  font-size: 58px;
  line-height: 1;
  filter: drop-shadow(0 6px 8px rgba(90, 30, 60, 0.28));
}

/* 座位信息牌：贴在角色腰侧 / 下方，不遮脸 */
.seat-hud {
  position: absolute;
  left: 50%;
  bottom: -12px;
  transform: translateX(-50%);
  min-width: 176px;
  max-width: 96%;
  padding: 7px 12px 8px;
  border-radius: 14px;
  border: 1px solid rgba(246, 216, 124, 0.26);
  background: linear-gradient(180deg, rgba(6, 34, 19, 0.92), rgba(3, 18, 10, 0.96));
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  z-index: 3;
  pointer-events: auto;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.seat-hud .avatar {
  width: 34px;
  height: 34px;
  font-size: 12px;
}

.seat-hud .seat-name {
  font-size: 13.5px;
  max-width: 132px;
}

.seat-hud .seat-bottom {
  margin-top: 5px;
}

.seat-hud .seat-count b {
  font-size: 20px;
}

.seat-hud .seat-backs {
  display: none;
}

#seat-1.active .seat-hud,
#seat-2.active .seat-hud {
  border-color: var(--gold);
  box-shadow:
    0 0 0 2px rgba(246, 216, 124, 0.16),
    0 0 26px rgba(246, 216, 124, 0.32),
    0 12px 26px rgba(0, 0, 0, 0.5);
}

#seat-1.active .seat-hud::after,
#seat-2.active .seat-hud::after {
  content: "行动中";
  position: absolute;
  top: -10px;
  right: 10px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #2a1c00;
  background: var(--gold);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  animation: hintPulse 1.2s ease-in-out infinite;
}

#seat-1.active .cat-img,
#seat-2.active .cat-img {
  filter: drop-shadow(0 0 26px rgba(246, 216, 124, 0.5)) drop-shadow(0 20px 28px rgba(0, 0, 0, 0.45));
}

#seat-1.active .cat-fallback,
#seat-2.active .cat-fallback {
  box-shadow: 0 0 0 2px rgba(246, 216, 124, 0.4), 0 20px 44px rgba(0, 0, 0, 0.45);
}

/* ------------------------------------------------------------------ AI 对话入口（头像角标） */
/* #seat-1/#seat-2 是 pointer-events:none（见上方 231 行），按钮必须显式 auto，否则点不动 */
.cat-log {
  position: absolute;
  bottom: 20%;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(246, 216, 124, 0.42);
  background: linear-gradient(180deg, rgba(6, 34, 19, 0.9), rgba(3, 18, 10, 0.96));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--gold);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  z-index: 5;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

/* 左右座位贴“外侧”，避开脸与中央牌桌 */
.cat-wrap.cat-left .cat-log {
  left: 2px;
}

.cat-wrap.cat-right .cat-log {
  right: 2px;
}

.cat-log:hover {
  transform: translateY(-2px) scale(1.06);
  border-color: var(--gold);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), 0 0 18px rgba(246, 216, 124, 0.35);
}

.cat-log.active {
  border-color: var(--gold);
  background: linear-gradient(180deg, #ffe28b 0%, #f1c64e 55%, #d9a92e 100%);
  color: #2a1c00;
}

/* 该座位正在深度思考时脉冲提示（app.js 同步 state.thinking.seat） */
.cat-log.thinking {
  animation: catLogPulse 1.2s ease-in-out infinite;
}

@keyframes catLogPulse {
  0%, 100% { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), 0 0 0 0 rgba(147, 197, 253, 0.55); }
  50% { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), 0 0 0 7px rgba(147, 197, 253, 0); }
}

.cat-log-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e5534b;
  border: 1px solid rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 15px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

/* ------------------------------------------------------------------ 玩家信息条（#seat-0 在手牌区顶部） */
#seat-0 {
  position: static;
  left: auto;
  bottom: auto;
  width: auto;
  transform: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 5px 14px 5px 7px;
  border-radius: 999px;
  border: 1px solid rgba(246, 216, 124, 0.2);
  background: rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  z-index: auto;
}

#seat-0.active {
  transform: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(246, 216, 124, 0.18), 0 0 18px rgba(246, 216, 124, 0.25);
}

.me-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
  color: var(--gold);
  background: radial-gradient(circle at 35% 30%, rgba(246, 216, 124, 0.34), rgba(246, 216, 124, 0.08));
  border: 1px solid rgba(246, 216, 124, 0.5);
}

.me-name {
  font-size: 13px;
  font-weight: 800;
}

.me-role {
  font-size: 11px;
  color: var(--muted);
}

.me-role.landlord {
  color: var(--gold);
  font-weight: 900;
}

.me-role.farmer {
  color: #9fd8b4;
}

.me-score {
  font-size: 12px;
  font-weight: 800;
  color: var(--gold);
}

.me-count {
  font-size: 12px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ 气泡（贴在角色旁） */
.bubble.pos-2 {
  left: calc(var(--cat-w) - 22px);
  right: auto;
  top: calc(var(--cat-top) + var(--cat-h) * 0.52);
  bottom: auto;
}

.bubble.pos-1 {
  right: calc(var(--cat-w) - 22px);
  left: auto;
  top: calc(var(--cat-top) + var(--cat-h) * 0.52);
  bottom: auto;
}

.bubble.pos-0 {
  bottom: calc(var(--dock-h) + 14px);
}

.chat-bubble.pos-2 {
  left: calc(var(--cat-w) - 8px);
  top: calc(var(--cat-top) + var(--cat-h) * 0.74);
  bottom: auto;
}

.chat-bubble.pos-1 {
  right: calc(var(--cat-w) - 8px);
  top: calc(var(--cat-top) + var(--cat-h) * 0.74);
  bottom: auto;
}

.chat-bubble.pos-0 {
  bottom: calc(var(--dock-h) + 24px);
}

/* ------------------------------------------------------------------ 出牌区 */
.trick-1 {
  left: 63%;
  top: 43%;
}

.trick-2 {
  left: 37%;
  top: 43%;
}

.trick-0 {
  left: 50%;
  top: 60%;
}

/* 桌面中央的场次信息牌（底分 / 倍数），参考图的桌心信息 */
.table-plaque {
  position: absolute;
  left: 50%;
  top: 2.4%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 1px;
  color: rgba(214, 240, 224, 0.82);
  background: rgba(2, 22, 12, 0.5);
  border: 1px solid rgba(246, 216, 124, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  pointer-events: none;
  white-space: nowrap;
}

.table-plaque .plaque-name {
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 2px;
}

.table-plaque .plaque-dot {
  opacity: 0.5;
}

/* ------------------------------------------------------------------ 中央信息 / 待机 */
.center-console {
  top: 15%;
  width: min(56%, 470px);
  gap: 6px;
  z-index: 3;
}

.center-banner {
  font-size: 18px;
}

.turn-hint.idle {
  color: var(--muted);
  letter-spacing: 1px;
}

/* 牌堆稍微靠上，避免和出牌区叠在一起 */
.deck {
  top: 38%;
}

/* idle「牌桌已就绪」控制台 */
.idle-console {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  padding: 26px 40px 22px;
  text-align: center;
  border-radius: 26px;
  border: 1px solid rgba(246, 216, 124, 0.3);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(46, 200, 120, 0.2), transparent 66%),
    rgba(2, 18, 10, 0.8);
  box-shadow: 0 26px 64px rgba(0, 0, 0, 0.55), inset 0 0 46px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  animation: idleIn 0.32s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}

@keyframes idleIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.94); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.idle-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 7px;
  color: var(--gold-2);
  text-shadow: 0 0 26px rgba(246, 216, 124, 0.38), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.idle-sub {
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--muted);
}

#btn-start {
  padding: 14px 48px;
  font-size: 19px;
  letter-spacing: 5px;
  border-radius: 14px;
}

.idle-meta {
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted-dim);
}

/* ------------------------------------------------------------------ 观战面板 */
#spectate-panel {
  position: absolute;
  left: 50%;
  bottom: calc(var(--dock-h) + 8px);
  transform: translateX(-50%);
  width: min(920px, 94%);
  max-height: 52%;
  overflow: auto;
  z-index: 22;
  margin: 0;
}

/* ------------------------------------------------------------------ 手牌区（底部大牌 + 操作条） */
.hand-area {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 6px 18px 10px;
  border: none;
  border-radius: 0;
  background: linear-gradient(180deg,
    rgba(2, 20, 11, 0) 0%,
    rgba(2, 20, 11, 0.62) 22%,
    rgba(2, 16, 9, 0.93) 58%,
    #020f08 100%);
  box-shadow: none;
}

.hand-topline {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 38px;
}

.hand-topline .hand-head {
  flex: 1 1 auto;
  margin: 0;
}

/* 玩家信息条里已经有身份，隐藏重复的角色 chip */
.hand-head #my-role {
  display: none;
}

.hand {
  min-height: calc(var(--card-h) + 26px);
  padding: 22px 6px 2px;
}

.hand .card {
  border-radius: 9px;
}

.hand .card .c-corner b {
  font-size: 21px;
}

.hand .card .c-corner i {
  font-size: 13px;
}

.hand .card .c-pip {
  font-size: 30px;
}

.hand .card:hover {
  transform: translateY(-14px);
}

.hand .card.selected {
  transform: translateY(-28px);
}

.hand .card.joker .joker-char {
  font-size: 40px;
}

.hand .card.joker .c-corner b {
  font-size: 19px;
}

.controls {
  position: relative;
  justify-content: center;
  min-height: 54px;
  margin-top: 4px;
  gap: 12px;
}

.controls .btn.big {
  padding: 12px 30px;
  font-size: 17px;
  letter-spacing: 1px;
  border-radius: 12px;
}

.controls .btn.ghost {
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--muted);
}

.controls-note {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  max-width: 30%;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* ------------------------------------------------------------------ 右侧抽屉：AI 思路 / 逐手日志 */
.rail-drawer {
  position: absolute;
  top: 10px;
  right: 10px;
  bottom: calc(var(--dock-h) + 6px);
  width: min(var(--rail-w), 36vw);
  z-index: 45;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateX(calc(100% + 26px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.24s ease;
}

.rail-drawer.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px 0;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--muted);
}

.rail-close {
  appearance: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(246, 216, 124, 0.32);
  background: rgba(0, 0, 0, 0.4);
  color: var(--gold);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
}

.rail-close:hover {
  background: rgba(246, 216, 124, 0.18);
  transform: rotate(90deg);
}

.rail-drawer .thought-panel,
.rail-drawer .log-panel {
  background: linear-gradient(180deg, rgba(4, 28, 15, 0.94), rgba(2, 16, 9, 0.97));
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.rail-drawer .thought-panel {
  flex: 0 0 auto;
  max-height: 38%;
}

.rail-drawer .log-panel {
  flex: 1 1 auto;
  min-height: 0;
}

.rail-drawer .thought-body {
  max-height: 168px;
  overflow-y: auto;
}

.rail-drawer .log-body {
  max-height: none;
  min-height: 80px;
}

/* ------------------------------------------------------------------ AI 对话抽屉（布局层；内部样式在 style.css） */
.transcript-drawer {
  position: absolute;
  top: 10px;
  right: 10px;
  bottom: calc(var(--dock-h) + 6px);
  width: min(480px, 42vw);
  z-index: 47;
  transform: translateX(calc(100% + 26px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.24s ease;
}

.transcript-drawer.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* 观战 + 对话抽屉同开：上帝视角面板左移让位，避免盖住 AI-1 的手牌 */
#table-stage.transcript-open #spectate-panel {
  left: calc(50% - min(240px, 21vw));
  width: min(920px, calc(100% - min(480px, 42vw) - 40px));
}

/* ------------------------------------------------------------------ 结算 / 浮层微调 */
.settlement {
  width: min(92vw, 470px);
}

.settlement-actions {
  flex-wrap: wrap;
  gap: 10px;
}

.settlement-actions .btn {
  min-width: 118px;
}

/* ------------------------------------------------------------------ 响应式 */
@media (min-width: 1700px) {
  :root {
    --topbar-h: 60px;
    --cat-h: clamp(360px, 44vh, 520px);
    --card-w: 90px;
    --card-h: 126px;
    --mini-w: 52px;
    --mini-h: 74px;
    --rail-w: 400px;
  }

  .hand .card .c-corner b {
    font-size: 23px;
  }

  .hand .card .c-pip {
    font-size: 34px;
  }

  .hand .card.joker .joker-char {
    font-size: 46px;
  }

  .idle-title {
    font-size: 30px;
  }

  #btn-start {
    padding: 16px 56px;
    font-size: 21px;
  }

  .center-console {
    width: min(50%, 560px);
  }
}

@media (max-width: 1500px) {
  :root {
    --rail-w: 336px;
  }
}

@media (max-width: 1280px) {
  :root {
    --cat-h: clamp(280px, 40vh, 400px);
    --card-w: 68px;
    --card-h: 96px;
    --rail-w: 320px;
  }

  .brand-sub {
    display: none;
  }

  .hand .card .c-corner b {
    font-size: 18px;
  }

  .hand .card .c-pip {
    font-size: 26px;
  }
}

@media (max-height: 840px) {
  :root {
    --topbar-h: 52px;
    --card-w: 66px;
    --card-h: 92px;
    --cat-h: clamp(270px, 42vh, 380px);
  }

  .center-console {
    top: 12%;
  }

  .idle-title {
    font-size: 23px;
  }

  #btn-start {
    padding: 12px 40px;
    font-size: 17px;
  }
}

@media (max-height: 720px) {
  :root {
    --topbar-h: 48px;
    --card-w: 56px;
    --card-h: 78px;
    --cat-h: clamp(230px, 40vh, 320px);
  }

  .hand {
    padding-top: 18px;
  }

  .hand .card .c-corner b {
    font-size: 16px;
  }

  .hand .card .c-pip {
    font-size: 22px;
  }

  .hand .card.selected {
    transform: translateY(-22px);
  }

  .center-console {
    top: 9%;
  }
}

/* 窄屏：纵向堆叠（不追求完美，但不错位/不遮操作）
   只给「竖屏 / 高窗口」用；手机横屏（高度 ≤ 520px）走文件末尾的专用横屏布局。 */
@media (max-width: 900px) and (min-height: 521px) {
  html,
  body {
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
  }

  .table-stage {
    flex: 0 0 auto;
    height: 74vh;
    min-height: 540px;
  }

  :root {
    --cat-h: clamp(180px, 26vh, 240px);
    --card-w: 54px;
    --card-h: 76px;
    --rail-w: 300px;
  }

  .topbar {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    padding: 8px 10px;
    gap: 6px;
  }

  .topbar .stats {
    order: 3;
    flex-basis: 100%;
    overflow-x: auto;
  }

  .top-actions {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
  }

  .topbar .stat.dim,
  .topbar .landlord-stat {
    display: none;
  }

  .top-actions {
    gap: 6px;
  }

  .top-actions .btn {
    padding: 0 10px;
    font-size: 12px;
    min-height: 40px;
  }

  .top-actions .icon-btn {
    width: 40px;
    height: 40px;
    font-size: 15px;
  }

  .table-plaque {
    display: none;
  }

  .center-console {
    top: 10%;
  }

  .seat-hud {
    min-width: 132px;
    bottom: -4px;
    padding: 5px 8px 6px;
  }

  .seat-hud .seat-name {
    font-size: 11px;
    max-width: 84px;
  }

  .seat-hud .seat-count b {
    font-size: 15px;
  }

  .bubble.pos-2 {
    left: calc(var(--cat-w) - 10px);
    top: calc(var(--cat-top) + var(--cat-h) * 0.48);
    bottom: auto;
  }

  .bubble.pos-1 {
    right: calc(var(--cat-w) - 10px);
    top: calc(var(--cat-top) + var(--cat-h) * 0.48);
    bottom: auto;
  }

  .chat-bubble.pos-2 {
    left: calc(var(--cat-w) - 4px);
    top: calc(var(--cat-top) + var(--cat-h) * 0.72);
    bottom: auto;
  }

  .chat-bubble.pos-1 {
    right: calc(var(--cat-w) - 4px);
    top: calc(var(--cat-top) + var(--cat-h) * 0.72);
    bottom: auto;
  }

  .trick-2 {
    left: 30%;
    top: 40%;
  }

  .trick-1 {
    left: 70%;
    top: 40%;
  }

  .trick-0 {
    top: 58%;
  }

  .center-console {
    top: 7%;
    width: 86%;
  }

  .hand-topline {
    gap: 8px;
    overflow-x: auto;
  }

  .hand-head {
    font-size: 11px;
    flex: 0 0 auto;
  }

  .hand-head .selected-hint {
    display: none;
  }

  .controls {
    min-height: 48px;
  }

  .controls .btn.big {
    padding: 10px 18px;
    font-size: 15px;
  }

  .controls-note {
    display: none;
  }

  .rail-drawer {
    width: min(320px, 88vw);
  }

  /* AI 对话入口：窄屏放到信息条下方（外角），避免压脸 / 压 HUD */
  .cat-log {
    bottom: auto;
    top: calc(100% + 6px);
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .cat-wrap.cat-left .cat-log {
    left: 4px;
  }

  .cat-wrap.cat-right .cat-log {
    right: 4px;
  }

  .cat-log-badge {
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    font-size: 9px;
    line-height: 13px;
  }

  /* 窄屏：对话抽屉变底部 sheet */
  .transcript-drawer {
    position: fixed;
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: min(62dvh, 560px);
    z-index: 74;
    transform: translateY(calc(100% + 16px));
  }

  .transcript-drawer.open {
    transform: translateY(0);
  }

  #table-stage.transcript-open #spectate-panel {
    left: 50%;
    width: min(920px, 94%);
  }
}


/* ==========================================================================
   手机横屏专用布局（POV 牌桌）
   --------------------------------------------------------------------------
   命中条件：orientation: landscape + 视口高度 ≤ 520px + 宽度 ≤ 1000px
   覆盖 640×360 / 667×375 / 844×390 / 915×412 / 932×430 等主流手机横屏。
   目标：牌桌 + 两家立绘/HUD + 手牌 + 操作条「一屏内」全部可见可点，
        页面不出现竖向/横向滚动，刘海（safe-area）不挡控件，点击目标 ≥ 40px。

   注意：本块必须放在最后，才能覆盖上面的「窄屏纵向堆叠」和桌面规则。
   ========================================================================== */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 1000px) {
  :root {
    --topbar-h: 42px;
    --card-w: 47px;
    --card-h: 66px;
    --mini-w: 28px;
    --mini-h: 40px;
    /* 立绘按视口高度缩放：短边 360 时约 158px，够看清脸又不吃满牌桌 */
    --cat-h: clamp(104px, 44vh, 188px);
    --cat-top: 2px;
    --rail-w: 300px;
    /* 手牌区高度：JS 会用 ResizeObserver 实测写回，这里给首帧兜底 */
    --dock-h: 150px;
    /* iOS 横屏刘海 / 底部横条安全区（探针可用内联 --safe-l 覆盖来模拟） */
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
  }

  /* 一屏锁死：不允许整页滚动（手机上横屏没有地方拖） */
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding: 0;
  }

  .table-stage {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }

  /* ------------------------------------------------------------ 顶栏：单行紧凑 */
  .topbar {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    padding: 1px calc(6px + var(--safe-r)) 1px calc(6px + var(--safe-l));
    gap: 8px;
  }

  .topbar .brand {
    align-items: center;
    gap: 4px;
  }

  .brand-icon {
    font-size: 15px;
  }

  .brand-name {
    font-size: 14px;
    letter-spacing: 1px;
  }

  .brand-sub {
    display: none;
  }

  .topbar .stats {
    order: 0;
    flex-wrap: nowrap;
    overflow: hidden;
    gap: 5px;
    font-size: 10.5px;
  }

  .topbar .stat {
    padding: 2px 7px;
  }

  .topbar .stat b {
    font-size: 12px;
  }

  .topbar .stat-label {
    font-size: 9.5px;
  }

  /* 手机上省略：种子 / 地主 / 积分（积分和地主身份在底部「你」信息条与 HUD 上都有） */
  .topbar .stat.dim,
  .topbar .landlord-stat,
  .topbar .score-stat {
    display: none;
  }

  .topbar .phase-pill {
    padding: 3px 9px;
    font-size: 10.5px;
    letter-spacing: 0.2px;
  }

  .topbar .llm-budget-badge {
    font-size: 9px;
    padding: 1px 5px;
  }

  .top-actions {
    margin-left: auto;
    width: auto;
    flex-wrap: nowrap;
    gap: 4px;
  }

  /* 触屏点击目标 ≥ 40px；「思路 / 日志 / 观战」只留图标（文字用 title 保留语义） */
  .top-actions .icon-btn {
    width: 40px;
    height: 40px;
    font-size: 16px;
    border-radius: 10px;
  }

  .top-actions .btn {
    height: 40px;
    min-height: 40px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 10px;
  }

  #btn-thought,
  #btn-log,
  #btn-spectate {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    font-size: 0;
    letter-spacing: 0;
    line-height: 1;
  }

  #btn-thought::before {
    content: "💡";
    font-size: 17px;
  }

  #btn-log::before {
    content: "📜";
    font-size: 16px;
  }

  #btn-spectate::before {
    content: "👁";
    font-size: 17px;
  }

  /* ------------------------------------------------------------ 牌桌 / 立绘 */
  .table-oval {
    width: 96%;
    height: 88%;
    top: 54%;
  }

  .table-oval::after {
    inset: 10px 16px;
  }

  /* 短屏上桌心水印与牌堆纯装饰，去掉给手牌腾地方 */
  .felt-mark,
  .deck,
  .table-plaque {
    display: none;
  }

  #seat-2 {
    left: var(--safe-l);
  }

  #seat-1 {
    right: var(--safe-r);
  }

  .cat-crown {
    font-size: 18px;
    right: 4%;
  }

  .seat-hud {
    width: 108px;
    min-width: 0;
    max-width: none;
    padding: 2px 6px 3px;
    border-radius: 10px;
    bottom: -2px;
  }

  .seat-hud .seat-top {
    gap: 5px;
  }

  .seat-hud .avatar {
    width: 20px;
    height: 20px;
    font-size: 9.5px;
  }

  .seat-hud .seat-name {
    font-size: 10.5px;
    max-width: 72px;
  }

  .seat-hud .llm-badge {
    display: none;
  }

  .seat-hud .seat-role,
  .seat-hud .seat-order {
    font-size: 9.5px;
  }

  .seat-hud .seat-persona {
    display: none;
  }

  .seat-hud .seat-bottom {
    margin-top: 1px;
    gap: 4px;
  }

  .seat-hud .seat-count {
    font-size: 9px;
  }

  .seat-hud .seat-count b {
    font-size: 13px;
  }

  #seat-1.active .seat-hud::after,
  #seat-2.active .seat-hud::after {
    top: -8px;
    right: 6px;
    padding: 0 6px;
    font-size: 8px;
    letter-spacing: 0.5px;
  }

  /* 对话入口：40px 点击目标，放在立绘下缘、HUD 上方 */
  .cat-log {
    bottom: 34%;
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .cat-wrap.cat-left .cat-log {
    left: 2px;
  }

  .cat-wrap.cat-right .cat-log {
    right: 2px;
  }

  .cat-log-badge {
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    font-size: 9px;
    line-height: 13px;
  }

  /* ------------------------------------------------------------ 中央提示 / 出牌区 */
  /* 中央控制台改成「整块舞台 + 绝对定位子项」：短屏上把提示信息压到顶部一条 */
  .center-console {
    inset: 0;
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    transform: none;
    display: block;
    z-index: 3;
  }

  .center-console > * {
    position: absolute;
    left: 50%;
    right: auto;
    translate: -50% 0;
  }

  .center-console .turn-hint {
    top: 2px;
    min-height: 16px;
    font-size: 11px;
    gap: 5px;
  }

  .center-console .turn-hint.you {
    font-size: 12.5px;
  }

  .center-console .thinking-strip {
    top: 22px;
    padding: 2px 10px;
    font-size: 10.5px;
  }

  .center-console .bottom-row {
    top: 44px;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 9px;
  }

  .center-console .bottom-label {
    font-size: 9.5px;
    letter-spacing: 1px;
    padding: 0;
  }

  .center-console .bottom-cards {
    gap: 3px;
  }

  .center-console .bottom-cards .card.mini {
    margin-left: 0;
  }

  .center-banner {
    top: 2px;
    min-height: 20px;
    padding: 2px 12px;
    font-size: 13px;
    letter-spacing: 1px;
  }

  /* 事件横幅出现时压住「轮到谁」，避免两行字叠在一起 */
  .center-console:has(.center-banner.show) .turn-hint {
    opacity: 0;
  }

  /* 注意：手牌区是覆盖在牌桌底部（absolute）的，所以可用牌桌高度 = 100% - --dock-h */
  .trick-2 {
    left: 33%;
    top: calc((100% - var(--dock-h)) * 0.46);
  }

  .trick-1 {
    left: 67%;
    top: calc((100% - var(--dock-h)) * 0.46);
  }

  .trick-0 {
    left: 50%;
    top: calc(100% - var(--dock-h) - 24px);
  }

  /* 小牌面（28×40 / 47×66）：中间大花色会挤到角标，短屏只留角标更好读 */
  .card.mini .c-pip {
    display: none;
  }

  .card.mini .c-corner b {
    font-size: 12px;
  }

  .card.mini .c-corner i {
    font-size: 8px;
  }

  .hand .card .c-pip {
    display: none;
  }

  /* 小牌面只保留左上角标：上下两个角标挤在 47×66 上会糊成一团 */
  .hand .card .c-corner.bottom,
  .card.mini .c-corner.bottom {
    display: none;
  }

  .trick-zone .card.mini {
    margin-left: -10px;
  }

  .trick-label {
    top: -13px;
    padding: 0 6px;
    font-size: 8.5px;
    letter-spacing: 0.5px;
  }

  .pass-tag {
    padding: 3px 9px;
    font-size: 10px;
    letter-spacing: 1px;
  }

  .bubble {
    max-width: 160px;
    padding: 4px 10px;
    font-size: 11.5px;
    letter-spacing: 0.5px;
  }

  .bubble.pos-2 {
    top: calc(var(--cat-top) + var(--cat-h) * 0.4);
  }

  .bubble.pos-1 {
    top: calc(var(--cat-top) + var(--cat-h) * 0.4);
  }

  .bubble.pos-0 {
    bottom: calc(var(--dock-h) + 4px);
  }

  .chat-bubble {
    max-width: 180px;
    padding: 4px 9px;
    font-size: 10.5px;
  }

  .chat-bubble.pos-2,
  .chat-bubble.pos-1 {
    top: calc(var(--cat-top) + var(--cat-h) * 0.58);
  }

  .chat-bubble.pos-0 {
    bottom: calc(var(--dock-h) + 10px);
  }

  /* 待机「牌桌已就绪」 */
  .idle-console {
    top: 50%;
    gap: 6px;
    padding: 10px 22px 9px;
    border-radius: 16px;
  }

  .idle-title {
    font-size: 17px;
    letter-spacing: 3px;
  }

  .idle-sub {
    font-size: 11px;
    letter-spacing: 0;
  }

  #btn-start {
    padding: 0 28px;
    height: 40px;
    font-size: 14px;
    letter-spacing: 2px;
    border-radius: 10px;
  }

  .idle-meta {
    font-size: 10px;
    letter-spacing: 0;
  }

  /* ------------------------------------------------------------ 手牌区 */
  .hand-area {
    padding: 2px calc(8px + var(--safe-r)) calc(4px + var(--safe-b)) calc(8px + var(--safe-l));
  }

  .hand-topline {
    min-height: 20px;
    gap: 8px;
    overflow: hidden;
  }

  #seat-0 {
    padding: 1px 8px 1px 4px;
    gap: 6px;
  }

  #seat-0 .me-avatar {
    width: 20px;
    height: 20px;
    font-size: 9px;
  }

  #seat-0 .me-role,
  #seat-0 .me-score,
  #seat-0 .me-count {
    font-size: 10px;
  }

  .hand-head {
    font-size: 10px;
    gap: 6px;
  }

  /* 张数已经在「你」信息条上，横屏不再重复一行标题，省下的宽度给「已选 N 张」 */
  .hand-title {
    display: none;
  }

  .hand-head .selected-hint {
    font-size: 10px;
    margin-left: 0;
  }

  .hand {
    min-height: calc(var(--card-h) + 12px);
    padding: 12px 2px 0;
  }

  .hand .card {
    border-radius: 7px;
  }

  .hand .card .c-corner b {
    font-size: 15px;
  }

  .hand .card .c-corner i {
    font-size: 10px;
  }

  .hand .card .c-pip {
    font-size: 17px;
    right: 4px;
  }

  .hand .card.joker .joker-char {
    font-size: 24px;
  }

  .hand .card.joker .c-corner b {
    font-size: 14px;
  }

  .hand .card.joker .joker-crown {
    width: 20px;
    height: 11px;
    top: 8px;
  }

  .hand .card.joker .joker-sub {
    display: none;
  }

  /* 触屏没有真正的 hover：别让点过的牌“粘”在抬起态 */
  .hand .card:hover:not(.selected) {
    transform: translateY(0);
  }

  .hand .card.selected {
    transform: translateY(-14px);
  }

  /* ------------------------------------------------------------ 操作条 */
  .controls {
    min-height: 40px;
    margin-top: 2px;
    gap: 8px;
    flex-wrap: nowrap;
  }

  .controls-group {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .controls .btn,
  .controls .btn.big,
  .controls .btn.ghost {
    height: 40px;
    min-height: 40px;
    padding: 0 16px;
    font-size: 14px;
    letter-spacing: 0;
    border-radius: 10px;
  }

  .controls .btn.ghost {
    padding: 0 12px;
    font-size: 13px;
  }

  .bid-label {
    font-size: 12px;
    margin-right: 0;
  }

  .controls-note {
    display: none;
  }

  /* ------------------------------------------------------------ 抽屉 / 观战 / 浮层 */
  .rail-drawer {
    top: 4px;
    right: calc(4px + var(--safe-r));
    bottom: 4px;
    width: min(300px, 44vw);
    gap: 6px;
  }

  .rail-head {
    font-size: 10px;
    letter-spacing: 1px;
  }

  .rail-drawer .thought-panel {
    max-height: 34%;
  }

  .rail-drawer .thought-body {
    font-size: 11px;
    padding: 6px 9px 8px;
  }

  .rail-drawer .log-body {
    min-height: 60px;
    padding: 6px 8px 9px;
  }

  .rail-drawer .log-item {
    font-size: 11px;
    padding: 4px 7px;
  }

  .rail-drawer .panel-head,
  .rail-drawer .log-head {
    padding: 5px 9px;
    font-size: 11px;
  }

  .transcript-drawer {
    top: 4px;
    right: calc(4px + var(--safe-r));
    bottom: 4px;
    width: min(400px, 52vw);
  }

  .transcript-head {
    padding: 5px 8px;
    gap: 6px;
  }

  .transcript-avatar {
    width: 24px;
    height: 24px;
    font-size: 9.5px;
  }

  .transcript-name {
    font-size: 11.5px;
  }

  .transcript-sub {
    font-size: 9.5px;
    max-width: 150px;
  }

  .transcript-tab {
    padding: 2px 7px;
    font-size: 10.5px;
    border-radius: 6px;
  }

  .transcript-close {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .transcript-body {
    padding: 6px 8px 10px;
    font-size: 11px;
    gap: 6px;
  }

  .transcript-msg {
    padding: 5px 7px;
  }

  .transcript-pre {
    font-size: 10.5px;
    max-height: 180px;
  }

  .transcript-foot {
    padding: 4px 9px 5px;
    font-size: 9.5px;
  }

  #spectate-panel {
    top: 4px;
    bottom: auto;
    max-height: 46%;
    width: min(620px, 60%);
  }

  #spectate-panel .spectate-head {
    padding: 3px 8px;
    font-size: 9.5px;
    gap: 6px;
  }

  .spectate-rows {
    gap: 3px;
    padding: 4px;
  }

  .sp-row {
    padding: 3px 6px;
    gap: 6px;
  }

  .sp-meta {
    width: 96px;
    gap: 4px;
  }

  .sp-name {
    font-size: 11px;
  }

  .sp-role,
  .sp-count {
    font-size: 9.5px;
  }

  .sp-cards .card.mini {
    margin-left: -12px;
  }

  #table-stage.transcript-open #spectate-panel {
    left: calc(50% - min(180px, 19vw));
    width: min(620px, calc(100% - min(400px, 52vw) - 24px));
  }

  /* 浮层：短屏上允许滚动，别把内容裁在视口外；同时避开刘海 / 底部横条 */
  .overlay {
    padding: calc(6px + var(--safe-b)) calc(6px + var(--safe-r)) 6px calc(6px + var(--safe-l));
    align-items: flex-start;
    overflow-y: auto;
  }

  /* 轻提示别被底部手势条压住，也别挡住点击 */
  .toast {
    bottom: calc(14px + var(--safe-b));
    padding: 7px 16px;
    font-size: 12.5px;
    pointer-events: none;
  }

  .settlement {
    width: min(94vw, 560px);
    max-height: calc(100dvh - 12px);
    margin: auto;
    padding: 10px 18px;
    border-radius: 16px;
    overflow-y: auto;
  }

  .settlement-badge {
    padding: 2px 8px;
    font-size: 10px;
    letter-spacing: 2px;
  }

  .settlement h2 {
    margin: 4px 0 8px;
    font-size: 19px;
    letter-spacing: 1px;
  }

  .settlement-grid {
    gap: 3px 18px;
    margin-bottom: 6px;
  }

  .settle-key,
  .settle-val {
    font-size: 11px;
  }

  .settlement-victory {
    margin-bottom: 8px;
    padding: 6px 8px;
    gap: 4px;
    border-radius: 10px;
  }

  .settle-victory-title {
    font-size: 10px;
  }

  .settle-victory-row {
    padding: 3px 6px;
  }

  .settle-victory-who,
  .settle-victory-text {
    font-size: 11px;
  }

  .settlement-actions {
    gap: 8px;
  }

  .settlement-actions .btn {
    min-width: 96px;
    height: 40px;
    min-height: 40px;
    padding: 0 14px;
    font-size: 13px;
  }

  .review-modal {
    max-height: calc(100dvh - 12px);
    margin: auto;
    border-radius: 16px;
  }

  .review-head {
    padding: 8px 12px;
  }

  .review-head h3 {
    font-size: 14px;
    letter-spacing: 0.5px;
  }

  .review-body {
    padding: 8px 10px 12px;
    gap: 5px;
  }

  .review-row {
    padding: 5px 8px;
  }

  .review-text {
    font-size: 11.5px;
  }

  .review-reason {
    font-size: 11px;
  }

  .help-modal {
    width: min(94vw, 620px);
    max-height: calc(100dvh - 12px);
    margin: auto;
    padding: 12px 16px;
    border-radius: 16px;
    overflow-y: auto;
  }

  .help-modal h3 {
    margin: 0 0 6px;
    font-size: 15px;
  }

  .help-list {
    margin: 0 0 10px;
    font-size: 11px;
    line-height: 1.7;
  }

  .persona-cards {
    gap: 6px;
    margin-bottom: 8px;
  }

  .persona-card {
    padding: 6px;
  }

  .persona-avatar {
    width: 40px;
    height: 52px;
  }

  .login-card {
    max-height: calc(100dvh - 12px);
    margin: auto;
    overflow-y: auto;
    padding: 14px 18px;
  }

  .settings-modal {
    max-height: calc(100dvh - 12px);
    margin: auto;
  }

  .settings-body {
    padding: 8px 12px 12px;
    gap: 5px;
  }

  .setting-row {
    padding: 5px 9px;
    font-size: 12px;
  }
}

/* 更窄的横屏（≤ 720px 宽，如 640×360 / 667×375）：再省一点顶栏空间 */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 720px) {
  .brand-name {
    display: none;
  }

  .topbar .stat-game,
  #stat-game {
    display: none;
  }

  .topbar {
    gap: 5px;
  }
}

/* ==========================================================================
   触屏基础卫生（所有手机/平板，不限横屏）
   - 点击别触发 300ms 延迟 / 双击缩放
   - 长按别弹「复制 / 保存图片」菜单
   - 触屏没有真 hover：别让悬停抬起效果粘在手指点过的牌上
   ========================================================================== */
@media (pointer: coarse) {
  .btn,
  .icon-btn,
  .rail-btn,
  .cat-log,
  .rail-close,
  .transcript-close,
  .transcript-tab,
  .card,
  .setting-row input,
  .setting-row select {
    touch-action: manipulation;
  }

  .card,
  .btn,
  .icon-btn,
  .seat-hud {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  .hand .card:hover:not(.selected) {
    transform: translateY(0);
  }

  .btn:hover:not(:disabled),
  .icon-btn:hover {
    transform: none;
  }
}
