/* ====== 基础 ====== */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #eef4ef;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* 桌面底色：亮青绿（参考图风格） */
  background:
    radial-gradient(circle at 50% 50%, #1d8a76 0%, #0f5a4a 75%),
    #0a3f34;
}

button { font-family: inherit; }
.hidden { display: none !important; }

/* ====== 顶栏 ====== */
.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(180deg, #0e3a2a 0%, #0a2a1e 100%);
  border-bottom: 1px solid rgba(233, 196, 106, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  position: relative;
  z-index: 10;
}

.topbar .brand,
.topbar .ghost { flex: 0 0 auto; }
.topbar .stats { flex: 1 1 auto; min-width: 0; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #e9c46a;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  padding: 3px 10px;
  border: 1px solid rgba(233, 196, 106, 0.35);
  border-radius: 6px;
  background: rgba(233, 196, 106, 0.08);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  flex: 1;
}

.stats .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #b9d4c5;
  line-height: 1;
}

.stats .chip b { color: #f4f8f5; font-weight: 600; }
.stats .chip.gold { border-color: rgba(233, 196, 106, 0.45); color: #e9c46a; }
.stats .chip.gold b { color: #e9c46a; }
.stats .chip .scorebar { margin: 0; }

.ghost {
  background: linear-gradient(180deg, #1f5b41 0%, #144330 100%);
  border: 1px solid rgba(233, 196, 106, 0.5);
  color: #e9c46a;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.ghost:hover { background: linear-gradient(180deg, #2a6f51 0%, #1d5239 100%); transform: translateY(-1px); }
.ghost:active { transform: translateY(0); }

/* ====== 牌桌：深绿毛毡纹理 + 金棕边框 ====== */
.table {
  position: relative;
  flex: 1;
  margin: 8px 12px;
  border-radius: 24px;
  /* 外圈木框 */
  background:
    linear-gradient(135deg, #3a2615 0%, #5c3a1f 30%, #8a5a2e 50%, #5c3a1f 70%, #3a2615 100%);
  padding: 10px;
  box-shadow:
    inset 0 0 20px rgba(0, 0, 0, 0.6),
    0 8px 32px rgba(0, 0, 0, 0.6);
  min-height: 0;
  overflow: hidden;
}

.table::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 20px;
  border: 1px solid rgba(233, 196, 106, 0.4);
  pointer-events: none;
  z-index: 1;
}

/* 毛毡纹理桌面 */
.table > * {
  position: relative;
  z-index: 2;
}

.table::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 18px;
  z-index: 0;
  background:
    /* 毛毡微纤维 */
    repeating-linear-gradient(
      60deg,
      rgba(255, 255, 255, 0.015) 0px,
      rgba(255, 255, 255, 0.015) 1px,
      transparent 1px,
      transparent 3px
    ),
    repeating-linear-gradient(
      -60deg,
      rgba(0, 0, 0, 0.025) 0px,
      rgba(0, 0, 0, 0.025) 1px,
      transparent 1px,
      transparent 4px
    ),
    /* 径向亮青绿毛毡（参考图主色） */
    radial-gradient(circle at 50% 45%, #45c4a8 0%, #2fa08c 38%, #1d7a68 72%, #125846 100%);
  box-shadow:
    inset 0 0 80px rgba(0, 0, 0, 0.35),
    inset 0 0 4px rgba(233, 196, 106, 0.15);
  pointer-events: none;
}

/* ====== 玩家座位 ====== */
.seat {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border-radius: 30px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 140px;
  backdrop-filter: blur(4px);
  transition: box-shadow 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
  z-index: 5;
}

.seat.top { top: 10px; left: 50%; transform: translateX(-50%); flex-direction: row-reverse; padding: 5px 5px 5px 12px; }
.seat.left { left: 10px; top: 46%; transform: translateY(-50%); }
.seat.right { right: 10px; top: 46%; transform: translateY(-50%); flex-direction: row-reverse; padding: 5px 5px 5px 12px; }
.seat.bottom { bottom: 8px; left: 50%; transform: translateX(-50%); }

/* 金框圆角方形头像（参考图风格） */
.seat .avatar {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2a7a62 0%, #144a3a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 800;
  color: #ffe9b0;
  border: 2px solid #ffd98a;
  box-shadow: 0 0 0 1px #8a5a2e, 0 2px 8px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  position: relative;
}

.seat.bottom .avatar {
  background: linear-gradient(135deg, #3d9c6a 0%, #1d6a44 100%);
  color: #fff3d0;
}

.seat .avatar.crown::after {
  content: "👑";
  position: absolute;
  top: -4px;
  font-size: 14px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.seat .info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.seat .name { font-size: 13px; font-weight: 700; color: #f4f8f5; }
.seat .meta { font-size: 11px; color: #9fc0ae; }

.seat .tags { display: flex; gap: 4px; margin-top: 2px; flex-wrap: wrap; }

.tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #dfeae2;
}

.tag.dealer { background: linear-gradient(180deg, #e9c46a 0%, #c49a3a 100%); color: #231a05; font-weight: 700; }
.tag.you { background: rgba(120, 200, 255, 0.3); color: #cfe9ff; }

/* 当前行动方：金色光圈脉动 */
@keyframes seat-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(233, 196, 106, 0.8), 0 0 12px 4px rgba(233, 196, 106, 0.35); }
  50% { box-shadow: 0 0 0 3px rgba(233, 196, 106, 1), 0 0 20px 8px rgba(233, 196, 106, 0.55); }
}

.seat.active {
  border-color: #e9c46a;
  animation: seat-pulse 1.4s ease-in-out infinite;
  transform-origin: center;
}

.seat.bottom.active { transform: translateX(-50%) scale(1.03); }
.seat.top.active { transform: translateX(-50%) scale(1.03); }
.seat.left.active { transform: translateY(-50%) scale(1.03); }
.seat.right.active { transform: translateY(-50%) scale(1.03); }

/* 收墩：赢家光圈 */
@keyframes seat-win {
  0% { box-shadow: 0 0 0 0 rgba(233, 196, 106, 0.85), 0 0 20px 8px rgba(233, 196, 106, 0.55); }
  100% { box-shadow: 0 0 0 14px rgba(233, 196, 106, 0); }
}

.seat.won { animation: seat-win 0.8s ease-out; }

/* ====== 对手背面牌堆 ====== */
.back-stack {
  display: flex;
  align-items: center;
  position: relative;
}

.back {
  width: 20px;
  height: 28px;
  border-radius: 4px;
  margin-left: -12px;
  flex-shrink: 0;
  /* 真牌背：金色边框 + 菱形花纹 */
  background:
    linear-gradient(135deg, #1a4a35 0%, #2a6b4a 50%, #1a4a35 100%);
  border: 1px solid rgba(233, 196, 106, 0.6);
  box-shadow:
    inset 0 0 0 2px rgba(233, 196, 106, 0.2),
    inset 0 0 4px rgba(0, 0, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.5);
  position: relative;
}

.back::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 2px;
  /* 菱形花纹 */
  background:
    repeating-linear-gradient(
      45deg,
      rgba(233, 196, 106, 0.18) 0px,
      rgba(233, 196, 106, 0.18) 2px,
      transparent 2px,
      transparent 5px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(233, 196, 106, 0.18) 0px,
      rgba(233, 196, 106, 0.18) 2px,
      transparent 2px,
      transparent 5px
    );
}

.back::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: rgba(233, 196, 106, 0.4);
  border: 1px solid rgba(233, 196, 106, 0.7);
}

.back:first-child { margin-left: 0; }

.seat .count {
  font-size: 11px;
  color: #e9c46a;
  font-weight: 700;
  margin-left: 3px;
}

/* ====== 桌面出牌区 ====== */
.center {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.slot {
  --slot-scale: 0.74;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70px;
  min-width: 120px;
  gap: 0;
  z-index: 6;
}

.slot .card {
  transform: scale(var(--slot-scale));
  margin-left: -14px;
}

.slot .card:first-child { margin-left: 0; }

.slot.bottom { left: 50%; bottom: 108px; transform: translateX(-50%); }
.slot.top { left: 50%; top: 90px; transform: translateX(-50%); }
.slot.left { left: 140px; top: 46%; transform: translateY(-50%); }
.slot.right { right: 140px; top: 46%; transform: translateY(-50%); }

.center-note {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: 13px;
  color: #cfe0d6;
  max-width: 340px;
  line-height: 1.8;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(233, 196, 106, 0.25);
  backdrop-filter: blur(2px);
}

/* ====== 牌面：大角标 + 大花色（参考图风格） ====== */
.card {
  width: 64px;
  height: 92px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #d8d2c4;
  background: linear-gradient(160deg, #ffffff 0%, #fdfdf8 60%, #f2f2e8 100%);
  color: #161616;
  position: relative;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.8);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
  user-select: none;
}

/* 左上角：超大数字 + 小花色 */
.card .idx {
  position: absolute;
  left: 5px;
  top: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  z-index: 2;
}

.card .idx b {
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-size: 27px;
  font-weight: 900;
  letter-spacing: -1px;
}

.card .idx i { font-size: 17px; font-style: normal; margin-top: 1px; }

/* 中央偏右下：大花色图案 */
.card .big-suit {
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-size: 46px;
  line-height: 1;
  z-index: 1;
}

/* 王：竖排大小王 + JOKER */
.card.joker {
  background: linear-gradient(160deg, #fffdf3, #fdf1d8 70%, #f6e3bf);
  border-color: #d9b96f;
}

.card.joker.big { color: #c02f2f; }

.card.joker .joker-face {
  position: absolute;
  left: 7px;
  top: 6px;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 3px;
  writing-mode: vertical-rl;
}

.card.joker .joker-word {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-size: 9px;
  letter-spacing: 2px;
  font-weight: 700;
  opacity: 0.55;
  writing-mode: vertical-rl;
}

.card.red { color: #c8281e; }

.card.trump {
  border-color: #e9c46a;
  box-shadow: 0 0 0 2px rgba(233, 196, 106, 0.6), 0 3px 8px rgba(0, 0, 0, 0.45);
}

/* ====== 手牌：直线紧密排列（参考图风格） ====== */
/* 手牌右侧为倒计时留出空间 */
.hand {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 132px;
  padding: 16px 112px 14px 12px;
  background:
    linear-gradient(180deg, rgba(13, 74, 58, 0.95) 0%, rgba(9, 54, 42, 0.98) 100%);
  border-top: 1px solid rgba(233, 196, 106, 0.35);
  /* 允许选中的牌上浮、两侧让位时不被裁切 */
  overflow: visible;
  z-index: 10;
  user-select: none;
  -webkit-user-select: none;
}

.hand .card {
  flex: 0 0 auto;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s ease, translate 0.16s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.hand .card.clickable:hover {
  transform: translateY(-14px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.55);
}

/* 拖拽连续选牌：光标提示 + 关闭悬停浮起，避免拖动时牌面抖动 */
.hand.dragging { cursor: ew-resize; }
.hand.dragging .card { transition: none; }
.hand.dragging .card.clickable:not(.selected):hover { transform: none; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45); }

.hand .card.clickable:active { transform: translateY(-10px); }

.hand .card.selected {
  transform: translateY(-20px);
  box-shadow: 0 0 0 3px #e9c46a, 0 12px 24px rgba(0, 0, 0, 0.55) !important;
}

/* 有牌被选中时，其余牌压暗而不是变透明，避免眼花 */
.hand:has(.card.selected) .card:not(.selected) { filter: brightness(0.58) saturate(0.8); }

/* 未选中的牌向两侧让开，让出宽度等于叠放宽度，保证完全不被遮挡 */
.hand .card.push-left { translate: calc(-1 * var(--push, 16px)) 0; }
.hand .card.push-right { translate: var(--push, 16px) 0; }

.card:focus { outline: none; }
.card:focus-visible { outline: 2px solid #7fd1a5; outline-offset: 2px; }

/* ====== 出牌入场动画 ====== */
@keyframes card-enter {
  from { opacity: 0; transform: translateY(-16px) scale(var(--slot-scale, 0.74)) rotate(var(--enter-rot, 0deg)); }
  to { opacity: 1; transform: translateY(0) scale(var(--slot-scale, 0.74)) rotate(var(--enter-rot, 0deg)); }
}

.slot .card.enter { animation: card-enter 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* ====== 闲家得分进度条 ====== */
.scorebar {
  position: relative;
  display: inline-block;
  width: 80px;
  height: 6px;
  margin: 0 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  vertical-align: middle;
  overflow: hidden;
  flex-shrink: 0;
}

.scorebar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #7fd1a5, #e9c46a);
  transition: width 0.35s ease;
}

.scorebar em {
  position: absolute;
  top: 0;
  left: 31.25%;
  width: 1px;
  height: 100%;
  background: rgba(255, 255, 255, 0.5);
}

/* ====== 上一墩回顾 ====== */
.history {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  padding: 4px 10px 5px;
  background: linear-gradient(180deg, rgba(10, 42, 30, 0.92) 0%, rgba(7, 27, 18, 0.95) 100%);
  border-top: 1px solid rgba(233, 196, 106, 0.18);
}

@keyframes history-flash {
  from { background: rgba(233, 196, 106, 0.2); }
  to { background: linear-gradient(180deg, rgba(10, 42, 30, 0.92) 0%, rgba(7, 27, 18, 0.95) 100%); }
}

.history.flash { animation: history-flash 0.7s ease-out; }

.history-head { font-size: 12px; color: #b9d4c5; white-space: nowrap; }
.history-head b { color: #eef6ef; }
.history-head .gold { color: #e9c46a; }

.history-plays { display: flex; flex-wrap: wrap; gap: 16px; }
.history-play { display: flex; align-items: center; gap: 6px; opacity: 0.65; }
.history-play.win { opacity: 1; }
.history-play .who { font-size: 12px; color: #9fbdb0; }
.history-play.win .who { color: #e9c46a; font-weight: 700; }

.mini { display: flex; }
.mini .card {
  width: 28px;
  height: 40px;
  border-radius: 4px;
  margin-left: -7px;
  flex: 0 0 auto;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.mini .card:first-child { margin-left: 0; }
.mini .idx { left: 2px; top: 2px; }
.mini .idx b { font-size: 12px; letter-spacing: -0.5px; }
.mini .idx i { font-size: 8px; margin-top: 0; }
.mini .big-suit { font-size: 18px; right: 2px; bottom: 1px; }
.mini .joker .joker-face { font-size: 10px; left: 3px; top: 3px; letter-spacing: 1px; }
.mini .joker-word { display: none; }
/* ====== 亮主面板：五格横排（参考图风格） ====== */
.declare {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 12px;
  background: linear-gradient(180deg, rgba(13, 74, 58, 0.95) 0%, rgba(9, 54, 42, 0.98) 100%);
  border-top: 1px solid rgba(233, 196, 106, 0.35);
}

.declare-tip { font-size: 13px; color: #ffe9b0; font-weight: 600; }

.declare-bar {
  display: flex;
  align-items: stretch;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid #c49a3a;
  box-shadow: 0 0 0 1px rgba(255, 217, 138, 0.3), 0 4px 14px rgba(0, 0, 0, 0.5), inset 0 2px 8px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.declare-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 76px;
  padding: 10px 0;
  background: transparent;
  border: none;
  border-right: 1px solid rgba(233, 196, 106, 0.18);
  color: #cfe0d6;
  cursor: default;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}

.declare-cell:last-child { border-right: none; }
.declare-cell .sym { font-size: 26px; font-weight: 800; line-height: 1; }
.declare-cell .num { font-size: 13px; font-weight: 700; align-self: flex-end; padding-bottom: 2px; opacity: 0.85; }
.declare-cell.red .sym { color: #ff7a6a; }
.declare-cell:disabled { opacity: 0.38; }

/* 可亮的格子：金框可点 */
.declare-cell.avail { cursor: pointer; color: #ffe9b0; background: rgba(233, 196, 106, 0.1); }
.declare-cell.avail .sym { text-shadow: 0 0 10px rgba(255, 217, 138, 0.5); }
.declare-cell.avail:hover { background: rgba(233, 196, 106, 0.28); }
.declare-cell.avail.pair { box-shadow: inset 0 0 0 2px #ffd98a; }

/* 当前主花色：金色高亮 */
.declare-cell.current { background: linear-gradient(180deg, #ffd98a, #e9c46a); color: #3a2a05; }
.declare-cell.current.red .sym { color: #a02318; }

.declare-skip { font-size: 12px; padding: 5px 18px; }

/* ====== 操作栏 ====== */
.actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(14, 58, 42, 0.95) 0%, rgba(10, 42, 30, 0.98) 100%);
  border-top: 1px solid rgba(233, 196, 106, 0.3);
  min-height: 50px;
}

.hint { font-size: 13px; color: #b9d4c5; }
.hint.error { color: #ff9b8a; }
.actions { display: flex; gap: 8px; align-items: center; }

/* ====== 房间文字聊天 + 语音输入 ====== */
.chat-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
}

.chat-input {
  width: 190px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(233, 196, 106, 0.4);
  background: rgba(0, 0, 0, 0.35);
  color: #eef4ef;
  font-size: 13px;
  outline: none;
}

.chat-input:focus { border-color: rgba(233, 196, 106, 0.85); }
.chat-input::placeholder { color: #8fae9f; }

.chat-btn {
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.chat-btn.listening {
  color: #ffd7d0;
  border-color: #ff7a62;
  animation: chat-pulse 1s ease-in-out infinite;
}

@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 122, 98, 0.55); }
  50% { box-shadow: 0 0 0 6px rgba(255, 122, 98, 0); }
}

.chat-log {
  position: fixed;
  left: 12px;
  bottom: 196px;
  z-index: 26;
  width: min(340px, 46vw);
  max-height: 160px;
  overflow-y: auto;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(4, 26, 20, 0.82);
  border: 1px solid rgba(233, 196, 106, 0.28);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  font-size: 13px;
  line-height: 1.5;
  pointer-events: auto;
}

.chat-msg { color: #dfeee5; word-break: break-all; }
.chat-msg + .chat-msg { margin-top: 3px; }
.chat-msg b { color: #e9c46a; font-weight: 600; margin-right: 4px; }
.chat-msg.mine b { color: #7ee2a8; }

/* 房主踢人按钮 */
.kick-btn {
  margin-left: auto;
  padding: 2px 10px;
  font-size: 12px;
  color: #ffc3b8;
  border-color: rgba(255, 122, 98, 0.55);
}

.kick-btn:hover { background: rgba(255, 122, 98, 0.16); }

/* 选牌张数提示：扣底/出牌时实时显示 */
.select-count {
  flex: 0 0 auto;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #ffe9b0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(233, 196, 106, 0.5);
  white-space: nowrap;
}

.select-count.ok {
  color: #c9ffe0;
  background: rgba(18, 92, 62, 0.8);
  border-color: #7ee2a8;
}

.select-count.over {
  color: #ffc3b8;
  border-color: #ff9b8a;
}

.primary, .secondary {
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  font-weight: 600;
}

.primary {
  background: linear-gradient(180deg, #f5d27a 0%, #e9c46a 50%, #c49a3a 100%);
  color: #241a04;
  box-shadow: 0 2px 6px rgba(233, 196, 106, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  border-color: rgba(196, 154, 58, 0.8);
}

.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffd88a 0%, #f0cc72 50%, #cba03e 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(233, 196, 106, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.primary:active:not(:disabled) { transform: translateY(0); box-shadow: 0 1px 3px rgba(233, 196, 106, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.5); }

.primary:disabled {
  background: linear-gradient(180deg, #5a5340 0%, #3d3828 100%);
  color: #9a927c;
  cursor: not-allowed;
  box-shadow: none;
  border-color: rgba(0, 0, 0, 0.3);
}

.secondary {
  background: rgba(0, 0, 0, 0.25);
  color: #cfe0d6;
  border-color: rgba(233, 196, 106, 0.35);
}

.secondary:hover { background: rgba(0, 0, 0, 0.4); border-color: rgba(233, 196, 106, 0.55); }

/* ====== 烟花 canvas：在弹窗之下（z-index 15 < modal 20） ====== */
#fireworks {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 15;
  pointer-events: none;
  display: block;
}

/* ====== 结算弹窗 ====== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 14, 9, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  z-index: 20;
  animation: modal-fade-in 0.35s ease-out;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: min(520px, 90vw);
  max-width: 90vw;
  min-width: 0;
  margin: auto;
  background: linear-gradient(180deg, #13513a 0%, #0d3a29 100%);
  border: 1px solid rgba(233, 196, 106, 0.45);
  border-radius: 16px;
  padding: 26px 28px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(233, 196, 106, 0.15);
  position: relative;
  max-height: calc(100dvh - 24px);
  max-height: calc(100svh - 24px);
  overflow-x: hidden;
  overflow-y: auto;
  animation: modal-card-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes modal-card-pop {
  from { opacity: 0; transform: scale(0.75); }
  to { opacity: 1; transform: scale(1); }
}

/* 金辉扫过 */
.modal-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(233, 196, 106, 0.18) 50%, transparent 100%);
  transform: skewX(-20deg);
  pointer-events: none;
  animation: modal-gold-sweep 2.4s ease-in-out infinite;
}

@keyframes modal-gold-sweep {
  0%, 100% { left: -60%; }
  50% { left: 120%; }
}

/* 顶部金辉条 */
.modal-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #e9c46a, transparent);
  opacity: 0.7;
}

.modal-card h2 {
  margin: 0 0 20px;
  font-size: 20px;
  color: #e9c46a;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  position: relative;
  animation: title-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
}

@keyframes title-pop {
  from { opacity: 0; transform: translateY(-10px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

.modal-body { font-size: 14px; line-height: 1.9; color: #dcebe2; position: relative; }
.modal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
  position: sticky;
  bottom: 0;
  padding: 10px 0 2px;
  background: linear-gradient(180deg, rgba(13, 58, 41, 0) 0%, #0d3a29 45%);
}

/* ====== 升级结果卡（弹窗内突出显示） ====== */
.upgrade-banner {
  text-align: center;
  padding: 18px 16px 14px;
  margin: -2px 0 18px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(233, 196, 106, 0.18) 0%, rgba(233, 196, 106, 0.06) 100%),
    linear-gradient(180deg, #2a6b4d 0%, #1a4a34 100%);
  border: 1px solid rgba(233, 196, 106, 0.5);
  position: relative;
  overflow: hidden;
}

.upgrade-banner.success {
  border-color: #e9c46a;
  box-shadow: 0 0 24px rgba(233, 196, 106, 0.35), inset 0 0 16px rgba(233, 196, 106, 0.15);
}

.upgrade-banner.fail {
  border-color: rgba(160, 120, 90, 0.55);
  box-shadow: 0 0 18px rgba(160, 120, 90, 0.25);
}

.upgrade-banner .banner-label {
  font-size: 12px;
  color: #d4c089;
  letter-spacing: 2px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.upgrade-banner .banner-judge {
  font-size: 22px;
  font-weight: 800;
  color: #e9c46a;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), 0 0 20px rgba(233, 196, 106, 0.4);
  margin-bottom: 2px;
}

.upgrade-banner.fail .banner-judge { color: #b39a76; text-shadow: none; }

.upgrade-banner .banner-points {
  font-size: 14px;
  color: #cfe0d6;
}

.upgrade-banner .banner-steps {
  display: inline-block;
  font-size: 28px;
  font-weight: 900;
  color: #e9c46a;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  min-width: 38px;
}

/* 升级数字弹跳 */
@keyframes step-count-bounce {
  0% { transform: scale(0.2) translateY(10px); opacity: 0; }
  30% { transform: scale(1.35) translateY(-6px); opacity: 1; }
  60% { transform: scale(0.9) translateY(2px); }
  80% { transform: scale(1.1) translateY(-2px); }
  100% { transform: scale(1) translateY(0); }
}

.banner-steps {
  animation: step-count-bounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.banner-steps.steps-0 { animation-delay: 0.5s; }
.banner-steps.steps-1 { animation-delay: 0.4s; }
.banner-steps.steps-2 { animation-delay: 0.35s; }
.banner-steps.steps-3 { animation-delay: 0.3s; }

/* 升 0 级时（闲家上台不升级）用另一种动画 */
@keyframes zero-slide-in {
  from { transform: translateX(-20px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.banner-steps.steps-n { animation: zero-slide-in 0.45s ease-out 0.45s both; color: #b39a76; }

/* 赢方闪烁 */
@keyframes team-win-glow {
  0%, 100% { text-shadow: 0 0 8px rgba(233, 196, 106, 0.4); }
  50% { text-shadow: 0 0 18px rgba(233, 196, 106, 0.9), 0 0 32px rgba(233, 196, 106, 0.4); }
}

.win-team { animation: team-win-glow 1.6s ease-in-out 2 infinite; color: #e9c46a; }

.score-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.score-table td { padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); animation: modal-fade-in 0.5s ease-out both; word-break: break-word; }
.score-table td:first-child { width: 34%; }
.score-table td:nth-child(1) { animation-delay: 0.2s; }
.score-table td:nth-child(2) { animation-delay: 0.28s; }
.score-table td:nth-child(3) { animation-delay: 0.36s; }
.score-table td:nth-child(4) { animation-delay: 0.44s; }
.score-table td:last-child { text-align: right; color: #f4f8f5; font-weight: 600; }

/* ====== 音效按钮 ====== */
.sound-btn { font-size: 14px; padding: 6px 10px; line-height: 1; }
.sound-btn.muted { opacity: 0.55; text-shadow: none; }

/* ====== 多人大厅 ====== */
.lobby {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(3, 14, 9, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modal-fade-in 0.3s ease-out;
}

.lobby-card {
  width: min(440px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #13513a 0%, #0d3a29 100%);
  border: 1px solid rgba(233, 196, 106, 0.45);
  border-radius: 16px;
  padding: 22px 24px 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(233, 196, 106, 0.15);
}

.lobby-brand {
  font-size: 22px;
  font-weight: 800;
  color: #e9c46a;
  text-align: center;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.lobby-sub {
  text-align: center;
  color: #9fc0ae;
  font-size: 12px;
  margin: 4px 0 16px;
}

.lobby-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.lobby-input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(233, 196, 106, 0.35);
  color: #eef4ef;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.lobby-input:focus { border-color: #e9c46a; }

.lobby-title {
  color: #d4c089;
  font-size: 13px;
  font-weight: 700;
  margin-top: 14px;
}

.lobby-title .gold { color: #e9c46a; font-size: 16px; }

.lobby-players {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 2px;
}

.lobby-player {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
}

.lobby-player .seat-no { color: #9fc0ae; font-size: 11px; width: 46px; flex-shrink: 0; }
.lobby-player.empty b { color: #6f8f7e; font-weight: 400; }

.lobby-tip {
  font-size: 11px;
  color: #9fc0ae;
  margin-top: 10px;
}

.lobby-error {
  color: #ff9b8a;
  font-size: 12px;
  min-height: 16px;
  margin-top: 6px;
}

.lobby-divider {
  text-align: center;
  color: #6f8f7e;
  font-size: 12px;
  margin: 14px 0 10px;
}

.lobby-solo { width: 100%; }

@media (max-width: 768px) {
  .lobby-card { padding: 16px 14px 14px; border-radius: 12px; }
  .lobby-brand { font-size: 18px; }
  .lobby-row { flex-wrap: wrap; }
  .lobby-row .primary, .lobby-row .secondary, .lobby-row .ghost { flex: 1 1 auto; }
}

/* ====== 移动端适配（≤ 768px） ====== */
@media (max-width: 768px) {
  body { overflow-y: auto; }

  /* 顶栏紧凑：brand 缩短，chip 单行 3 个 */
  .topbar { padding: 6px 8px; gap: 6px; flex-wrap: wrap; }
  .brand { font-size: 13px; padding: 2px 6px; letter-spacing: 0.5px; order: 0; }
  .stats { flex: 1 0 100%; order: 2; gap: 4px; margin-top: 2px; }
  .stats .chip { font-size: 10.5px; padding: 2px 7px; }
  .stats .chip .scorebar { width: 48px; height: 4px; }
  .ghost { padding: 5px 10px; font-size: 12px; order: 1; }

  /* 牌桌：更小圆角 + 更窄 padding */
  .table { margin: 4px; border-radius: 14px; padding: 5px; min-height: 340px; }
  .table::before { inset: 3px; border-radius: 11px; }
  .table::after { inset: 5px; border-radius: 9px; }

  /* 玩家座位：紧凑头像 + 最小文字 */
  .seat { padding: 3px 8px 3px 3px; min-width: 0; gap: 5px; border-radius: 20px; }
  .seat.top { padding: 3px 3px 3px 8px; }
  .seat.right { padding: 3px 3px 3px 8px; }
  .seat .avatar { width: 28px; height: 28px; font-size: 13px; border-width: 1.5px; }
  .seat .avatar.crown::after { font-size: 11px; top: -2px; }
  .seat .name { font-size: 11px; }
  .seat .tags { display: none; }
  .seat .meta { font-size: 10px; }
  .seat .back { width: 12px; height: 17px; margin-left: 0; }
  .seat .back::before { inset: 2px; }
  .seat .back::after { width: 4px; height: 4px; }
  .seat .count { font-size: 11px; }

  /* 桌面出牌 slot：缩小 */
  .slot { --slot-scale: 0.44; min-height: 40px; min-width: 72px; }
  .slot .card { margin-left: -20px; }
  .slot.bottom { bottom: 72px; }
  .slot.top { top: 70px; }
  .slot.left { left: 84px; }
  .slot.right { right: 84px; }

  /* 中央提示更小 */
  .center-note { font-size: 11px; max-width: 240px; padding: 6px 10px; line-height: 1.6; }

  /* 上一墩回顾 */
  .history { padding: 3px 8px; gap: 3px 8px; font-size: 10px; flex-wrap: nowrap; overflow-x: auto; }
  .history-play .who { font-size: 10px; }
  .history-head { font-size: 10px; }
  .history-plays { gap: 4px; }
  .history .mini .card { width: 18px; height: 26px; margin-left: -5px; }
  .history .mini .idx { left: 2px; top: 2px; }
  .history .mini .idx b { font-size: 9px; }
  .history .mini .idx i { font-size: 6px; }
  .history .mini .big-suit { font-size: 11px; right: 1px; bottom: 0; }
  .history .mini .joker-face { font-size: 7px; left: 2px; top: 2px; letter-spacing: 0; }

  /* 亮主面板：五格等比缩小 */
  .declare { padding: 6px 8px 8px; gap: 6px; }
  .declare-tip { font-size: 11px; text-align: center; }
  .declare-bar { max-width: 100%; }
  .declare-cell { width: clamp(48px, 15vw, 64px); padding: 8px 0; gap: 2px; }
  .declare-cell .sym { font-size: 22px; }
  .declare-cell .num { font-size: 11px; }
  .declare-skip { font-size: 11px; padding: 4px 14px; }

  /* 行动栏 */
  .actionbar { padding: 6px 8px; min-height: 40px; gap: 6px; flex-wrap: wrap; }
  .hint { font-size: 11px; flex: 1 1 140px; min-width: 0; }
  .actions { flex-shrink: 0; margin-left: auto; }
  .select-count { font-size: 12px; padding: 3px 9px; }
  .chat-input { width: 104px; padding: 5px 8px; font-size: 12px; }
  .chat-btn { padding: 5px 8px; font-size: 12px; }
  .chat-log { width: min(300px, 72vw); bottom: 176px; max-height: 120px; font-size: 12px; }
  .primary, .secondary { padding: 7px 14px; font-size: 13px; border-radius: 10px; white-space: nowrap; }

  /* 倒计时：放在手牌右侧空白区 */
  .turn-timer { right: 10px; bottom: 30px; min-width: 54px; padding: 3px 8px; font-size: 16px; border-radius: 7px; }

  /* 手牌：大角标直线排列，保留选中上抬空间 */
  .hand { height: 102px; padding: 10px 86px 10px 8px; }
  .hand .card { width: 48px; height: 70px; border-radius: 6px; }
  .hand .card .idx { left: 4px; top: 4px; }
  .hand .card .idx b { font-size: 20px; }
  .hand .card .idx i { font-size: 13px; margin-top: 0; }
  .hand .card .big-suit { font-size: 34px; right: 3px; bottom: 2px; }
  .hand .card .joker-face { left: 5px; top: 5px; font-size: 16px; letter-spacing: 1px; }
  .hand .card .joker-word { display: none; }

  /* 弹窗：占满 92vw，内边距更紧凑 */
  .modal-card { width: 92vw; padding: 16px 18px 14px; border-radius: 12px; }
  .modal-card h2 { font-size: 17px; margin-bottom: 12px; }
  .modal-body { font-size: 13px; }
  .modal-actions { margin-top: 16px; gap: 8px; }
  /* 判定与得分已在顶部结果卡展示，小屏隐藏重复行，避免弹窗过高 */
  .score-table tr:nth-child(1),
  .score-table tr:nth-child(2) { display: none; }

  .upgrade-banner { padding: 12px 12px 10px; margin-bottom: 12px; border-radius: 10px; }
  .upgrade-banner .banner-label { font-size: 10px; }
  .upgrade-banner .banner-judge { font-size: 18px; }
  .upgrade-banner .banner-steps { font-size: 22px; }
  .score-table { font-size: 12px; }
  .score-table td { padding: 5px 0; }
}

/* 超窄屏幕 ≤ 480px */
@media (max-width: 480px) {
  .table { min-height: 280px; margin: 2px; }
  .seat { min-width: 0; padding: 2px 6px 2px 2px; }
  .seat.top, .seat.right { padding: 2px 2px 2px 6px; }
  .seat .avatar { width: 24px; height: 24px; font-size: 11px; }
  .seat .back { width: 12px; height: 17px; margin-left: -7px; }

  .slot { --slot-scale: 0.38; }
  .slot.bottom { bottom: 62px; }
  .slot.top { top: 60px; }
  .slot.left { left: 72px; }
  .slot.right { right: 72px; }
  .slot .card { margin-left: -18px; }

  .hand { height: 86px; padding: 10px 76px 8px 6px; }
  .hand .card { width: 42px; height: 60px; }
  .hand .card .idx { left: 3px; top: 3px; }
  .hand .card .idx b { font-size: 18px; }
  .hand .card .idx i { font-size: 11px; }
  .hand .card .big-suit { font-size: 30px; right: 2px; bottom: 1px; }
  .hand .card .joker-face { left: 4px; top: 4px; font-size: 14px; }

  .stats .chip { font-size: 9.5px; padding: 2px 6px; }
  .stats .chip .scorebar { width: 36px; }

  /* 结算弹窗：小屏压缩，确保内容与按钮完整可见 */
  .modal { padding: 8px; }
  .modal-card { padding: 14px 16px 10px; border-radius: 12px; }
  .modal-card h2 { font-size: 16px; margin-bottom: 10px; }
  .upgrade-banner { padding: 10px 10px 8px; margin-bottom: 10px; }
  .upgrade-banner .banner-judge { font-size: 18px; }
  .upgrade-banner .banner-steps { font-size: 20px; }
  .score-table { font-size: 11.5px; }
  .score-table td { padding: 4px 0; }
  .modal-actions { margin-top: 10px; }
}

/* 横屏小屏：压缩纵向空间，确保手牌始终完整可见 */
@media (max-height: 500px) and (orientation: landscape) {
  html, body { height: 100dvh; }

  /* 顶部仅预留系统状态栏高度（取安全区与实际状态栏的较大值，避免重复叠加） */
  .topbar {
    padding: max(16px, env(safe-area-inset-top, 0px)) calc(8px + env(safe-area-inset-right, 0px)) 3px calc(8px + env(safe-area-inset-left, 0px));
    gap: 5px;
    row-gap: 3px;
    justify-content: center;
  }
  .brand { display: none; }
  .stats { gap: 3px; font-size: 10px; justify-content: center; flex: 1 1 auto; }
  .stats .chip { padding: 2px 6px; }
  /* 操作按钮下移到牌桌上缘，给顶部信息让出空间 */
  .topbar-actions {
    position: absolute;
    top: calc(100% + 3px);
    right: calc(8px + env(safe-area-inset-right, 0px));
    z-index: 12;
    gap: 5px;
    padding: 3px 5px;
    border-radius: 8px;
    background: rgba(6, 32, 25, 0.72);
    border: 1px solid rgba(233, 196, 106, 0.3);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
  }
  .topbar .ghost { padding: 3px 7px; font-size: 11px; }

  .table { min-height: 0; margin: 2px 6px; border-radius: 14px; padding: 6px; }

  .hand { height: 78px; padding: 3px 78px 2px 8px; }
  .hand .card { width: 44px; height: 62px; border-radius: 5px; }
  .hand .card .idx { left: 3px; top: 3px; }
  .hand .card .idx b { font-size: 17px; }
  .hand .card .idx i { font-size: 11px; margin-top: 0; }
  .hand .card .big-suit { font-size: 28px; right: 2px; bottom: 1px; }
  .hand .card .joker-face { left: 4px; top: 4px; font-size: 15px; letter-spacing: 1px; }
  .hand .card .joker-word { display: none; }
  .hand .card.clickable:hover { transform: translateY(-6px); }
  .hand .card.clickable:active { transform: translateY(-4px); }
  .hand .card.selected { transform: translateY(-8px); }

  /* 其他三家：缩小信息条，避免遮挡出牌 */
  .seat { min-width: 0; gap: 4px; padding: 2px 6px 2px 2px; font-size: 10px; }
  .seat.top { top: 4px; padding: 2px 2px 2px 6px; }
  .seat.right { padding: 2px 2px 2px 6px; }
  .seat.left, .seat.right { top: 42%; }
  .seat .avatar { width: 22px; height: 22px; font-size: 10px; border-width: 1px; border-radius: 6px; }
  .seat .avatar.crown::after { font-size: 8px; top: -3px; }
  .seat .name { font-size: 10px; }
  .seat .meta { display: none; }
  .seat .back { width: 10px; height: 14px; margin-left: 0; }
  .seat .back::before { inset: 1.5px; }
  .seat .back::after { width: 3px; height: 3px; }
  .seat .count { font-size: 10px; }
  .seat .back-stack { margin-top: 0 !important; gap: 2px; }

  /* 上一墩：更紧凑，避免挤压当前出牌区域 */
  .history { padding: 2px 8px; gap: 2px 8px; flex-wrap: nowrap; overflow-x: auto; }
  .history-head { font-size: 10px; }
  .history-play .who { font-size: 10px; }
  .history-plays { gap: 4px; }
  .history .mini .card { width: 18px; height: 26px; margin-left: -5px; }
  .history .mini .idx { left: 2px; top: 2px; }
  .history .mini .idx b { font-size: 9px; }
  .history .mini .idx i { font-size: 6px; }
  .history .mini .big-suit { font-size: 11px; right: 1px; bottom: 0; }
  .history .mini .joker-face { font-size: 7px; left: 2px; top: 2px; letter-spacing: 0; }

  .slot { --slot-scale: 0.36; }
  .slot .card { margin-left: -18px; }
  .slot.bottom { bottom: 64px; }
  .slot.top { top: 34px; }
  .slot.left { left: 96px; }
  .slot.right { right: 96px; }

  .actionbar { padding: 3px 8px; gap: 6px; }
  .actionbar .hint { font-size: 11px; }
  .actionbar button { padding: 4px 8px; font-size: 12px; }
  .chat-log { bottom: 100px; max-height: 84px; width: min(280px, 46vw); }

  .turn-timer { right: 8px; bottom: 18px; min-width: 50px; padding: 3px 8px; font-size: 15px; border-radius: 6px; }

  /* 结算弹窗：横屏空间有限，整体压缩并允许内部滚动 */
  .modal { padding: 6px; }
  .modal-card {
    width: min(620px, 90vw);
    max-height: calc(100dvh - 12px);
    padding: 10px 14px 10px;
    border-radius: 12px;
  }
  .modal-card h2 { font-size: 16px; margin: 0 0 8px; }
  .modal-body { font-size: 12px; line-height: 1.5; }
  .upgrade-banner {
    padding: 8px 10px 6px;
    margin: 0 0 8px;
    border-radius: 8px;
  }
  .upgrade-banner .banner-label { font-size: 10px; }
  .upgrade-banner .banner-judge { font-size: 22px; }
  .upgrade-banner .banner-points { font-size: 12px; }
  .upgrade-banner .banner-steps { font-size: 20px; }
  .score-table { font-size: 12px; }
  .score-table td { padding: 3px 0; }
  .modal-actions { margin-top: 10px; gap: 8px; }
  .modal-actions .primary,
  .modal-actions .secondary { padding: 6px 18px; font-size: 13px; }
}

@media (max-width: 480px) and (max-height: 500px) and (orientation: landscape) {
  .hand { height: 68px; padding: 3px 68px 2px 8px; }
  .hand .card { width: 38px; height: 54px; }
  .hand .card .idx b { font-size: 15px; }
  .hand .card .big-suit { font-size: 24px; }
  .slot { --slot-scale: 0.32; }
}

/* 安全区域（iPhone 刘海屏） */
@supports (padding: max(0px)) {
  @media (max-width: 768px) {
    .hand { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    .topbar { padding-top: calc(6px + env(safe-area-inset-top)); padding-left: calc(8px + env(safe-area-inset-left)); padding-right: calc(8px + env(safe-area-inset-right)); }
  }
}

/* ====== 手机竖屏提示：引导横屏 ====== */
.rotate-hint {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 22, 16, 0.95);
  /* 不拦截点击，保证顶栏「横屏」按钮仍可操作 */
  pointer-events: none;
}

.rotate-card { pointer-events: auto; }

.rotate-card.shake { animation: rotate-shake 0.5s ease; }
@keyframes rotate-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

.rotate-card {
  text-align: center;
  padding: 26px 34px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(233, 196, 106, 0.35);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.rotate-icon {
  font-size: 46px;
  line-height: 1;
  animation: rotate-tip 2.2s ease-in-out infinite;
}

.rotate-card p {
  margin: 14px 0 18px;
  color: #e9c46a;
  font-size: 15px;
}

.rotate-card button {
  display: block;
  width: 100%;
  margin-top: 10px;
}

@keyframes rotate-tip {
  0%, 40% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(90deg); }
}

/* ====== 思考倒计时 / 暂停 ====== */
.turn-timer {
  position: fixed;
  right: 14px;
  bottom: 44px;
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 800;
  color: #ffe9b0;
  background: rgba(6, 32, 25, 0.74);
  border: 1px solid rgba(233, 196, 106, 0.7);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 0 8px rgba(233, 196, 106, 0.12);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.turn-timer.urgent {
  color: #ffd2cc;
  border-color: #ff6b5a;
  background: rgba(120, 20, 10, 0.45);
  animation: timer-pulse 0.9s ease-in-out infinite;
}

@keyframes timer-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 100, 80, 0.6); }
  50% { box-shadow: 0 0 0 4px rgba(255, 100, 80, 0); }
}

.pause-banner {
  position: fixed;
  left: 50%;
  top: 56px;
  transform: translateX(-50%);
  z-index: 31;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(20, 50, 40, 0.95);
  border: 1px solid rgba(233, 196, 106, 0.6);
  color: #ffe9b0;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  max-width: 90vw;
  text-align: center;
}

/* 非法操作提示浮层 */
.error-toast {
  position: fixed;
  left: 50%;
  top: 150px;
  transform: translateX(-50%) translateY(-8px);
  z-index: 32;
  padding: 10px 20px;
  border-radius: 10px;
  background: rgba(96, 20, 20, 0.96);
  border: 1px solid rgba(255, 140, 120, 0.85);
  color: #ffe4dc;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  max-width: 90vw;
  text-align: center;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.error-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 庄家查看底牌 */
.bottom-panel {
  position: fixed;
  inset: 0;
  z-index: 22;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}

.bottom-card {
  max-width: 92vw;
  padding: 12px 16px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(13, 74, 58, 0.98), rgba(8, 40, 30, 0.99));
  border: 2px solid #c49a3a;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.6);
}

.bottom-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #ffe9b0;
}

.bottom-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.bottom-cards .card { width: 48px; height: 68px; border-radius: 6px; }
.bottom-cards .idx { left: 4px; top: 3px; }
.bottom-cards .idx b { font-size: 20px; letter-spacing: -1px; }
.bottom-cards .idx i { font-size: 12px; }
.bottom-cards .big-suit { font-size: 32px; right: 3px; bottom: 1px; }
.bottom-cards .joker .joker-face { font-size: 14px; left: 5px; top: 4px; letter-spacing: 1px; }
.bottom-cards .joker-word { display: none; }

/* 暂停申请表决条 */
.pause-req {
  position: fixed;
  left: 50%;
  top: 100px;
  transform: translateX(-50%);
  z-index: 31;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(20, 50, 40, 0.97);
  border: 1px solid rgba(233, 196, 106, 0.7);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  max-width: 94vw;
  flex-wrap: wrap;
  justify-content: center;
}

.pause-req-text { font-size: 13px; color: #ffe9b0; }

.pause-req-btn {
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* ====== 发牌飞入动画 ====== */
@keyframes deal-in {
  from {
    opacity: 0;
    transform: translate(-90px, -120px) rotate(-25deg) scale(0.7);
  }
  60% { opacity: 1; }
  to {
    opacity: 1;
    transform: none;
  }
}

.hand .card.dealing {
  animation: deal-in 0.34s cubic-bezier(0.2, 0.8, 0.3, 1) backwards;
}

/* ====== 左侧功能菜单 ====== */
.menu-btn {
  padding: 5px 11px;
  font-size: 16px;
  line-height: 1;
  flex: 0 0 auto;
}

.menu-drawer {
  position: fixed;
  left: 10px;
  top: 56px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(8, 38, 29, 0.97);
  border: 1px solid rgba(233, 196, 106, 0.45);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  max-height: calc(100dvh - 70px);
  overflow-y: auto;
}

.menu-title {
  font-size: 12px;
  color: #9fc0ae;
  letter-spacing: 1px;
  padding: 0 2px 2px;
}

.menu-item {
  width: 138px;
  text-align: left;
  padding: 8px 12px;
  font-size: 13px;
}

/* ====== 桌布设置 ====== */
.theme-panel {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 16px;
}

.theme-card {
  width: min(360px, 92vw);
  max-height: 86dvh;
  overflow-y: auto;
  border-radius: 14px;
  padding: 16px;
  background: linear-gradient(180deg, #0f4634 0%, #0a2f22 100%);
  border: 1px solid rgba(233, 196, 106, 0.55);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65);
}

.theme-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: #ffe9b0;
  margin-bottom: 10px;
}

.theme-label {
  font-size: 12px;
  color: #9fc0ae;
  margin: 10px 0 6px;
}

.theme-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.theme-swatch {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
}

.theme-swatch.current {
  border-color: #e9c46a;
  box-shadow: 0 0 0 2px rgba(233, 196, 106, 0.5);
}

.theme-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.theme-row input[type="file"] {
  width: 100%;
  font-size: 12px;
  color: #cfe0d6;
}

/* ====== 自定义桌布生效：覆盖毛毡渐变 ====== */
.table.custom::after {
  background-image: var(--felt-image, none);
  background-color: var(--felt-color, #1d7a68);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* ====== 跟牌约束：非同花色不可选 ====== */
.hand .card.disabled {
  cursor: not-allowed;
  filter: brightness(0.42) grayscale(0.5);
}

.hand .card.disabled:hover { transform: none; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45); }

/* 刚入手的底牌标记 */
.hand .card.from-bottom {
  box-shadow: 0 0 0 2px rgba(120, 200, 255, 0.85), 0 3px 8px rgba(0, 0, 0, 0.45);
}

.hand .card .bottom-tag {
  position: absolute;
  right: 2px;
  top: 2px;
  z-index: 4;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  padding: 2px 3px;
  border-radius: 3px;
  background: #2f7fc4;
  color: #fff;
}

/* 扣底时中央展示刚入手的 8 张底牌 */
.bury-preview {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(6, 32, 25, 0.86);
  border: 1px solid rgba(120, 200, 255, 0.65);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  z-index: 9;
  max-width: 94vw;
  overflow-x: auto;
}

.bury-preview .bury-label {
  font-size: 12px;
  color: #bfe2ff;
  white-space: nowrap;
  margin-right: 4px;
}

.bury-preview .card {
  transform: scale(0.52);
  transform-origin: center;
  margin: 0 -12px;
}

/* ====== 思考倒计时改到页面正中央 ====== */
.turn-timer {
  left: 50%;
  right: auto;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  font-size: 30px;
  padding: 10px 22px;
  border-radius: 14px;
  background: rgba(6, 32, 25, 0.55);
  border-width: 2px;
  z-index: 17;
}

@media (max-height: 500px) and (orientation: landscape) {
  .turn-timer { font-size: 22px; padding: 6px 16px; }
  .menu-drawer { top: 46px; max-height: calc(100dvh - 56px); }
  .menu-item { padding: 6px 10px; }
}
