/* ============================================================
   炸金花 · 样式表
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #070b10;
  color: #e8eef5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-0: #070b10;
  --bg-1: #0d141c;
  --bg-2: #16202b;
  --bg-3: #1e2b38;
  --line: rgba(255,255,255,.08);
  --gold: #e8c37a;
  --gold-2: #f9e6b8;
  --gold-dim: #8a7443;
  --red: #e5484d;
  --green: #46a758;
  --blue: #4a9eff;
  --txt: #e8eef5;
  --txt-dim: #90a3b6;
  --felt-1: #2c9563;
  --felt-2: #12603c;
  --felt-3: #07301e;
  --card-w: 58px;
  --card-h: 82px;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0,0,0,.55);
}

/* ---------------- 背景特效画布 ---------------- */
#fx {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1200px 800px at 50% -10%, #17364a 0%, transparent 60%),
    radial-gradient(900px 700px at 10% 100%, #10352a 0%, transparent 55%),
    radial-gradient(900px 700px at 90% 100%, #2a1730 0%, transparent 55%),
    linear-gradient(180deg, #070b10, #0a1119 60%, #060a0e);
}

/* ---------------- 屏幕容器 ---------------- */
#app { position: relative; z-index: 2; width: 100%; height: 100%; }
.screen {
  position: absolute; inset: 0;
  display: none;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; flex-direction: column; }
.screen.no-scroll { overflow: hidden; }

/* ---------------- 通用按钮 ---------------- */
.btn {
  position: relative;
  border: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.03));
  color: var(--txt);
  font-family: inherit; font-size: 15px; font-weight: 600;
  padding: 11px 18px;
  border-radius: 11px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.24); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: linear-gradient(180deg, #2fae72, #146b45);
  border-color: rgba(120,255,190,.35);
  box-shadow: 0 8px 22px rgba(20,140,90,.35), inset 0 1px 0 rgba(255,255,255,.25);
  color: #eafff5;
}
.btn-primary:hover { box-shadow: 0 12px 30px rgba(20,160,100,.5), inset 0 1px 0 rgba(255,255,255,.3); }
.btn-gold {
  background: linear-gradient(180deg, #f0cf8d, #b8893a);
  border-color: rgba(255,230,170,.5);
  color: #2b1c05;
  box-shadow: 0 8px 22px rgba(190,140,60,.35), inset 0 1px 0 rgba(255,255,255,.5);
}
.btn-danger { background: linear-gradient(180deg, #e5484d, #9b2226); border-color: rgba(255,150,150,.35); }
.btn-ghost { background: rgba(255,255,255,.04); }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 20px; font-size: 17px; border-radius: 14px; }
.btn-mini { padding: 5px 11px; font-size: 12px; border-radius: 8px; font-weight: 500; }
.btn-back {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
  border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--txt);
  font-size: 19px; cursor: pointer; display: grid; place-items: center;
}
.btn-back:hover { background: rgba(255,255,255,.12); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--line);
  background: rgba(255,255,255,.05); color: var(--txt); font-size: 16px;
  cursor: pointer; display: grid; place-items: center; transition: background .18s;
}
.icon-btn:hover { background: rgba(255,255,255,.14); }

/* ---------------- 表单 ---------------- */
.input {
  width: 100%; padding: 11px 14px; border-radius: 11px;
  border: 1px solid var(--line); background: rgba(0,0,0,.35); color: var(--txt);
  font-family: inherit; font-size: 15px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: rgba(232,195,122,.55); box-shadow: 0 0 0 3px rgba(232,195,122,.12); }
.input.sm { padding: 7px 10px; font-size: 13px; }
.input[type=range] { padding: 0; background: none; border: none; accent-color: var(--gold); }
.code-input { text-transform: uppercase; letter-spacing: 5px; font-weight: 700; text-align: center; font-size: 18px; }

.form-row { margin-bottom: 18px; }
.form-row > label { display: block; font-size: 13px; color: var(--txt-dim); margin-bottom: 9px; font-weight: 600; letter-spacing: .3px; }
.row-inline { display: flex; gap: 9px; }
.row-inline .input { flex: 1; }
.hint { font-size: 12.5px; color: var(--txt-dim); line-height: 1.65; margin: 8px 0 0; }
.hint code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.chips-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,.05);
  color: var(--txt-dim); font-family: inherit; font-size: 13.5px; font-weight: 600;
  transition: all .18s;
}
.chip-btn:hover { background: rgba(255,255,255,.11); color: var(--txt); }
.chip-btn.active {
  background: linear-gradient(180deg, rgba(232,195,122,.28), rgba(232,195,122,.12));
  border-color: rgba(232,195,122,.6); color: var(--gold-2);
  box-shadow: 0 0 16px rgba(232,195,122,.18);
}

