/* ============================================================
   德州扑克 H5 · 样式表
   全部图形由 CSS 绘制（牌面、筹码、牌桌），不依赖任何图片素材，
   既保证合规（无第三方美术资产），也让首屏加载几乎为零成本。
   移动端优先，桌面端自动居中收窄。
   ============================================================ */

:root {
  --felt-dark: #0a2e23;
  --felt: #0f4635;
  --felt-light: #146b4f;
  --gold: #d9b45b;
  --gold-dim: #8a7238;
  --ink: #0b1512;
  --text: #e9f2ee;
  --text-dim: #90a89e;
  --danger: #c8453b;
  --danger-dark: #8e2f28;
  --call: #2f7fb5;
  --raise: #c98a2b;
  --ok: #3f9d6c;
  --card-face: #fbfaf6;
  --card-back: linear-gradient(135deg, #7b1e2b 0%, #4a1119 100%);
  --radius: 12px;
  --shadow: 0 4px 14px rgba(0, 0, 0, .35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(ellipse at 50% 0%, #14483a 0%, #071b15 70%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
}

/* 屏幕切换 */
.screen { display: none; height: 100dvh; flex-direction: column; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ─────────────── 通用按钮 ─────────────── */
.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .08);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  padding: 12px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .08s, filter .15s, opacity .15s;
}
.btn:active:not(:disabled) { transform: scale(.96); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-block { width: 100%; display: block; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-primary { background: linear-gradient(180deg, #e0bd68, #b8933f); color: #2b2107; border-color: #e6c87f; }
.btn-fold  { background: linear-gradient(180deg, #b4433a, var(--danger-dark)); border-color: #d1584e; }
.btn-check { background: linear-gradient(180deg, #4a9a72, #2f6d4f); border-color: #5cb188; }
.btn-call  { background: linear-gradient(180deg, #3a8dc4, #235f87); border-color: #4fa2d8; }
.btn-raise { background: linear-gradient(180deg, #d59a35, #9c6c1c); border-color: #e3ad4c; }

.icon-btn {
  appearance: none; border: none; background: rgba(255, 255, 255, .1);
  color: var(--text); width: 34px; height: 34px; border-radius: 50%;
  font-size: 16px; cursor: pointer; flex-shrink: 0;
}

/* ─────────────── 大厅 ─────────────── */
#lobby { align-items: center; justify-content: center; padding: 24px 18px; overflow-y: auto; }

.lobby-card {
  width: 100%; max-width: 380px;
  background: rgba(4, 24, 18, .72);
  border: 1px solid rgba(217, 180, 91, .22);
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.logo { text-align: center; font-size: 30px; margin: 0 0 6px; letter-spacing: 3px; }
.suit.red { color: #e0574c; }
.suit.black { color: #e9f2ee; }

.lobby-title {
  text-align: center; margin: 0; font-size: 26px; letter-spacing: 4px;
  color: var(--gold); font-weight: 700;
}
.lobby-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin: 4px 0 22px; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.field input,
.advanced-grid input {
  width: 100%; padding: 12px 14px; font-size: 16px; font-family: inherit;
  background: rgba(0, 0, 0, .35); color: var(--text);
  border: 1px solid rgba(255, 255, 255, .16); border-radius: var(--radius);
  outline: none;
}
.field input:focus { border-color: var(--gold); }
#input-code { letter-spacing: 6px; text-transform: uppercase; font-weight: 700; text-align: center; }

.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-dim); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: rgba(255, 255, 255, .12); }

.advanced { margin-top: 18px; font-size: 13px; color: var(--text-dim); }
.advanced summary { cursor: pointer; padding: 6px 0; }
.advanced-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.advanced-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.advanced-grid input { padding: 8px 10px; font-size: 14px; }

.lobby-status { text-align: center; font-size: 13px; color: var(--danger); min-height: 20px; margin: 12px 0 0; }

/* ─────────────── 顶栏 ─────────────── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  background: rgba(0, 0, 0, .3);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  flex-shrink: 0;
}
.room-info { display: flex; align-items: center; gap: 8px; }
.room-code-label { font-size: 11px; color: var(--text-dim); }
.room-code {
  appearance: none; border: 1px dashed rgba(217, 180, 91, .5); background: transparent;
  color: var(--gold); font-size: 19px; font-weight: 700; letter-spacing: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  padding: 2px 8px; border-radius: 8px; cursor: pointer;
}
.phase-info { margin-left: auto; text-align: right; font-size: 12px; color: var(--text-dim); }
#phase-label { display: block; color: var(--text); font-size: 13px; font-weight: 600; }

/* ─────────────── 牌桌 ─────────────── */
.felt-wrap { flex: 1; min-height: 0; padding: 10px; display: flex; }
.felt {
  position: relative; flex: 1; margin: auto;
  width: 100%; max-width: 560px; aspect-ratio: 3 / 4; max-height: 100%;
  background: radial-gradient(ellipse at 50% 40%, var(--felt-light) 0%, var(--felt) 45%, var(--felt-dark) 100%);
  border: 5px solid #3c2a17;
  border-radius: 46% / 34%;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, .55), 0 8px 26px rgba(0, 0, 0, .45);
}
/* 牌桌内圈装饰线 */
.felt::after {
  content: ""; position: absolute; inset: 10%;
  border: 1px solid rgba(217, 180, 91, .16); border-radius: 46% / 34%;
  pointer-events: none;
}

.felt-inner {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 86%; z-index: 2;
}

.pot-display {
  font-size: 13px; color: var(--gold); font-weight: 700;
  background: rgba(0, 0, 0, .4); padding: 3px 12px; border-radius: 20px;
  border: 1px solid rgba(217, 180, 91, .3); white-space: nowrap;
  min-height: 24px; display: flex; align-items: center;
}
.pot-display:empty { display: none; }

.community { display: flex; gap: 6px; justify-content: center; min-height: 74px; align-items: center; }

.board-msg {
  font-size: 12px; color: var(--text-dim); text-align: center; min-height: 16px;
  max-width: 100%; padding: 0 8px;
}

/* ─────────────── 扑克牌（纯 CSS 绘制） ─────────────── */
.card {
  width: 48px; height: 68px; border-radius: 5px;
  background: var(--card-face); color: #17171a;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; line-height: 1;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .4);
  flex-shrink: 0;
  animation: dealIn .22s ease-out both;
}
.card .card-rank { font-size: 20px; }
.card .card-suit { font-size: 18px; margin-top: 2px; }
.card.red { color: #cc2f2a; }
.card.back {
  background: var(--card-back);
  border: 1px solid rgba(255, 255, 255, .18);
  position: relative;
}
/* 牌背花纹：两层重复渐变交叉出菱形网格 */
.card.back::after {
  content: ""; position: absolute; inset: 3px; border-radius: 3px;
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,.11) 0 3px, transparent 3px 6px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.11) 0 3px, transparent 3px 6px);
}
.card.sm { width: 38px; height: 54px; border-radius: 4px; }
.card.sm .card-rank { font-size: 16px; }
.card.sm .card-suit { font-size: 14px; }
.card.dim { filter: brightness(.55) saturate(.5); }
.card.highlight { box-shadow: 0 0 0 2px var(--gold), 0 2px 8px rgba(0,0,0,.5); }

@keyframes dealIn {
  from { opacity: 0; transform: translateY(-14px) scale(.85); }
  to   { opacity: 1; transform: none; }
}

/* ─────────────── 座位 ─────────────── */
.seats { position: absolute; inset: 0; z-index: 3; }

.seat {
  position: absolute; transform: translate(-50%, -50%);
  width: 84px; text-align: center;
}
.seat-box {
  background: rgba(3, 18, 14, .88);
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 10px; padding: 4px 3px;
  transition: border-color .2s, box-shadow .2s;
}
.seat.acting .seat-box {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(217, 180, 91, .35), 0 0 16px rgba(217, 180, 91, .3);
}
.seat.folded .seat-box { opacity: .42; }
.seat.self .seat-box { border-color: rgba(94, 200, 148, .6); }
.seat.empty .seat-box { border-style: dashed; opacity: .4; }

.seat-name {
  font-size: 11px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.seat-chips { font-size: 12px; color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.seat-cards { display: flex; gap: 3px; justify-content: center; margin-bottom: 2px; min-height: 56px; align-items: center; }

.seat-tags { display: flex; gap: 3px; justify-content: center; margin-top: 2px; flex-wrap: wrap; }
.tag {
  font-size: 9px; padding: 1px 5px; border-radius: 8px; font-weight: 700;
  background: rgba(255, 255, 255, .14);
}
.tag.dealer { background: #f2f0e6; color: #1a1a1a; }
.tag.sb { background: #3a6f9c; }
.tag.bb { background: #9c5c3a; }
.tag.allin { background: var(--danger); }
.tag.bot { background: #5b4b8a; }
.tag.bot-rock { background: #4a5568; }
.tag.bot-maniac { background: #c53030; }
.tag.bot-tag { background: #2b6cb0; }
.tag.bot-passive { background: #6b7280; }
.tag.bot-lag { background: #c05621; }
.tag.offline { background: #555; color: #bbb; }

/* 玩家面前的下注筹码 */
.seat-bet {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 700; color: #fff;
  background: rgba(0, 0, 0, .6); border: 1px solid var(--gold-dim);
  padding: 1px 7px; border-radius: 10px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.seat-bet::before { content: "●"; color: var(--gold); margin-right: 3px; font-size: 8px; }

/* 最近动作气泡 */
.seat-action {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 700;
  background: rgba(0, 0, 0, .78); border: 1px solid rgba(255,255,255,.25);
  padding: 2px 8px; border-radius: 10px; white-space: nowrap;
  line-height: 1.4;
  animation: popIn .2s ease-out both;
}
@keyframes popIn { from { opacity: 0; transform: translate(-50%, 4px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ─────────────── 底部操作区 ─────────────── */
.host-bar, .rebuy-bar {
  display: flex; gap: 8px; padding: 10px 12px calc(10px + var(--safe-bottom));
  background: rgba(0, 0, 0, .34); justify-content: center; flex-shrink: 0;
  border-top: 1px solid rgba(255, 255, 255, .06);
}
.rebuy-bar { align-items: center; font-size: 13px; color: var(--text-dim); }

.action-bar {
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: rgba(0, 0, 0, .4);
  border-top: 1px solid rgba(217, 180, 91, .2);
  flex-shrink: 0;
}
.action-row { display: flex; gap: 8px; }
.action-row .btn { flex: 1; padding: 14px 6px; font-size: 15px; }

.raise-panel { margin-bottom: 10px; }
.raise-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.raise-value { font-size: 19px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }

.raise-slider { width: 100%; height: 30px; appearance: none; background: transparent; }
.raise-slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-dim) 100%);
}
.raise-slider::-webkit-slider-thumb {
  appearance: none; width: 26px; height: 26px; border-radius: 50%; margin-top: -10px;
  background: linear-gradient(180deg, #f5e6bd, #d9b45b);
  border: 2px solid #8a7238; box-shadow: 0 2px 6px rgba(0, 0, 0, .5); cursor: pointer;
}
.raise-slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--gold-dim); }
.raise-slider::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%; background: #f0dca6;
  border: 2px solid #8a7238; cursor: pointer;
}

.raise-quick { display: flex; gap: 6px; margin-top: 4px; }
.chip-btn {
  flex: 1; appearance: none; font-family: inherit;
  background: rgba(255, 255, 255, .08); color: var(--text);
  border: 1px solid rgba(255, 255, 255, .15); border-radius: 8px;
  padding: 7px 2px; font-size: 12px; cursor: pointer;
}
.chip-btn:active { transform: scale(.95); }

.turn-timer { height: 3px; background: rgba(255, 255, 255, .1); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.turn-timer-fill { height: 100%; width: 100%; background: var(--gold); transition: width .25s linear; }
.turn-timer-fill.warn { background: var(--danger); }

.waiting-hint {
  padding: 14px 12px calc(14px + var(--safe-bottom));
  text-align: center; font-size: 13px; color: var(--text-dim);
  background: rgba(0, 0, 0, .3); flex-shrink: 0;
}

/* ─────────────── 结算浮层 ─────────────── */
/* ─────────────── 牌型提示 ─────────────── */
.hand-hint {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 6px auto 0; padding: 4px 14px;
  border: 1px solid rgba(227,189,107,.35); border-radius: 10px;
  background: linear-gradient(90deg, rgba(227,189,107,.10), rgba(227,189,107,.05));
  font-size: 13px; color: var(--gold); text-align: center; min-height: 28px;
  transition: opacity .25s;
}
.hand-hint.hidden { display: none; }
.hand-hint .hand-desc { font-weight: 600; }
.hand-hint .hand-kicker { font-size: 11px; color: var(--muted); margin-left: 4px; }

/* ─────────────── 结算弹窗 ─────────────── */
.result-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .62);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .18s ease-out both;
}
.result-card {
  background: linear-gradient(180deg, #123c30, #08211a);
  border: 1px solid var(--gold-dim); border-radius: 16px;
  padding: 20px 22px; max-width: 340px; width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .6);
  max-height: 80vh; overflow-y: auto;
}
.result-card h3 { margin: 0 0 12px; text-align: center; color: var(--gold); font-size: 18px; }
.result-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 13px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.07);
}
.result-row.winner { background: rgba(227,189,107,.08); margin: 0 -22px; padding: 8px 22px; border-bottom-color: rgba(227,189,107,.15); }
.result-row:last-child { border-bottom: none; }
.result-name { min-width: 0; }
.result-hand { font-size: 11px; color: var(--muted); margin-top: 1px; }
.result-hand.win { color: var(--gold); }
.result-reveal { display: flex; gap: 3px; margin-top: 3px; }
.result-win {
  color: var(--gold); font-weight: 700; font-size: 14px;
  white-space: nowrap; margin-left: auto; padding-left: 10px;
}
.result-close {
  display: block; margin: 12px auto 0;
  background: none; border: 1px solid var(--gold-dim); color: var(--gold-dim);
  border-radius: 8px; padding: 6px 24px; font-size: 12px; cursor: pointer;
  transition: .15s;
}
.result-close:hover { border-color: var(--gold); color: var(--gold); }
.result-cards { display: flex; gap: 3px; margin-top: 3px; }

/* ─────────────── 提示 ─────────────── */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(10px);
  background: rgba(0, 0, 0, .88); color: #fff; font-size: 13px;
  padding: 9px 18px; border-radius: 20px; z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: 84vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.conn-banner {
  position: fixed; top: var(--safe-top); left: 0; right: 0; z-index: 90;
  background: var(--danger); color: #fff; text-align: center;
  font-size: 12px; padding: 6px;
}

/* ─────────────── 小屏适配 ─────────────── */
@media (max-height: 700px) {
  .card { width: 42px; height: 60px; }
  .card .card-rank { font-size: 18px; }
  .card .card-suit { font-size: 15px; }
  .seat { width: 74px; }
}
@media (max-width: 340px) {
  .seat { width: 66px; }
  .action-row .btn { font-size: 13px; padding: 12px 4px; }
}
/* 桌面端：限制宽度，避免牌桌被拉得过大 */
@media (min-width: 720px) {
  #table-screen { max-width: 620px; margin: 0 auto; box-shadow: 0 0 60px rgba(0,0,0,.5); }
}
