/* ===== 设计基座：令牌 / 按钮 / 弹窗 / 提示 ===== */
:root {
  --bg: #0a0f1c;
  --bg2: #0d1526;
  --panel: #121c30;
  --panel2: #182642;
  --line: #24365c;
  --line2: #31497c;
  --gold: #e8c15a;
  --gold2: #f5d67b;
  --gold-dk: #a97f1c;
  --txt: #e9eef7;
  --txt2: #9fb0cc;
  --txt3: #64769a;
  --red: #e0524d;
  --green: #39c48e;
  --blue: #5aa2e8;
  --violet: #9a6ee8;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --radius: 14px;
  --cw: clamp(48px, 6.6vmin, 78px); /* 纸牌宽度 */
  font-size: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: radial-gradient(120% 90% at 50% 0%, #12203c 0%, var(--bg) 58%, #070b14 100%);
  color: var(--txt);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* 屏幕切换 */
.screen {
  position: fixed; inset: 0;
  display: none; flex-direction: column;
  animation: scrIn .28s ease;
}
.screen.active { display: flex; }
@keyframes scrIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px; border-radius: 12px;
  font-size: 15px; font-weight: 700; letter-spacing: .04em;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none; }
.btn-gold {
  background: linear-gradient(180deg, #f7dc8a, #e8bd54 55%, #c99a2e);
  color: #4a3200;
  box-shadow: 0 4px 14px rgba(232, 193, 90, .35), inset 0 1px 0 rgba(255, 255, 255, .55);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.07); }
.btn-green {
  background: linear-gradient(180deg, #52d6a2, #2ba476);
  color: #04321f; box-shadow: 0 4px 14px rgba(57, 196, 142, .3), inset 0 1px 0 rgba(255, 255, 255, .4);
}
.btn-red {
  background: linear-gradient(180deg, #ef7a72, #c93f38);
  color: #fff; box-shadow: 0 4px 14px rgba(224, 82, 77, .3), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-ghost {
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line2);
  color: var(--txt2);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--gold); color: var(--gold2); }
.btn-big { padding: 14px 34px; font-size: 17px; border-radius: 14px; }
.btn-play {
  min-width: 108px; padding: 12px 26px; font-size: 18px; border-radius: 16px;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line);
  color: var(--txt2); transition: all .15s;
}
.icon-btn:hover { color: var(--gold2); border-color: var(--gold-dk); }

/* 输入框 */
.inp {
  width: 100%; padding: 12px 16px;
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--line); border-radius: 12px;
  color: var(--txt); font-size: 15px; outline: none;
  transition: border-color .15s;
}
.inp:focus { border-color: var(--gold); }
.inp::placeholder { color: var(--txt3); }

/* 头像 */
.avatar { width: 100%; height: 100%; display: block; }
.ava-frame {
  border-radius: 50%; overflow: hidden; flex: none;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .4), inset 0 0 0 2px rgba(255, 255, 255, .18);
  background: var(--panel2);
}

/* 顶栏 */
.topbar {
  height: 60px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; gap: 12px;
  background: linear-gradient(180deg, rgba(10, 15, 28, .9), rgba(10, 15, 28, .55));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
  z-index: 5;
}
.tb-user { display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.tb-user .ava-frame { width: 40px; height: 40px; }
/* 房间屏返回按钮 */
.room-back {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 16px 8px 12px; font-size: 14px; font-weight: 700; border-radius: 11px;
}
.room-back svg { margin-top: -1px; }
.tb-name { font-weight: 700; font-size: 15px; }
.tb-tier { font-size: 12px; font-weight: 700; }
.tb-right { display: flex; align-items: center; gap: 8px; }
.tb-beans {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 20px;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line);
  font-weight: 800; color: var(--gold2); font-variant-numeric: tabular-nums;
}
.tb-title { font-weight: 800; color: var(--gold2); letter-spacing: .2em; }

