:root {
  /* 经典绿：自然沉稳 */
  --bg: #10241a;
  --bg2: #173528;
  --table: #2a6e4d;
  --table-dark: #1c4d35;
  --gold: #e8c877;
  --gold-light: #f5e3b0;
  --gold-dark: #c9a254;
  --red: #e0483e;
  --green: #3dcc73;
  --card-bg: #fffdf5;
  --card-bg2: #f4eeda;
  --text: #f5f2e8;
  --text-dim: #a8bfa8;
  --shadow: 0 8px 24px rgba(0,0,0,.4);
  --radius: 14px;
  --spacing: 12px;
}

/* ============ 主题皮肤（各主题独立配色，柔和协调） ============ */
/* 海洋蓝：清爽宁静 */
body[data-theme="ocean"] {
  --bg: #0f1c28;
  --bg2: #162b3c;
  --table: #34728a;
  --table-dark: #225068;
  --gold: #8fd4ef;
  --gold-light: #c2e6f7;
  --gold-dark: #5fb2d4;
  --text-dim: #a3b8c4;
}
/* 暖橙：温暖活力 */
body[data-theme="red"] {
  --bg: #20150e;
  --bg2: #332217;
  --table: #a8703e;
  --table-dark: #7a4e28;
  --gold: #f0c888;
  --gold-light: #f7e0b8;
  --gold-dark: #c99c5a;
  --text-dim: #c4b0a0;
}
/* 雾紫：优雅梦幻 */
body[data-theme="purple"] {
  --bg: #1a1526;
  --bg2: #292038;
  --table: #6a5488;
  --table-dark: #4a3a62;
  --gold: #cda8ef;
  --gold-light: #e0c8f7;
  --gold-dark: #a57ed0;
  --text-dim: #b4a8c4;
}

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

html, body {
  width: 100%; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(ellipse at top, #123522, var(--bg));
  color: var(--text);
  overflow: hidden;
  user-select: none;
}
/* 输入框需允许选择/复制文字，避免全局 user-select:none 影响输入体验 */
input, textarea { user-select: text; -webkit-user-select: text; }

.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; animation: screenIn .3s ease; }

/* 登录页 */
#login-screen { align-items: center; justify-content: center; }
.login-box {
  background: rgba(16,48,31,.92);
  border: 1px solid rgba(245,197,66,.3);
  border-radius: 20px;
  padding: 40px 36px;
  text-align: center;
  width: 90vw; max-width: 380px;
  box-shadow: var(--shadow);
  animation: floatUp .4s ease;
}
.logo { font-size: 34px; font-weight: 800; color: var(--gold); letter-spacing: 2px; text-shadow: 0 2px 12px rgba(245,197,66,.35); }
.subtitle { font-size: 13px; color: var(--text-dim); margin: 8px 0 24px; }
#nickname-input {
  width: 100%; padding: 14px 16px; font-size: 16px;
  border-radius: 12px; border: 1px solid #2a5a3a; background: #0c2415; color: var(--text);
  outline: none; margin-bottom: 16px; transition: border-color .2s, box-shadow .2s;
}
#nickname-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,197,66,.15); }
.tips { font-size: 12px; color: var(--text-dim); margin-top: 16px; }
#login-btn, #login-skip { width: 100%; padding: 14px; font-size: 16px; }

/* 通用按钮 */
button {
  cursor: pointer; border: none; border-radius: var(--radius); font-weight: 600;
  transition: transform .12s ease, filter .18s ease, box-shadow .18s ease, opacity .18s ease;
  position: relative; overflow: hidden;
}
button:active { transform: scale(.96); }
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.3); transform: none; }

