/* ===== 高级赌场质感：自托管 Cinzel + 金属渐变 + 双层描边 + 胶片颗粒。主题色 --gold 由 game.js 按房间注入 ===== */
@font-face { font-family: "Cinzel"; font-style: normal; font-weight: 400 900; font-display: swap; src: url("fonts/cinzel-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Cinzel"; font-style: normal; font-weight: 400 900; font-display: swap; src: url("fonts/cinzel-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --gold: #e8c46a; --live: #ff3b5c;
  --ink: rgba(14, 10, 6, .74); --ink-2: rgba(6, 4, 2, .9);
  --line: color-mix(in srgb, var(--gold) 60%, transparent);
  --line-soft: color-mix(in srgb, var(--gold) 26%, transparent);
  --hi: color-mix(in srgb, var(--gold) 88%, #fff);   /* 金属高光 */
  --lo: color-mix(in srgb, var(--gold) 55%, #000);   /* 金属暗部 */
  --metal: linear-gradient(180deg, #fff6d5 0%, var(--hi) 28%, var(--lo) 52%, var(--gold) 68%, var(--hi) 100%);
  --serif: "Cinzel", "Didot", "Bodoni 72", "Songti SC", "Noto Serif SC", "Times New Roman", serif;
  --sans: -apple-system, "PingFang SC", "Helvetica Neue", "Noto Sans SC", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #07060a; color: #fff; font-family: var(--sans); overflow: hidden; }
body { display: flex; align-items: center; justify-content: center; }
#stage { position: relative; width: min(100vw, calc(100vh * 16 / 9)); aspect-ratio: 16 / 9; background: #111; overflow: hidden; font-size: clamp(10px, 1.1vw, 15px); }
#stage video, #stage img.fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#stage video { opacity: 0; transition: opacity .12s; }
#stage.fade video { transition: opacity .4s; }
#stage video.on { opacity: 1; }
/* 暗角 + 极淡颗粒：把视频和 UI 揉成一张"电影画面" */
#vignette { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: radial-gradient(ellipse at 50% 38%, transparent 52%, rgba(0,0,0,.5) 100%); }
#grain { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: .055; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

/* 金属字 */
.metal { background: var(--metal); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 1px 0 rgba(0,0,0,.6)); }

/* 身体热区：完全不可见，只让鼠标变小手 */
.hot { position: absolute; cursor: pointer; z-index: 3; }

/* ===== 面板材质：磨砂玻璃 + 双层描边（外金线、内暗线）+ 顶部高光 ===== */
.glass, #score, #liveBar, #badge, #chat {
  background: linear-gradient(180deg, var(--ink), var(--ink-2));
  border: 1px solid var(--line-soft);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), inset 0 0 0 1px rgba(0,0,0,.35), 0 12px 34px rgba(0,0,0,.5);
  backdrop-filter: blur(10px) saturate(1.2);
}

/* ===== 顶栏 ===== */
#topbar { position: absolute; top: 2.5%; left: 2%; right: 2%; z-index: 5; display: flex; align-items: center; gap: .6em; pointer-events: none; }
#topbar > * { pointer-events: auto; }
#badge { font-family: var(--serif); font-size: .74em; font-weight: 700; padding: .45em .95em; border-radius: 999px; letter-spacing: .14em; color: rgba(255,255,255,.7); text-transform: uppercase; }
#badge.live { color: #fff; border-color: var(--live); background: linear-gradient(180deg, rgba(255,59,92,.6), rgba(120,10,30,.75)); animation: pulse 1.2s infinite; }
#badge.flash { animation: flash .9s ease-out; }
@keyframes pulse { 50% { opacity: .65; } }
@keyframes flash { 0% { box-shadow: 0 0 0 0 var(--gold); border-color: var(--gold); } 100% { box-shadow: 0 0 0 16px transparent; } }
#liveBar { display: none; align-items: center; gap: .5em; font-size: .78em; font-weight: 600; padding: .4em .9em; border-radius: 999px; border-color: color-mix(in srgb, var(--live) 70%, transparent); box-shadow: 0 0 20px color-mix(in srgb, var(--live) 45%, transparent), inset 0 1px 0 rgba(255,255,255,.08); }
#liveBar.show { display: flex; }
#liveBar .dot { width: .55em; height: .55em; border-radius: 50%; background: var(--live); box-shadow: 0 0 8px var(--live); animation: pulse 1s infinite; }
#liveBar .t { font-family: var(--serif); font-variant-numeric: tabular-nums; color: var(--gold); min-width: 3.2em; }
#score { margin-left: auto; display: flex; align-items: center; gap: 1.2em; padding: .4em 1em .4em 1.1em; border-radius: 999px; }
#score .stat { display: flex; flex-direction: column; line-height: 1; min-width: 3.6em; }
#score .stat small { font-size: .6em; letter-spacing: .16em; opacity: .5; }
#score .stat b { font-family: var(--serif); font-size: 1.25em; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: .12em; }
#score button { height: 2.1em; padding: 0 .85em; font-size: .78em; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid var(--line-soft); letter-spacing: .08em; }
#score button.off { opacity: .45; text-decoration: line-through; }

/* ===== 结果大字 ===== */
#toast { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(.8); z-index: 6; font-family: var(--serif); font-size: 3.6em; font-weight: 800; letter-spacing: .1em; opacity: 0; pointer-events: none; white-space: nowrap;
  background: var(--metal); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 22px color-mix(in srgb, var(--gold) 55%, transparent)) drop-shadow(0 6px 16px rgba(0,0,0,.85)); }
#toast.show { animation: toast 1.15s ease-out forwards; }
#toast.lose { background: linear-gradient(180deg, #ffd6d6, #ff7b7b 45%, #b3222c 60%, #ff9a9a); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 0 22px rgba(255,80,80,.45)) drop-shadow(0 6px 16px rgba(0,0,0,.85)); }
#toast.push { background: linear-gradient(180deg, #fff, #cfcfcf 50%, #8a8a8a 60%, #eee); -webkit-background-clip: text; background-clip: text; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.7); } 15% { opacity: 1; transform: translate(-50%,-50%) scale(1.08); } 30% { transform: translate(-50%,-50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%,-62%) scale(1); } }
#toast i { position: absolute; left: 50%; top: 50%; width: .2em; height: .2em; border-radius: 50%; background: var(--hi); box-shadow: 0 0 10px var(--gold); animation: spark 1s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; } }

/* ===== 桌沿：皮革包边 + 金线镶嵌，下面是绒面 ===== */
#rail { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; height: 26%; padding: 1.2em 2% .8em; display: grid; grid-template-columns: 1fr 1.2fr 12em; gap: 0 2em; align-items: center; pointer-events: none;
  background: linear-gradient(180deg, rgba(10,7,4,.0), rgba(10,7,4,.62) 18%, rgba(6,4,2,.9) 100%), radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--gold) 16%, transparent), transparent 60%); }