/* 弹窗 */
.modal-ov {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4, 7, 14, .66); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s; padding: 20px;
}
.modal-ov.show { opacity: 1; }
.modal {
  width: min(430px, 94vw); max-height: 86vh;
  background: linear-gradient(175deg, var(--panel2), var(--panel) 70%);
  border: 1px solid var(--line2); border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transform: translateY(14px) scale(.97); transition: transform .2s;
  overflow: hidden;
}
.modal-ov.show .modal { transform: none; }
.modal.wide { width: min(560px, 96vw); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line); flex: none;
}
.modal-title { font-weight: 800; font-size: 17px; color: var(--gold2); letter-spacing: .06em; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--line); flex: none; }
.confirm-text { color: var(--txt2); line-height: 1.7; font-size: 15px; }

/* Toast */
#toastBox {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 22px; border-radius: 12px;
  background: rgba(16, 24, 44, .92); border: 1px solid var(--line2);
  color: var(--txt); font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-8px); transition: all .25s;
}
.toast.show { opacity: 1; transform: none; }

/* 撒花 */
.confetti {
  position: fixed; top: -20px; z-index: 80;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(540deg); opacity: .7; }
}

/* 统计格 */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-cell {
  background: rgba(0, 0, 0, .25); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 8px; text-align: center;
}
.stat-cell b { display: block; font-size: 18px; color: var(--gold2); font-variant-numeric: tabular-nums; }
.stat-cell span { font-size: 12px; color: var(--txt2); }