.btn-primary { background: linear-gradient(180deg, #ff6b5e, #e0483e); color: #fff; box-shadow: 0 4px 12px rgba(224,72,62,.35); }
.btn-green { background: linear-gradient(180deg, #3ddc84, #27ae60); color: #fff; box-shadow: 0 4px 12px rgba(39,174,96,.35); }
.btn-blue { background: linear-gradient(180deg, #4aa8ff, #2f7de0); color: #fff; box-shadow: 0 4px 12px rgba(47,125,224,.35); }
.btn-gold { background: linear-gradient(180deg, #ffd86b, var(--gold-dark)); color: #4a3200; box-shadow: 0 4px 12px rgba(217,168,32,.35); }
.btn-purple { background: linear-gradient(180deg, #b58cff, #8b5cf6); color: #fff; box-shadow: 0 4px 12px rgba(139,92,246,.35); }
.btn-cyan { background: linear-gradient(180deg, #4ad9e0, #2aa8b8); color: #fff; box-shadow: 0 4px 12px rgba(42,168,184,.35); }
.btn-gray { background: #3a4a42; color: #cfe0d4; box-shadow: 0 4px 10px rgba(0,0,0,.25); }
.btn-big { width: 100%; padding: 18px; font-size: 20px; margin-bottom: 14px; border-radius: 16px; }
.btn-mid { padding: 12px 20px; font-size: 15px; }
.btn-red { background: var(--red); color: #fff; }

.btn-big:hover { transform: translateY(-2px); }
.btn-mid:hover { transform: translateY(-1px); }
.btn-big:active, .btn-mid:active { transform: translateY(0) scale(.97); }

/* 菜单页 */
#menu-screen { padding: 0; }
.menu-header {
  padding: 40px 24px 12px; display: flex; align-items: center; justify-content: space-between;
}
.menu-title { font-size: 30px; font-weight: 800; color: var(--gold); letter-spacing: 2px; text-shadow: 0 2px 12px rgba(245,197,66,.3); animation: titleGlow 2.8s ease-in-out infinite; }
@keyframes titleGlow {
  0%, 100% { text-shadow: 0 2px 12px rgba(245,197,66,.3); }
  50% { text-shadow: 0 2px 26px rgba(245,197,66,.62); }
}
.profile-chip {
  background: rgba(245,197,66,.15); padding: 10px 16px; border-radius: 20px;
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  border: 1px solid rgba(245,197,66,.2);
  cursor: pointer; transition: background .2s, border-color .2s;
}
.profile-chip:hover { background: rgba(245,197,66,.25); border-color: rgba(245,197,66,.4); }
.menu-body { padding: 20px 24px; max-width: 420px; margin: 0 auto; width: 100%; flex: 1; }
.menu-sub { text-align: center; font-size: 13px; color: var(--text-dim); margin: -6px 0 16px; }
/* 主界面加倍卡开关 */
.double-card-row { display: flex; justify-content: center; margin: -2px 0 4px; }
.double-card-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--gold); cursor: pointer;
  padding: 6px 14px; border-radius: 16px;
  background: rgba(245,197,66,.1); border: 1px solid rgba(245,197,66,.3);
}
.double-card-toggle input { accent-color: var(--gold-dark); width: 16px; height: 16px; cursor: pointer; }
.double-card-toggle b { color: var(--gold-light); }
.join-row { display: flex; gap: 10px; margin: 4px 0 16px; }
.join-row input {
  flex: 1; padding: 12px 14px; font-size: 16px; border-radius: 12px;
  border: 1px solid #2a5a3a; background: #0c2415; color: var(--text); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.join-row input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,197,66,.15); }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-grid .btn-mid { padding: 16px; font-size: 16px; }

/* 房间页 */
#room-screen { align-items: center; justify-content: center; padding: 16px; }
.room-panel {
  background: rgba(16,48,31,.92); border-radius: 20px; padding: 24px;
  width: 92vw; max-width: 520px; box-shadow: var(--shadow); border: 1px solid rgba(245,197,66,.25);
  animation: floatUp .35s ease;
}
.room-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 8px; }
.room-id { font-size: 20px; font-weight: 700; }
.room-id span { color: var(--gold); letter-spacing: 2px; }
.room-config { font-size: 12px; color: var(--text-dim); }
.seat-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.seat {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: #0c2415; border-radius: 14px; border: 1px solid #2a5a3a;
  transition: border-color .2s, background .2s;
}
.seat.empty { opacity: .55; border-style: dashed; }
.seat .avatar { font-size: 30px; }
.seat .s-name { flex: 1; font-size: 16px; font-weight: 600; }
.seat .s-badge { font-size: 12px; color: var(--text-dim); }
.room-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.room-tip { font-size: 12px; color: var(--text-dim); margin-top: 14px; text-align: center; }

/* 游戏桌 */
#game-screen {
  background:
    radial-gradient(ellipse at 50% 35%, #2e9160 0%, #1d6b3f 38%, #145030 68%, #0c3520 100%);
}
.table {
  position: relative; width: 100%; height: 100%;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255,255,255,.07) 0%, transparent 52%),
    radial-gradient(ellipse at 50% 120%, rgba(0,0,0,.35) 0%, transparent 60%),
    linear-gradient(160deg, var(--table), var(--table-dark));
  transition: background .3s ease;
}
/* 桌面纹理：细腻的同心圆装饰 */
.table::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, transparent 0%, transparent 46%, rgba(255,255,255,.04) 47%, transparent 49%),
    radial-gradient(ellipse at 50% 42%, transparent 0%, transparent 58%, rgba(255,255,255,.03) 59%, transparent 61%);
}
/* 桌面金色镶边 */
.table::after {
  content: '';
  position: absolute; inset: 10px; pointer-events: none;
  border: 1px solid rgba(245,197,66,.14);
  border-radius: 24px;
  box-shadow: inset 0 0 40px rgba(0,0,0,.25);
}

.player { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; z-index: 7; }
.player .avatar {
  font-size: 40px; width: 58px; height: 58px; border-radius: 50%;
  background: rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,.15); transition: border-color .25s, box-shadow .25s;
}
.player.turn-highlight .avatar { border-color: var(--gold); box-shadow: 0 0 14px rgba(245,197,66,.6); animation: pulse 1.2s infinite; }
.p-name { font-size: 14px; font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-cards { font-size: 12px; color: var(--text-dim); }
/* 状态与地主标签改为绝对定位：不占布局高度，保证左右玩家头像严格水平对齐 */
.p-status {
  position: absolute; bottom: -28px; left: 50%; transform: translateX(-50%);
  font-size: 12px; padding: 3px 10px; border-radius: 10px; background: rgba(0,0,0,.45);
  display: none; white-space: nowrap;
}
.p-status.show { display: block; animation: popIn .25s ease; }
.p-status.turn { background: var(--gold); color: #4a3200; font-weight: 700; }
.landlord-tag {
  position: absolute; top: -28px; left: 50%; transform: translateX(-50%);
  font-size: 11px; padding: 3px 10px; border-radius: 9px; background: linear-gradient(180deg, var(--gold-light), var(--gold-dark));
  color: #4a3200; font-weight: 800; display: none; box-shadow: 0 2px 8px rgba(217,168,32,.5);
  letter-spacing: 1px; white-space: nowrap; z-index: 2;
}
.landlord-tag.show { display: inline-block; animation: popIn .3s ease; }
/* 农民角色标签：灰色，区别于地主的金色 */
.landlord-tag.farmer {
  background: rgba(0,0,0,.55);
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,.15);
  box-shadow: none;
  font-weight: 600;
}
/* 地主玩家头像：金色光环 + 皇冠 */
.player.is-landlord .avatar,
.my-info.is-landlord .avatar {
  border-color: var(--gold) !important;
  box-shadow: 0 0 18px rgba(245,197,66,.65) !important;
  position: relative;
}
.player.is-landlord .avatar::after,
.my-info.is-landlord .avatar::after {
  content: '👑';
  position: absolute; top: -14px; right: -6px; font-size: 18px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
  animation: crownDrop .4s cubic-bezier(.34,1.56,.64,1);
}

.player-left { left: 18px; top: 6%; transform: translateY(-50%); }
.player-right { right: 18px; top: 6%; transform: translateY(-50%); }

/* 出牌区 */
.play-area {
  position: absolute; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center;
  max-width: 40%; min-height: 50px; z-index: 6;
}
#area-left { left: 92px; top: 19%; }
#area-right { right: 92px; top: 19%; }

/* 迷你牌基础样式（出牌区 / 底牌 / 我的出牌区共享） */
.mini-card {
  background: linear-gradient(180deg, var(--card-bg), var(--card-bg2));
  border-radius: 5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.play-area .mini-card { width: 36px; height: 50px; font-size: 16px; animation: dealIn .25s ease; }
.mini-card.red { color: var(--red); }
.mini-card.black { color: #222; }
.mini-card.joker { color: #b40000; }
.mini-card.joker-black { color: #222; }

/* 底牌区（顶部中央，与左右玩家对齐） */
.bottom-area {
  position: absolute; top: 6%; left: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 7;
}
.bottom-label {
  font-size: 12px; color: var(--gold-light); font-weight: 700; letter-spacing: 1px;
  padding: 3px 12px; border-radius: 10px;
  background: rgba(0,0,0,.45); border: 1px solid rgba(245,197,66,.35);
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .3s;
}
.bottom-label.show { opacity: 1; }
.bottom-cards {
  display: flex; gap: 8px; justify-content: center;
}
.bottom-cards .mini-card {
  width: 52px; height: 72px; font-size: 18px;
  border: 2px solid rgba(245,197,66,.5);
  box-shadow: 0 4px 14px rgba(0,0,0,.4), 0 0 14px rgba(245,197,66,.25);
}
/* 底牌翻开动画 */
.bottom-cards .mini-card.flip {
  animation: flipIn .5s cubic-bezier(.34,1.56,.64,1);
}
/* 牌背样式 */
.mini-card.card-back {
  background: repeating-linear-gradient(45deg, #2c5e3e 0 4px, #1f4a2f 4px 8px);
  border: 2px solid rgba(245,197,66,.4) !important;
  color: transparent !important;
  box-shadow: 0 3px 10px rgba(0,0,0,.35);
  position: relative;
}
.mini-card.card-back::after {
  content: '';
  position: absolute; inset: 4px; border-radius: 3px;
  border: 1px solid rgba(255,255,255,.15);
}

/* 中央信息 */
.center-info {
  position: absolute; top: 32%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none; z-index: 4;
}
.multiplier {
  font-size: 14px; font-weight: 700; color: var(--gold);
  background: rgba(0,0,0,.45); padding: 6px 16px; border-radius: 16px;
  border: 1px solid rgba(245,197,66,.25);
  transition: transform .2s; letter-spacing: 1px;
}
.multiplier.bump { animation: multiplierBump .4s cubic-bezier(.34,1.56,.64,1); }

/* 我的出牌区 */
.my-play {
  position: absolute; bottom: 292px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; min-height: 52px; max-width: 62%;
  z-index: 6;
}
.my-play .mini-card { width: 40px; height: 56px; font-size: 16px; animation: dealIn .25s ease; }

/* 操作按钮区（我的出牌区与手牌之间） */
.action-bar {
  position: absolute; bottom: 178px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 12; width: 92vw; max-width: 560px;
}
.actions { display: flex; gap: 14px; justify-content: center; align-items: center; }
.bid-actions { display: flex; gap: 12px; justify-content: center; align-items: center; }

/* 操作按钮样式 */
.btn-act {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 54px; min-width: 108px; padding: 0 22px;
  border-radius: 16px; font-size: 18px; font-weight: 700; letter-spacing: 2px;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, filter .2s ease;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
  cursor: pointer;
}
.btn-act .act-ico { font-size: 20px; }
.btn-act:hover { transform: translateY(-3px); filter: brightness(1.08); }
.btn-act:active { transform: translateY(0) scale(.95); }
.btn-hint { background: linear-gradient(180deg, #4a5a52, #35443c); color: #dce8de; }
.btn-pass { background: linear-gradient(180deg, #5a6a62, #425248); color: #e6efe8; }
.btn-play {
  background: linear-gradient(180deg, #ffd86b, #e8a820); color: #4a3200;
  min-width: 150px; font-size: 20px;
  box-shadow: 0 6px 18px rgba(232,168,32,.5);
}
.btn-bid { background: linear-gradient(180deg, #4aa8ff, #2f7de0); color: #fff; }

/* 常驻工具按钮（托管 + AI 速度，始终可见可点击） */
.bar-utils {
  display: flex; gap: 8px; justify-content: center; align-items: center;
}
.btn-util {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 34px; padding: 0 14px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  background: rgba(0,0,0,.35); color: var(--text-dim);
  border: 1px solid rgba(255,255,255,.12);
  transition: all .15s ease; cursor: pointer;
}
.btn-util:hover { background: rgba(255,255,255,.1); color: var(--text); }
.btn-util.active { background: rgba(245,197,66,.22); color: var(--gold); border-color: rgba(245,197,66,.45); }
.btn-util .act-ico { font-size: 15px; }
.btn-exit { color: #ff9a90; border-color: rgba(224,72,62,.35); }
.btn-exit:hover { background: rgba(224,72,62,.15); color: #ffb0a8; }

/* 底部面板 */
.bottom-panel { position: absolute; bottom: 0; left: 0; right: 0; padding: 10px 16px 14px; z-index: 10; }
.my-info { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.my-info .avatar {
  font-size: 26px; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,.15); transition: border-color .25s, box-shadow .25s;
}
.my-info .avatar.turn-glow { border-color: var(--gold); box-shadow: 0 0 14px rgba(245,197,66,.6); animation: pulse 1.2s infinite; }
.my-info .landlord-tag { display: none; }
.my-info .landlord-tag.show { display: inline-block; }

.hand {
  display: flex; gap: 2px; flex-wrap: nowrap; overflow-x: auto;
  padding: 32px 6px 12px; min-height: 140px;
}
/* 用 margin:auto 技巧实现"居中显示 + 溢出可滚动到两端"，修复窄屏左右牌被裁切 */
.hand::before { content: ''; margin: auto; }
.hand::after { content: ''; margin: auto; }
.card {
  width: 68px; height: 96px; flex-shrink: 0;
  background: linear-gradient(180deg, #ffffff, var(--card-bg2));
  border-radius: 9px; position: relative; font-weight: 700;
  box-shadow: 0 2px 4px rgba(0,0,0,.25), 0 6px 14px rgba(0,0,0,.3);
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .22s ease;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid rgba(0,0,0,.08);
  will-change: transform;
}
.card:hover { transform: translateY(-8px); box-shadow: 0 4px 8px rgba(0,0,0,.3), 0 12px 22px rgba(0,0,0,.35); }
.card .rank { font-size: 27px; line-height: 1; }
.card .suit { font-size: 24px; position: absolute; bottom: 7px; right: 8px; }
.card .suit-top { font-size: 15px; position: absolute; top: 6px; left: 8px; }
.card.red { color: var(--red); }
.card.black { color: #2b2b2b; }
.card.selected {
  transform: translateY(-24px) scale(1.05);
  box-shadow: 0 0 0 2px var(--gold), 0 10px 24px rgba(245,197,66,.55);
  border-color: var(--gold);
  animation: selectedGlow 1s ease infinite alternate;
}
/* 发牌动画：手牌依次飞入 */
.card.deal-in { animation: handDeal .35s ease backwards; }
@keyframes handDeal {
  from { opacity: 0; transform: translateY(36px) scale(.75); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.card.joker { color: #b40000; }
.card.joker .rank.joker-text { font-size: 18px; writing-mode: vertical-lr; letter-spacing: 1px; font-weight: 800; }
.card.joker-black { color: #2b2b2b; }
.card.joker-black .rank.joker-text { font-size: 18px; writing-mode: vertical-lr; letter-spacing: 1px; font-weight: 800; }

/* 弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.62); display: none;
  align-items: center; justify-content: center; z-index: 1000;
}
.modal.show { display: flex; }
.modal-content {
  background: linear-gradient(180deg, #16462c, #123522); border-radius: 20px; padding: 28px;
  width: 90vw; max-width: 440px; box-shadow: var(--shadow);
  border: 1px solid rgba(245,197,66,.3); text-align: center;
  animation: modalIn .3s cubic-bezier(.34,1.56,.64,1);
}
.modal-title { font-size: 22px; font-weight: 800; color: var(--gold); margin-bottom: 16px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; margin-top: 20px; }

/* 结算 */
.settle-result { font-size: 30px; font-weight: 800; margin-bottom: 8px; animation: popIn .4s ease; }
.settle-result.win { color: var(--gold); text-shadow: 0 2px 18px rgba(245,197,66,.6); animation: winCelebrate .8s cubic-bezier(.34,1.56,.64,1); }
.settle-result.lose { color: #a0a8a0; }
.settle-detail { font-size: 14px; color: var(--text-dim); margin-bottom: 16px; }
.settle-badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.badge-chip {
  padding: 4px 12px; font-size: 13px; font-weight: 700; border-radius: 16px;
  background: rgba(245,197,66,.15); border: 1px solid rgba(245,197,66,.35); color: var(--gold);
  animation: popIn .3s ease;
}
.settle-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: #0c2415; border-radius: 10px; margin-bottom: 6px;
  transition: background .2s;
}
.settle-row.is-landlord { background: rgba(245,197,66,.1); border: 1px solid rgba(245,197,66,.25); }
.settle-row .s-name { font-weight: 600; }
.settle-row .s-delta { font-weight: 700; }
.settle-row .s-delta.pos { color: var(--green); }
.settle-row .s-delta.neg { color: var(--red); }

/* 信息弹窗 */
.info-body { max-height: 60vh; overflow-y: auto; text-align: left; }
.rank-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: #0c2415; border-radius: 10px; margin-bottom: 6px;
  transition: background .2s;
}
.rank-row:hover { background: #10301f; }
.rank-row .r-rank { font-weight: 800; width: 36px; text-align: center; font-size: 18px; }
.rank-row .r-rank.top { color: var(--gold); }
.rank-row .r-name { flex: 1; font-weight: 600; }
.rank-row .r-score { color: var(--gold); font-weight: 700; }
.rank-row .r-stat { font-size: 12px; color: var(--text-dim); }
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: #0c2415; border-radius: 10px;
}
.history-row .h-win { color: var(--green); font-weight: 700; font-size: 15px; min-width: 26px; }
.history-row .h-lose { color: var(--red); font-weight: 700; font-size: 15px; min-width: 26px; }
.history-row .h-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.history-row .h-role { font-size: 13px; font-weight: 600; }
.history-row .h-time { font-size: 11px; color: var(--text-dim); }

/* 统计卡片 */
.stat-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-bottom: 12px;
}
.stat-item {
  background: #0c2415; border-radius: 12px; padding: 12px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.stat-num { font-size: 22px; font-weight: 800; color: var(--text); }
.stat-num.green { color: var(--green); }
.stat-num.red { color: var(--red); }
.stat-num.gold { color: var(--gold); }
.stat-label { font-size: 11px; color: var(--text-dim); }

/* 个人资料头部 */
.profile-head {
  display: flex; align-items: center; gap: 14px; padding: 8px 4px 16px;
}
.profile-avatar {
  font-size: 44px; width: 68px; height: 68px; border-radius: 50%;
  background: rgba(245,197,66,.15); border: 2px solid rgba(245,197,66,.4);
  display: flex; align-items: center; justify-content: center;
}
.profile-name { font-size: 20px; font-weight: 800; }
.profile-score { font-size: 26px; font-weight: 800; color: var(--gold); }

/* 牌局特效浮标 */
.fx-burst {
  position: absolute; font-size: 52px; pointer-events: none; z-index: 60;
  animation: fxBurst .95s ease-out forwards;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.5));
}
@keyframes fxBurst {
  0% { transform: scale(.3) translateY(0); opacity: 0; }
  25% { transform: scale(1.6) translateY(-6px); opacity: 1; }
  100% { transform: scale(2.4) translateY(-46px); opacity: 0; }
}

/* 庆祝彩带（胜利时从结算弹窗飘落） */
.fx-confetti {
  position: fixed; top: -20px; pointer-events: none; z-index: 300;
  animation: confettiFall 2.6s ease-in forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: .8; }
}

/* 明牌地主手牌展示 */
.landlord-hand-show {
  display: flex; gap: 2px; flex-wrap: wrap; justify-content: center;
  max-width: 230px; margin-top: 4px;
  background: rgba(0,0,0,.35); padding: 5px 7px; border-radius: 8px;
  border: 1px solid rgba(245,197,66,.35);
  animation: popIn .3s ease;
}
.landlord-hand-show .mini-card {
  width: 24px; height: 34px; font-size: 11px;
}
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; z-index: 200; display: none; max-width: 80vw; text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.1);
}
.toast.show { display: block; animation: toastIn 2.4s ease forwards; }

/* 动画 */
@keyframes screenIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes floatUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes modalIn { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
@keyframes popIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
@keyframes dealIn {
  0% { opacity: 0; transform: translateY(-18px) scale(.7) rotate(-5deg); }
  60% { opacity: 1; transform: translateY(4px) scale(1.06) rotate(1deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
@keyframes flipIn {
  0% { opacity: 0; transform: rotateY(90deg) scale(.7); }
  60% { opacity: 1; transform: rotateY(-12deg) scale(1.06); }
  100% { opacity: 1; transform: rotateY(0) scale(1); }
}
@keyframes crownDrop {
  0% { opacity: 0; transform: translateY(-16px) scale(.4); }
  60% { opacity: 1; transform: translateY(3px) scale(1.15); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes multiplierBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
@keyframes winCelebrate {
  0% { transform: scale(.5); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  70% { transform: scale(.95); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes selectedGlow {
  from { box-shadow: 0 0 0 2px var(--gold), 0 8px 20px rgba(245,197,66,.45); }
  to { box-shadow: 0 0 0 2px var(--gold-light), 0 8px 26px rgba(245,197,66,.7); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(245,197,66,.5); }
  50% { box-shadow: 0 0 20px rgba(245,197,66,.9); }
}
@keyframes toastIn {
  0% { opacity: 0; transform: translate(-50%, -14px); }
  12% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* 响应式 */
@media (max-width: 600px) {
  .card { width: 48px; height: 68px; }
  .card .rank { font-size: 19px; }
  .card .suit { font-size: 16px; }
  .card .suit-top { font-size: 11px; }
  .card.selected { transform: translateY(-18px) scale(1.04); }
  .player .avatar { font-size: 28px; width: 42px; height: 42px; }
  .play-area .mini-card { width: 28px; height: 40px; font-size: 14px; }
  .my-play .mini-card { width: 30px; height: 42px; font-size: 14px; }
  .bottom-cards .mini-card { width: 36px; height: 52px; font-size: 14px; }
  .bottom-label { font-size: 10px; padding: 2px 9px; }
  /* 手机端紧凑布局 */
  .player-left { left: 4px; top: 4%; }
  .player-right { right: 4px; top: 4%; }
  .bottom-area { top: 4%; }
  #area-left { left: 52px; top: 15%; }
  #area-right { right: 52px; top: 15%; }
  .center-info { top: 26%; }
  .my-play { bottom: 216px; }
  .action-bar { bottom: 132px; }
  .btn-act { height: 46px; min-width: 82px; padding: 0 16px; font-size: 16px; letter-spacing: 1px; }
  .btn-act .act-ico { font-size: 17px; }
  .btn-play { min-width: 118px; font-size: 17px; }
  .actions { gap: 10px; }
  .bid-actions { gap: 8px; }

  /* ===== 菜单页移动端适配：压缩间距，确保所有入口完整可见 ===== */
  .menu-header { padding: 20px 16px 8px; }
  .menu-title { font-size: 24px; letter-spacing: 1px; }
  .profile-chip { padding: 8px 12px; font-size: 12px; gap: 5px; }
  .menu-body { padding: 12px 16px; }
  .btn-big { padding: 14px; font-size: 17px; margin-bottom: 10px; border-radius: 13px; }
  .menu-sub { font-size: 12px; margin: -4px 0 10px; }
  .join-row { gap: 8px; margin: 2px 0 10px; }
  .join-row input { padding: 10px 12px; font-size: 15px; }
  .menu-grid { gap: 8px; }
  .menu-grid .btn-mid { padding: 12px; font-size: 14px; }

  /* ===== 对局内移动端优化：信息栏与间距更紧凑 ===== */
  .my-info { gap: 6px; }
  .my-info .avatar { width: 34px; height: 34px; font-size: 20px; }
  .my-name { font-size: 14px; }
  .hand { padding: 22px 4px 8px; min-height: 110px; }
  .bottom-panel { padding: 6px 10px 10px; }
  .center-info { top: 24%; }
  .my-play { bottom: 196px; }
  .action-bar { bottom: 120px; }
  .btn-act { height: 44px; min-width: 74px; padding: 0 12px; font-size: 15px; }
  .btn-play { min-width: 108px; font-size: 16px; }

  /* ===== 弹窗与排行榜/历史/资料等组件的移动端适配 ===== */
  .modal-content { padding: 20px 16px; width: 94vw; max-width: 440px; }
  .modal-title { font-size: 18px; margin-bottom: 12px; }
  .modal-actions { gap: 8px; }
  .info-body { max-height: 70vh; }
  .rank-row { gap: 8px; padding: 8px 10px; }
  .rank-row .r-rank { width: 26px; font-size: 15px; }
  .rank-row .r-name { font-size: 14px; }
  .rank-row .r-stat { font-size: 11px; }
  .rank-row .r-score { font-size: 13px; }
  .history-row { gap: 8px; padding: 8px 10px; }
  .history-row .h-role { font-size: 12px; }
  .stat-summary { gap: 6px; margin-bottom: 10px; }
  .stat-item { padding: 10px 4px; }
  .stat-num { font-size: 18px; }
  .stat-label { font-size: 10px; }
  .profile-head { gap: 10px; padding: 4px 2px 12px; }
  .profile-avatar { width: 52px; height: 52px; font-size: 32px; }
  .profile-name { font-size: 17px; }
  .profile-score { font-size: 20px; }
  .settle-result { font-size: 24px; }
  .settle-detail { font-size: 12px; }
  .login-box { padding: 28px 22px; }
  .logo { font-size: 26px; }
}

/* ============ 横屏矮屏幕适配（手机横过来：宽 > 高，高度受限） ============ */
@media (orientation: landscape) and (max-height: 560px) {
  /* 缩小手牌，避免牌过大撑破布局 */
  .card { width: 42px; height: 58px; border-radius: 6px; }
  .card .rank { font-size: 16px; }
  .card .suit { font-size: 14px; bottom: 3px; right: 4px; }
  .card .suit-top { font-size: 9px; top: 3px; left: 4px; }
  .card.selected { transform: translateY(-12px) scale(1.03); }
  .card.joker .rank.joker-text,
  .card.joker-black .rank.joker-text { font-size: 12px; }

  /* 缩小玩家头像与信息（保持可读，勿过度缩小导致看不清） */
  .player { gap: 2px; }
  .player .avatar { width: 40px; height: 40px; font-size: 26px; }
  .p-name { font-size: 13px; }
  .p-cards { font-size: 10px; }
  .p-status { font-size: 10px; padding: 2px 8px; min-height: 16px; }
  .landlord-tag { font-size: 10px; padding: 2px 8px; }

  /* 缩小底牌 */
  .bottom-cards { gap: 4px; }
  .bottom-cards .mini-card { width: 28px; height: 38px; font-size: 11px; }
  .bottom-label { font-size: 8px; padding: 1px 6px; }

  /* 缩小出牌区牌 */
  .play-area { gap: 2px; min-height: 30px; }
  .play-area .mini-card { width: 22px; height: 30px; font-size: 10px; }
  .my-play { gap: 2px; min-height: 30px; }
  .my-play .mini-card { width: 24px; height: 32px; font-size: 10px; }

  /* 横屏定位：覆盖默认的 translateY(-50%)，防止玩家/底牌被上移一半高度而卡出屏幕顶部 */
  .player-left { left: 4px; top: 8px; transform: none; }
  .player-right { right: 4px; top: 8px; transform: none; }
  .bottom-area { top: 8px; transform: translateX(-50%); }
  /* 出牌区外移，避开左上/右上玩家昵称，防止遮挡 */
  #area-left { left: 104px; top: 13%; }
  #area-right { right: 104px; top: 13%; }
  .center-info { top: 23%; }
  .multiplier { font-size: 11px; padding: 3px 10px; }
  .my-play { bottom: 122px; }
  .action-bar { bottom: 76px; width: 94vw; max-width: 760px; }

  /* 缩小操作按钮 */
  .actions { gap: 6px; }
  .bid-actions { gap: 5px; }
  .bar-utils { gap: 5px; }
  .btn-act { height: 32px; min-width: 56px; padding: 0 10px; font-size: 13px; border-radius: 8px; letter-spacing: 1px; }
  .btn-act .act-ico { font-size: 13px; }
  .btn-play { min-width: 88px; font-size: 14px; }
  .btn-util { height: 24px; padding: 0 8px; font-size: 10px; border-radius: 7px; }
  .btn-util .act-ico { font-size: 11px; }

  /* 手牌区紧凑：横屏隐藏自己的头像信息行，腾出空间给手牌 */
  .my-info { display: none; }
  .hand { padding: 14px 6px 5px; min-height: 74px; }
  .bottom-panel { padding: 2px 10px 4px; }

  /* 横屏下快捷语菜单位置调整，避免与手牌/按钮重叠 */
  .chat-menu { bottom: 96px; }
  .chat-bubbles { top: 26%; }

  /* ===== 主菜单横屏适配：压缩高度，确保底部入口（排行榜等）完整可见 ===== */
  .menu-header { padding: 8px 16px 4px; }
  .menu-title { font-size: 22px; }
  .profile-chip { padding: 6px 12px; font-size: 13px; }
  .btn-sound { padding: 6px 8px; font-size: 14px; }
  .menu-body { padding: 10px 16px; }
  .btn-big { padding: 11px; font-size: 16px; border-radius: 12px; }
  .menu-sub { font-size: 12px; margin: 0 0 8px; }
  .join-row { gap: 8px; margin: 0 0 8px; }
  .join-row input { padding: 8px 12px; font-size: 14px; }
  .join-row .btn-mid { padding: 9px 14px; font-size: 13px; }
  .menu-grid { gap: 6px; margin-bottom: 4px; }
  .menu-grid .btn-mid { padding: 9px; font-size: 13px; }
}

/* ============ GM 调试面板（隐藏，Ctrl+Shift+G 触发） ============ */
.gm-panel {
  position: fixed; right: 16px; top: 16px; z-index: 500;
  width: 340px; background: rgba(12,36,21,.96);
  border: 1px solid rgba(245,197,66,.4); border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  display: flex; flex-direction: column; overflow: hidden;
}
.gm-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: rgba(245,197,66,.15);
  font-weight: 700; color: var(--gold); font-size: 14px;
  cursor: move; user-select: none;
}
.gm-close {
  background: none; border: none; color: var(--text-dim); font-size: 22px;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.gm-panel-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.gm-btn {
  padding: 10px 14px; border-radius: 10px; border: none; cursor: pointer;
  background: rgba(245,197,66,.2); color: var(--gold); font-weight: 600; font-size: 13px;
  transition: background .15s;
}
.gm-btn:hover { background: rgba(245,197,66,.32); }
.gm-row { display: flex; gap: 8px; }
.gm-row input {
  flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid #2a5a3a;
  background: #0c2415; color: var(--text); outline: none; font-size: 13px;
}

/* GM 面板分页 */
.gm-tabs { display: flex; gap: 4px; padding: 8px 12px 0; flex-wrap: wrap; }
.gm-tab {
  padding: 5px 12px; font-size: 12px; border-radius: 8px 8px 0 0; border: 1px solid transparent;
  background: transparent; color: var(--text-dim); cursor: pointer;
}
.gm-tab.active { background: rgba(245,197,66,.15); color: var(--gold); border-color: rgba(245,197,66,.3); }
.gm-tab-content { display: none; flex-direction: column; gap: 10px; }
.gm-tab-content.active { display: flex; }

/* GM 详情 / 日志 */
.gm-detail { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.gm-detail b { color: var(--gold); }
.gm-log-list { display: flex; flex-direction: column; gap: 4px; }
.gm-log-row { font-size: 12px; padding: 4px 6px; background: #0c2415; border-radius: 6px; }
.gm-log-time { color: var(--text-dim); margin-right: 6px; }

#gm-result { font-size: 12px; color: var(--text-dim); line-height: 1.6; max-height: 320px; overflow-y: auto; }
.gm-hand-list { display: flex; flex-direction: column; gap: 6px; }
.gm-hand-row { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.gm-hand-row .mini-card { width: 22px; height: 32px; font-size: 10px; }

/* GM 排行榜管理 */
.gm-btn-danger { background: rgba(224,72,62,.2); color: #ff9a90; }
.gm-btn-danger:hover { background: rgba(224,72,62,.35); }
.gm-btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.gm-rank-list { display: flex; flex-direction: column; gap: 5px; }
.gm-rank-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; background: #0c2415; border-radius: 8px;
}
.gm-rank-medal { width: 24px; text-align: center; flex-shrink: 0; }
.gm-rank-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.gm-rank-score { color: var(--gold); font-weight: 700; flex-shrink: 0; }

/* ============ 音效开关 + 快捷语 ============ */
.menu-actions { display: flex; align-items: center; gap: 8px; }
.btn-sound {
  background: rgba(245,197,66,.15); border: 1px solid rgba(245,197,66,.2);
  border-radius: 20px; padding: 8px 10px; font-size: 16px; cursor: pointer;
  line-height: 1; transition: background .2s;
}
.btn-sound:hover { background: rgba(245,197,66,.25); }

.chat-menu {
  position: absolute; bottom: 150px; left: 50%; transform: translateX(-50%);
  z-index: 30; flex-wrap: wrap; gap: 6px; justify-content: center;
  width: 92vw; max-width: 460px; padding: 8px;
  background: rgba(12,36,21,.96); border: 1px solid rgba(245,197,66,.3);
  border-radius: 12px;
}
.chat-item {
  padding: 6px 12px; font-size: 13px; border-radius: 16px; border: 1px solid #2a5a3a;
  background: #0c2415; color: var(--text); cursor: pointer; white-space: nowrap;
  transition: background .15s;
}
.chat-item:hover { background: rgba(245,197,66,.15); color: var(--gold); }

.chat-bubbles {
  position: absolute; top: 42%; left: 50%; transform: translateX(-50%);
  z-index: 29; display: flex; flex-direction: column; gap: 6px; align-items: center;
  pointer-events: none; width: 100%;
}
.chat-bubble {
  padding: 6px 14px; font-size: 13px; border-radius: 16px;
  background: rgba(0,0,0,.7); color: #fff; animation: bubbleIn 3s ease forwards;
  max-width: 80%;
}
@keyframes bubbleIn {
  0% { opacity: 0; transform: translateY(10px); }
  10% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ============ 设置界面 ============ */
.settings-body { display: flex; flex-direction: column; text-align: left; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 4px; border-bottom: 1px solid #2a5a3a;
}
.setting-label { font-size: 15px; font-weight: 600; }
.switch {
  width: 48px; height: 26px; border-radius: 13px; border: none; cursor: pointer;
  background: #2a5a3a; position: relative; transition: background .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: left .2s;
}
.switch.on { background: var(--gold-dark); }
.switch.on::after { left: 25px; }
.speed-group { display: flex; gap: 6px; }
.speed-btn {
  padding: 6px 14px; border-radius: 16px; border: 1px solid #2a5a3a;
  background: #0c2415; color: var(--text-dim); cursor: pointer; font-size: 13px;
  transition: all .15s;
}
.speed-btn.active { background: rgba(245,197,66,.2); color: var(--gold); border-color: rgba(245,197,66,.4); }

/* ============ 横屏提示层（竖屏时提示旋转，由 JS 控制显示） ============ */
.rotate-hint {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: radial-gradient(ellipse at top, #123522, #0a1a12);
  align-items: center; justify-content: center; flex-direction: column;
}
.rotate-hint-inner { text-align: center; padding: 24px; }
.rotate-icon { font-size: 60px; animation: rotatePhone 2s ease-in-out infinite; }
.rotate-text { font-size: 18px; color: var(--gold); margin-top: 18px; line-height: 1.8; }
.rotate-btn {
  margin-top: 24px; padding: 14px 32px; font-size: 16px; font-weight: 700;
  border-radius: 26px; border: none; cursor: pointer;
  background: linear-gradient(180deg, #ffd86b, var(--gold-dark)); color: #4a3200;
}
.rotate-tip {
  margin-top: 20px; font-size: 13px; color: var(--text-dim);
  line-height: 1.6; opacity: .9;
}
@keyframes rotatePhone {
  0%, 20% { transform: rotate(0deg); }
  60%, 80% { transform: rotate(90deg); }
  100% { transform: rotate(90deg); }
}