#rail::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: .55em; background: linear-gradient(180deg, #3a2417, #1c110a 55%, #2a1a10); box-shadow: 0 2px 6px rgba(0,0,0,.6); }
#rail::after { content: ""; position: absolute; left: 0; right: 0; top: .55em; height: 1px; background: linear-gradient(90deg, transparent, var(--hi) 20%, var(--gold) 50%, var(--hi) 80%, transparent); opacity: .9; }
#rail button, #bets { pointer-events: auto; }
.hand { display: flex; gap: .9em; align-items: center; min-height: 5em; }
.hand .label { font-size: .68em; letter-spacing: .18em; opacity: .65; width: 3.4em; text-align: center; line-height: 1.2; }
.hand .label b { display: block; font-family: var(--serif); font-size: 2.3em; font-weight: 800; letter-spacing: 0; opacity: 1; margin-top: .1em; }
.hand.mine .label b { color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.8); }
.cards { display: flex; align-items: center; }
#status { margin-left: .8em; max-width: 9.5em; font-size: .8em; line-height: 1.35; opacity: .8; }
#status.win { color: var(--gold); opacity: 1; } #status.lose { color: #f87171; opacity: 1; }

/* ===== 扑克牌：纸纹、微微扇开、真牌背 ===== */
.card { position: relative; width: 4em; height: 5.6em; margin-right: -.45em; border-radius: .45em; color: #16161a; font-family: var(--serif);
  background: linear-gradient(160deg, #fffdf7, #eee9dc), repeating-linear-gradient(0deg, rgba(0,0,0,.015) 0 1px, transparent 1px 3px);
  box-shadow: 0 8px 18px rgba(0,0,0,.6), inset 0 0 0 1px rgba(0,0,0,.1), inset 0 0 0 .22em #fff; animation: deal .45s cubic-bezier(.2,.9,.3,1.2); transform-style: preserve-3d; }
.cards .card:nth-child(1) { transform: rotate(-4deg); } .cards .card:nth-child(2) { transform: rotate(-1deg); } .cards .card:nth-child(3) { transform: rotate(2deg); } .cards .card:nth-child(4) { transform: rotate(5deg); } .cards .card:nth-child(5) { transform: rotate(8deg); }
.cards .card:last-child { margin-right: 0; }
.card .rank { position: absolute; left: .38em; top: .32em; font-size: 1.05em; font-weight: 800; line-height: 1; }
.card .rank.rev { left: auto; top: auto; right: .38em; bottom: .32em; transform: rotate(180deg); }
.card .pip { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); font-size: 2.3em; line-height: 1; font-family: var(--sans); }
.card.red { color: #b3222c; }
.card.back { background: #6b0f1e repeating-linear-gradient(45deg, rgba(255,255,255,.07) 0 3px, transparent 3px 8px), repeating-linear-gradient(-45deg, rgba(0,0,0,.12) 0 3px, transparent 3px 8px); box-shadow: inset 0 0 0 .22em #f3e6c8, inset 0 0 0 .32em #6b0f1e, inset 0 0 0 .38em rgba(243,230,200,.5), 0 8px 18px rgba(0,0,0,.6); }
.card.back::after { content: "♠"; position: absolute; inset: 0; display: grid; place-items: center; color: rgba(243,230,200,.55); font-size: 1.6em; font-family: var(--sans); }
.card.flip { animation: flip .6s ease-out; }
.cards .card.dbl { transform: rotate(90deg) translateY(-.45em); margin: 0 .7em; }
@keyframes deal { from { transform: translate(-1em, -5em) rotate(-14deg) scale(.85); opacity: 0; } }
@keyframes flip { 0% { transform: rotateY(90deg); } 100% { transform: rotateY(0); } }

/* ===== 按钮：金属倒角 + 悬停流光 ===== */
#controls { display: flex; flex-direction: column; gap: .5em; justify-content: center; }
#controls button[hidden], #bets[hidden] { display: none; }
button { position: relative; overflow: hidden; flex: 0 0 auto; height: 2.7em; border: 1px solid var(--line-soft); border-radius: .7em; font-size: 1em; font-weight: 700; color: #fff; background: rgba(255,255,255,.08); cursor: pointer; white-space: nowrap; letter-spacing: .06em; transition: transform .08s, filter .15s; box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 4px 10px rgba(0,0,0,.4); }
button::after { content: ""; position: absolute; top: -50%; bottom: -50%; left: -60%; width: 40%; background: linear-gradient(105deg, transparent, rgba(255,255,255,.35), transparent); transform: skewX(-20deg); transition: left .5s ease; pointer-events: none; }
button:hover::after { left: 120%; }
button:hover { filter: brightness(1.1); } button:active { transform: translateY(1px); }
button kbd { font: inherit; font-size: .68em; opacity: .5; margin-left: .3em; }
button.primary { background: linear-gradient(180deg, var(--hi) 0%, var(--gold) 45%, var(--lo) 100%); color: #1a1200; border-color: color-mix(in srgb, var(--lo) 70%, #000); text-shadow: 0 1px 0 rgba(255,255,255,.35); box-shadow: inset 0 1px 0 rgba(255,255,255,.55), inset 0 -2px 0 rgba(0,0,0,.25), 0 6px 14px rgba(0,0,0,.5); }
button.gold { background: rgba(0,0,0,.4); color: var(--gold); border: 1px solid var(--gold); box-shadow: 0 0 18px color-mix(in srgb, var(--gold) 45%, transparent), inset 0 0 14px color-mix(in srgb, var(--gold) 22%, transparent); animation: glow 1.6s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 30px color-mix(in srgb, var(--gold) 75%, transparent), inset 0 0 14px color-mix(in srgb, var(--gold) 32%, transparent); } }
button.ghost { background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.35); }
button:disabled { opacity: .35; cursor: default; filter: none; }

/* 筹码：真筹码的边条（conic）+ 同心环 + 厚度 */
#bets { display: flex; gap: .55em; justify-content: center; }
/* 边条画在圆内、外面包一圈深色描边，圆的抗锯齿边就不会露出白毛边 */
#bets button { --c: #1f5fbf; width: 3.3em; height: 3.3em; padding: 0; border: 2px solid #17120c; border-radius: 50%; font-family: var(--serif); font-weight: 800; font-size: .84em; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7); letter-spacing: 0; background-clip: padding-box;
  background: radial-gradient(circle, var(--c) 0 44%, #f4efe4 44.5% 52%, var(--c) 52.5% 66%, transparent 66.5%), radial-gradient(circle, transparent 0 72%, #17120c 72.5%), repeating-conic-gradient(from 8deg, #f4efe4 0 14deg, var(--c) 14deg 45deg);
  box-shadow: 0 .25em 0 color-mix(in srgb, var(--c) 55%, #000), 0 .5em 10px rgba(0,0,0,.55), inset 0 0 0 1px rgba(0,0,0,.35), inset 0 1px 2px rgba(255,255,255,.35); transition: transform .12s, box-shadow .12s; }
#bets button::after { display: none; }
#bets button:hover { transform: translateY(-2px); }
#bets button.sel { transform: translateY(-5px) scale(1.1); box-shadow: 0 0 0 2px var(--gold), 0 0 16px color-mix(in srgb, var(--gold) 60%, transparent), 0 .25em 0 color-mix(in srgb, var(--c) 55%, #000), 0 .8em 14px rgba(0,0,0,.6), inset 0 1px 2px rgba(255,255,255,.45); }
#bets button.chip-1 { --c: #1f5fbf; } #bets button.chip-2 { --c: #b3222c; } #bets button.chip-3 { --c: #1c1c1e; }
#bets button.chip-4 { --c: #1b8a4b; } #bets button.chip-5 { --c: #6d2fa8; } #bets button.chip-6 { --c: #e07b1a; } #bets button.chip-7 { --c: #b8922e; }

/* ===== 聊天：右下角可折叠 ===== */
#chat { position: absolute; right: 2%; bottom: 28%; width: 26%; max-height: 58%; z-index: 5; display: flex; flex-direction: column; border-radius: 1em; overflow: hidden; }
#chat header { display: flex; align-items: center; gap: .6em; padding: .6em .9em; font-size: .78em; border-bottom: 1px solid var(--line-soft); background: linear-gradient(180deg, rgba(255,255,255,.04), transparent); }
#chat header .who { font-weight: 700; letter-spacing: .06em; }
#chat header #chatMode { margin-left: auto; opacity: .75; color: var(--live); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat header button { height: 1.9em; width: 1.9em; padding: 0; border-radius: .5em; font-size: 1em; background: rgba(255,255,255,.08); transition: transform .25s; box-shadow: none; }
#chat header button::after { display: none; }
#chat.collapsed header button { transform: rotate(180deg); }
#msgs { flex: 1; overflow-y: auto; padding: .6em .8em; display: flex; flex-direction: column; gap: .5em; max-height: 40vh; transition: max-height .3s; scrollbar-width: thin; }
#chat.collapsed #msgs { max-height: 8.2em; }
.msg { position: relative; max-width: 92%; padding: .55em .8em; border-radius: .9em; font-size: .92em; line-height: 1.4; }
.msg.me { align-self: flex-end; background: linear-gradient(180deg, var(--hi), var(--lo)); color: #1a1200; border-bottom-right-radius: .25em; box-shadow: inset 0 1px 0 rgba(255,255,255,.5); }
.msg.her { align-self: flex-start; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.1); border-bottom-left-radius: .25em; }
.msg.her.replay { cursor: pointer; border-color: color-mix(in srgb, var(--live) 55%, transparent); }
.msg.her.replay:hover { background: color-mix(in srgb, var(--live) 22%, transparent); }
.msg button.tip { display: block; width: 100%; margin-top: .45em; height: 2.2em; font-size: .9em; background: linear-gradient(180deg, var(--hi), var(--gold) 45%, var(--lo)); color: #1a1200; border-color: transparent; text-shadow: 0 1px 0 rgba(255,255,255,.35); }
.msg .meta { display: block; margin-top: .35em; font-size: .74em; opacity: .65; font-variant-numeric: tabular-nums; }
.msg .meta.live { color: var(--live); opacity: 1; }
.msg .prog { display: block; height: 3px; margin-top: .4em; border-radius: 2px; background: rgba(255,255,255,.12); overflow: hidden; }
.msg .prog::after { content: ""; display: block; height: 100%; width: 40%; background: linear-gradient(90deg, transparent, var(--live), transparent); animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
#chat form { display: flex; gap: .4em; padding: .55em; border-top: 1px solid var(--line-soft); }
#chat input { flex: 1; min-width: 0; height: 2.5em; border: 1px solid rgba(255,255,255,.1); border-radius: .6em; padding: 0 .8em; font-size: .92em; background: rgba(0,0,0,.4); color: #fff; outline: none; box-shadow: inset 0 2px 6px rgba(0,0,0,.5); }
#chat input:focus { border-color: var(--line); }
#chat input::placeholder { color: rgba(255,255,255,.4); }
#chat form button { width: 4.4em; height: 2.5em; background: linear-gradient(180deg, #ff6b87, #d5213f 55%, #8e1029); border-color: transparent; }
#hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); z-index: 5; font-size: 1.1em; background: var(--ink); border: 1px solid var(--line); padding: .6em 1.2em; border-radius: 999px; cursor: pointer; }

/* ===== 选桌：金框立绘卡 ===== */
#rooms { position: absolute; inset: 0; z-index: 7; display: none; align-items: center; justify-content: center; gap: 2.6em; background: radial-gradient(ellipse at 50% 28%, rgba(52,36,16,.92), rgba(4,3,2,.97) 70%); transition: opacity .45s, transform .45s; }
#rooms.show { display: flex; }
#rooms.leave { opacity: 0; transform: translateX(-4%); pointer-events: none; }
#roomsTitle { position: absolute; top: 9%; left: 0; right: 0; text-align: center; font-family: var(--serif); font-size: 2.1em; font-weight: 800; letter-spacing: .32em; background: var(--metal); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 26px color-mix(in srgb, var(--gold) 40%, transparent)); }
#roomsTitle::after { content: ""; display: block; width: 5em; height: 1px; margin: .55em auto 0; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.room { width: 21%; aspect-ratio: 3 / 4.2; border-radius: 1em; overflow: hidden; position: relative; cursor: pointer; background: #222 center 12% / cover no-repeat;
  box-shadow: 0 0 0 1px var(--line-soft), 0 0 0 .35em rgba(6,4,2,.9), 0 0 0 calc(.35em + 1px) var(--line-soft), 0 24px 60px rgba(0,0,0,.65); transition: transform .25s cubic-bezier(.2,.8,.3,1.2), box-shadow .25s; animation: rise .5s ease-out backwards; }
.room:nth-child(2) { animation-delay: .05s; } .room:nth-child(3) { animation-delay: .12s; } .room:nth-child(4) { animation-delay: .19s; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.room:hover { transform: translateY(-8px) scale(1.03); box-shadow: 0 0 0 1px var(--gold), 0 0 0 .35em rgba(6,4,2,.9), 0 0 0 calc(.35em + 1px) var(--gold), 0 30px 70px rgba(0,0,0,.7), 0 0 40px color-mix(in srgb, var(--gold) 35%, transparent); }
.room .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 3.4em 1.1em 1.1em; background: linear-gradient(to top, rgba(0,0,0,.94) 30%, transparent); }
.room .cap b { display: block; font-family: var(--serif); font-size: 1.75em; font-weight: 800; letter-spacing: .14em; background: var(--metal); -webkit-background-clip: text; background-clip: text; color: transparent; }
.room .cap .rt { display: block; font-size: .78em; letter-spacing: .22em; color: var(--gold); margin: .25em 0 .4em; }
.room .cap small { display: block; opacity: .72; font-size: .78em; line-height: 1.45; }
.room.locked { cursor: not-allowed; filter: grayscale(.85) brightness(.55); }
.room.locked:hover { transform: none; box-shadow: 0 0 0 1px var(--line-soft), 0 0 0 .35em rgba(6,4,2,.9), 0 0 0 calc(.35em + 1px) var(--line-soft), 0 24px 60px rgba(0,0,0,.65); }
.room .lock { position: absolute; top: .9em; right: .9em; background: rgba(0,0,0,.8); border: 1px solid var(--line-soft); padding: .35em .75em; border-radius: 999px; font-size: .78em; letter-spacing: .05em; }

/* ===== 加载 / 结束 ===== */
#loading { position: absolute; inset: 0; z-index: 8; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 1em; background: rgba(4,3,2,.86); }
#loading.show { display: flex; }
#loading .who { font-family: var(--serif); font-size: 1.6em; font-weight: 800; letter-spacing: .18em; background: var(--metal); -webkit-background-clip: text; background-clip: text; color: transparent; }
#loading .bar { width: 34%; height: .45em; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; border: 1px solid var(--line-soft); box-shadow: inset 0 2px 4px rgba(0,0,0,.6); }
#loading .bar div { height: 100%; width: 0; background: linear-gradient(90deg, var(--lo), var(--gold), var(--hi)); transition: width .15s; }
#loading .txt { font-size: .85em; opacity: .7; font-variant-numeric: tabular-nums; letter-spacing: .1em; }
#over { position: absolute; inset: 0; z-index: 6; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 1em; background: rgba(4,3,2,.82); }
#over.show { display: flex; }
#over h1 { margin: 0; font-family: var(--serif); font-size: 3.2em; font-weight: 800; letter-spacing: .18em; background: var(--metal); -webkit-background-clip: text; background-clip: text; color: transparent; }
#over p { margin: 0; opacity: .8; }
#over button { padding: 0 2.4em; height: 3em; }

/* ===== 入口页：介绍视频铺底 + 金属标题 ===== */
#splash { position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; background: #07060a; transition: opacity .7s; }
#splash.leave { opacity: 0; pointer-events: none; }
#splash video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .75; }
#splash .veil { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,.15), rgba(0,0,0,.78) 75%), linear-gradient(180deg, rgba(0,0,0,.35), transparent 30%, transparent 70%, rgba(0,0,0,.6)); }
#splash .inner { position: relative; text-align: center; animation: rise .8s ease-out both; }
#splash .eyebrow { font-family: var(--serif); font-size: .8em; letter-spacing: .5em; color: var(--gold); opacity: .85; margin-bottom: .8em; }
#splash h1 { margin: 0; font-family: var(--serif); font-size: 5.2em; font-weight: 800; line-height: .95; letter-spacing: .06em; background: var(--metal); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 30px color-mix(in srgb, var(--gold) 45%, transparent)) drop-shadow(0 8px 24px rgba(0,0,0,.9)); }
#splash p { margin: 1.2em 0 2em; font-size: 1.05em; letter-spacing: .18em; opacity: .85; text-shadow: 0 2px 10px #000; }
#splash #enter { font-size: 1.15em; height: 3em; padding: 0 3.2em; letter-spacing: .3em; border-radius: 999px; box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 0 40px color-mix(in srgb, var(--gold) 45%, transparent), inset 0 1px 0 rgba(255,255,255,.6); }

/* 选桌骨架：立绘图没到之前显示流动的占位 */
.room.skel { background-image: none !important; background-color: #1a1410; }
.room.skel::before { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.06) 50%, transparent 70%); background-size: 220% 100%; animation: skel 1.4s linear infinite; }
@keyframes skel { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.room.skel .cap { opacity: .35; }

/* 首次引导：三条气泡指向荷官 / 聊天 / 开局 */
#guide { position: absolute; inset: 0; z-index: 6; display: none; pointer-events: none; }
#guide.show { display: block; }
#guide .tip { position: absolute; font-size: .9em; padding: .55em .9em; border-radius: .8em; background: var(--ink-2); border: 1px solid var(--gold); color: #fff; box-shadow: 0 0 24px color-mix(in srgb, var(--gold) 40%, transparent); animation: rise .5s ease-out both; white-space: nowrap; }
#guide .tip::after { content: ""; position: absolute; width: .7em; height: .7em; background: var(--ink-2); border: 1px solid var(--gold); border-width: 0 1px 1px 0; transform: rotate(45deg); }
#guide .tip[data-at="dealer"] { left: 50%; top: 44%; transform: translateX(-50%); }
#guide .tip[data-at="dealer"]::after { left: 50%; bottom: -.4em; margin-left: -.35em; }
#guide .tip[data-at="chat"] { right: 3%; bottom: 43%; animation-delay: .25s; }
#guide .tip[data-at="chat"]::after { right: 1.2em; bottom: -.4em; }
#guide .tip[data-at="deal"] { right: 3%; bottom: 20%; animation-delay: .5s; }
#guide .tip[data-at="deal"]::after { right: 1.2em; bottom: -.4em; }
#guide .tip b { color: var(--gold); font-weight: 700; }

/* 分牌：两手并排，当前手抬起发光，爆掉的手压暗 */
.split-hand { display: flex; align-items: flex-end; gap: 0; padding: .25em .35em .25em .25em; border-radius: .6em; border: 1px solid transparent; transition: transform .2s, border-color .2s, box-shadow .2s; }
.split-hand.active { border-color: var(--gold); box-shadow: 0 0 16px color-mix(in srgb, var(--gold) 45%, transparent); transform: translateY(-.3em); }
.split-hand.busted { opacity: .45; filter: grayscale(.6); }
.split-hand .ht { font-family: var(--serif); font-size: 1.2em; font-weight: 800; margin-left: .55em; color: #fff; text-shadow: 0 2px 6px #000; }
.split-hand.active .ht { color: var(--gold); }
.split-sep { align-self: center; margin: 0 .3em; opacity: .4; }

/* A dedicated black-gold header keeps language buttons clear of the dealer, scores and chat. */
body { padding-top:64px; }
#stage { width:min(100vw,calc((100vh - 64px) * 16 / 9)); width:min(100vw,calc((100dvh - 64px) * 16 / 9)); }
#languageControl { position:fixed;top:max(4px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right));z-index:200;display:flex;align-items:center;gap:4px;padding:4px;background:#1a1510;border:1px solid #927644;border-radius:999px;box-shadow:inset 0 1px 0 #f4deb033,0 4px 16px #0006; }
#languageControl button { appearance:none;min-width:48px;min-height:44px;height:auto;padding:8px 12px;border:1px solid transparent;border-radius:999px;background:#1a1510;color:#f4deb0;font:700 13px/20px var(--serif);letter-spacing:.04em;text-shadow:none;box-shadow:none;touch-action:manipulation; }
#languageControl button::after { display:none; }
#languageControl button[aria-pressed=true] { background:#e4c877;color:#22190a;border-color:#f4deb0;box-shadow:inset 0 1px 0 #fff4; }
#languageControl button:hover:not([aria-pressed=true]) { background:#342819;color:#fff1ce; }
#languageControl button:focus-visible { outline:2px solid #fff1bd;outline-offset:2px; }
@supports(padding-top:env(safe-area-inset-top)) { body { padding-top:calc(64px + env(safe-area-inset-top)); } #stage { width:min(100vw,calc((100dvh - 64px - env(safe-area-inset-top)) * 16 / 9)); } }
html[lang=en] #chat { min-width:min(420px,90vw); }

@media (orientation: portrait) {
  body {padding-top: 0;}
  #languageControl {top: max(8px, calc((100dvh - 100vw * 9 / 16) / 2 - 62px));}
}

/* ===== H5 手机适配：竖屏优先 =====
   竖屏时舞台不再做 16:9 信箱，而是铺满整屏（视频本来就是 object-fit: cover，荷官居中不会被切到）；
   桌沿和聊天改成文档流里的两层底部面板，其余浮层保持绝对定位。 */
button, #bets button, #languageControl button { touch-action: manipulation; }
html { -webkit-text-size-adjust: 100%; }

@media (orientation: portrait) and (max-width: 860px) {
  body { padding-top: 0; }
  #stage { width: 100vw; height: 100dvh; aspect-ratio: auto; font-size: clamp(12px, 3.5vw, 17px);
           display: flex; flex-direction: column; justify-content: flex-end; }

  #languageControl { top: max(6px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
  #languageControl button { min-width: 44px; padding: 8px 10px; font-size: 12px; }

  /* 顶栏：第一行牌库/生成状态（右上角留给语言键），第二行余额战绩铺满整行 */
  #topbar { top: max(6px, env(safe-area-inset-top)); left: 3%; right: 3%;
            display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: minmax(48px, auto) auto; gap: .5em; }
  #badge { grid-area: 1 / 1; justify-self: start; align-self: start; }
  #liveBar { grid-area: 1 / 2; justify-self: start; align-self: start; margin-right: 104px; }
  #score { grid-area: 2 / 1 / 3 / 3; margin-left: 0; width: auto; padding: .45em .8em; gap: .6em;
           justify-content: space-between; }
  #score .stat { min-width: 0; }
  #score .stat b { white-space: nowrap; }
  #score button { flex: 0 0 auto; min-height: 38px; }

  /* 桌沿：上排两手牌并排，下排按钮和筹码 */
  #rail { position: relative; order: 2; height: auto; display: grid; grid-template-columns: 1fr 1fr;
          gap: .5em .8em; padding: .9em 3% calc(.7em + env(safe-area-inset-bottom));
          align-items: start; pointer-events: auto; }
  #rail > * { pointer-events: auto; }
  .hand { min-height: 0; gap: .5em; align-items: flex-start; flex-wrap: wrap; }
  .hand .label { width: auto; min-width: 2.6em; text-align: left; }
  .hand .label b { font-size: 1.9em; }
  .card { width: 3.1em; height: 4.4em; margin-right: -.5em; }
  .card .pip { font-size: 1.8em; }
  #status { margin-left: 0; flex-basis: 100%; max-width: none; font-size: .78em; }
  #controls { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; gap: .45em; }
  #controls > button { flex: 1 1 calc(50% - .25em); min-height: 2.9em; height: auto; }
  #deal { flex-basis: 100%; }
  #bets { flex: 1 1 100%; flex-wrap: wrap; gap: .45em; }
  #bets button { width: 2.9em; height: 2.9em; }
  button kbd { display: none; }

  /* 聊天：铺在桌沿上面的一层，收起时只占一小条 */
  #chat { position: relative; order: 1; right: auto; bottom: auto; width: auto; margin: 0 3% .5em; max-height: 46dvh; }
  #msgs { max-height: 26dvh; }
  #chat.collapsed #msgs { max-height: 5.4em; }
  #chat input { font-size: 16px; }
  html[lang=en] #chat { min-width: 0; }

  /* 选桌：改成可横向滑动的大卡片 */
  #rooms { justify-content: flex-start; align-items: center; gap: .8em; padding: 24% .8em 6%;
           overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; }
  .room { flex: 0 0 62%; width: auto; scroll-snap-align: center; }
  .room .cap { padding: 2.4em .9em .9em; }
  .room .cap b { font-size: 1.4em; }
  #roomsTitle { top: 7%; font-size: 1.5em; letter-spacing: .22em; }

  /* 入口页与提示 */
  #splash h1 { font-size: 4em; }
  #splash p { margin: 1em 1.5em 1.6em; font-size: .95em; letter-spacing: .1em; }
  #splash #enter { padding: 0 2.4em; letter-spacing: .22em; }
  #loading .bar { width: 70%; }
  #guide .tip { white-space: normal; max-width: 70vw; }
  #guide .tip[data-at="chat"] { right: 4%; bottom: 46%; }
  #guide .tip[data-at="deal"] { right: 4%; bottom: 32%; }
  #over h1 { font-size: 2.6em; text-align: center; }
  #toast { font-size: 3em; }
}

/* 手机横屏：去掉给语言键留的整条顶栏，让画面按高度铺满；聊天收窄，别盖住半张桌子 */
@media (orientation: landscape) and (max-height: 520px) {
  body { padding-top: 0; }
  #stage { width: min(100vw, calc(100dvh * 16 / 9)); font-size: clamp(11px, 2vw, 15px); }
  #languageControl { top: max(4px, env(safe-area-inset-top)); }
  #topbar { padding-right: 104px; }
  #score button { min-height: 34px; }
  #chat { width: 32%; max-height: 52%; }
  html[lang=en] #chat { min-width: min(300px, 44vw); }
  #msgs { max-height: 22dvh; }
  #chat.collapsed #msgs { max-height: 5em; }
  #chat input { font-size: 16px; }
  #rail { height: auto; min-height: 26%; padding-bottom: calc(.8em + env(safe-area-inset-bottom)); }
  button kbd { display: none; }
}

/* 横屏分牌：网格可收缩，避免两手牌把操作列挤出舞台。 */
@media (orientation: landscape) and (max-height: 520px) {
  #rail { grid-template-columns: minmax(0, .9fr) minmax(0, 1.6fr) minmax(108px, .9fr); gap: 0 .75em; }
  .hand { min-width: 0; flex-wrap: wrap; gap: .35em; }
  .cards { min-width: 0; max-width: 100%; flex-wrap: wrap; }
  .card { width: 2.6em; height: 3.7em; }
  .card .pip { font-size: 1.6em; }
  #pCards { gap: .3em; }
  .split-hand { max-width: 100%; padding: .15em; }
  .split-hand .ht { font-size: .9em; margin-left: .25em; }
  .split-sep { display: none; }
  #status { flex-basis: 100%; max-width: 100%; margin: 0; font-size: .7em; }
  #controls { min-width: 0; }
  #controls > button { width: 100%; white-space: normal; }
}
