/* ============================================================
   牌九 + 炸金花  ·  共用样式
   移动端优先，深色赌桌风
   ============================================================ */

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

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2430;
  --line: #2b3543;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --gold: #f0b429;
  --gold-2: #ffd666;
  --green: #2ea043;
  --red: #da3633;
  --blue: #388bfd;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ───────────────────────── 通用组件 ───────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 11px 18px; border: 0; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  color: #fff; background: var(--panel-2);
  transition: transform .12s ease, opacity .12s ease;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, #ff8a3d, #e8493a); }
.btn-gold { background: linear-gradient(135deg, #f0b429, #d98e04); color: #1a1a1a; }
.btn-green { background: linear-gradient(135deg, #34d058, #1e7c33); }
.btn-blue { background: linear-gradient(135deg, #58a6ff, #2f6fd0); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text-dim); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font-size: 15px; font-family: inherit;
  outline: none; transition: border-color .15s;
}
.field input:focus { border-color: var(--gold); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--text-dim); font-size: 13px; }
.gold { color: var(--gold); font-weight: 700; }
.center { text-align: center; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }

/* ───────────────────────── 顶部条 ───────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(13, 17, 23, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .who { font-weight: 700; font-size: 15px; }
.topbar .wallet {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(240, 180, 41, .12);
  border: 1px solid rgba(240, 180, 41, .3);
  color: var(--gold-2); font-weight: 700; font-size: 14px;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }

/* ───────────────────────── 登录/注册 ───────────────────────── */
.auth-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
}
.logo { text-align: center; margin-bottom: 26px; }
.logo h1 {
  font-size: 30px; letter-spacing: 3px;
  background: linear-gradient(135deg, #ffd666, #f0b429 45%, #e8493a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo p { color: var(--text-dim); font-size: 13px; margin-top: 6px; letter-spacing: 1px; }

.auth-card { width: 100%; max-width: 380px; }
.tabs { display: flex; margin-bottom: 20px; background: var(--panel-2); border-radius: 10px; padding: 4px; }
.tabs button {
  flex: 1; padding: 9px; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--text-dim);
  font-size: 14px; font-weight: 600; font-family: inherit;
}
.tabs button.active { background: var(--panel); color: var(--gold); }

.msg { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; display: none; }
.msg.err { display: block; background: rgba(218, 54, 51, .14); color: #ff8b87; border: 1px solid rgba(218, 54, 51, .35); }
.msg.ok { display: block; background: rgba(46, 160, 67, .14); color: #7ee787; border: 1px solid rgba(46, 160, 67, .35); }

/* ───────────────────────── 大厅 ───────────────────────── */
.section-title {
  font-size: 13px; color: var(--text-dim); font-weight: 600;
  letter-spacing: 1px; margin: 22px 0 10px; text-transform: uppercase;
}
.section-title:first-child { margin-top: 4px; }

.game-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, #1a2230, #151a22);
  border: 1px solid var(--line); margin-bottom: 12px;
}
.game-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; flex: 0 0 auto;
  background: rgba(240, 180, 41, .14); color: var(--gold);
}
.game-card .meta { flex: 1; min-width: 0; }
.game-card .meta h3 { font-size: 16px; margin-bottom: 3px; }
.game-card .meta .sub { font-size: 12px; color: var(--text-dim); }

.rule-pick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.rule-pick button {
  padding: 8px 13px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text-dim); font-size: 13px; font-family: inherit;
}
.rule-pick button.sel {
  border-color: var(--gold); color: var(--gold);
  background: rgba(240, 180, 41, .12); font-weight: 700;
}

.room-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line);
  margin-bottom: 8px;
}
.room-item .no { font-family: ui-monospace, Consolas, monospace; font-size: 17px; letter-spacing: 2px; color: var(--gold-2); font-weight: 700; }

.invite-box {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 13px 15px; border-radius: 10px;
  background: rgba(56, 139, 253, .1); border: 1px solid rgba(56, 139, 253, .3);
}
.invite-box .code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 20px; letter-spacing: 3px; color: #79c0ff; font-weight: 700;
}

