:root {
  --felt: #1b4d33;
  --felt-2: #17503a;
  --felt-deep: #0f3525;
  --gold: #e8b64c;
  --gold-2: #c99a2e;
  --text: #f2f4f0;
  --text-dim: rgba(242, 244, 240, 0.6);
  --panel: rgba(10, 30, 20, 0.82);
  --panel-2: rgba(255, 255, 255, 0.06);
  --red: #d64545;
  --blue: #3b82f6;
  --green: #22a06b;
  --purple: #8b5cf6;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0d2417;
  color: var(--text);
  overflow: hidden;
}

button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }
.hidden { display: none !important; }

/* ---------------- 动效 ---------------- */
@keyframes popIn { from { transform: scale(.88) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cardIn { from { transform: translateY(-16px) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rowIn { from { transform: translateX(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes numPop { 0% { transform: scale(.5); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes winnerGlow { 0%, 100% { box-shadow: 0 0 0 0 rgba(232, 182, 76, 0); } 50% { box-shadow: 0 0 22px 3px rgba(232, 182, 76, 0.35); } }
@keyframes chipPop { 0% { transform: translateY(8px) scale(.7); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes seatPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(232, 182, 76, 0.6); } 50% { box-shadow: 0 0 0 6px rgba(232, 182, 76, 0); } }

.modal-card { animation: popIn .22s ease; }
.card { animation: cardIn .28s ease both; }
.bet-chip { animation: chipPop .25s ease both; }
.result-row { animation: rowIn .3s ease both; }
.result-row.winner { background: rgba(232, 182, 76, 0.12); border: 1px solid rgba(232, 182, 76, 0.35); animation: rowIn .3s ease both, winnerGlow 1.4s ease-in-out infinite; }
.result-row.loss { opacity: 0.75; }
.r-net { animation: numPop .35s ease both; }
.r-hole { display: inline-flex; gap: 2px; }
.r-hole .card { width: 22px; height: 31px; font-size: 8px; border-radius: 3px; animation: cardIn .3s ease both; }
.r-hole .card .suit { font-size: 7px; }
.r-hole .card .center-suit { font-size: 8px; }
.seat.acting .avatar { animation: seatPulse 1s ease-in-out infinite; }

/* ---------- 顶栏 ---------- */
#topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  background: rgba(8, 24, 15, 0.92);
  border-bottom: 1px solid rgba(232, 182, 76, 0.18);
  z-index: 20;
  position: relative;
}
.logo { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.logo span { color: var(--gold); }
.room-info { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-dim); }
.room-info b { color: var(--gold); font-size: 15px; letter-spacing: 2px; }
.room-info .dot { width: 8px; height: 8px; border-radius: 50%; background: #37d67a; box-shadow: 0 0 6px #37d67a; }
.balances { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.bal { font-size: 13px; color: var(--text-dim); background: var(--panel-2); padding: 5px 10px; border-radius: 8px; }
.bal b { color: var(--gold); font-size: 14px; }
.bal.credit b { color: #6ee7b7; }
.ghost-btn {
  background: transparent; border: 1px solid rgba(232, 182, 76, 0.4); color: var(--gold);
  padding: 6px 12px; border-radius: 8px; font-size: 13px;
}
.ghost-btn:hover { background: rgba(232, 182, 76, 0.12); }
.chip-btn {
  background: linear-gradient(180deg, #f0c25c, var(--gold-2)); border: none; color: #3a2a05;
  font-weight: 600; padding: 6px 12px; border-radius: 8px; font-size: 13px;
}
.chip-btn:hover { filter: brightness(1.08); }

/* ---------- 大厅 ---------- */
.view { position: absolute; inset: 0; }
#lobby {
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(232, 182, 76, 0.08), transparent 60%),
    radial-gradient(1000px 800px at 50% 110%, rgba(34, 160, 107, 0.12), transparent 60%),
    #0d2417;
}
.lobby-card {
  width: 400px; background: var(--panel); border: 1px solid rgba(232, 182, 76, 0.2);
  border-radius: 20px; padding: 34px 32px 26px; text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.lobby-logo { font-size: 40px; font-weight: 800; letter-spacing: 1px; }
.lobby-logo span { color: var(--gold); }
.slogan { margin-top: 8px; font-size: 15px; color: var(--text); }
.sub-slogan { margin-top: 4px; font-size: 12px; color: var(--text-dim); }
.field { margin-top: 26px; text-align: left; }
.field label { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 6px; }
.field input, .code-input {
  width: 100%; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text); border-radius: 10px; padding: 12px 14px; font-size: 15px; outline: none;
}
.field input:focus, .code-input:focus { border-color: var(--gold); }
.btn {
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.16); color: var(--text);
  padding: 11px 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
}
.btn:hover { background: rgba(255, 255, 255, 0.16); }
.btn.primary {
  background: linear-gradient(180deg, #f0c25c, var(--gold-2)); border: none; color: #3a2a05;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { width: 100%; margin-top: 12px; padding: 13px; font-size: 15px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--text-dim); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: rgba(255, 255, 255, 0.12); }
.row { display: flex; gap: 10px; }
.row .code-input { flex: 1; text-transform: uppercase; letter-spacing: 4px; text-align: center; }
.row .btn { flex: 1; }
.perks { display: flex; justify-content: center; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.perk { font-size: 11px; color: var(--text-dim); background: rgba(255, 255, 255, 0.05); border-radius: 20px; padding: 5px 10px; }
.perk b { color: var(--gold); }
.hint { margin-top: 14px; font-size: 11px; color: rgba(110, 231, 183, 0.55); }

/* ---------- 牌桌 ---------- */
#table { display: flex; }
#felt {
  position: absolute; inset: 52px 300px 0 0; min-width: 640px;
  background:
    radial-gradient(900px 480px at 50% 50%, rgba(23, 80, 58, 0.4), transparent 70%),
    radial-gradient(1200px 700px at 50% 50%, #0f3525, #0a2418);
  overflow: hidden;
}
#tableText {
  position: absolute; top: 14px; left: 0; right: 0; text-align: center;
  color: rgba(242, 244, 240, 0.5); font-size: 12px; letter-spacing: 3px;
}
#boardArea {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -56%);
  display: flex; gap: 8px; align-items: center;
}
#potLabel {
  position: absolute; left: 50%; top: calc(50% + 34px); transform: translateX(-50%);
  color: var(--gold); font-size: 15px; font-weight: 600; letter-spacing: 1px;
}
#seats { position: absolute; inset: 0; }
.seat {
  position: absolute; transform: translate(-50%, -50%); width: 92px; text-align: center;
  user-select: none;
}
.seat .avatar {
  width: 44px; height: 44px; border-radius: 50%; margin: 0 auto;
  background: linear-gradient(180deg, #2a7a54, #1a533a);
  border: 2px solid rgba(232, 182, 76, 0.6);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; color: #fff; position: relative;
}
.seat .avatar .dealer-btn {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; color: #333; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 1px solid #999;
}
.seat .name { margin-top: 4px; font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-tag {
  display: inline-block; font-size: 9px; padding: 0 4px; margin-left: 3px;
  background: rgba(139, 92, 246, 0.35); color: #c4b5fd; border-radius: 4px; vertical-align: 1px;
}
.seat .stack { font-size: 11px; color: var(--gold); }
.seat .status-tag {
  font-size: 10px; padding: 1px 6px; border-radius: 8px; margin-top: 2px; display: inline-block;
  background: rgba(255, 255, 255, 0.1); color: var(--text-dim);
}
.seat .status-tag.folded { background: rgba(214, 69, 69, 0.25); color: #f3a0a0; }
.seat .status-tag.allin { background: rgba(139, 92, 246, 0.3); color: #c4b5fd; }
.seat .status-tag.acting { background: var(--gold); color: #3a2a05; font-weight: 700; }
.seat .bet-chip {
  margin-top: 3px; font-size: 11px; color: #ffd77a; background: rgba(0, 0, 0, 0.35);
  display: inline-block; padding: 2px 8px; border-radius: 10px;
}
.seat .hole { display: flex; gap: 3px; justify-content: center; margin-top: 3px; min-height: 34px; }
.seat .hole .mini { width: 20px; height: 30px; border-radius: 3px; background: #fff; color: #222; font-size: 9px; display: flex; align-items: center; justify-content: center; }
.seat .hole .mini.back { background: #7a4d21; border: 1px solid #a96a33; color: transparent; }
.seat .hand-desc { font-size: 10px; color: #7ee2ab; margin-top: 2px; }

/* 扑克牌 */
.card {
  width: 44px; height: 62px; border-radius: 6px; background: #fff; color: #222;
  position: relative; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.card .rank { position: absolute; top: 3px; left: 5px; font-size: 14px; font-weight: 700; line-height: 1; }
.card .suit { position: absolute; bottom: 2px; right: 5px; font-size: 12px; line-height: 1; }
.card .center-suit { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; opacity: 0.9; }
.card.red { color: #d1342f; }
.card.face-down {
  background: linear-gradient(135deg, #7a4d21, #5a3614);
  border: 1px solid #a96a33;
}
.card.face-down::after {
  content: ""; position: absolute; inset: 4px; border-radius: 3px;
  border: 1px dashed rgba(255, 255, 255, 0.35);
}

/* 行动条 */
#actionBar {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--panel); border-radius: 14px; border: 1px solid rgba(232, 182, 76, 0.25);
  min-width: 430px; justify-content: center;
}
.action-btn {
  border: none; border-radius: 9px; padding: 10px 16px; font-size: 14px; font-weight: 700; color: #fff;
}
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.action-btn.fold { background: var(--red); }
.action-btn.call { background: var(--blue); }
.action-btn.raise { background: var(--gold-2); color: #3a2a05; }
.action-btn.allin { background: var(--purple); }
#raiseBox { display: flex; flex-direction: column; align-items: center; gap: 2px; }
#raiseBox input[type=range] { width: 130px; accent-color: var(--gold-2); }
#raiseVal { font-size: 11px; color: #ffd77a; }
#timerBar {
  position: absolute; bottom: 0; left: 0; right: 0; height: 4px; background: rgba(255, 255, 255, 0.08);
}
#timerFill { height: 100%; width: 100%; background: var(--gold); transition: width 1s linear; }

/* 聊天 */
#chatPanel {
  position: absolute; top: 52px; right: 0; bottom: 0; width: 300px;
  background: rgba(8, 24, 15, 0.95); border-left: 1px solid rgba(232, 182, 76, 0.15);
  display: flex; flex-direction: column;
}
.chat-head {
  padding: 12px 16px; font-size: 13px; color: var(--gold); font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
#chatList { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.msg-line { font-size: 12px; line-height: 1.5; color: var(--text); word-break: break-word; }
.msg-line .who { color: var(--gold); font-weight: 600; margin-right: 6px; }
.msg-line.sys { color: rgba(110, 231, 183, 0.6); font-style: italic; }
.chat-input-row { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.chat-input-row input {
  flex: 1; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 13px; outline: none;
}
.chat-input-row button {
  background: var(--gold-2); border: none; color: #3a2a05; font-weight: 700;
  border-radius: 8px; padding: 0 14px;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-card {
  width: 430px; max-height: 82vh; overflow-y: auto;
  background: #12291c; border: 1px solid rgba(232, 182, 76, 0.3); border-radius: 16px;
  padding: 20px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal-card.wide { width: 760px; }
.modal-head {
  display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 700; color: var(--gold);
  padding-bottom: 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.credit-num { margin-left: auto; font-size: 13px; color: var(--text-dim); font-weight: 400; }
.credit-num b { color: #6ee7b7; font-size: 16px; }
.close-x {
  background: rgba(255, 255, 255, 0.1); border: none; color: var(--text);
  width: 26px; height: 26px; border-radius: 7px; font-size: 15px; line-height: 1;
}
.close-x:hover { background: rgba(255, 255, 255, 0.2); }

#resultList { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.result-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05); border-radius: 10px; font-size: 13px;
}
.result-row.winner { background: rgba(232, 182, 76, 0.12); border: 1px solid rgba(232, 182, 76, 0.35); }
.result-row .r-name { font-weight: 700; width: 70px; }
.result-row .r-hand { flex: 1; color: var(--text-dim); font-size: 12px; }
.result-row .r-net { font-weight: 700; }
.result-row .r-net.pos { color: #4ade80; }
.result-row .r-net.neg { color: #f87171; }
.result-row .r-credit { font-size: 11px; color: #6ee7b7; }
.modal-foot { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.modal-foot .btn.big { margin-top: 0; }
.modal-foot .wait { font-size: 12px; color: var(--text-dim); }

/* 额度中心 */
.key-panel {
  margin-top: 14px; padding: 12px; border: 1px solid rgba(110, 231, 183, 0.25);
  border-radius: 12px; background: rgba(34, 160, 107, 0.07);
}
.key-form { display: flex; gap: 8px; flex-wrap: wrap; }
.key-form input {
  flex: 1; min-width: 140px; background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; outline: none;
}
.key-form input:focus { border-color: var(--gold); }
.key-form .btn { margin-left: auto; }
.key-status { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text); }
.key-status b { color: #6ee7b7; }
.key-status .dim { color: var(--text-dim); font-size: 11px; }
.key-tip { margin-top: 8px; font-size: 11px; color: rgba(110, 231, 183, 0.65); line-height: 1.5; }
.bond-row {
  font-size: 12px; padding: 7px 9px; margin-bottom: 5px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.05); display: flex; justify-content: space-between; gap: 8px;
}
.bond-row .who { color: var(--gold); }
.bond-row .rem { color: #6ee7b7; }
.bond-row.debt { border-left: 2px solid rgba(248, 113, 113, 0.7); }
.bond-row.credit { border-left: 2px solid rgba(74, 222, 128, 0.7); }
.credit-body { display: flex; gap: 16px; margin-top: 14px; height: 440px; }
.chat-wrap { flex: 1.4; display: flex; flex-direction: column; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px; overflow: hidden; }
.llm-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; font-size: 13px; line-height: 1.55; padding: 8px 11px; border-radius: 10px; white-space: pre-wrap; }
.msg.bot { background: rgba(255, 255, 255, 0.07); align-self: flex-start; }
.msg.user { background: rgba(232, 182, 76, 0.18); align-self: flex-end; color: #ffe6ad; }
.msg.meta { align-self: center; font-size: 11px; color: rgba(110, 231, 183, 0.7); background: none; padding: 2px; }
.llm-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.llm-input-row textarea {
  flex: 1; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 13px; resize: none; outline: none;
}
.ledger-wrap { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.ledger-head { font-size: 12px; color: var(--gold); margin-top: 6px; }
.ledger-row { font-size: 11px; color: var(--text-dim); display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.06); }
.ledger-row .d { font-weight: 700; }
.ledger-row .d.pos { color: #4ade80; }
.ledger-row .d.neg { color: #f87171; }

/* 排行榜 */
#boardList { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.board-row { display: flex; gap: 10px; align-items: center; font-size: 13px; padding: 8px 10px; background: rgba(255, 255, 255, 0.05); border-radius: 8px; }
.board-row .rank { width: 24px; color: var(--gold); font-weight: 700; }
.board-row .b-name { flex: 1; }
.board-row .b-token { color: var(--gold); font-weight: 700; }
.board-row .b-credit { color: #6ee7b7; font-size: 12px; }

/* toast */
#toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  background: rgba(20, 40, 30, 0.95); border: 1px solid rgba(232, 182, 76, 0.4);
  color: var(--text); padding: 10px 18px; border-radius: 10px; font-size: 13px;
  z-index: 99; opacity: 0; transition: opacity 0.25s; pointer-events: none;
  max-width: 70vw;
}
#toast.show { opacity: 1; }