/* 记录表 */
.rec-list { display: flex; flex-direction: column; gap: 8px; }
.rec-row {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center;
  padding: 10px 14px; border-radius: 10px;
  background: rgba(0, 0, 0, .22); border: 1px solid var(--line);
  font-size: 13px;
}
.rec-row .r-time { color: var(--txt3); font-size: 12px; }
.rec-row .r-delta { font-weight: 800; font-variant-numeric: tabular-nums; }
.rec-delta-plus { color: var(--green); }
.rec-delta-minus { color: var(--red); }
.rec-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 8px; font-weight: 700;
  background: rgba(232, 193, 90, .12); color: var(--gold2);
}
.rec-tag.lose { background: rgba(224, 82, 77, .12); color: #ff9b96; }
.rec-tag.win { background: rgba(57, 196, 142, .12); color: #7fe6bd; }
.rec-empty { text-align: center; color: var(--txt3); padding: 30px 0; font-size: 14px; }

/* 开关 */
.switch {
  position: relative; width: 46px; height: 26px; border-radius: 13px;
  background: rgba(0, 0, 0, .4); border: 1px solid var(--line2);
  transition: background .18s; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--txt2); transition: all .18s;
}
.switch.on { background: linear-gradient(180deg, #f0cd6d, #d9ac3d); border-color: var(--gold-dk); }
.switch.on::after { left: 22px; background: #fff; }

.set-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px dashed var(--line);
  font-size: 15px;
}
.set-row:last-child { border-bottom: none; }

/* ---------- 头像框（等级解锁，每 10 级一档） ---------- */
.ava-frame { position: relative; }
.ava-frame.fr1 { box-shadow: 0 3px 10px rgba(0, 0, 0, .4), inset 0 0 0 3px #b08d57; }
.ava-frame.fr2 { box-shadow: 0 3px 10px rgba(0, 0, 0, .4), inset 0 0 0 3px #c0c8d4, 0 0 10px rgba(192, 200, 212, .35); }
.ava-frame.fr3 { box-shadow: 0 3px 10px rgba(0, 0, 0, .4), inset 0 0 0 3px #f0c040, 0 0 14px rgba(240, 192, 64, .45); }
.ava-frame.fr4 { box-shadow: 0 3px 10px rgba(0, 0, 0, .4), inset 0 0 0 3px #7fd6c2, 0 0 14px rgba(127, 214, 194, .45); }
.ava-frame.fr5 { box-shadow: 0 3px 10px rgba(0, 0, 0, .4), inset 0 0 0 3px #7ab8ff, 0 0 16px rgba(122, 184, 255, .55); }
.ava-frame.fr6 { box-shadow: 0 3px 10px rgba(0, 0, 0, .4), inset 0 0 0 3px #ff7a7a, 0 0 18px rgba(255, 122, 122, .6), 0 0 6px rgba(240, 192, 64, .8); }
.ava-wrap { position: relative; display: inline-flex; flex: none; }
.lv-tag {
  position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  padding: 1px 7px; border-radius: 8px; white-space: nowrap;
  background: linear-gradient(180deg, #2a3550, #1a2338);
  border: 1px solid var(--gold-dk); color: var(--gold2);
  font-size: 10px; font-weight: 800; line-height: 1.4; z-index: 2; pointer-events: none;
}
.lv-tag.big { bottom: -4px; font-size: 12px; }

/* ---------- 顶栏：签到 / 补给 / 豆子变动飘字 ---------- */
.tb-beans { position: relative; }
.sign-btn { color: var(--gold2); border-color: var(--gold-dk); animation: signPulse 2.2s infinite; }
.supply-btn { color: #7fd6c2; border-color: #2a7a68; }
@keyframes signPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 192, 64, .35); }
  50% { box-shadow: 0 0 0 6px rgba(240, 192, 64, 0); }
}
.bean-float {
  position: absolute; left: 50%; top: -4px; transform: translateX(-50%);
  font-size: 13px; font-weight: 900; pointer-events: none; z-index: 3;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .6);
  animation: beanFloat 1.35s ease-out forwards;
}
.bean-float.plus { color: #8fd66a; }
.bean-float.minus { color: #ff7a7a; }
@keyframes beanFloat {
  from { opacity: 0; transform: translate(-50%, 6px) scale(.8); }
  25% { opacity: 1; }
  to { opacity: 0; transform: translate(-50%, -34px) scale(1.05); }
}

/* ---------- 个人信息：经验 / 补给状态 / 豆子流水 / 编辑提示 ---------- */
.exp-line {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--txt2); margin-bottom: 10px;
}
.exp-bar {
  flex: 1; height: 8px; border-radius: 5px; overflow: hidden;
  background: rgba(0, 0, 0, .4); border: 1px solid var(--line);
}
.exp-bar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, #d9ac3d, #f5d67b); transition: width .4s; }
.bean-status {
  display: flex; gap: 18px; flex-wrap: wrap;
  font-size: 13px; color: var(--txt2);
  padding: 9px 12px; margin-bottom: 12px;
  background: rgba(0, 0, 0, .25); border: 1px solid var(--line); border-radius: 10px;
}
.bean-log { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.bean-log-t { font-size: 12px; color: var(--txt3); margin-bottom: 6px; font-weight: 700; }
.bean-log-row {
  display: flex; align-items: center; gap: 12px;
  font-size: 12.5px; padding: 4px 0; color: var(--txt2);
}
.bean-log-row span:first-child { flex: 1; }
.edit-tip { font-size: 12px; color: var(--txt3); margin-top: 6px; }

/* ---------- 房间：高倍场勾选 / 标识 ---------- */
.high-opt {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 0 14px; font-size: 13.5px; font-weight: 700; color: var(--txt2);
  cursor: pointer; user-select: none;
}
.high-opt input { width: 16px; height: 16px; accent-color: #f0c040; cursor: pointer; }
.high-badge {
  display: inline-block; margin-left: 8px; padding: 2px 9px; border-radius: 9px;
  background: linear-gradient(180deg, #e0524d, #b23a36); color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .08em; vertical-align: 1px;
}
.high-mark { color: #ff9c6b !important; }

@media (max-width: 640px) {
  :root { font-size: 14px; }
  .topbar { height: 52px; padding: 0 10px; }
  .tb-beans { padding: 5px 10px; font-size: 13px; }
  .icon-btn { width: 34px; height: 34px; }
  .modal-body { padding: 14px; }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; }
}
