/* 扑克牌拖拉机移动端沉浸式唯美绿毛呢风格 */
:root {
  color-scheme: light;
  --card-width: 48px;
  --card-height: 68px;
  --card-overlap: 20px;
  --card-advance: 28px;
  --felt-green: #36976c;
  --felt-dark: #1d704c;
  --gold-accent: #ffd166;
  --gold-border: #f39c12;
  --red-suit: #e63946;
  --black-suit: #1d3557;
  --card-bg: #fdfaf1;
  --card-shadow: rgba(0, 0, 0, 0.4);
  --glass-bg: rgba(19, 82, 56, 0.58);
  --glass-border: rgba(255, 255, 255, 0.22);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--felt-dark);
  color: #fff;
}

/* 游戏全屏容器 */
.game-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  background: radial-gradient(circle at center, var(--felt-green) 0%, var(--felt-dark) 100%);
}

/* 顶部状态条 */
.top-nav {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 50;
}

.room-info-pill, .scoreboard-pill, .actions-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-tag, .rank-tag, .trump-tag {
  font-size: 13px;
  background: rgba(255, 255, 255, 0.12);
  padding: 3px 8px;
  border-radius: 12px;
}

.trump-tag b {
  color: var(--gold-accent);
}

.last-trick-btn {
  margin-left: 2px;
  padding: 3px 8px;
  font-size: 11px;
  white-space: nowrap;
}

.score-item {
  font-size: 13px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.score-val {
  font-weight: bold;
  color: var(--gold-accent);
  font-size: 16px;
  margin-left: 4px;
}

.score-target {
  font-size: 11px;
  opacity: 0.6;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid var(--glass-border);
  color: #fff;
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.icon-btn.active {
  background: #2a9d8f;
  border-color: #52b788;
}

/* 牌桌中央主战场 */
.table-felt {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* 4方位玩家信息 Pod */
.player-pod {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 8px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 20;
}

.avatar-ring {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
}

.avatar-face {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, #457b9d, #1d3557);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  border: 2px solid #fff;
}

.speaking-glow {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid #06d6a0;
  opacity: 0;
  animation: pulseSpeaking 1.2s infinite;
}

.speaking-glow.active {
  opacity: 1;
}

@keyframes pulseSpeaking {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 0.3; }
  100% { transform: scale(1); opacity: 0.8; }
}

.banker-crown {
  position: absolute;
  top: -10px;
  left: 8px;
  font-size: 16px;
  display: none;
}

.player-meta {
  display: flex;
  flex-direction: column;
}

.player-name {
  font-size: 12px;
  font-weight: 500;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-counter {
  font-size: 11px;
  color: #a8dadc;
}

/* 北方对家 (正上方顶格居中) */
.pod-north {
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
}

/* 东方玩家 (靠右靠上，避开出牌区) */
.pod-east {
  right: 8px;
  top: 14%;
}

/* 西方玩家 (靠左靠上，避开出牌区) */
.pod-west {
  left: 8px;
  top: 14%;
}

/* 南方自己（居左侧靠下） */
.pod-south {
  bottom: 8px;
  left: 10px;
}

/* 舞台中央提示与出牌展示 */
.center-stage {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* 核心优化：提示条固定在正中央，清晰醒目，且远离北家头像与出牌 */
.stage-info-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 58, 39, 0.9);
  padding: 6px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: bold;
  color: var(--gold-accent);
  border: 1.5px solid rgba(255, 209, 102, 0.7);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7);
  z-index: 12;
  text-align: center;
  max-width: min(86vw, 720px);
  white-space: normal;
  pointer-events: auto;
}

.trump-call-display {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 11;
  pointer-events: none;
}

/* 按叫牌人所在方位显示：对家在上、下家在右、上家在左、自己在下 */
.trump-call-display.pos-north {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}
.trump-call-display.pos-south {
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
}
.trump-call-display.pos-east {
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
}
.trump-call-display.pos-west {
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
}

.trump-call-cards {
  display: flex;
  justify-content: center;
}

.called-card {
  width: 42px;
  height: 59px;
  margin-left: -14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffd166;
  font-size: 26px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .18) 0 24%, transparent 24% 50%, rgba(255, 255, 255, .18) 50% 74%, transparent 74%),
    linear-gradient(145deg, #256d4c, #124631);
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 5px;
  box-shadow: 0 3px 9px rgba(0, 0, 0, .3);
}

