:root {
  --bg1: #090c1e;
  --bg2: #131838;
  --card: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.12);
  --text: #eef1ff;
  --muted: #9aa3c7;
  --gold: #ffd97a;
  --accent: #2dd4bf;
  --danger: #ff2e4d;
  --tier-low: #6ea8ff;
  --tier-mid: #a8f06a;
  --tier-high: #ffd97a;
  --mono: Consolas, "SF Mono", Menlo, "Courier New", monospace;
}

* { box-sizing: border-box; }

/* ---------- 舞台背景：暗场 + 细网格 + 金紫光晕 ---------- */
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1000px 520px at 12% -8%, rgba(255, 217, 122, 0.09), transparent 60%),
    radial-gradient(1100px 620px at 108% 18%, rgba(124, 77, 255, 0.16), transparent 60%),
    radial-gradient(900px 480px at 50% 118%, rgba(255, 217, 122, 0.07), transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(168deg, var(--bg1) 0%, var(--bg2) 52%, #0b0f26 100%);
  background-size: auto, auto, auto, 42px 42px, 42px 42px, auto;
  background-attachment: fixed;
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  line-height: 1.6;
}

.container { max-width: 880px; margin: 0 auto; padding: 24px 16px 60px; }

.hub-link { text-align: center; margin: 0 0 6px; }
.hub-link a { color: var(--muted); font-size: 13px; text-decoration: none; }
.hub-link a:hover { color: var(--gold); }

.hero h1 {
  margin: 0 0 20px;
  text-align: center;
  font-size: 28px;
  letter-spacing: 1px;
  text-shadow: 0 0 24px rgba(255, 217, 122, 0.25);
}
.hero .en { font-size: 15px; color: var(--muted); font-weight: 400; margin-left: 6px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.hidden { display: none !important; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: #10132b;
  font-family: inherit;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: #8b93ff; }
.btn-big { width: 100%; padding: 14px; font-size: 17px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-sim { background: #6d5bd0; color: #fff; }
.btn-danger { background: #c62337; color: #fff; }
.btn-danger-ghost { background: transparent; color: #ff5f6d; border-color: rgba(244, 80, 106, 0.5); }
.btn-danger.armed { animation: armedPulse 1s ease-in-out infinite; }

@keyframes armedPulse {
  50% { filter: brightness(1.35); }
}

/* ---------- 开始屏 ---------- */
.start-card {
  max-width: 480px;
  margin: 0 auto;
  background: linear-gradient(170deg, rgba(255, 217, 122, 0.05), rgba(255, 255, 255, 0.04));
}
.start-card h2 { margin: 0 0 18px; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.field input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}
.field input:focus { outline: 2px solid #6d5bd0; }

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.seg button {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
}
.seg button.active { background: #6d5bd0; color: #fff; }

.rules-hint { color: var(--muted); font-size: 13px; margin: 4px 0 20px; }
.rules-hint b { color: var(--gold); }

/* ---------- 游戏屏头部 ---------- */
.game-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.game-head h2 { margin: 0; font-size: 18px; }

.chip {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip-gold {
  border-color: rgba(255, 217, 122, 0.55);
  color: var(--gold);
  box-shadow: 0 0 14px rgba(255, 217, 122, 0.18);
}

/* 轮次提示：放大加粗，舞台正中 */
.banner {
  text-align: center;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 0 22px rgba(255, 217, 122, 0.35);
  min-height: 32px;
  margin: 0 0 10px;
}

/* ---------- 倒计时条 ---------- */
.timer-wrap {
  position: relative;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  margin: 0 auto 16px;
  max-width: 520px;
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 0.1s linear;
}
.timer-wrap.danger .timer-fill { background: var(--danger); }
.timer-wrap.danger { animation: timerPulse 0.6s ease-in-out infinite; }
.timer-secs {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  line-height: 10px;
  font-weight: 700;
  color: #fff;
  font-family: var(--mono);
}
.timer-wrap.in-modal { margin: 16px 0 0; max-width: none; }

@keyframes timerPulse {
  50% { filter: brightness(1.6); }
}

/* ---------- 手提箱 ---------- */
.cases {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 14px 10px;
  margin-bottom: 22px;
  padding-top: 12px;
}

.case {
  position: relative;
  aspect-ratio: 3 / 3.2;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  /* 深色金属箱体：顶部高光 + 底部厚度 */
  background: linear-gradient(180deg, #4a5382 0%, #2c3359 46%, #1b2144 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.28),
    inset 0 -7px 14px rgba(0, 0, 0, 0.5),
    0 8px 18px rgba(0, 0, 0, 0.5);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px 12px;
  transition: transform 0.15s ease, filter 0.15s ease;
}

/* 提手 */
.case::before {
  content: '';
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 42%;
  height: 12px;
  border: 3px solid #59639c;
  border-bottom: none;
  border-radius: 9px 9px 0 0;
}
/* 金色锁扣 */
.case::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(180deg, #ffe9ad, #c9992e);
  box-shadow: 0 0 7px rgba(255, 217, 122, 0.55);
}

.case:not(:disabled):hover {
  transform: translateY(-4px);
  filter: brightness(1.15);
}

.case:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.case:disabled { cursor: default; }

.case-num {
  font-family: var(--mono);
  font-size: 23px;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

/* 我的箱子：青色描边 + 呼吸灯 */
.case.mine {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  animation: mineBreath 2s ease-in-out infinite;
}

@keyframes mineBreath {
  0%, 100% { box-shadow: 0 0 8px rgba(45, 212, 191, 0.4); }
  50% { box-shadow: 0 0 26px rgba(45, 212, 191, 0.95); }
}

.mine-tag {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #07211d;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* 已开箱：变暗、锁扣消失、金额浮现 */
.case.opened {
  background: rgba(10, 13, 30, 0.55);
  border: 1px dashed rgba(255, 255, 255, 0.16);
  box-shadow: none;
  animation: none;
}
.case.opened::before, .case.opened::after { display: none; }

.case.opened .case-num {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 400;
  opacity: 0.5;
  text-shadow: none;
}

.case-amount {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
  line-height: 1.3;
  padding: 0 2px;
}

.case.opened .case-amount {
  color: #ffb3c0;
  text-decoration: line-through;
  opacity: 0.85;
}

/* 揭示 / 最终箱：金色 */
.case.final {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  box-shadow: 0 0 30px rgba(255, 217, 122, 0.65);
}
.case.final .case-amount {
  color: var(--gold);
  text-decoration: none;
  font-size: 14px;
}

/* 开箱瞬间：抖动 → 放大 → 翻转 → 金额弹出 */
.case.pop { animation: casePop 0.6s cubic-bezier(0.3, 1.3, 0.4, 1); z-index: 2; }

@keyframes casePop {
  0% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-5deg) scale(1.06); }
  55% { transform: rotate(4deg) scale(1.2) rotateY(28deg); }
  100% { transform: rotate(0) scale(1); }
}

.case.pop .case-amount, .case.pop .case-num { animation: amountIn 0.45s 0.18s both; }

@keyframes amountIn {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- 金额板：赌场记分牌，浮在背景上 ---------- */
.board-wrap { padding: 6px 4px 0; }
.board-wrap h3 { margin: 0 0 14px; font-size: 15px; color: var(--gold); }
.board-tip { font-size: 12px; color: var(--muted); font-weight: 400; }

.board { display: grid; gap: 10px; }

.board-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  justify-content: center;
}

.tier-tag {
  flex: none;
  width: 46px;
  margin-right: 6px;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}
.tier-tag::before { content: '● '; }
.tag-low::before { color: var(--tier-low); }
.tag-mid::before { color: var(--tier-mid); }
.tag-high::before { color: var(--tier-high); }

.amt {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
}

.amt.tier-low { color: var(--tier-low); }
.amt.tier-mid { color: var(--tier-mid); }
.amt.tier-high { color: var(--tier-high); text-shadow: 0 0 12px rgba(255, 217, 122, 0.35); }

.amt.hit {
  color: #565e82;
  background: transparent;
  text-decoration: line-through;
  opacity: 0.55;
  text-shadow: none;
}

/* 场上最大剩余金额：发光 */
.amt.max { border: 1px solid rgba(255, 217, 122, 0.6); animation: maxGlow 1.6s ease-in-out infinite; }

@keyframes maxGlow {
  50% { box-shadow: 0 0 18px rgba(255, 217, 122, 0.85); }
}

/* ---------- 历史屏 ---------- */
.history-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.table-scroll { padding: 0; overflow-x: auto; }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 640px;
}

.history-table th,
.history-table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.history-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.history-table td.num { text-align: right; }
.history-table th:nth-child(5), .history-table th:nth-child(6) { text-align: right; }

.history-row { cursor: pointer; }
.history-row:hover { background: rgba(139, 147, 255, 0.1); }

.empty { text-align: center; color: var(--muted); padding: 30px 0; }

/* ---------- 弹窗 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 24, 0.72);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.overlay.show { display: flex; }

.modal {
  width: 100%;
  max-width: 430px;
  max-height: 86vh;
  overflow-y: auto;
  background: linear-gradient(165deg, #232a52, #171c3a);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  animation: modalIn 0.25s cubic-bezier(0.2, 1.2, 0.4, 1);
}

@keyframes modalIn {
  from { transform: scale(0.85) translateY(14px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal h3 { margin: 0 0 12px; }
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

.confirm-text { color: #ffb3c0; margin: 8px 0 0; }

/* ===== 银行家：红光、震动、压迫感 ===== */
#modalBanker.show {
  background: rgba(46, 4, 16, 0.78);
  animation: redFlash 1.3s ease;
}

@keyframes redFlash {
  0% { background: rgba(46, 4, 16, 0); }
  25% { background: rgba(165, 12, 42, 0.62); }
  100% { background: rgba(46, 4, 16, 0.78); }
}

#modalBanker .modal {
  background: radial-gradient(130% 120% at 50% -10%, #4a1024 0%, #23091f 55%, #150a24 100%);
  border: 1px solid rgba(255, 46, 77, 0.6);
  box-shadow: 0 0 70px rgba(255, 46, 77, 0.35), inset 0 0 44px rgba(255, 46, 77, 0.12);
  animation: modalIn 0.25s cubic-bezier(0.2, 1.2, 0.4, 1), modalShake 0.5s 0.18s ease-in-out;
}

@keyframes modalShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

.banker-caller { margin: 0; font-size: 14px; color: #ff8fa0; animation: ring 1s ease-in-out infinite; }

@keyframes ring {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-7deg); }
  75% { transform: rotate(7deg); }
}

.banker-round { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.banker-offer {
  margin: 10px 0;
  font-family: var(--mono);
  font-size: 46px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--danger);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 34px rgba(255, 46, 77, 0.7);
  word-break: break-all;
  line-height: 1.15;
}

.banker-ev { margin: 0; font-size: 12px; color: var(--muted); }

/* 成交 = 金色，不成交 = 深红；均为大按钮 */
.btn-deal {
  background: linear-gradient(180deg, #ffe9ad, #eeb93e);
  color: #241703;
  font-size: 17px;
  padding: 13px 26px;
  box-shadow: 0 0 24px rgba(255, 217, 122, 0.4);
}
.btn-nodeal {
  background: linear-gradient(180deg, #ff5f6d, #b31f31);
  color: #fff;
  font-size: 17px;
  padding: 13px 26px;
  box-shadow: 0 0 24px rgba(255, 46, 77, 0.4);
}

/* 最终交换 */
.swap-desc { color: var(--muted); font-size: 14px; margin: 0; }
.btn-swap { background: var(--gold); }

/* 结束 */
.over-title { margin: 0; font-size: 22px; font-weight: 800; }
.over-amount {
  margin: 10px 0;
  font-family: var(--mono);
  font-size: 42px;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 28px rgba(255, 217, 122, 0.4);
  word-break: break-all;
}
.over-type { margin: 0; font-size: 14px; }
.over-original { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

/* 详情 */
.detail-modal { max-width: 560px; text-align: left; }
.detail-modal h3 { text-align: center; }
.detail-body { font-size: 13px; }

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 14px;
}
.detail-table th, .detail-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 8px;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.detail-table th { color: var(--muted); }
.detail-table td.num { text-align: right; }
.deal-word { color: var(--accent); }
.detail-line { margin: 6px 0; }
.gold { color: var(--gold); }

/* ---------- 响应式 ---------- */
@media (max-width: 560px) {
  .container { padding: 16px 12px 48px; }
  .hero h1 { font-size: 22px; }
  .banner { font-size: 17px; }
  .cases { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 12px 8px; }
  .case-num { font-size: 19px; }
  .case-amount { font-size: 10px; }
  .board-row { gap: 5px 6px; }
  .amt { font-size: 11px; padding: 3px 6px; }
  .tier-tag { width: 38px; font-size: 11px; }
  .banker-offer { font-size: 36px; }
  .over-amount { font-size: 32px; }
  .game-head { gap: 8px; }
  .chip { font-size: 12px; padding: 4px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .case, .modal, .timer-fill { transition: none; animation: none; }
  .banker-caller, .case.mine, .amt.max, .btn-danger.armed { animation: none; }
  #modalBanker .modal { animation: modalIn 0.01s; }
  #modalBanker.show { animation: none; }
}
