/* 21点娱乐小游戏样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --felt: #1c6b46;
  --felt-dark: #145034;
  --panel: #ffffff;
  --panel-border: #d9e2dc;
  --ink: #1c2b24;
  --accent: #0f8a5f;
  --accent-dark: #0b6b49;
  --warn: #c0392b;
  --gold: #d4a017;
  --red: #d63031;
  --gray: #7a8a80;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #10281d 0%, #173a2a 55%, #10281d 100%);
  color: var(--ink);
  min-height: 100vh;
}

.app { max-width: 980px; margin: 0 auto; padding: 16px; }

.screen { display: none; }
.screen.active { display: block; }

.hidden { display: none !important; }

/* ---------- 通用 ---------- */
.btn {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 22px; border-radius: 10px; font-size: 15px;
  cursor: pointer; transition: .15s; font-weight: 600;
}
.btn:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.big { font-size: 19px; padding: 16px 34px; }
.btn.alt { background: #2563a8; }
.btn.alt:hover { background: #1d4f85; }
.btn.warn { background: var(--gold); color: #3a2c00; }
.btn.warn:hover { background: #b58910; }
.btn.ghost { background: transparent; color: #cfe3d7; border: 1px solid #3d5c4c; }
.btn.ghost:hover { background: rgba(255,255,255,.08); }
.btn.small { padding: 6px 12px; font-size: 13px; }

input {
  padding: 10px 12px; border: 1px solid #b9ccc1; border-radius: 8px;
  font-size: 15px; outline: none; background: #fbfdfc; color: var(--ink);
}
input:focus { border-color: var(--accent); }

.card-panel {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 18px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

.tag {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  background: #e4efe9; color: var(--accent-dark); font-size: 13px; font-weight: 600;
}

/* ---------- 首页 ---------- */
.home-wrap { text-align: center; padding: 48px 12px; color: #eaf5ee; }
.logo { font-size: 56px; letter-spacing: 4px; color: #fff; text-shadow: 0 3px 12px rgba(0,0,0,.5); }
.logo span { color: var(--gold); }
.slogan { margin: 12px 0 34px; color: #a9c9b6; letter-spacing: 2px; }
.home-btns { display: flex; gap: 18px; justify-content: center; margin-bottom: 40px; flex-wrap: wrap; }

.rules { max-width: 620px; margin: 0 auto; text-align: left; }
.rules h3 { margin-bottom: 10px; color: var(--accent-dark); }
.rules li { margin: 6px 0 6px 20px; color: #33463c; font-size: 14px; line-height: 1.6; }

/* ---------- 大厅 ---------- */
.lobby-wrap { max-width: 560px; margin: 30px auto; }
.lobby-wrap h2 { color: #fff; margin-bottom: 16px; text-align: center; }
.form-panel label { display: block; font-size: 13px; color: var(--gray); margin: 14px 0 6px; }
.form-panel input { width: 100%; }
.mode-row { display: flex; gap: 10px; }
.mode-opt {
  flex: 1; display: flex; gap: 8px; align-items: flex-start;
  border: 1px solid var(--panel-border); border-radius: 10px; padding: 10px;
  cursor: pointer; font-size: 13px; line-height: 1.5;
}
.mode-opt:has(input:checked) { border-color: var(--accent); background: #f0f9f4; }
.divider { text-align: center; color: #a7b8ae; font-size: 13px; margin: 20px 0 6px; }
.join-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.join-row .code-input { width: 110px; text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 700; }
.join-row .mini { font-size: 12px; color: var(--gray); margin: 0; }
.join-row .mini-input { width: 90px; }
#create-box .btn { width: 100%; margin-top: 18px; }

/* ---------- 房间 ---------- */
.room-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px; color: #eaf5ee;
}
.room-code { font-size: 15px; }
.room-code b { font-size: 22px; letter-spacing: 5px; color: var(--gold); margin: 0 4px; }
#btn-copy { background: none; border: none; color: #a9c9b6; cursor: pointer; font-size: 15px; }

.table {
  background:
    radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
  border-radius: 20px; padding: 26px 20px; min-height: 320px;
  border: 6px solid #6b4a1f; box-shadow: inset 0 0 60px rgba(0,0,0,.45), 0 8px 24px rgba(0,0,0,.4);
  margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
/* 庄家视角：庄家牌区翻转到自己面前（下方） */
.table.as-banker { justify-content: flex-end; }

.banker-area { text-align: center; margin-bottom: 22px; }
.seat-label { color: #ffe9b0; font-weight: 700; letter-spacing: 2px; margin-bottom: 8px; font-size: 14px; }
.hand-total {
  display: inline-block; margin-top: 6px; padding: 2px 12px; border-radius: 14px;
  background: rgba(0,0,0,.35); color: #fff; font-weight: 700; font-size: 15px;
}
.banker-chips { margin-top: 8px; color: #ffd97a; font-weight: 700; }

.players-area { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.player-seat {
  background: rgba(0,0,0,.28); border-radius: 14px; padding: 12px;
  min-width: 150px; max-width: 230px; text-align: center; flex: 0 1 auto;
  border: 2px solid transparent; transition: .2s;
}
.player-seat.is-turn { border-color: var(--gold); box-shadow: 0 0 14px rgba(212,160,23,.55); }
.player-seat.is-me { border-color: #7fd4a8; }
.player-seat .pname { color: #fff; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.player-seat .pinfo { color: #b7d6c4; font-size: 12px; margin-top: 6px; line-height: 1.5; }
.player-seat .result-tag {
  display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 700;
}
.result-win  { background: #ffe08a; color: #6b4e00; }
.result-lose { background: rgba(255,255,255,.18); color: #ffb3b3; }
.result-push { background: rgba(255,255,255,.25); color: #fff; }

/* ---------- 扑克牌 ---------- */
.cards { display: flex; gap: 8px; justify-content: center; min-height: 84px; flex-wrap: wrap; }
.pcard {
  width: 58px; height: 82px; background: #fff; border-radius: 8px;
  box-shadow: 0 3px 8px rgba(0,0,0,.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; position: relative;
  animation: dealIn .3s ease; border: 2px solid #e8e8e8;
}
.pcard .suit { font-size: 24px; }
.pcard.red { color: var(--red); }
.pcard.black { color: #222; }
.pcard.hidden-card { background: repeating-linear-gradient(45deg, #264d8f 0 6px, #1d3d73 6px 12px); border-color: #16305c; }
.pcard.hidden-card .suit, .pcard.hidden-card .rank { visibility: hidden; }
@keyframes dealIn { from { transform: translateY(-24px) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 我的面板 ---------- */
.my-panel { margin-bottom: 14px; }
.my-info { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; font-weight: 600; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.bet-row { display: flex; gap: 8px; align-items: center; }
.bet-row input { width: 110px; }
.phase-tip { margin-top: 10px; color: var(--accent-dark); font-size: 14px; font-weight: 600; }
#btn-next { margin-top: 10px; background: var(--gold); color: #3a2c00; }

#game-over-banner {
  background: linear-gradient(90deg, #d4a017, #f0c94a);
  color: #3a2c00; text-align: center; font-size: 20px; font-weight: 800;
  padding: 14px; border-radius: 12px; margin-bottom: 14px;
}

/* ---------- 日志 ---------- */
.log-panel h4 { color: var(--accent-dark); margin-bottom: 8px; }
#log-list {
  max-height: 180px; overflow-y: auto; font-size: 13px; line-height: 1.8; color: #41564a;
}
#log-list div { border-bottom: 1px dashed #e4ece7; padding: 2px 0; }

/* ---------- 单人模式 ---------- */
.single-player-area { text-align: center; }
#s-tip { min-height: 20px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: #23342b; color: #fff; padding: 10px 22px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 99;
  box-shadow: 0 6px 18px rgba(0,0,0,.4); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 620px) {
  .logo { font-size: 40px; }
  .home-btns { flex-direction: column; align-items: center; }
  .pcard { width: 46px; height: 66px; font-size: 16px; }
  .pcard .suit { font-size: 18px; }
}

/* ---------- 追加：筹码式下注 / 负债 / 角色切换 ---------- */
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.pchip {
  width: 54px; height: 54px; border-radius: 50%;
  border: 4px dashed rgba(255,255,255,.85);
  color: #fff; font-weight: 800; font-size: 14px;
  cursor: pointer; box-shadow: 0 3px 8px rgba(0,0,0,.35), inset 0 0 0 4px rgba(0,0,0,.12);
  transition: .12s; display: inline-flex; align-items: center; justify-content: center;
}
.pchip:hover:not(:disabled) { transform: translateY(-3px) scale(1.05); }
.pchip:disabled { opacity: .4; cursor: not-allowed; }
.c10   { background: #4a90d9; }
.c50   { background: #2fa360; }
.c100  { background: #1f1f1f; }
.c500  { background: #a0522d; }
.cclear, .call {
  width: auto; height: 40px; border-radius: 20px; padding: 0 14px;
  background: #555; font-size: 13px;
}
.call  { background: var(--gold); color: #3a2c00; }
.bet-confirm { display: flex; gap: 12px; align-items: center; font-size: 15px; }
.bet-confirm b { color: var(--accent-dark); font-size: 18px; }

.debt-badge {
  background: #fdecea; color: #c0392b; border: 1px solid #f5c6c0;
  padding: 3px 10px; border-radius: 20px; font-size: 13px; font-weight: 700;
}
.pdebt { color: #ffb3b3; font-size: 12px; margin-top: 4px; font-weight: 700; }
.player-seat.defeated { opacity: .5; filter: grayscale(.7); }

#no-banker-banner {
  background: #fff3cd; color: #7a5b00; text-align: center; font-weight: 700;
  padding: 10px; border-radius: 10px; margin-bottom: 14px; border: 1px solid #f1dc9b;
}

.role-btn { background: #6c5ce7; }
.role-btn:hover { background: #5546c9; }
.role-btn:disabled { opacity: .45; }

.rejoin-tip { margin-top: 12px; font-size: 12px; color: var(--gray); line-height: 1.6; }
.rejoin-tip b { color: var(--accent-dark); }

/* ---------- 观战席 ---------- */
.player-seat.spectating { opacity: .55; }
.c1000 { background: #8e44ad; font-size: 12px; }
.portal-link { margin: -22px 0 30px; }
.portal-link a { color: #a9c9b6; font-size: 14px; text-decoration: none; border-bottom: 1px dashed #3d5c4c; padding-bottom: 2px; }
.portal-link a:hover { color: #fff; }
.room-hall-link { color: #a9c9b6; font-size: 13px; text-decoration: none; border: 1px solid #3d5c4c; border-radius: 20px; padding: 4px 12px; transition: .15s; }
.room-hall-link:hover { color: #fff; background: rgba(255,255,255,.08); }

/* ---------- 账号系统 ---------- */
.acct-box { border: 1px dashed #b9ccc1; border-radius: 10px; padding: 12px; margin-bottom: 16px; background: #f6faf7; }
.acct-row { display: flex; gap: 8px; }
.acct-row input { flex: 1; min-width: 0; }
.acct-btns { display: flex; gap: 8px; margin-top: 10px; }
.acct-btns .btn { flex: 1; }
.acct-hint { margin-top: 8px; font-size: 12px; color: var(--gray); }
#acct-profile { display: flex; align-items: center; gap: 12px; }
.acct-avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: #dfe9e2; cursor: pointer; border: 2px solid var(--accent); }
.acct-info { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 14px; min-width: 0; }
.acct-records, .acct-bank { color: var(--gray); font-size: 12px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-card { background: #fff; border-radius: 14px; padding: 18px; max-width: 320px; width: 100%; }
.modal-card h3 { margin-bottom: 10px; color: var(--accent-dark); }
.modal-card p { font-size: 14px; line-height: 1.6; color: #33463c; }
.crop-wrap { display: flex; justify-content: center; margin: 10px 0; }
#crop-canvas { border-radius: 8px; touch-action: none; cursor: grab; max-width: 100%; }
.zoom-row { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--gray); }
.zoom-row input { flex: 1; }
.crop-hint { font-size: 12px; color: var(--gray); margin: 6px 0 10px; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
#avatar-file { font-size: 12px; }
.seat-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; vertical-align: -6px; margin-right: 5px; border: 1px solid rgba(255,255,255,.4); }

/* ---------- 账号面板布局修正（覆盖 form-panel 按钮全宽规则） ---------- */
.acct-box .btn { width: auto; margin-top: 0; }
.acct-box .btn.ghost { color: var(--gray); border-color: #b9ccc1; }
.acct-box .btn.ghost:hover { background: #eef4ef; color: var(--ink); }
.acct-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.acct-actions .acct-link { text-decoration: none; text-align: center; }
