:root {
  --felt: #0e5c3a;
  --felt-dark: #0a4229;
  --gold: #f0c35a;
  --bg: #10241b;
  --card-w: 74px;
  --card-h: 104px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: radial-gradient(ellipse at 50% 20%, #187a4c 0%, var(--felt) 40%, var(--felt-dark) 100%);
  color: #f2f6f3;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.hidden { display: none !important; }
.screen { height: 100%; display: flex; flex-direction: column; }

/* ---------- 大厅 ---------- */
#lobby { align-items: center; justify-content: center; padding: 16px; }
.lobby-card {
  width: 100%; max-width: 380px; background: rgba(0,0,0,.35);
  border: 1px solid rgba(240,195,90,.25); border-radius: 18px; padding: 28px 22px;
  display: flex; flex-direction: column; gap: 12px; backdrop-filter: blur(6px);
}
.logo { font-size: 40px; font-weight: 900; text-align: center; color: var(--gold); letter-spacing: 6px; text-shadow: 0 2px 12px rgba(0,0,0,.5); }
.sub { text-align: center; font-size: 13px; opacity: .7; margin-bottom: 8px; }
.txt {
  padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.35); color: #fff; font-size: 17px; width: 100%; outline: none;
}
.txt:focus { border-color: var(--gold); }
.txt.code { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 700; }
.btn {
  padding: 12px 18px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.12); color: #fff; font-size: 16px; cursor: pointer;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #e8b64c, #c9922e); border-color: #a87c1e; color: #3a2503; font-weight: 800; }
.btn.big { padding: 15px; font-size: 18px; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.3); font-size: 14px; }
.btn.danger { background: #b3392e; border-color: #8d2b23; }
.btn:disabled { opacity: .4; }
.divider { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.55); font-size: 12px; margin: 6px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.18); }
.join-row { display: flex; gap: 10px; }
.join-row .txt { flex: 1; }
details summary { color: var(--gold); font-size: 14px; cursor: pointer; margin: 2px 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.form-grid label { font-size: 12px; opacity: .85; display: flex; flex-direction: column; gap: 4px; }
.form-grid input, .form-grid select { padding: 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.35); color: #fff; font-size: 15px; }
.msg { color: #ffb3a7; font-size: 13px; min-height: 18px; text-align: center; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); background: rgba(0,0,0,.28); }
.room-info { flex: 1; min-width: 0; font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-info b { color: var(--gold); font-size: 16px; margin-left: 8px; letter-spacing: 3px; }
.pot-info { font-size: 14px; }
.pot-info b { color: var(--gold); font-size: 20px; margin-left: 4px; }
.icon-btn { background: rgba(255,255,255,.12); color: #fff; border: none; border-radius: 8px; width: 36px; height: 32px; font-size: 16px; cursor: pointer; }

/* ---------- 对手 ---------- */
.opponents { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 10px 8px; min-height: 96px; }
.seat {
  background: rgba(0,0,0,.32); border: 2px solid rgba(255,255,255,.12); border-radius: 12px;
  padding: 6px 10px; min-width: 104px; text-align: center; position: relative; transition: border-color .2s;
}
.seat.turn { border-color: var(--gold); box-shadow: 0 0 14px rgba(240,195,90,.5); }
.seat.offline { opacity: .55; }
.seat.folded { opacity: .5; }
.seat .nm { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 13px; font-weight: 700; }
.seat .nm .nm-txt { max-width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 醒目的闷/明标识: 静态样式, 不加动画(每秒快照重渲染会重播) */
.role-tag { flex: none; font-size: 13px; font-weight: 900; border-radius: 6px; padding: 2px 8px; line-height: 1.1; }
.role-tag.men { background: #24457e; color: #bcd4ff; border: 1.5px solid #5d8ee0; }
.role-tag.ming { background: var(--gold); color: #3a2503; border: 1.5px solid #b3822e; box-shadow: 0 0 9px rgba(240,195,90,.65); }
.role-tag.allin { background: #c0392b; color: #fff; border: 1.5px solid #e74c3c; }
.role-tag.fold { background: #4a4a4a; color: #9a9a9a; border: 1.5px solid #666; }
.seat .ch { font-size: 12px; color: var(--gold); }
.seat .mini-cards { display: flex; gap: 3px; justify-content: center; margin: 4px 0 2px; }
.seat .la { font-size: 11px; color: #ffd9a0; min-height: 14px; }
.seat .dealer-tag { position: absolute; top: -8px; left: -6px; background: var(--gold); color: #3a2503; font-size: 10px; font-weight: 900; border-radius: 6px; padding: 1px 5px; }
.turn-clock { position: absolute; top: -8px; right: -6px; background: #c0392b; color: #fff; font-size: 11px; font-weight: 800; border-radius: 50%; width: 22px; height: 22px; line-height: 22px; }

/* 中央 */
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 60px; }
.phase-text { font-size: 15px; color: #ffe9b8; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.pot-big { font-size: 30px; font-weight: 900; color: var(--gold); text-shadow: 0 2px 10px rgba(0,0,0,.55); }
.pot-big.pulse { animation: potPulse .45s ease-out; }
@keyframes potPulse { 0% { transform: scale(1); } 45% { transform: scale(1.28); } 100% { transform: scale(1); } }
.level-text { font-size: 12px; opacity: .75; }

/* ---------- 筹码投掷动画 ---------- */
.fly-chip {
  position: fixed; left: 0; top: 0; z-index: 36; pointer-events: none;
  border-radius: 50%;
  background:
    radial-gradient(circle, #f4d47c 0 36%, transparent 36.5%),
    conic-gradient(#f0c35a 0 15%, #fff6d8 15% 30%, #f0c35a 30% 45%, #fff6d8 45% 60%,
                   #f0c35a 60% 75%, #fff6d8 75% 90%, #f0c35a 90% 100%);
  box-shadow: 0 2px 10px rgba(0,0,0,.55), inset 0 0 0 2px rgba(122,84,15,.4);
  will-change: transform, opacity;
}
.float-label {
  position: fixed; z-index: 37; pointer-events: none;
  transform: translate(-50%, -50%);
  font-size: 17px; font-weight: 900; color: #ffd9a0;
  text-shadow: 0 1px 5px rgba(0,0,0,.8), 0 0 12px rgba(0,0,0,.4);
  animation: floatUp .95s ease-out forwards;
}
.float-label.in { color: #8affb0; }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  30% { transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, calc(-50% - 44px)) scale(1); }
}

/* ---------- 我的区域 ---------- */
.me-area { padding: 4px 14px 8px; }
.me-head { display: flex; align-items: center; gap: 8px; font-size: 14px; justify-content: center; margin-bottom: 8px; }
.badge { font-size: 13px; font-weight: 900; padding: 3px 10px; border-radius: 9px; background: rgba(255,255,255,.15); }
.badge.men { background: #24457e; color: #bcd4ff; border: 1.5px solid #5d8ee0; }
.badge.ming { background: var(--gold); color: #3a2503; border: 1.5px solid #b3822e; box-shadow: 0 0 10px rgba(240,195,90,.55); }
.badge.fold { background: #4a4a4a; color: #9a9a9a; }
.badge.allin { background: #c0392b; box-shadow: 0 0 8px rgba(192,57,43,.6); }
.chips { color: var(--gold); font-weight: 800; }
.my-clock {
  background: #c0392b; color: #fff; font-size: 16px; font-weight: 900; border-radius: 50%;
  min-width: 32px; height: 32px; line-height: 32px; text-align: center; padding: 0 4px;
  box-shadow: 0 0 10px rgba(192,57,43,.7);
}
.my-clock.urgent { animation: tickPulse 1s infinite; }
@keyframes tickPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.tip { text-align: center; font-size: 12px; opacity: .55; }
.bet { opacity: .75; font-size: 12px; }
.my-cards { display: flex; justify-content: center; gap: 10px; min-height: calc(var(--card-h) + 8px); }

/* ---------- 扑克牌 ---------- */
.card {
  width: var(--card-w); height: var(--card-h); border-radius: 9px; position: relative;
  background: linear-gradient(160deg, #fdfdf8, #e8e6dc); color: #1c1c1c;
  box-shadow: 0 3px 10px rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 900;
}
.card.red { color: #c0392b; }
.card .corner { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 1.05; font-size: 16px; font-weight: 800; }
.card .corner small { font-size: 15px; }
.card .corner.tl { top: 5px; left: 7px; }
.card .corner.br { bottom: 5px; right: 7px; transform: rotate(180deg); }
.card .pip { font-size: 36px; }
.card.back {
  background: repeating-linear-gradient(45deg, #8e2f46 0 6px, #7a283c 6px 12px);
  border: 3px solid #f4efe2; display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.35); font-size: 24px;
}
.card.mini { width: 26px; height: 37px; font-size: 12px; border-radius: 4px; }
.card.mini .corner { display: none; }
.card.mini.back { border-width: 2px; font-size: 12px; }
.card.peekable { cursor: pointer; }

/* ---------- 操作栏 ---------- */
.action-bar { display: flex; gap: 8px; padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); justify-content: center; flex-wrap: wrap; }
.action-bar .btn { flex: 1; min-width: 72px; max-width: 120px; padding: 13px 6px; font-size: 15px; }
.action-bar .btn small { display: block; font-size: 11px; font-weight: 400; opacity: .85; }

/* ---------- 工具条 & 抽屉 ---------- */
.tabbar { display: flex; background: rgba(0,0,0,.4); border-top: 1px solid rgba(255,255,255,.1); }
.tab { flex: 1; background: none; border: none; color: rgba(255,255,255,.8); font-size: 13px; padding: 9px 0; cursor: pointer; }
.tab.danger { color: #ff9d92; }
.tab.active { color: var(--gold); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e74c3c; margin-left: 5px; vertical-align: middle; box-shadow: 0 0 6px rgba(231,76,60,.8); }
.drawer { position: fixed; left: 0; right: 0; bottom: 0; max-height: 55%; background: #12281e; border-top: 2px solid rgba(240,195,90,.4); border-radius: 16px 16px 0 0; display: flex; flex-direction: column; z-index: 30; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; font-weight: 700; color: var(--gold); }
.drawer-head button { background: none; border: none; color: #fff; font-size: 16px; }
.drawer-body { overflow-y: auto; padding: 0 16px 16px; flex: 1; }
.tabpane { display: none; }
.tabpane.active { display: block; }
#tab-chat.active { display: flex; flex-direction: column; }
#tab-chat .list { flex: 1; }
.list { font-size: 13px; line-height: 1.7; }
.list .li { border-bottom: 1px solid rgba(255,255,255,.07); padding: 3px 0; }
.chat-row { display: flex; gap: 8px; padding-top: 8px; }
.chat-row .txt { flex: 1; font-size: 15px; padding: 9px 12px; }
.chat-msg b { color: #9fd8b5; }
/* 聊天新消息弹出气泡 */
.chat-pop {
  position: fixed; top: calc(54px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 45; background: rgba(12,26,18,.95); border: 1px solid rgba(240,195,90,.55);
  border-radius: 12px; padding: 9px 16px; max-width: 82vw; font-size: 14px; line-height: 1.5;
  box-shadow: 0 4px 18px rgba(0,0,0,.55); animation: chatPop .2s ease-out; overflow-wrap: anywhere;
}
.chat-pop b { color: #9fd8b5; margin-right: 4px; }
@keyframes chatPop { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
/* 房主标记 */
.host-tag { background: var(--gold); color: #3a2503; font-size: 10px; font-weight: 900; border-radius: 4px; padding: 1px 5px; margin-left: 5px; vertical-align: middle; }

/* ---------- 结算 & toast ---------- */
.settle-banner {
  position: fixed; top: 18%; left: 50%; transform: translateX(-50%); z-index: 25;
  background: rgba(10,20,14,.94); border: 2px solid var(--gold); border-radius: 14px;
  padding: 16px 22px; text-align: center; max-width: 92vw; box-shadow: 0 8px 40px rgba(0,0,0,.6);
  animation: pop .25s ease-out;
}
.settle-banner .win-names { font-size: 20px; font-weight: 900; color: var(--gold); margin-bottom: 6px; }
.settle-banner .win-amt { font-size: 15px; }
.settle-banner .hands { font-size: 12px; opacity: .8; margin-top: 8px; line-height: 1.6; }
.settle-banner .next-hint { font-size: 13px; opacity: .85; margin-top: 10px; color: #ffe9b8; }
@keyframes pop { from { transform: translateX(-50%) scale(.7); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: rgba(179,57,46,.95); padding: 9px 18px; border-radius: 20px; font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4); max-width: 86vw; text-align: center;
}

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; display: flex; align-items: center; justify-content: center; }
.modal { background: #143326; border: 1px solid rgba(240,195,90,.4); border-radius: 14px; padding: 18px; width: min(92vw, 360px); max-height: 80vh; overflow-y: auto; }
.modal-title { font-weight: 800; color: var(--gold); margin-bottom: 12px; font-size: 16px; }
.modal-body .btn { width: 100%; margin-top: 8px; }
.modal-body input.txt { margin-top: 8px; }
.qr-wrap { text-align: center; }
.qr-wrap img { width: 220px; height: 220px; border-radius: 10px; background: #fff; padding: 6px; }
.qr-code { font-size: 30px; letter-spacing: 10px; font-weight: 900; color: var(--gold); margin: 10px 0 2px; }
.qr-tip { font-size: 12px; opacity: .7; }
.lb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lb-table th { color: var(--gold); text-align: left; padding: 4px 4px; border-bottom: 1px solid rgba(255,255,255,.15); font-size: 12px; }
.lb-table td { padding: 5px 4px; border-bottom: 1px solid rgba(255,255,255,.06); }

#connBanner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60; background: #c0392b;
  text-align: center; padding: 8px; font-size: 14px; font-weight: 700;
}

/* ---------- 开牌翻牌层 ---------- */
.reveal-mask {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(4,12,8,.8);
  display: flex; align-items: center; justify-content: center; padding: 14px;
  animation: fadeIn .2s ease-out;
}
.reveal-panel {
  background: #122a1f; border: 2px solid rgba(240,195,90,.55); border-radius: 16px;
  padding: 14px 14px 12px; width: min(94vw, 480px); max-height: 84vh; overflow-y: auto;
  box-shadow: 0 10px 50px rgba(0,0,0,.65);
}
.reveal-title { text-align: center; font-size: 18px; font-weight: 900; color: var(--gold); letter-spacing: 2px; }
.reveal-hint { text-align: center; font-size: 12px; opacity: .75; margin: 4px 0 10px; min-height: 16px; }
.reveal-seats { display: flex; flex-direction: column; gap: 10px; }
.reveal-seat { border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 8px 10px; background: rgba(0,0,0,.25); }
.reveal-seat.win { border-color: var(--gold); box-shadow: 0 0 16px rgba(240,195,90,.45); }
.reveal-seat.lose { opacity: .6; }
.rv-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.rv-name { font-size: 14px; font-weight: 700; }
.rv-desc { font-size: 12px; color: #ffd9a0; }
.rv-tag { font-size: 11px; font-weight: 900; border-radius: 6px; padding: 1px 8px; margin-left: auto; }
.rv-tag.win-tag { background: var(--gold); color: #3a2503; }
.rv-tag.lose-tag { background: #b3392e; color: #fff; }
.rv-cards { display: flex; gap: 8px; justify-content: center; }
.rv-cards .card.flippable { cursor: pointer; box-shadow: 0 0 12px rgba(240,195,90,.55); animation: breathe 1.6s infinite; }
.rv-cards .card.flip-in { animation: flipIn .38s ease-out; }
.my-cards .card.flip-in { animation: flipIn .38s ease-out; }
@keyframes breathe { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes flipIn { from { transform: rotateY(90deg) scale(1.06); } to { transform: rotateY(0) scale(1); } }
.reveal-actions { margin-top: 10px; text-align: center; }
.reveal-actions .btn { min-width: 170px; }
.reveal-outcome { font-size: 17px; font-weight: 800; color: var(--gold); animation: rvPop .25s ease-out; }
@keyframes rvPop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 机器人 ---------- */
.bot-tag { font-size: 10px; font-weight: 800; background: #4a3b78; color: #cabef5; border: 1px solid #7d6cc0; border-radius: 6px; padding: 1px 5px; }
.bot-panel { width: min(94vw, 400px); }
.bot-form { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.bot-form > label { font-size: 12px; opacity: .7; }
.bot-personas, .bot-diffs { display: flex; flex-wrap: wrap; gap: 6px; }
.bot-chip { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.2); border-radius: 8px; padding: 5px 10px; font-size: 13px; cursor: pointer; }
.bot-chip.sel { background: var(--gold); color: #3a2503; border-color: var(--gold); font-weight: 800; }
.bot-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.bot-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; background: rgba(0,0,0,.2); border-radius: 8px; padding: 6px 10px; }
.btn.sm { padding: 3px 12px; font-size: 12px; min-width: 0; }
.btn.danger { background: #8e2f26; }

/* ---------- 房主发放筹码 ---------- */
.seat .ch { display: flex; align-items: center; justify-content: center; gap: 4px; }
.chip-add {
  width: 20px; height: 20px; line-height: 18px; padding: 0;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12); color: var(--gold);
  font-size: 13px; font-weight: 800; cursor: pointer; flex: none;
}
.chip-add:active { transform: scale(.9); }
.me-add { width: 24px; height: 24px; line-height: 22px; font-size: 15px; }
.chip-add.hidden { display: none; }
.grant-tip { font-size: 13px; opacity: .85; margin-bottom: 10px; }
.grant-quick { display: flex; gap: 8px; flex-wrap: wrap; }
.grant-quick .btn { flex: 1; min-width: 0; margin-top: 0; }
.grant-row { display: flex; gap: 8px; margin-top: 10px; }
.grant-row .txt { flex: 1; }
.grant-row .btn { width: auto; min-width: 84px; margin-top: 0; }
.grant-note { font-size: 12px; opacity: .55; margin-top: 10px; text-align: center; }
.chips-tip { font-size: 12px; opacity: .55; margin-bottom: 6px; }
.chip-li { padding: 5px 0 !important; }
.chip-line { font-size: 13px; }
.chip-line b { color: var(--gold); }
.chip-sub { font-size: 12px; opacity: .55; }
