/* 家庭牌桌：深绿台面、白牌。手机竖屏优先，电脑自动放大。 */
:root {
  --felt: #1d5a3c; --felt-d: #123d2a; --felt-l: #2a7350;
  --ink: #f2efe6; --muted: #a9c2b4; --gold: #e8c45a; --red: #d23c3c; --black: #1b1f27;
  --card-w: 46px; --card-h: 66px; --overlap: -30px;
  --panel: rgba(8, 28, 19, 0.55); --line: rgba(255, 255, 255, 0.12);
  font-family: system-ui, -apple-system, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: radial-gradient(120% 90% at 50% 30%, var(--felt-l), var(--felt) 45%, var(--felt-d)); color: var(--ink); min-height: 100vh; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.08); border-radius: 10px; padding: 8px 14px; touch-action: manipulation; }
button:disabled { opacity: 0.35; cursor: default; }
button.primary { background: var(--gold); color: #2b2208; border-color: transparent; font-weight: 600; }
button.danger { background: transparent; border-color: rgba(210, 60, 60, 0.6); color: #f2a0a0; }
button.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
button.big { padding: 12px 28px; font-size: 17px; }
button.ghost { background: transparent; }
button.link, a.link { background: none; border: none; color: var(--muted); padding: 4px 6px; text-decoration: none; font-size: 14px; }
input { font: inherit; width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); color: var(--ink); font-size: 16px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.err { color: #ffb4a8; }

/* 顶栏 */
header.top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(0, 0, 0, 0.18); }
.brand { color: var(--ink); text-decoration: none; font-weight: 700; font-size: 17px; }
.net { width: 9px; height: 9px; border-radius: 50%; background: #777; }
.net.open { background: #5fd38d; } .net.connecting { background: var(--gold); } .net.closed { background: var(--red); }
#who { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 14px; }
main { padding: 12px 16px 40px; max-width: 1100px; margin: 0 auto; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: rgba(0, 0, 0, 0.82); padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none; transition: 0.25s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 登录 */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.login { max-width: 360px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0; font-size: 24px; }
.login p { margin: 0; }
.user-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.user-pick { padding: 14px; font-size: 18px; font-weight: 700; letter-spacing: 0.05em; }
.user-pick.on { background: var(--gold); color: #2b2208; border-color: transparent; }

/* 大厅 */
.lobby h2 { font-size: 16px; color: var(--muted); font-weight: 600; margin: 18px 0 10px; }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.game { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.game .icon { font-size: 30px; }
.game .gname { font-weight: 700; font-size: 17px; }
.game .gdesc { font-size: 13px; color: var(--muted); flex: 1; }
.game.soon { opacity: 0.5; }
.rooms { display: flex; flex-direction: column; gap: 8px; }
.room-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--ink); text-decoration: none; }
.room-row .rname { font-weight: 600; }
.rstatus { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); }
.rstatus.playing { background: rgba(232, 196, 90, 0.25); color: var(--gold); }
.rseats { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; font-size: 13px; }
.dot::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; background: #777; vertical-align: 1px; }
.dot.on::before { background: #5fd38d; } .dot.bot::before { background: #8ab4f8; } .dot.empty { color: var(--muted); } .dot.empty::before { background: transparent; border: 1px solid var(--muted); }

/* 等人：选座位 */
.room-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.room-head h2 { margin: 8px 0; font-size: 20px; }
.seat-table { position: relative; width: min(100%, 460px); aspect-ratio: 1; margin: 12px auto; }
.seat-table .felt { position: absolute; inset: 22%; border-radius: 18px; background: rgba(0, 0, 0, 0.22); border: 2px solid rgba(232, 196, 90, 0.35); display: grid; place-items: center; color: var(--muted); font-size: 18px; }
.seat { position: absolute; width: 38%; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.seat.mine { border-color: var(--gold); }
.seat-name { font-size: 13px; color: var(--muted); }
.seat .who { font-weight: 700; margin: 0; }
.seat .who.off { color: var(--muted); }
.seat button { width: 100%; }
.n4 .pos0 { top: 0; left: 31%; } .n4 .pos1 { right: 0; top: 34%; width: 30%; } .n4 .pos2 { bottom: 0; left: 31%; } .n4 .pos3 { left: 0; top: 34%; width: 30%; }
.bar { display: flex; justify-content: center; gap: 12px; margin-top: 8px; }

/* ---------- 扑克牌 ---------- */
.card { position: relative; width: var(--card-w); height: var(--card-h); border-radius: 6px; background: #fbfaf6; color: var(--black); border: 1px solid #c9c4b8; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); padding: 0; flex: 0 0 auto; font-weight: 700; }
.card.red { color: var(--red); }
.card .r { position: absolute; left: 4px; top: 2px; font-size: 15px; line-height: 1; letter-spacing: -0.04em; }
.card .s { position: absolute; left: 4px; top: 18px; font-size: 13px; line-height: 1; }
.card .pip { position: absolute; right: 4px; bottom: 2px; font-size: 22px; line-height: 1; opacity: 0.9; }
.card.back { background: repeating-linear-gradient(45deg, #2c4f8c 0 4px, #24427a 4px 8px); border: 2px solid #f5f2ea; }
.card.dim { filter: brightness(0.62); }
.card.playable { cursor: pointer; }
.card.playable:hover, .card.playable:focus-visible { transform: translateY(-10px); outline: none; }
.card.win { box-shadow: 0 0 0 3px var(--gold); }
.backs { display: flex; align-items: center; position: relative; }
.backs .card { width: 22px; height: 32px; margin-left: -16px; border-width: 1px; border-radius: 3px; }
.backs .card:first-child { margin-left: 0; }
.backs .count { margin-left: 8px; font-size: 13px; color: var(--muted); }

/* ---------- 桥牌 ---------- */
.bridge { display: flex; flex-direction: column; gap: 10px; }
.b-info { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.pill { background: rgba(0, 0, 0, 0.25); padding: 3px 10px; border-radius: 999px; }
.pill.vul { background: rgba(210, 60, 60, 0.35); }
.pill.strong { background: rgba(232, 196, 90, 0.25); color: var(--gold); font-weight: 600; }
.b-info .link { margin-left: auto; }
.b-table { display: grid; grid-template-columns: 1fr minmax(0, 1.6fr) 1fr; grid-template-areas: ". top ." "left center right" "bottom bottom bottom"; gap: 8px; align-items: center; }
.b-player { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.b-player.top { grid-area: top; } .b-player.left { grid-area: left; } .b-player.right { grid-area: right; } .b-player.bottom { grid-area: bottom; }
.b-tag { display: flex; align-items: center; gap: 6px; font-size: 13px; background: rgba(0, 0, 0, 0.25); padding: 3px 10px; border-radius: 999px; white-space: nowrap; max-width: 100%; overflow: hidden; }
.b-player.turn .b-tag { background: var(--gold); color: #2b2208; }
.b-dir { font-weight: 700; }
.b-name.off { opacity: 0.6; }
.b-role { font-size: 11px; padding: 0 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.18); }
.b-center { grid-area: center; display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 180px; justify-content: center; }
.b-trick { position: relative; width: 170px; height: 170px; }
.b-trick .card { position: absolute; }
.b-trick .at-top { left: calc(50% - var(--card-w) / 2); top: 0; }
.b-trick .at-bottom { left: calc(50% - var(--card-w) / 2); bottom: 0; }
.b-trick .at-left { left: 0; top: calc(50% - var(--card-h) / 2); }
.b-trick .at-right { right: 0; top: calc(50% - var(--card-h) / 2); }
.b-trick.last { opacity: 0.75; }

.hand.fan { display: flex; justify-content: center; padding-top: 12px; max-width: 100%; }
.hand.fan .card { margin-left: var(--overlap); }
.hand.fan .card:first-child { margin-left: 0; }
.hand.rows { display: flex; flex-direction: column; gap: 2px; font-size: 14px; background: rgba(0, 0, 0, 0.18); padding: 6px 8px; border-radius: 10px; }
.suit-row { display: flex; align-items: center; gap: 3px; min-height: 24px; flex-wrap: wrap; }
.suit-sym { width: 16px; font-size: 15px; }
.suit-sym.red, .mini.red { color: #ff8a80; } .suit-sym.black, .mini.black { color: #f2efe6; }
.mini { font-weight: 700; padding: 1px 3px; border: none; background: none; border-radius: 5px; font-size: 15px; }
button.mini.playable { background: #fbfaf6; color: var(--black); padding: 2px 6px; }
button.mini.playable.red { color: var(--red); }

.auction { display: grid; gap: 2px; font-size: 14px; background: rgba(0, 0, 0, 0.22); border-radius: 10px; padding: 8px; min-width: 200px; }
.a-row { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 4px; }
.a-row.head { color: var(--muted); font-size: 12px; }
.call { font-weight: 700; }
.call.red { color: #ff8a80; } .call.nt { color: var(--gold); } .call.pass { color: var(--muted); font-weight: 400; } .call.x { color: #ff8a80; } .call.xx { color: #8ab4f8; }
.q { color: var(--gold); }

.b-action { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hint { color: var(--gold); font-weight: 600; margin: 0; }
.bidbox { background: rgba(0, 0, 0, 0.28); padding: 10px; border-radius: 12px; width: min(100%, 420px); }
.bids { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.bid { padding: 8px 0; font-weight: 700; background: #fbfaf6; color: var(--black); border: none; border-radius: 7px; }
.bid.red { color: var(--red); } .bid.nt { color: #6b4e00; }
.bid:disabled { opacity: 0.18; }
.bid-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 6px; margin-top: 8px; }
.bid.special { background: rgba(255, 255, 255, 0.12); color: var(--ink); }
.bid.special.pass { background: #3e9e6a; color: #fff; }
.bid.special.x { background: #b63a3a; color: #fff; }
.bid.special.xx { background: #3a62b6; color: #fff; }
.result { text-align: center; background: rgba(0, 0, 0, 0.25); padding: 14px 18px; border-radius: 14px; }
.result h3 { margin: 0 0 6px; font-size: 16px; }
.big-score { font-size: 26px; font-weight: 800; color: var(--gold); margin: 6px 0 12px; }
.history { background: rgba(0, 0, 0, 0.2); border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.history table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.history th, .history td { padding: 4px 6px; text-align: center; border-bottom: 1px solid var(--line); }

/* 10 太宽：收窄 */
.card .r.ten { letter-spacing: -0.14em; font-size: 13px; left: 2px; }

/* 手机竖屏：中间区域单独一行，左右两家并排，不和叫牌记录挤 */
@media (max-width: 600px) {
  .b-table { grid-template-columns: 1fr 1fr; grid-template-areas: "top top" "left right" "center center" "bottom bottom"; }
  .b-player.left { align-items: flex-start; } .b-player.right { align-items: flex-end; }
  .b-center { min-height: 0; }
}

@media (min-width: 720px) {
  .card .r.ten { font-size: 16px; }
  :root { --card-w: 62px; --card-h: 88px; --overlap: -26px; }
  .card .r { font-size: 19px; } .card .s { top: 22px; font-size: 16px; } .card .pip { font-size: 30px; }
  .b-trick { width: 240px; height: 230px; }
  .b-center { min-height: 250px; }
}
@media (max-width: 380px) {
  :root { --card-w: 40px; --card-h: 58px; --overlap: -27px; }
  main { padding: 8px 10px 30px; }
}

/* ---------- 桌子页：选位子、选游戏 ---------- */
.step { text-align: center; font-size: 17px; font-weight: 600; color: var(--gold); margin: 6px 0 0; }
.waiting .games { margin-top: 8px; }
.game .ghost.small { margin-top: 2px; }
.seat .who.bot { color: var(--muted); font-weight: 400; }
.notice { text-align: center; margin: 0; color: var(--gold); font-size: 14px; }

/* ---------- 王 ---------- */
.card.joker .jk { position: absolute; left: 3px; top: 3px; font-size: 11px; writing-mode: vertical-rl; letter-spacing: 0.05em; }
.card.joker .pip { font-size: 20px; }

/* ---------- 升级 ---------- */
.shengji { display: flex; flex-direction: column; gap: 8px; }
.sj-table { grid-template-areas: ". top ." "left center right" "bottom bottom bottom"; }
.sj-center { min-height: 200px; width: 100%; }
.sj-trick { display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-areas: ". t ." "l . r" ". b ."; gap: 4px; width: 100%; min-height: 190px; align-items: center; }
.sj-slot { display: flex; justify-content: center; flex-wrap: wrap; padding-left: 22px; min-height: 10px; }
.sj-slot .card, .sj-mini .card, .decl .card { --card-w: 34px; --card-h: 48px; margin-left: -22px; }
.sj-slot .card .r, .sj-mini .card .r, .decl .card .r { font-size: 12px; left: 2px; }
.sj-slot .card .s, .sj-mini .card .s, .decl .card .s { top: 14px; font-size: 10px; left: 2px; }
.sj-slot .card .pip, .sj-mini .card .pip, .decl .card .pip { font-size: 15px; }
.sj-slot .card.joker .jk, .sj-mini .card.joker .jk, .decl .card.joker .jk { font-size: 9px; }
.sj-slot.at-top { grid-area: t; } .sj-slot.at-left { grid-area: l; } .sj-slot.at-right { grid-area: r; } .sj-slot.at-bottom { grid-area: b; }
.sj-slot.win .card { box-shadow: 0 0 0 2px var(--gold); }
.sj-trick.last { opacity: 0.75; }
.small-note { margin: 0; font-size: 13px; }
.decl { display: flex; align-items: center; gap: 6px; padding-left: 22px; }
.decl span { margin-right: 22px; }
.sj-hand { display: flex; flex-wrap: wrap; justify-content: center; padding: 14px 0 0 30px; max-width: 100%; row-gap: 18px; }
.sj-hand .card { margin-left: -30px; }
.card.sel { transform: translateY(-12px); box-shadow: 0 0 0 2px var(--gold), 0 4px 8px rgba(0, 0, 0, 0.4); }
.sj-hand .card.playable:hover { transform: none; }
.sj-hand .card.playable.sel:hover { transform: translateY(-12px); }
.sj-opts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.sj-buried { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; font-size: 13px; margin: 6px 0; }
.sj-mini { display: flex; padding-left: 22px; }
@media (max-width: 600px) {
  .sj-table { grid-template-columns: 1fr 1fr; grid-template-areas: "top top" "left right" "center center" "bottom bottom"; }
}
@media (min-width: 720px) {
  .sj-hand .card { margin-left: -38px; }
  .sj-hand { padding-left: 38px; }
}

/* ---------- 德州 ---------- */
.holdem { display: flex; flex-direction: column; gap: 8px; }
.holdem .b-player { background: rgba(0, 0, 0, 0.15); border-radius: 12px; padding: 6px; }
.holdem .b-player.folded { opacity: 0.45; }
.chips { font-size: 13px; color: var(--muted); }
.hole { display: flex; gap: 3px; min-height: 48px; }
.hole .card, .board .card, .bj-cards .card { --card-w: 40px; --card-h: 56px; }
.hole .card .pip, .board .card .pip, .bj-cards .card .pip { font-size: 18px; }
.act-line { display: flex; gap: 6px; align-items: center; font-size: 13px; min-height: 20px; flex-wrap: wrap; justify-content: center; }
.bet-chip { background: var(--gold); color: #2b2208; border-radius: 999px; padding: 0 8px; font-weight: 700; }
.win-amt { color: #5fd38d; font-weight: 700; }
.hand-name { color: var(--gold); }
.dealer-btn { background: #fbfaf6; color: #222; font-weight: 800; border-radius: 50%; padding: 0 5px; }
.board { display: flex; gap: 4px; justify-content: center; }
.card.slot { background: rgba(255, 255, 255, 0.06); border: 1px dashed rgba(255, 255, 255, 0.25); box-shadow: none; }
.pot { font-weight: 700; color: var(--gold); }
.raise-box { display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(100%, 420px); background: rgba(0, 0, 0, 0.22); border-radius: 12px; padding: 10px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.presets .on { background: var(--gold); color: #2b2208; }
.raise-box input[type=range] { padding: 0; accent-color: var(--gold); }
@media (min-width: 720px) {
  .hole .card, .board .card, .bj-cards .card { --card-w: 56px; --card-h: 78px; }
  .hole .card .pip, .board .card .pip, .bj-cards .card .pip { font-size: 26px; }
}

/* ---------- 21 点 ---------- */
.blackjack { display: flex; flex-direction: column; gap: 10px; }
.bj-dealer { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bj-cards { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.bj-seats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.bj-seat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; }
.bj-seat.mine { border-color: var(--gold); }
.bj-seat.turn { box-shadow: 0 0 0 2px var(--gold); }
.bj-hand { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; border-radius: 8px; }
.bj-hand.cur { background: rgba(232, 196, 90, 0.18); }
.bj-res { font-weight: 700; }
.bj-res.win, .bj-res.bj { color: #5fd38d; } .bj-res.lose, .bj-res.bust { color: #ff8a80; } .bj-res.push { color: var(--muted); }
.chip-btn { border-radius: 999px; background: #fbfaf6; color: #2b2208; font-weight: 700; border: 3px dashed #c33; min-width: 64px; }

.bar button { white-space: nowrap; }
.blackjack .bar { flex-wrap: wrap; gap: 8px; }
.blackjack .bar .big { padding: 12px 18px; }
.final-rank { margin: 0; padding-left: 22px; text-align: left; }
.chip-btn { min-width: 72px; }

.bj-counter { background: rgba(0, 0, 0, 0.2); border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.bj-count-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.bj-count { background: rgba(255, 255, 255, 0.06); border-radius: 8px; padding: 4px; text-align: center; }
.bj-count .rk { font-weight: 700; font-size: 13px; }
.bj-count .n { font-size: 12px; color: var(--muted); }
.bj-count.gone { opacity: 0.4; }
.meter { height: 4px; background: rgba(255, 255, 255, 0.12); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.meter > div { height: 100%; background: var(--gold); }
@media (min-width: 720px) { .bj-count-grid { grid-template-columns: repeat(10, 1fr); } }

.blind { font-weight: 700; }
.blind.sb { background: #8ab4f8; color: #10213f; } .blind.bb { background: #e8c45a; color: #2b2208; }
.cheat-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.cheat-row.mine { background: rgba(232, 196, 90, 0.15); border-radius: 8px; }
.cheat-rank { font-weight: 800; color: var(--gold); text-align: center; }
.cheat-name { font-weight: 700; }
.cheat-text .muted { font-size: 12px; }
.cheat .sj-mini .card { --card-w: 28px; --card-h: 40px; margin-left: -12px; }
.cheat .sj-mini .card .pip { display: none; }
@media (max-width: 420px) { .cheat-row { grid-template-columns: 22px 1fr; } .cheat-row .sj-mini { grid-column: 2; } }

.teach-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; background: rgba(138, 180, 248, 0.18); border: 1px solid rgba(138, 180, 248, 0.45); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; font-size: 14px; }
.teach-tag { font-weight: 700; color: #b9d1ff; }
.teach-seats { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.teach-seats .on { background: #8ab4f8; color: #10213f; }
.teach-panel { margin: 10px 0; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.teach-panel p { margin: 0; font-size: 13px; }