.called-card:first-child { margin-left: 0; }

  .trump-call-label {
    padding: 3px 8px;
  border-radius: 12px;
  background: rgba(10, 58, 39, .9);
  border: 1px solid rgba(255, 209, 102, .55);
  color: #ffd166;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* 出牌摆放槽 (环绕正中央提示条，前后左右间距充足，绝不互相遮挡) */
.trick-area {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  z-index: 15;
}

.trick-north { top: 12px; }
.trick-east { right: 18px; top: 50%; transform: translateY(-50%); }
.trick-west { left: 18px; top: 50%; transform: translateY(-50%); }
.trick-south { bottom: 8px; }

/* 底部操作区与手牌区 */
.player-deck-container {
  height: auto;
  max-height: min(50dvh, 380px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(to top, rgba(8, 48, 32, 0.68) 0%, rgba(8, 48, 32, 0.24) 75%, transparent 100%);
  z-index: 40;
}

.action-dock {
  height: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 4px 10px 2px 10px;
  position: relative;
  z-index: 10;
}

.action-pill {
  padding: 7px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.btn-primary {
  background: linear-gradient(135deg, #e76f51, #e63946);
  color: #fff;
}

.btn-secondary {
  background: #2a9d8f;
  color: #fff;
}

.lobby-fullscreen-button {
  width: 100%;
  margin-top: 10px;
  padding: 10px 16px;
}

.btn-accent {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: #fff;
  box-shadow: 0 0 10px rgba(243, 156, 18, 0.5);
}

.btn-warning {
  background: #e76f51;
  color: #fff;
}

.btn-dim {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.btn-info {
  background: linear-gradient(135deg, #3a86ff, #0077b6);
  color: #fff;
  box-shadow: 0 2px 6px rgba(58, 134, 255, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: #fff;
  box-shadow: 0 2px 8px rgba(46, 204, 113, 0.4);
}

.btn-success:disabled {
  background: #555;
  color: #888;
  box-shadow: none;
  cursor: not-allowed;
}

/* 手牌横向滚动与扇形层叠 */
.hand-scroll-wrapper {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  padding: 27px 10px 8px;
  display: block;
  scrollbar-width: none;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
.hand-scroll-wrapper::-webkit-scrollbar {
  display: none;
}

.cards-fan-layout {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 3px;
  height: auto;
  width: 100%;
  padding: 0 2px;
}

.hand-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  width: 100%;
  position: relative;
}

/* 含选中牌的整排抬到上层：既让被选中的牌露出来，又不会盖住同排右侧邻牌 */
.hand-row.has-selected {
  z-index: 30;
}

.hand-row-fixed {
  flex-wrap: nowrap;
  overflow: visible;
}

/* 扑克单张卡片微观物理质感 */
.poker-card {
  width: var(--card-width);
  height: var(--card-height);
  background-color: var(--card-bg) !important;
  background: var(--card-bg);
  border-radius: 5px;
  box-shadow: -2px 2px 5px var(--card-shadow);
  position: relative;
  margin-left: calc(var(--card-overlap) * -1);
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  color: var(--black-suit);
  flex-shrink: 0;
  border: 1px solid #d9d0bb;
}

.poker-card:first-child {
  margin-left: 0;
}

.hand-row .poker-card:first-child {
  margin-left: 0;
}

/* 副牌按花色分组：每个新花色的第一张牌前留出明显间隔 */
.hand-row .poker-card.suit-break {
  margin-left: 7px !important;
}

.poker-card.selected {
  /* 只抬起并描金边：不再提升层级，避免遮住右侧邻牌的角标 */
  transform: translateY(-24px) !important;
  box-shadow: 0 6px 15px rgba(255, 215, 0, 0.75);
  border: 2px solid var(--gold-border);
  outline: 1px solid rgba(255, 209, 102, 0.9);
  outline-offset: -3px;
}

.poker-card.red {
  color: var(--red-suit);
}

.poker-card.trump-card {
  border-top: 3px solid var(--gold-border);
}

/* 牌面元素 */
.card-corner-top {
  position: absolute;
  top: 2px;
  left: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 0;
}

.corner-rank {
  font-size: 18px;
  font-weight: 800;
  font-family: Arial, Helvetica, sans-serif;
}

.corner-suit {
  font-size: 15.2px;
}

.card-center-suit {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  opacity: 0.9;
}

.card-joker-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  line-height: 1.1;
}

/* 弹窗蒙层 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.lobby-card {
  width: 90%;
  max-width: 380px;
  background: rgba(18, 48, 33, 0.95);
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 18px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

.lobby-badge {
  display: inline-block;
  background: rgba(255, 215, 0, 0.15);
  color: var(--gold-accent);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  margin-bottom: 10px;
}

.game-title {
  font-size: 24px;
  margin-bottom: 4px;
  color: #fff;
}

.game-sub {
  font-size: 12px;
  color: #a8dadc;
  margin-bottom: 20px;
}

.input-group {
  text-align: left;
  margin-bottom: 14px;
}

.input-group label {
  display: block;
  font-size: 12px;
  color: #ddd;
  margin-bottom: 4px;
}

.input-group input {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  padding: 0 12px;
  font-size: 15px;
  outline: none;
}

.input-group input:focus {
  border-color: var(--gold-accent);
}

.btn-primary {
  width: 100%;
  height: 44px;
  border-radius: 22px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  cursor: pointer;
}

.mobile-tips {
  margin-top: 14px;
  font-size: 11px;
  color: #8da99a;
  line-height: 1.4;
  text-align: left;
}

.login-error {
  min-height: 18px;
  margin-top: 8px;
  color: #ff8a80;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

/* 聊天抽屉 */
.chat-drawer {
  position: fixed;
  right: -320px;
  top: 0;
  width: 300px;
  height: 100%;
  background: rgba(13, 37, 24, 0.95);
  backdrop-filter: blur(12px);
  border-left: 1px solid var(--glass-border);
  z-index: 80;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
}

.chat-drawer.open {
  right: 0;
}

.chat-header {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--glass-border);
  font-weight: bold;
}

.close-x {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.chat-history {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-bubble {
  background: rgba(255, 255, 255, 0.1);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  max-width: 85%;
}

.chat-bubble b {
  color: var(--gold-accent);
  font-size: 11px;
}

.chat-system {
  font-size: 11px;
  color: #8da99a;
  text-align: center;
}

.quick-phrases {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
}

.phrase-tag {
  background: rgba(255, 255, 255, 0.15);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  cursor: pointer;
}

/* 快捷表情 / 垃圾话 */
.phrase-group-label {
  width: 100%;
  font-size: 10px;
  opacity: 0.65;
  margin: 4px 2px 0;
  text-align: left;
}
.phrase-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}
.phrase-chip {
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #eaf6ef;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.phrase-chip.emoji-chip {
  font-size: 18px;
  padding: 2px 9px;
  line-height: 1.2;
}
.phrase-chip:active { transform: scale(0.94); }
.chat-emoji { font-size: 26px; line-height: 1.2; }

.chat-input-row {
  display: flex;
  padding: 8px;
  gap: 6px;
  border-top: 1px solid var(--glass-border);
}

.chat-input-row input {
  flex: 1;
  height: 36px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  color: #fff;
  padding: 0 12px;
  font-size: 13px;
  outline: none;
}

.btn-send {
  background: #2a9d8f;
  border: none;
  color: #fff;
  border-radius: 18px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 13px;
}

/* 结算弹窗底牌展示 */
.bottom-cards-reveal {
  margin-top: 14px;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px;
  border-radius: 10px;
}

.reveal-title {
  font-size: 12px;
  margin-bottom: 6px;
  color: #a8dadc;
}

.reveal-cards-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.reveal-cards-row .poker-card {
  margin-left: 0;
  width: 32px;
  height: 48px;
}
.reveal-cards-row .corner-rank { font-size: 15px; }
.reveal-cards-row .corner-suit { font-size: 12px; }
.reveal-cards-row .card-center-suit { font-size: 16px; }

/* 观战模式：隐藏手牌与操作区，整屏看牌 */
body.spectating .player-deck-container { display: none; }

/* 观战面板：选择视角 + 查看该玩家手牌 */
.spectator-panel {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px 8px 10px;
  background: linear-gradient(to top, rgba(8, 48, 32, 0.85) 0%, rgba(8, 48, 32, 0.3) 80%, transparent 100%);
  z-index: 40;
}
body.spectating .spectator-panel { display: flex; }

.spectator-seats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.spectator-seat-btn {
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.38);
  color: #e8f5ee;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.spectator-seat-btn.active {
  background: var(--gold-accent);
  border-color: var(--gold-accent);
  color: #123024;
  font-weight: 700;
}

.spectator-hand {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 64px;
  overflow-x: auto;
  padding: 2px 2px 0 2px;
}
.spectator-hand .poker-card {
  width: 42px;
  height: 60px;
  margin-left: -16px;
  border-radius: 4px;
  flex: 0 0 auto;
}
.spectator-hand .poker-card:first-child { margin-left: 0; }

.spectator-empty {
  font-size: 12px;
  color: #a8c7b8;
  padding: 18px 8px;
}

.spectator-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 209, 102, 0.16);
  border: 1px solid rgba(255, 209, 102, 0.5);
  color: var(--gold-accent);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

/* 设置弹窗样式：标题固定 + 内容滚动 + 房间按钮常驻底部 */
.settings-card {
  max-width: 360px;
  max-height: min(86dvh, 680px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
  /* 竖屏默认：单栏排列 */
  display: flex;
  flex-direction: column;
  gap: 0;
}
.settings-col { display: flex; flex-direction: column; min-width: 0; }
.setting-hint { display: block; font-size: 11px; opacity: 0.6; }
.settings-tip { font-size: 11px; color: #8da99a; margin-top: 8px; text-align: left; line-height: 1.35; }
.settings-save-btn { margin-top: 12px; }

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.setting-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.setting-item-label {
  text-align: left;
  font-size: 14px;
}

/* 全局提示条：出牌被拒/操作反馈，一眼可见 */
.game-toast {
  position: fixed;
  left: 50%;
  top: calc(42px + env(safe-area-inset-top));
  transform: translateX(-50%) translateY(-12px);
  max-width: min(88vw, 520px);
  padding: 8px 16px;
  border-radius: 18px;
  background: rgba(230, 57, 70, 0.95);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 300;
  text-align: center;
}
.game-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.game-toast.info { background: rgba(42, 157, 143, 0.95); }
.game-toast.warn { background: rgba(233, 145, 42, 0.96); }

/* 出牌按钮"未选牌"状态：仍然可点（点了会提示原因），只是变暗 */
.action-pill.btn-inactive {
  filter: grayscale(0.55) brightness(0.8);
  opacity: 0.75;
}

/* 房间操作放在设置弹窗最上方，醒目好点 */
.settings-room-actions-top {
  margin: 0 0 12px 0;
  padding: 0 0 10px 0;
  border-top: none;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.settings-room-actions button {
  touch-action: manipulation;
}

.settings-room-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, .12);
}

.settings-room-actions button {
  padding: 9px 10px;
  border: none;
  border-radius: 18px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn-danger {
  background: linear-gradient(135deg, #e63946, #b31217);
}

.level-tag {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.12);
  padding: 3px 8px;
  border-radius: 12px;
  color: #ffe6a7;
  white-space: nowrap;
}

.finish-level-result {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 209, 102, 0.35);
  text-align: left;
}

.finish-level-result .level-line {
  font-size: 13px;
  line-height: 1.7;
  color: #e8f5ee;
}

.finish-level-result .level-line.strong {
  color: #ffd166;
  font-weight: 700;
}


.last-trick-card {
  width: min(94vw, 780px);
  max-height: min(88dvh, 720px);
  overflow-y: auto;
}

.last-trick-players {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.last-trick-seat {
  min-height: 108px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.last-trick-seat.winner {
  border-color: var(--gold-accent);
  background: rgba(255, 209, 102, 0.12);
}

.last-trick-seat-name {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.last-trick-seat-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 52px;
  align-items: center;
}

.last-trick-seat-cards .poker-card {
  width: 35px;
  height: 50px;
  margin-left: 0;
}

.last-trick-seat-cards .corner-rank { font-size: 13px; }
.last-trick-seat-cards .corner-suit { font-size: 10px; }

.last-trick-empty {
  color: #a8dadc;
  font-size: 12px;
}

.last-trick-summary {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffd166;
  font-size: 13px;
  text-align: center;
}

/* 开关组件 */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #555;
  transition: .3s;
  border-radius: 24px;
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
input:checked + .toggle-slider {
  background-color: #2ecc71;
}
input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* 4副牌卡面背景皮肤网格选择器 */
.setting-section-title {
  font-size: 13px;
  font-weight: bold;
  color: var(--gold-accent);
  text-align: left;
  margin-top: 14px;
  margin-bottom: 8px;
}

.skin-selector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.skin-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.skin-card.active {
  border-color: var(--gold-accent);
  box-shadow: 0 0 10px rgba(255, 209, 102, 0.4);
  background: rgba(255, 215, 0, 0.1);
}

.skin-preview {
  height: 70px;
  border-radius: 6px;
  margin-bottom: 6px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
}

.skin-preview-default {
  background: #fdfdfd;
  color: #333;
  font-weight: bold;
  border: 1px solid #ccc;
}

.skin-name {
  font-size: 11px;
  font-weight: 500;
}

.skin-status {
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e8f5ee;
  font-size: 12px;
  text-align: left;
}

.skin-status.loading {
  color: #ffd166;
  border-color: rgba(255, 209, 102, 0.55);
}

/* 泳池比基尼写真背景卡牌样式 - 智能透叠不遮挡数字花色，超清写真全透无灰蒙 */
.poker-card.skin-bikini {
  background-color: #ffffff !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border: 1px solid rgba(255, 255, 255, 0.75) !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4) !important;
  position: relative;
  overflow: hidden;
}

/* 仅在左上角数字区域提供微弱渐变保护，模特主体 100% 纯净透亮，无灰蒙遮挡 */
.poker-card.skin-bikini::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0) 32%, rgba(255,255,255,0) 72%, rgba(0,0,0,0.16) 100%);
  pointer-events: none;
}

.poker-card.skin-bikini .card-corner-top {
  z-index: 2;
  text-shadow: 0 0 3px #fff, 0 0 5px #fff;
  font-weight: 800;
}

.poker-card.skin-bikini .card-image.failed + .card-corner-top,
.poker-card.skin-bikini .card-corner-top {
  z-index: 2;
}

.poker-card.skin-bikini .card-center-suit {
  display: none !important; /* 彻底去除卡牌中央的大花色图标，模特写真完全清爽无遮挡 */
}

.poker-card.skin-bikini .card-joker-text {
  display: none !important; /* 彻底去除王牌中央的 BLACK JOKER / RED JOKER 遮挡字样 */
}

/* ==========================================================================
   移动端与响应式适配：支持横竖屏无缝切换、防遮挡、智能排版
   ========================================================================== */

/* 1. 手机竖屏模式优化 (Portrait) */
@media (orientation: portrait) {
  /* 竖屏设置弹窗：跟随竖屏布局（单栏 + 可滚动） */
  .settings-card {
    width: 92%;
    max-width: 420px;
    max-height: 88dvh;
    padding: 14px 16px;
  }
  .settings-body { flex-direction: column; overflow-y: auto; }
  .settings-save-btn { margin-top: 14px; }
  .top-nav {
    height: auto;
    min-height: calc(40px + env(safe-area-inset-top));
    flex-wrap: wrap;
    gap: 6px;
    padding-top: max(2px, env(safe-area-inset-top));
  }
  .player-deck-container {
    height: auto;
    max-height: min(52dvh, 430px);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .action-dock {
    min-height: 40px;
    max-height: 74px;
    height: auto;
    flex-wrap: wrap;
    overflow-y: auto;
    gap: 8px;
    padding: 2px 8px;
  }
  .action-pill {
    padding: 6px 14px;
    font-size: 11px;
  }
  .cards-fan-layout {
    --card-width: 42px;
    --card-height: 60px;
    --card-overlap: 16px;
    --card-advance: 26px;
    height: auto;
  }
  .poker-card {
    width: var(--card-width);
    height: var(--card-height);
    margin-left: calc(var(--card-overlap) * -1);
  }
  .center-stage {
    height: 200px;
    width: 94%;
  }
  .stage-info-badge {
    max-width: 88vw;
    line-height: 1.25;
  }
  .trick-area .poker-card {
    width: 44px;
    height: 64px;
    margin-left: -26px;
  }
  .pod-west {
    top: 15%;
    left: 6px;
  }
  .pod-east {
    top: 15%;
    right: 6px;
  }
}

/* 2. 手机横屏模式优化 (Landscape & 短屏支持) */
@media (orientation: landscape) and (max-height: 540px), (max-height: 480px) {
  .game-container {
    height: 100vh;
    height: 100dvh;
  }
  .top-nav {
    height: 34px;
    min-height: 34px;
    padding: 2px 8px;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
  .room-tag, .rank-tag, .trump-tag {
    font-size: 11px;
    padding: 2px 6px;
  }
  .score-item {
    font-size: 11px;
    padding: 2px 8px;
  }
  .score-val {
    font-size: 13px;
  }
  .icon-btn {
    padding: 3px 8px;
    font-size: 11px;
    gap: 2px;
  }

  /* 手机横屏头像集中到顶部状态带，避免遮挡中央和两侧出牌。 */
  .pod-north {
    top: 4px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    padding: 2px 6px;
  }
  .pod-west {
    left: 6px;
    top: 32%;
    right: auto;
    transform: translateY(-50%);
    padding: 2px 6px;
  }
  .pod-east {
    right: 6px;
    top: 32%;
    transform: translateY(-50%);
    padding: 2px 6px;
  }
  /* 自己(南家)：固定到左下角，正好在首行手牌上方，不再挡中间的牌 */
  .pod-south {
    bottom: 4px;
    left: 8px;
    right: auto;
    top: auto;
    transform: none;
    padding: 2px 6px;
  }
  .avatar-ring {
    width: 30px;
    height: 30px;
  }
  .avatar-face {
    font-size: 11px;
  }
  .player-name {
    max-width: 60px;
    font-size: 11px;
  }
  .card-counter {
    font-size: 10px;
  }

  /* 舞台铺满整张牌桌：中间只留系统提示，各家出牌贴着自己头像 */
  .center-stage {
    top: 0;
    left: 0;
    transform: none;
    width: 100%;
    height: 100%;
    display: block;
  }
  .stage-info-badge {
    top: 54%;
    padding: 4px 14px;
    font-size: 11px;
  }
  .trump-call-display.pos-north { top: 40px; }
  .trump-call-display.pos-south { bottom: 8px; }
  .trump-call-display.pos-east { right: 46px; }
  .trump-call-display.pos-west { left: 46px; }

  /* 北家(对家)：出牌贴在其头像右边 */
  .trick-north { top: 6px; left: 50%; transform: translateX(76px); }
  /* 东家：出牌贴在自己头像正下方 */
  .trick-east { top: 32%; right: 8px; transform: translateY(30px); }
  /* 上家(西家)：出牌移到其头像右边（原来在头像下方，容易和我方出牌挤在一起） */
  .trick-west { top: 32%; left: 122px; transform: translateY(-50%); }
  /* 自己(南家)：出牌放到"重选"按钮左边，并再往右/往下挪，避免贴近上家 */
  .trick-south { bottom: -22px; left: calc(50% - 72px); transform: translateX(-100%); z-index: 45; }
  /* 允许出牌区画到操作栏那一行（否则往下移会被牌桌裁掉） */
  .table-felt { overflow: visible; }

  .trick-area .poker-card {
    width: 38px;
    height: 54px;
    margin-left: -23px;
    border-radius: 4px;
  }
  /* 关键：单张/首张出牌不再被负外边距推到屏幕外（西家会被裁掉） */
  .trick-area .poker-card:first-child { margin-left: 0; }
.trick-area .corner-rank { font-size: 15px; }
  .trick-area .corner-suit { font-size: 12.4px; }

  /* 底部操作区与手牌区高度压缩，腾出视野，绝对不遮挡牌桌 */
  .player-deck-container {
    height: auto;
    max-height: min(58dvh, 240px);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .action-dock {
    height: 32px;
    padding: 2px 8px;
    gap: 8px;
  }
  .action-pill {
    padding: 4px 14px;
    font-size: 11px;
    border-radius: 14px;
  }
  /* 手机横屏：设置弹窗更紧凑，重新开始/退出房间始终可见 */
  .settings-card {
    max-height: 94dvh;
    padding: 12px 14px;
  }
  .settings-header { margin-bottom: 8px; padding-bottom: 6px; }
  .setting-item-row { padding: 6px 0; }
  /* 全局提示条：出牌被拒/操作反馈，一眼可见 */
.game-toast {
  position: fixed;
  left: 50%;
  top: calc(42px + env(safe-area-inset-top));
  transform: translateX(-50%) translateY(-12px);
  max-width: min(88vw, 520px);
  padding: 8px 16px;
  border-radius: 18px;
  background: rgba(230, 57, 70, 0.95);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 300;
  text-align: center;
}
.game-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.game-toast.info { background: rgba(42, 157, 143, 0.95); }
.game-toast.warn { background: rgba(233, 145, 42, 0.96); }

/* 出牌按钮"未选牌"状态：仍然可点（点了会提示原因），只是变暗 */
.action-pill.btn-inactive {
  filter: grayscale(0.55) brightness(0.8);
  opacity: 0.75;
}

/* 房间操作放在设置弹窗最上方，醒目好点 */
.settings-room-actions-top {
  margin: 0 0 12px 0;
  padding: 0 0 10px 0;
  border-top: none;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.settings-room-actions button {
  touch-action: manipulation;
}

.settings-room-actions { margin-top: 8px; padding-top: 8px; }
  .settings-room-actions button { padding: 8px 8px; font-size: 11px; }
  .spectator-badge { font-size: 10px; padding: 1px 6px; }
  .spectator-panel { padding: 4px 8px 6px 8px; }
  .spectator-hand { min-height: 58px; }
  .spectator-hand .poker-card { width: 38px; height: 54px; margin-left: -14px; }
  .spectator-seat-btn { padding: 2px 8px; font-size: 10px; }
  .hand-scroll-wrapper {
    min-height: 0;
    overflow: visible;
    padding: 30px 8px 4px 8px;
  }
  .cards-fan-layout {
    --card-width: 38px;
    --card-height: 54px;
    --card-overlap: 8px;
    --card-advance: 30px;
    height: auto;
    padding: 0 2px;
  }
  .poker-card {
    width: var(--card-width);
    height: var(--card-height);
    margin-left: calc(var(--card-overlap) * -1);
    border-radius: 4px;
  }
  .corner-rank { font-size: 15.2px; }
  .corner-suit { font-size: 12.4px; }
  .poker-card.selected {
    transform: translateY(-14px) !important;
  }
  .card-image {
    transform: translateZ(0);
  }
}
/* ============================================================
   设置弹窗排版重做（放在文件末尾，优先级最高）
   目标：手机横屏一屏看全所有功能；竖屏跟随竖直布局
   ============================================================ */

/* —— 手机横屏（短屏）：两栏紧凑排版，全部功能一屏可见 —— */
@media (orientation: landscape) and (max-height: 560px) {
  .settings-card {
    width: min(96vw, 780px);
    max-width: 780px;
    max-height: 97dvh;
    padding: 8px 12px 10px 12px;
  }
  .settings-header { margin-bottom: 6px; padding-bottom: 4px; }
  .settings-header h2 { font-size: 15px !important; }
  .settings-room-actions-top { margin: 0 0 6px 0; padding: 0 0 6px 0; }
  .settings-room-actions button { padding: 5px 8px; font-size: 11px; }

  /* 两栏：左=开关+卡面风格，右=保存+观战席+提示 */
  .settings-body { flex-direction: row; gap: 14px; overflow: hidden; }
  .settings-col-main { flex: 1.15 1 0; }
  .settings-col-side { flex: 1 1 0; }

  .setting-item-row { padding: 4px 0; }
  .setting-item-label { font-size: 12px; }
  .setting-hint { font-size: 10px; }
  .setting-section-title { margin: 6px 0 4px 0; font-size: 12px; }
  .skin-selector-grid { gap: 6px; }
  .skin-card { padding: 4px; }
  .skin-preview { height: 40px; margin-bottom: 3px; font-size: 10px; }
  .skin-name { font-size: 10px; }
  .skin-status { margin-top: 5px; padding: 4px 8px; font-size: 11px; }
  .settings-save-btn { margin-top: 2px; padding: 6px 10px; font-size: 12px; }
  .settings-tip { margin-top: 6px; font-size: 10px; }
}

/* —— 手机竖屏：单栏 + 自适应高度（跟随竖屏布局） —— */
@media (orientation: portrait) {
  .settings-card {
    width: 92%;
    max-width: 420px;
    max-height: 88dvh;
    padding: 14px 16px;
  }
  .settings-body { flex-direction: column; overflow-y: auto; }
  .settings-col-main, .settings-col-side { flex: 0 0 auto; }
  .settings-save-btn { margin-top: 14px; }
}
/* ============================================================
   玩家头像旁的"说话气泡"（表情 / 语音垃圾话）
   谁发的就在谁的头像旁边弹出，让所有人第一时间知道是谁
   ============================================================ */
.player-pod .pod-speech {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  max-width: 190px;
  padding: 5px 11px;
  border-radius: 14px;
  background: #ffffff;
  color: #16324a;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  border: 2px solid #ffd166;
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
  z-index: 80;
}
.player-pod .pod-speech.show { opacity: 1; }
.player-pod .pod-speech.emoji { font-size: 26px; padding: 2px 12px; line-height: 1.1; }
/* 小尾巴指向头像 */
.player-pod .pod-speech::after {
  content: '';
  position: absolute;
  left: 14px;
  bottom: -8px;
  border-width: 8px 8px 0 8px;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent;
}
/* 对家（上方头像）：气泡改到头像下方，避免超出屏幕 */
.pod-north .pod-speech { bottom: auto; top: calc(100% + 8px); }
.pod-north .pod-speech::after {
  bottom: auto; top: -8px;
  border-width: 0 8px 8px 8px;
  border-color: transparent transparent #ffffff transparent;
}
/* 正在发言的头像高亮 */
.player-pod.speaking-now .avatar-ring {
  box-shadow: 0 0 0 3px rgba(255, 209, 102, .9), 0 0 14px rgba(255, 209, 102, .8);
  border-radius: 50%;
}