/* ───────────────────────── 牌桌 ───────────────────────── */
.table-page {
  position: fixed; inset: 0;
  background: #0a1a12 url('/assets/ui/table.jpg') center/cover no-repeat;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.table-page::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 35%, rgba(0,0,0,.15), rgba(0,0,0,.72) 75%);
}

.table-top {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0, 0, 0, .45);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.table-top .info { font-size: 13px; color: #c9d1d9; }
.table-top .info b { color: var(--gold-2); font-size: 16px; font-family: ui-monospace, monospace; letter-spacing: 2px; }

.seats {
  position: relative; z-index: 4; flex: 1;
  display: grid; gap: 8px; padding: 12px;
  grid-template-columns: 1fr 1fr;
  align-content: start;
  overflow-y: auto;
}

.seat {
  border-radius: 12px; padding: 10px;
  background: rgba(0, 0, 0, .42);
  border: 1px solid rgba(255,255,255,.1);
  min-height: 118px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .2s, box-shadow .2s;
}
.seat.me { border-color: rgba(240, 180, 41, .65); box-shadow: 0 0 0 1px rgba(240,180,41,.2) inset; }
.seat.banker { border-color: rgba(218, 54, 51, .75); }
.seat.turn { border-color: var(--gold); box-shadow: 0 0 14px rgba(240,180,41,.45); }
.seat.offline { opacity: .45; }
.seat.folded { opacity: .38; filter: grayscale(.6); }

/* 抢庄定庄动画：光环随机跳到某个座位上 */
.seat.roll-hl {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(240,180,41,.55), 0 0 22px rgba(240,180,41,.65);
  transform: scale(1.035);
  transition: transform .08s ease, box-shadow .08s ease;
}
.seat.roll-hl .seat-name { color: var(--gold-2); }

/* 定庄动画落定后的庄家光环（一直亮着） */
.seat.banker {
  position: relative;
}
.seat.banker::after {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 15px;
  border: 2px solid rgba(218,54,51,.8);
  box-shadow: 0 0 16px rgba(218,54,51,.45);
  animation: bankerGlow 1.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes bankerGlow {
  0%, 100% { opacity: .6; }
  50% { opacity: 1; }
}

.seat-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.seat-name { font-size: 12px; color: #e6edf3; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  font-size: 10px; padding: 2px 6px; border-radius: 999px;
  background: rgba(240,180,41,.2); color: var(--gold-2); font-weight: 700;
  flex: 0 0 auto;
}
.badge.red { background: rgba(218,54,51,.25); color: #ff887f; }
.badge.blue { background: rgba(56,139,253,.22); color: #79c0ff; }
.badge.green { background: rgba(46,160,67,.22); color: #7ee787; }

.cards { display: flex; gap: 4px; flex-wrap: nowrap; }
/* 牌九是图片，按原图比例走（85×178），不塞进固定宽度里，避免两边留白看着像「横牌」 */
.tile { height: 46px; width: auto; border-radius: 4px; display: block; object-fit: contain; background: #f5f0e6; }
/* 牌九的牌背跟牌面同宽，和扑克桌（34 宽牌背）分开 */
.cards.tiles .card-back { width: 22px; }
.card-back {
  width: 34px; height: 46px; border-radius: 4px;
  background: linear-gradient(135deg, #2b3a55, #16202f);
  border: 1px solid rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.25); font-size: 15px;
}
/* 扑克牌 */
.pcard {
  width: 34px; height: 46px; border-radius: 4px; background: #fff;
  color: #111; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; line-height: 1;
  border: 1px solid #ccc; position: relative;
}
.pcard.red { color: #d0342c; }
.pcard .r { font-size: 13px; }
.pcard .s { font-size: 13px; }

.seat-foot { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #9aa4af; }
.delta-pos { color: #7ee787; font-weight: 700; }
.delta-neg { color: #ff887f; font-weight: 700; }

.hand-tag {
  font-size: 11px; padding: 2px 7px; border-radius: 6px;
  background: rgba(255,255,255,.1); color: #ffd666;
}

.table-bottom {
  position: relative; z-index: 5;
  padding: 12px 14px 18px;
  background: rgba(0, 0, 0, .55);
  border-top: 1px solid rgba(255,255,255,.08);
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1; min-width: 84px; }

/* 投注菜单上方的「我的牌」（和座位区同一套牌，只是放大一档，都不换行） */
.my-hand {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: nowrap; padding: 4px 4px 10px;
}
.my-hand-label { font-size: 12px; color: #9aa4af; letter-spacing: .5px; white-space: nowrap; }
.my-hand-cards { display: flex; gap: 5px; align-items: center; flex-wrap: nowrap; }
.my-hand-cards .tile { height: 56px; width: auto; }
.my-hand-cards .pcard { width: 40px; height: 56px; font-size: 14px; }
.my-hand-cards .pcard .r { font-size: 15px; }
.my-hand-cards .pcard .s { font-size: 15px; }
.my-hand-cards .card-back { width: 40px; height: 56px; font-size: 16px; }
.my-hand-cards.tiles .card-back { width: 27px; }
.my-hand-side { display: flex; align-items: center; gap: 6px; white-space: nowrap; }

.hint {
  text-align: center; font-size: 13px; color: #c9d1d9;
  margin-bottom: 10px; min-height: 20px;
}
.hint b { color: var(--gold-2); }

.countdown {
  display: inline-block; min-width: 26px; padding: 1px 7px;
  border-radius: 999px; background: rgba(240,180,41,.2);
  color: var(--gold-2); font-weight: 700; font-size: 12px;
}

/* 结算弹层 */
.result-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.72); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.result-mask.show { display: flex; }
.result-box {
  width: 100%; max-width: 400px; max-height: 82vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 20px;
}
.result-box h2 { font-size: 18px; text-align: center; margin-bottom: 4px; }
.result-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.result-row:last-child { border-bottom: 0; }

/* ── 结算里带牌面的行 ── */
.result-row.res-with-cards {
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 10px;
  border-bottom: 1px solid var(--line);
}
.result-row.res-with-cards.win {
  background: rgba(240, 180, 41, .1);
  border: 1px solid rgba(240, 180, 41, .35);
  margin-bottom: 6px;
}
.result-row.res-with-cards.fold { opacity: .55; }

.res-cards { display: flex; gap: 3px; flex: 0 0 auto; align-items: center; }
.res-cards .pcard {
  width: 28px; height: 38px; border-radius: 3px;
  font-size: 10px;
}
.res-cards .tile { height: 38px; width: auto; border-radius: 3px; }
.res-cards .pcard .r { font-size: 11px; }
.res-cards .pcard .s { font-size: 10px; }
.res-cards .card-back { width: 28px; height: 38px; font-size: 12px; }

.res-mid { flex: 1; min-width: 0; }
.res-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.res-type { font-size: 11px; color: var(--gold-2); margin-top: 2px; }
.res-delta { font-size: 15px; font-weight: 700; flex: 0 0 auto; }

/* 背包 / 透视提示 */
.cheat-on {
  position: fixed; top: 60px; right: 14px; z-index: 50;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(218,54,51,.9); color: #fff;
  font-size: 12px; font-weight: 700;
  box-shadow: 0 3px 14px rgba(218,54,51,.5);
  animation: pulse 1.8s infinite;
}
@keyframes pulse { 0%,100% { opacity: .85; } 50% { opacity: 1; } }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  z-index: 90; padding: 10px 18px; border-radius: 999px;
  background: rgba(0,0,0,.88); color: #fff; font-size: 14px;
  opacity: 0; transition: opacity .2s; pointer-events: none;
  max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; }

/* 管理面板 */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); }
.admin-table th { color: var(--text-dim); font-weight: 600; font-size: 12px; }
.admin-table td.mono { font-family: ui-monospace, monospace; }

@media (min-width: 560px) {
  .seats { grid-template-columns: repeat(3, 1fr); }
}

/* 后台开关行 */
.switch-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  font-size: 14px;
  cursor: pointer;
}
.switch-line input {
  width: 18px;
  height: 18px;
  accent-color: #20a53a;
  cursor: pointer;
}