.switch { display: flex; align-items: center; gap: 11px; cursor: pointer; margin-top: 10px; }
.switch input { display: none; }
.switch .slider {
  width: 44px; height: 25px; border-radius: 999px; background: rgba(255,255,255,.13);
  position: relative; transition: background .22s; flex: 0 0 auto;
}
.switch .slider::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px;
  border-radius: 50%; background: #fff; transition: transform .22s;
}
.switch input:checked + .slider { background: linear-gradient(90deg, #2fae72, #1c8a58); }
.switch input:checked + .slider::after { transform: translateX(19px); }
.switch-label { font-size: 14px; color: var(--txt); }

/* ---------------- 首页 ---------------- */
#screen-home { align-items: center; justify-content: center; }
.home-inner { width: min(520px, 92vw); padding: 30px 0 40px; text-align: center; }
.logo-cards { display: flex; justify-content: center; gap: -10px; margin-bottom: 16px; height: 74px; }
.mini-card {
  width: 50px; height: 70px; border-radius: 8px; background: linear-gradient(160deg,#fff,#e7ecf2);
  color: #1a1a1a; font-weight: 800; font-size: 17px; display: grid; place-items: center;
  box-shadow: 0 10px 26px rgba(0,0,0,.55); position: relative;
  animation: floatCard 3.4s ease-in-out infinite;
}
.mini-card i { position: absolute; bottom: 4px; right: 5px; font-size: 15px; font-style: normal; }
.mini-card.red { color: #c8102e; }
.mini-card:nth-child(1) { transform: rotate(-16deg) translateX(14px) translateY(6px); animation-delay: 0s; }
.mini-card:nth-child(2) { transform: rotate(-1deg); z-index: 2; animation-delay: .35s; }
.mini-card:nth-child(3) { transform: rotate(15deg) translateX(-14px) translateY(6px); animation-delay: .7s; }
@keyframes floatCard { 0%,100% { margin-top: 0; } 50% { margin-top: -8px; } }

.logo h1 {
  font-size: clamp(42px, 11vw, 62px); margin: 6px 0 6px; letter-spacing: 8px;
  background: linear-gradient(180deg, #fdf3d8 10%, #e8c37a 45%, #9c7530 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 14px rgba(232,195,122,.3));
  font-weight: 900;
}
.subtitle { color: var(--txt-dim); font-size: 12.5px; letter-spacing: 2.1px; margin: 0 0 34px; }
.menu { display: flex; flex-direction: column; gap: 13px; }
.menu .btn-lg { justify-content: flex-start; text-align: left; padding: 15px 20px; }
.menu .btn-lg .ico { font-size: 25px; opacity: .95; width: 30px; text-align: center; }
.menu .btn-lg .txt { display: flex; flex-direction: column; gap: 3px; }
.menu .btn-lg .txt b { font-size: 17px; letter-spacing: 1px; }
.menu .btn-lg .txt small { font-size: 11.5px; font-weight: 500; opacity: .72; letter-spacing: .2px; }
.menu-row { display: flex; gap: 11px; }
.menu-row .btn { flex: 1; }
.share-entry { margin-top: 13px; justify-content: flex-start; text-align: left; padding: 13px 16px; }
.share-entry .ico { font-size: 20px; }
.share-entry .txt { display: flex; flex-direction: column; gap: 2px; }
.share-entry .txt b { font-size: 14.5px; }
.share-entry .txt small { font-size: 11px; opacity: .7; font-weight: 500; }

.share-list { display: flex; flex-direction: column; gap: 12px; margin: 16px 0 6px; }
.share-item {
  display: flex; gap: 14px; align-items: center; padding: 13px;
  background: #fff; border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.share-item canvas { display: block; border-radius: 6px; flex: 0 0 auto; image-rendering: pixelated; }
.share-item.public { box-shadow: 0 0 0 3px rgba(232,195,122,.85), 0 8px 24px rgba(0,0,0,.4); }
.share-item.public .share-iface { color: #a8600f; }
.share-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.share-iface { font-size: 11px; color: #64748b; font-weight: 700; letter-spacing: .5px; }
.share-url {
  font-size: 13.5px; color: #0f172a; font-weight: 700; word-break: break-all;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.share-info .btn { align-self: flex-start; background: #eef2f7; border-color: #cbd5e1; color: #1e293b; }
.share-info .btn:hover { background: #e2e8f0; }

.home-foot { margin-top: 30px; font-size: 11.5px; color: var(--txt-dim); display: flex; align-items: center; justify-content: center; gap: 8px; }
.net-status { padding: 3px 9px; border-radius: 999px; font-weight: 700; font-size: 11px; }
.net-status.on { background: rgba(70,167,88,.2); color: #7ee29a; }
.net-status.off { background: rgba(255,255,255,.08); color: var(--txt-dim); }

/* ---------------- 面板 ---------------- */
.panel {
  width: min(560px, 94vw); margin: auto; margin-top: 3vh; margin-bottom: 3vh;
  background: linear-gradient(180deg, rgba(24,34,45,.96), rgba(13,20,28,.98));
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column; max-height: 94vh;
}
.panel-head { display: flex; align-items: center; gap: 13px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.panel-head h2 { margin: 0; font-size: 18px; letter-spacing: 2px; font-weight: 700; }
.panel-body { padding: 20px 18px; overflow-y: auto; flex: 1 1 auto; }
.panel-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 11px; flex: 0 0 auto; }
.panel-foot .btn { flex: 1; }
.rules-body h3 { font-size: 15px; color: var(--gold); margin: 22px 0 9px; letter-spacing: 1px; }
.rules-body h3:first-child { margin-top: 0; }
.rules-body p, .rules-body li { font-size: 13.5px; line-height: 1.85; color: #c6d3e0; }
.rules-body ol { padding-left: 20px; margin: 8px 0; }
.rules-body b { color: var(--gold-2); }
.rules-table { width: 100%; border-collapse: collapse; }
.rules-table td { padding: 9px 11px; font-size: 13px; border-bottom: 1px solid var(--line); color: #c6d3e0; }
.rules-table td:first-child { color: var(--gold-2); font-weight: 700; width: 84px; }

.llm-quick { display: flex; align-items: center; gap: 10px; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.09); color: var(--txt-dim); }
.tag.ok { background: rgba(70,167,88,.22); color: #7ee29a; }
.tag.bad { background: rgba(229,72,77,.2); color: #ff9a9d; }
.preset-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.test-row { display: flex; align-items: center; gap: 11px; margin-top: 16px; }

/* ---------------- 房间 ---------------- */
.room-code-box {
  display: flex; align-items: center; gap: 11px; padding: 13px 16px; margin-bottom: 18px;
  background: linear-gradient(90deg, rgba(232,195,122,.14), rgba(232,195,122,.03));
  border: 1px solid rgba(232,195,122,.3); border-radius: 13px;
}
.room-code-box span { font-size: 12px; color: var(--txt-dim); }
.room-code-box strong { font-size: 26px; letter-spacing: 7px; color: var(--gold-2); flex: 1; font-family: ui-monospace, Menlo, Consolas, monospace; }
.seat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 20px; }
.seat-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,.045); border: 1px solid var(--line); position: relative;
}
.seat-card.ready { border-color: rgba(70,167,88,.45); background: rgba(70,167,88,.1); }
.seat-card.empty { opacity: .38; border-style: dashed; justify-content: center; font-size: 12.5px; color: var(--txt-dim); }
.seat-card .av { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; font-size: 15px; font-weight: 800; color: #06110c; }
.seat-card .nm { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.seat-card .sub { font-size: 11px; color: var(--txt-dim); }
.seat-card .rm { position: absolute; top: 5px; right: 6px; font-size: 13px; color: var(--txt-dim); cursor: pointer; }
.tag-host { font-size: 9.5px; background: var(--gold); color: #241a05; padding: 1px 5px; border-radius: 4px; font-weight: 800; }
.tag-bot { font-size: 9.5px; background: rgba(74,158,255,.25); color: #8ec6ff; padding: 1px 5px; border-radius: 4px; font-weight: 700; }
.cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cfg-grid label { font-size: 12px; color: var(--txt-dim); display: flex; flex-direction: column; gap: 5px; }
.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 13px; border-radius: 11px;
  background: rgba(255,255,255,.045); border: 1px solid var(--line); cursor: pointer; transition: all .18s;
}
.room-item:hover { background: rgba(255,255,255,.1); border-color: rgba(232,195,122,.4); }
.room-item .rc { font-family: ui-monospace, monospace; font-weight: 800; color: var(--gold-2); letter-spacing: 2px; }
.room-item .rn { flex: 1; font-size: 13px; }
.room-item .rr { font-size: 11.5px; color: var(--txt-dim); }

/* ---------------- 牌桌 ---------------- */
#screen-game { display: none; flex-direction: column; height: 100%; overflow: hidden; }
#screen-game.active { display: flex; }

.game-top {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; flex: 0 0 auto;
  background: linear-gradient(180deg, rgba(0,0,0,.5), transparent); z-index: 20;
}
.game-title { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.game-title span:first-child { font-size: 14px; letter-spacing: 4px; color: var(--gold-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.hand-no { font-size: 11px; color: var(--txt-dim); }
.game-top-right { display: flex; gap: 8px; }

.table-stage { position: relative; flex: 1 1 auto; min-height: 0; padding: 8px 14px; }
.table-rim {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  border-radius: 50% / 44%;
  background:
    linear-gradient(180deg, #8a5a2c, #5a3417 35%, #3a1f0b 75%, #241205),
    #3a1f0b;
  padding: 16px;
  box-shadow:
    0 40px 90px rgba(0,0,0,.75),
    0 0 0 1px rgba(255,215,150,.22),
    inset 0 2px 3px rgba(255,220,170,.35),
    inset 0 -6px 14px rgba(0,0,0,.7);
}
.table-rim::after {
  content: ''; position: absolute; inset: 7px; border-radius: 50% / 44%;
  border: 1.5px solid rgba(255,215,150,.22); pointer-events: none;
}
.table-felt {
  position: relative; width: 100%; height: 100%;
  border-radius: 50% / 44%;
  background:
    radial-gradient(ellipse at 50% 34%, #35a874 0%, #1a7a4e 32%, #0f5334 62%, #07301e 100%);
  box-shadow: inset 0 0 70px rgba(0,0,0,.72), inset 0 3px 12px rgba(0,0,0,.55);
  display: grid; place-items: center;
  overflow: hidden;
}
.felt-ring {
  position: absolute; inset: 13%; border-radius: 50% / 44%;
  border: 1.5px dashed rgba(255,255,255,.09);
  pointer-events: none;
}
.table-center { position: relative; text-align: center; z-index: 3; }
.pot-box { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pot-label { font-size: 10.5px; letter-spacing: 4px; color: rgba(255,255,255,.5); }
.pot-value {
  font-size: clamp(26px, 5.2vw, 40px); font-weight: 900; letter-spacing: 1px;
  color: #ffe9b0; text-shadow: 0 2px 14px rgba(255,200,90,.5), 0 0 40px rgba(255,180,60,.28);
  font-variant-numeric: tabular-nums; line-height: 1.05;
}
.pot-value.bump { animation: potBump .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes potBump { 0% { transform: scale(1); } 45% { transform: scale(1.28); } 100% { transform: scale(1); } }
.pot-unit { font-size: 11px; color: rgba(255,255,255,.55); letter-spacing: .5px; }
.center-msg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  font-size: clamp(20px, 4.6vw, 34px); font-weight: 900; letter-spacing: 5px;
  color: #fff; text-shadow: 0 3px 24px rgba(0,0,0,.85); opacity: 0; pointer-events: none;
  white-space: nowrap;
}
.center-msg.show { animation: centerPop 1.5s ease forwards; }
@keyframes centerPop {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.5); }
  22% { opacity: 1; transform: translate(-50%,-50%) scale(1.08); }
  70% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-90%) scale(.95); }
}

/* ---------------- 座位 ---------------- */
.seats { position: absolute; inset: 0; pointer-events: none; }
.seat {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  transition: left .5s cubic-bezier(.3,1,.4,1), top .5s cubic-bezier(.3,1,.4,1);
  pointer-events: auto;
}
.seat-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; }

.avatar-wrap { position: relative; width: 52px; height: 52px; }
.avatar {
  width: 100%; height: 100%; border-radius: 50%;
  display: grid; place-items: center; font-size: 20px; font-weight: 900; color: #05130c;
  border: 2px solid rgba(255,255,255,.28);
  box-shadow: 0 6px 18px rgba(0,0,0,.55);
  transition: all .25s;
}
.seat.turn .avatar { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232,195,122,.3), 0 0 26px rgba(232,195,122,.55); }
.seat.folded { opacity: .38; filter: grayscale(.85); }
.seat.winner .avatar { animation: winnerPulse 1s ease-in-out infinite; border-color: #7ee29a; }
@keyframes winnerPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(126,226,154,.7); } 50% { box-shadow: 0 0 0 12px rgba(126,226,154,0); } }
.seat.you .avatar { border-color: rgba(120,200,255,.6); }

.timer-ring { position: absolute; inset: -5px; transform: rotate(-90deg); pointer-events: none; }
.timer-ring circle { fill: none; stroke-width: 3; }
.timer-ring .bg { stroke: rgba(255,255,255,.1); }
.timer-ring .fg { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset .25s linear; }

.seat-name { font-size: 11.5px; font-weight: 700; text-shadow: 0 1px 4px #000; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-chips {
  font-size: 11px; color: var(--gold-2); font-weight: 700; font-variant-numeric: tabular-nums;
  background: rgba(0,0,0,.5); padding: 1.5px 8px; border-radius: 999px; border: 1px solid rgba(232,195,122,.25);
}
.seat-badges { display: flex; gap: 4px; align-items: center; min-height: 15px; }
.badge { font-size: 9.5px; padding: 1px 6px; border-radius: 999px; font-weight: 700; letter-spacing: .3px; }
.badge.blind { background: rgba(74,158,255,.25); color: #9ccdff; }
.badge.seen { background: rgba(232,195,122,.25); color: #f3dca6; }
.badge.fold { background: rgba(255,255,255,.1); color: var(--txt-dim); }
.badge.bot { background: rgba(168,85,247,.25); color: #d7b0ff; }
.badge.broke { background: rgba(229,72,77,.28); color: #ffb0b3; }
.seat-chips.low { color: #ff9a9d; border-color: rgba(229,72,77,.5); }
.chip-warn {
  width: 100%; font-size: 12.5px; color: #ffd88a; background: rgba(232,161,58,.12);
  border: 1px solid rgba(232,161,58,.35); border-radius: 9px; padding: 7px 11px; margin-bottom: 8px;
}
.badge.off { background: rgba(229,72,77,.25); color: #ff9a9d; }

.seat-cards { display: flex; gap: 2px; min-height: calc(var(--card-h) * .74); align-items: center; order: 1; }
.seat-cards.mini { --card-w: 30px; --card-h: 42px; }
.avatar-wrap { order: 2; }
.seat-name { order: 3; }
.seat-badges { order: 4; }
.seat-chips { order: 5; }
/* 上半区的座位把手牌放到名牌下面，让牌朝向桌子中心 */
.seat.half-top .avatar-wrap { order: 1; }
.seat.half-top .seat-name { order: 2; }
.seat.half-top .seat-badges { order: 3; }
.seat.half-top .seat-chips { order: 4; }
.seat.half-top .seat-cards { order: 5; }

.bubble {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%) scale(.85);
  background: #fff; color: #16202b; font-size: 11.5px; font-weight: 600;
  padding: 6px 11px; border-radius: 12px; white-space: nowrap; max-width: 190px;
  overflow: hidden; text-overflow: ellipsis; opacity: 0; pointer-events: none;
  box-shadow: 0 8px 22px rgba(0,0,0,.55); transition: all .25s cubic-bezier(.3,1.5,.5,1); z-index: 30;
}
.bubble.show { opacity: 1; transform: translateX(-50%) scale(1); }
.bubble::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #fff;
}
.bubble.thought { background: #dbe7f3; font-weight: 500; font-style: italic; }

.bet-chips {
  position: absolute; right: -15px; top: 0;
  display: flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 800; color: #ffdf9b;
  background: rgba(0,0,0,.55); padding: 2px 8px; border-radius: 999px;
  border: 1px solid rgba(232,195,122,.28); white-space: nowrap;
}
.seat.half-top .bet-chips { top: auto; bottom: 0; }
.bet-chips.fly { animation: chipFly .5s ease; }
@keyframes chipFly { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }

/* ---------------- 扑克牌 ---------------- */
.card {
  width: var(--card-w); height: var(--card-h);
  perspective: 700px; flex: 0 0 auto; position: relative;
}
.card-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .5s cubic-bezier(.4,.1,.2,1);
}
.card.face-up .card-inner { transform: rotateY(180deg); }
.card-face, .card-back {
  position: absolute; inset: 0; border-radius: 6px; backface-visibility: hidden;
  -webkit-backface-visibility: hidden; overflow: hidden;
  box-shadow: 0 3px 9px rgba(0,0,0,.55);
}
.card-back {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.07) 0 3px, transparent 3px 7px),
    linear-gradient(150deg, #1c3a63, #0e1f38 55%, #16294a);
  border: 1px solid rgba(255,255,255,.16);
  display: grid; place-items: center;
}
.card-back::after {
  content: '\2660'; font-size: calc(var(--card-w) * .42); color: rgba(232,195,122,.35);
  text-shadow: 0 0 10px rgba(232,195,122,.35);
}
.card-face {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, #ffffff, #eef2f6 70%, #dfe6ee);
  border: 1px solid rgba(0,0,0,.22);
  color: #12181f;
  display: block;
}
.card-face.red { color: #cf1233; }
.card-face .c-rank {
  position: absolute; top: 3px; left: 5px; font-size: calc(var(--card-w) * .34);
  font-weight: 900; line-height: 1; letter-spacing: -.5px;
}
.card-face .c-suit { position: absolute; top: calc(var(--card-w) * .40); left: 5px; font-size: calc(var(--card-w) * .26); line-height: 1; }
.card-face .c-big {
  position: absolute; right: 4px; bottom: 2px; font-size: calc(var(--card-w) * .78);
  line-height: 1; opacity: .92;
}
.card-face .c-rank-b {
  position: absolute; bottom: 3px; left: 5px; font-size: calc(var(--card-w) * .26);
  font-weight: 800; line-height: 1; transform: rotate(180deg); opacity: .75;
}
.card.deal-in { animation: dealIn .42s cubic-bezier(.2,.9,.35,1) backwards; }
@keyframes dealIn {
  0% { transform: translate(var(--from-x,0), var(--from-y,-160px)) scale(.55) rotate(-25deg); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
.card.hl .card-face { box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgba(232,195,122,.75); }
.card.dim { filter: brightness(.6) saturate(.5); }

/* ---------------- 比牌动画 ---------------- */
.compare-stage {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  display: flex; align-items: center; gap: 20px;
  padding: 16px 22px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(14,22,31,.95), rgba(6,11,17,.97));
  border: 1px solid rgba(232,195,122,.35);
  box-shadow: 0 26px 70px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.06);
  z-index: 60;
  animation: cmpIn .35s cubic-bezier(.3,1.4,.5,1);
}
.compare-stage.out { animation: cmpOut .45s ease forwards; }
@keyframes cmpIn { from { opacity: 0; transform: translate(-50%,-50%) scale(.72); } to { opacity: 1; transform: translate(-50%,-50%) scale(1); } }
@keyframes cmpOut { to { opacity: 0; transform: translate(-50%,-58%) scale(.94); } }

.cmp-side { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.cmp-side.lose { opacity: .42; filter: grayscale(.55); }
.cmp-name { font-size: 12.5px; font-weight: 700; color: #dbe7f3; }
.cmp-cards { display: flex; gap: 5px; --card-w: 54px; --card-h: 76px; }
.cmp-card { animation: cmpCardIn .4s cubic-bezier(.2,1.3,.4,1) backwards; }
@keyframes cmpCardIn { from { transform: translateY(-28px) scale(.6) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
.cmp-tag {
  font-size: 11.5px; padding: 2px 11px; border-radius: 999px; font-weight: 700;
  background: rgba(255,255,255,.1); color: #9fb0c0;
}
.cmp-side.win .cmp-tag {
  background: linear-gradient(180deg,#2fae72,#146b45); color: #eafff5;
  box-shadow: 0 0 18px rgba(47,174,114,.65);
}
.cmp-side.win .card-face { box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(232,195,122,.75); }
.cmp-vs {
  font-size: 19px; font-weight: 900; font-style: italic; color: var(--gold);
  text-shadow: 0 0 18px rgba(232,195,122,.75);
  animation: vsPulse .8s ease-in-out infinite;
}
@keyframes vsPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }

.showdown-banner {
  position: absolute; left: 50%; top: 30%; transform: translate(-50%,-50%);
  font-size: clamp(18px,3.4vw,26px); font-weight: 900; letter-spacing: 6px; color: #fff;
  text-shadow: 0 4px 26px rgba(0,0,0,.9), 0 0 32px rgba(232,195,122,.6);
  padding: 10px 26px; border-radius: 14px;
  background: rgba(6,12,18,.72); border: 1px solid rgba(232,195,122,.4);
  animation: cmpIn .3s cubic-bezier(.3,1.4,.5,1); z-index: 60; white-space: nowrap;
}
.showdown-banner.out { animation: cmpOut .4s ease forwards; }

/* ---------------- 底部操作区 ---------------- */
.game-bottom { flex: 0 0 auto; padding: 0 14px 14px; position: relative; z-index: 15; }
.side-log {
  max-height: 54px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end;
  gap: 2px; padding: 0 4px 6px; mask-image: linear-gradient(180deg, transparent, #000 40%);
}
.log-line { font-size: 12px; color: #a9bccd; line-height: 1.5; text-shadow: 0 1px 3px #000; }
.log-line.b-win { color: #8ff0b0; font-weight: 700; }
.log-line.b-raise { color: #ffd88a; }
.log-line.b-compare { color: #9ccdff; }
.log-line.b-sys { color: #6f8296; }

.action-bar {
  background: linear-gradient(180deg, rgba(20,30,40,.92), rgba(9,14,20,.97));
  border: 1px solid var(--line); border-radius: 16px; padding: 11px 13px;
  box-shadow: 0 -8px 30px rgba(0,0,0,.5);
}
.action-info { font-size: 12px; color: var(--txt-dim); margin-bottom: 9px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.action-info b { color: var(--gold-2); }
.action-btns { display: flex; gap: 9px; flex-wrap: wrap; }
.action-btns .btn { flex: 1 1 0; min-width: 88px; padding: 13px 10px; font-size: 14.5px; flex-direction: column; gap: 2px; }
.action-btns .btn small { font-size: 10.5px; font-weight: 500; opacity: .8; }
.btn-look { background: linear-gradient(180deg,#5b6bff,#3a3fbf); border-color: rgba(150,160,255,.4); }
.btn-call { background: linear-gradient(180deg,#2fae72,#146b45); border-color: rgba(120,255,190,.35); }
.btn-raise { background: linear-gradient(180deg,#e8a13a,#a8600f); border-color: rgba(255,210,140,.45); color: #22150a; }
.btn-compare { background: linear-gradient(180deg,#c452e0,#7a1c9e); border-color: rgba(230,160,255,.4); }
.btn-fold { background: linear-gradient(180deg,#4a5765,#2a333e); }
.raise-opts { display: flex; gap: 7px; flex-wrap: wrap; width: 100%; margin-top: 2px; }
.raise-opts .chip-btn { padding: 7px 12px; font-size: 13px; }

.waiting-tip {
  text-align: center; font-size: 13px; color: var(--txt-dim); padding: 15px;
  display: flex; align-items: center; justify-content: center; gap: 9px;
}
.spinner {
  width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255,255,255,.2);
  border-top-color: var(--gold); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 钱包 / 通用 ---------------- */
.wallet-pill {
  padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: 14px;
  background: linear-gradient(180deg, rgba(232,195,122,.22), rgba(232,195,122,.08));
  border: 1px solid rgba(232,195,122,.45); color: var(--gold-2);
  font-variant-numeric: tabular-nums;
}
.wallet-pill.flash { animation: walletFlash .5s ease; }
@keyframes walletFlash { 0%{transform:scale(1)} 40%{transform:scale(1.16); box-shadow:0 0 22px rgba(232,195,122,.7)} 100%{transform:scale(1)} }

/* ---------------- 21点 ---------------- */
#screen-blackjack { display: none; flex-direction: column; height: 100%; overflow: hidden; }
#screen-blackjack.active { display: flex; }
.bj-stage {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: space-between; padding: 10px 16px 4px;
}
.bj-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bj-label { font-size: 13px; color: var(--txt-dim); font-weight: 700; letter-spacing: 1px; }
.bj-val {
  display: inline-block; min-width: 34px; padding: 1px 9px; border-radius: 999px;
  background: rgba(232,195,122,.18); color: var(--gold-2); font-weight: 800; font-size: 13px;
}
.bj-val.bust { background: rgba(229,72,77,.25); color: #ff9a9d; }
.bj-val.bj { background: linear-gradient(180deg,#f0cf8d,#b8893a); color: #2b1c05; }
.bj-hand { display: flex; gap: 8px; min-height: 104px; align-items: center; --card-w: 72px; --card-h: 102px; }
.bj-hand .card { animation: bjDeal .4s cubic-bezier(.2,1.2,.4,1) backwards; }
@keyframes bjDeal { from { transform: translateY(-40px) scale(.6) rotate(-10deg); opacity: 0; } to { transform: none; opacity: 1; } }
.bj-mid { text-align: center; }
.bj-msg {
  font-size: clamp(16px,2.6vw,22px); font-weight: 800; letter-spacing: 2px;
  color: var(--gold-2); text-shadow: 0 2px 16px rgba(0,0,0,.8); min-height: 30px;
}
.bj-msg.win { color: #8ff0b0; }
.bj-msg.lose { color: #ff9a9d; }
.bj-bottom {
  flex: 0 0 auto; padding: 10px 16px 14px; background: linear-gradient(180deg, transparent, rgba(0,0,0,.35));
}
.bj-bet-row, .sl-bet-row {
  display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 10px;
}
.bj-bet-label { font-size: 12.5px; color: var(--txt-dim); }
.bj-bet-cur {
  font-weight: 800; color: var(--gold-2); font-size: 15px; min-width: 60px; text-align: center;
  font-variant-numeric: tabular-nums;
}
#bj-actions { justify-content: center; }
#bj-actions .btn { flex: 1 1 0; max-width: 240px; }

/* ---------------- 老虎机 ---------------- */
#screen-slots { display: none; flex-direction: column; height: 100%; overflow: hidden; }
#screen-slots.active { display: flex; }
.sl-stage { flex: 1 1 auto; display: grid; place-items: center; min-height: 0; padding: 8px; }
.sl-machine {
  position: relative; padding: 16px; border-radius: 22px;
  background: linear-gradient(180deg, #2b1a3d, #170d24 60%, #0d0716);
  border: 2px solid rgba(232,195,122,.5);
  box-shadow: 0 30px 80px rgba(0,0,0,.8), inset 0 2px 0 rgba(255,255,255,.08);
}
.sl-reels { display: flex; gap: 7px; }
.sl-reel {
  --cell: 86px;
  width: 98px; height: calc(var(--cell) * 3);
  overflow: hidden; border-radius: 12px; position: relative;
  background: linear-gradient(180deg, #101720, #070b10);
  box-shadow: inset 0 0 26px rgba(0,0,0,.95), 0 0 0 1px rgba(255,255,255,.06);
}
.sl-strip { display: flex; flex-direction: column; will-change: transform; }
.sl-cell {
  height: var(--cell); display: grid; place-items: center;
  font-size: 46px; line-height: 1; user-select: none;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.6));
}
.sl-cell.win {
  background: radial-gradient(circle at 50% 50%, rgba(232,195,122,.45), transparent 72%);
  animation: slWin .7s ease-in-out infinite alternate;
}
@keyframes slWin { from { transform: scale(1); } to { transform: scale(1.13); } }
.sl-reel::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,.75), transparent 22%, transparent 78%, rgba(0,0,0,.75));
}
.sl-win {
  text-align: center; height: 30px; margin-top: 10px; font-size: 19px; font-weight: 900;
  color: var(--gold-2); text-shadow: 0 0 18px rgba(232,195,122,.6); letter-spacing: 1px;
}
.sl-win.show { animation: walletFlash .6s ease; }
.sl-bottom { flex: 0 0 auto; padding: 8px 16px 14px; }
.sl-bottom .action-btns { justify-content: center; }
.sl-bottom .action-btns .btn { max-width: 240px; }

@media (max-width: 720px) {
  .bj-hand { --card-w: 52px; --card-h: 74px; min-height: 76px; }
  .sl-reel { --cell: 58px; width: 64px; }
  .sl-cell { font-size: 31px; }
  .sl-machine { padding: 10px; border-radius: 16px; }
  .sl-reels { gap: 5px; }
  .bj-bottom, .sl-bottom { padding: 8px 8px 10px; }
}

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 200; display: none;
  align-items: center; justify-content: center; padding: 18px;
  background: rgba(3,6,10,.72); backdrop-filter: blur(6px);
}
.modal.show { display: flex; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: min(480px, 94vw); max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #1b2632, #0e161f);
  border: 1px solid var(--line); border-radius: 19px; box-shadow: var(--shadow);
  animation: popIn .28s cubic-bezier(.3,1.4,.5,1);
}
.modal-card.small { width: min(400px, 92vw); }
@keyframes popIn { from { transform: scale(.9) translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; letter-spacing: 1px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.modal-foot .btn { flex: 1; }

.result-card { text-align: center; }
.result-title { font-size: 26px; font-weight: 900; letter-spacing: 4px; padding: 24px 20px 4px;
  background: linear-gradient(180deg,#fdf3d8,#e8c37a 50%,#a67c2e); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-sub { font-size: 12.5px; color: var(--txt-dim); margin-bottom: 16px; }
.result-list { padding: 0 18px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.result-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.result-row.win { background: rgba(70,167,88,.14); border-color: rgba(70,167,88,.45); }
.result-row .rn { flex: 1; font-size: 13.5px; font-weight: 700; }
.result-row .rc { display: flex; gap: 3px; --card-w: 26px; --card-h: 37px; }
.result-row .rw { font-size: 14px; font-weight: 800; color: var(--gold-2); }
.result-row .rw.neg { color: #ff8f93; }
.result-row .rt { font-size: 11px; color: var(--txt-dim); }

/* ---------------- Toast ---------------- */
#toasts {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 400;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  padding: 10px 18px; border-radius: 11px; font-size: 13.5px; font-weight: 600;
  background: rgba(22,32,43,.96); border: 1px solid var(--line); color: var(--txt);
  box-shadow: 0 10px 30px rgba(0,0,0,.55); animation: toastIn .28s cubic-bezier(.3,1.4,.5,1);
  max-width: 88vw; text-align: center; white-space: pre-line; line-height: 1.7;
}
.toast.warn { border-color: rgba(232,161,58,.5); color: #ffd88a; }
.toast.err { border-color: rgba(229,72,77,.5); color: #ff9a9d; }
.toast.ok { border-color: rgba(70,167,88,.5); color: #8ff0b0; }
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(-12px); opacity: 0; } }

.conn-banner {
  position: fixed; left: 0; right: 0; top: 0; z-index: 500; text-align: center;
  padding: 7px; font-size: 12.5px; font-weight: 700;
  background: linear-gradient(90deg, #a8600f, #e8a13a, #a8600f); color: #241a05;
}

/* ---------------- 飘字 / 粒子 ---------------- */
.fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 40; }
.float-text {
  position: absolute; transform: translate(-50%,-50%); font-weight: 900; font-size: 17px;
  color: #ffdf9b; text-shadow: 0 2px 10px rgba(0,0,0,.8); pointer-events: none;
  animation: floatUp 1.15s ease-out forwards; white-space: nowrap;
}
.float-text.win { color: #8ff0b0; font-size: 22px; }
.float-text.lose { color: #ff9a9d; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.6); } 25% { opacity: 1; transform: translate(-50%,-70%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%,-160%) scale(1); } }

.confetti { position: absolute; width: 8px; height: 12px; border-radius: 2px; pointer-events: none; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 720px) {
  :root { --card-w: 42px; --card-h: 60px; }
  .table-rim { padding: 9px; border-radius: 46% / 42%; }
  .table-felt, .table-rim::after, .felt-ring { border-radius: 46% / 42%; }
  .avatar-wrap { width: 42px; height: 42px; }
  .avatar { font-size: 16px; }
  .seat-name { font-size: 10.5px; max-width: 74px; }
  .seat-cards.mini { --card-w: 24px; --card-h: 34px; }
  .game-bottom { padding: 0 8px 8px; }
  .action-bar { padding: 9px 10px; border-radius: 13px; }
  .action-btns .btn { padding: 11px 6px; font-size: 13px; min-width: 70px; }
  .action-btns .btn small { font-size: 9.5px; }
  .compare-stage { gap: 10px; padding: 12px 14px; }
  .cmp-cards { --card-w: 36px; --card-h: 52px; }
  .cmp-vs { font-size: 15px; }
  .cmp-name { font-size: 11px; }
  .side-log { max-height: 38px; }
  .log-line { font-size: 11px; }
  .panel { margin-top: 0; margin-bottom: 0; border-radius: 0; max-height: 100vh; width: 100%; }
  .screen .panel { width: 100%; }
}
@media (max-height: 620px) {
  :root { --card-w: 40px; --card-h: 56px; }
  .side-log { max-height: 34px; }
}
@media (min-width: 1100px) {
  :root { --card-w: 66px; --card-h: 93px; }
}
