/* ========== 设计系统 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --red-deep: #8E0000;
  --red: #C62828;
  --red-bright: #E53935;
  --gold: #F57F17;
  --gold-light: #FFD54F;
  --gold-soft: #FFF8E1;
  --bg: #6D0F0F;

  --header-h: 52px;
  --topbar-h: 84px;

  --f-xxl: 26px; --f-xl: 22px; --f-lg: 19px; --f-md: 17px; --f-sm: 15px; --f-xs: 13px;

  --radius: 12px;
  --radius-round: 50%;
}

html, body { height: 100%; }
body {
  background: radial-gradient(ellipse at top, #B71C1C 0%, var(--red-deep) 55%, #5C0000 100%);
  background-attachment: fixed;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  max-width: 430px; margin: 0 auto; min-height: 100vh;
  color: #fff; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  position: relative;
}

/* ========== 头部 ========== */
.header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: var(--header-h); padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  background: linear-gradient(180deg, rgba(142,0,0,.6), rgba(142,0,0,0));
}
.back-btn {
  width: 32px; height: 32px; border-radius: var(--radius-round); border: none;
  background: rgba(255,255,255,.16); color: #fff; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.back-btn:active { background: rgba(255,255,255,.3); }
.header h1 { font-size: var(--f-lg); font-weight: 700; letter-spacing: 1px; }

/* ========== 顶部状态条 ========== */
.topbar {
  position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top)); z-index: 29;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  height: var(--topbar-h); padding: 0 16px;
  background: linear-gradient(180deg, rgba(109,15,15,.55), rgba(109,15,15,0));
}
.stats-row { display: flex; align-items: center; justify-content: center; gap: 26px; }
.stat { text-align: center; }
.stat-num {
  font-size: var(--f-xl); font-weight: 900; color: var(--gold-light);
  text-shadow: 0 2px 4px rgba(0,0,0,.35);
}
.stat-num small { font-size: var(--f-sm); font-weight: 700; }
.stat-label { font-size: var(--f-xs); color: rgba(255,255,255,.75); letter-spacing: 1px; margin-top: 2px; }
.stat-divider { width: 1px; height: 34px; background: rgba(255,255,255,.22); }
.countdown-box {
  font-size: var(--f-sm); color: rgba(255,255,255,.85); letter-spacing: 1px; min-height: 18px;
}
.countdown-box b { color: var(--gold-light); font-size: var(--f-md); margin: 0 2px; }

/* ========== 红包雨场地 ========== */
.play-field {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: 0; bottom: 0; width: 100%; max-width: 430px;
  z-index: 1; overflow: hidden;
}
.play-tip {
  position: absolute; left: 0; right: 0; top: 46%; text-align: center;
  color: rgba(255,255,255,.7); font-size: var(--f-md); letter-spacing: 3px;
  pointer-events: none; z-index: 2;
}

/* 掉落红包 */
.env {
  position: absolute;
  top: calc(var(--header-h) + env(safe-area-inset-top) + var(--topbar-h) - 64px);
  width: 58px; height: 74px; margin-left: -29px; border-radius: 10px; cursor: pointer; z-index: 5;
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  box-shadow: 0 6px 14px rgba(0,0,0,.35), inset 0 0 0 2px rgba(255,213,79,.5);
  display: flex; align-items: center; justify-content: center;
  animation: fall var(--dur) linear forwards;
  will-change: transform;
}
.env.gold {
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  box-shadow: 0 6px 18px rgba(245,127,23,.55), inset 0 0 0 2px rgba(255,255,255,.5);
}
.env-seal {
  width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 70%, #C96600);
  display: flex; align-items: center; justify-content: center;
  color: var(--red-deep); font-size: 16px; font-weight: 900;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4);
}
.env.gold .env-seal {
  background: radial-gradient(circle at 35% 30%, #fff, var(--red-bright) 75%);
  color: var(--gold);
}
@keyframes fall {
  0%   { transform: translateY(0) rotate(-8deg); opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { transform: translateY(105vh) rotate(8deg); opacity: .5; }
}

/* 抢到反馈：浮动金额 */
.float-tip {
  position: fixed; transform: translate(-50%, -50%); font-weight: 900;
  color: var(--gold-light); text-shadow: 0 2px 4px rgba(0,0,0,.45);
  font-size: 22px; pointer-events: none; z-index: 60;
  animation: rise .9s ease-out forwards;
}
.float-tip.miss { color: #fff; font-size: 15px; }
@keyframes rise {
  0%   { opacity: 0; transform: translate(-50%, -20%) scale(.6); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1.15); }
}

/* 抢到反馈：金币迸射 */
.pop { position: fixed; width: 0; height: 0; z-index: 59; pointer-events: none; }
.pop .c {
  position: absolute; left: 0; top: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 70%, #BF6A00);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4);
  animation: pop .7s ease-out forwards;
}
@keyframes pop {
  0%   { transform: translate(0,0) scale(.3); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}

/* ========== 失败弹窗 ========== */
.overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity .25s;
}
.overlay.show { opacity: 1; visibility: visible; }
.fail-box {
  width: 78%; max-width: 300px; background: #fff; border-radius: 16px;
  padding: 26px 22px 20px; text-align: center; color: #1A1A1A;
  transform: scale(.7); transition: transform .25s cubic-bezier(.2,1.4,.4,1);
}
.overlay.show .fail-box { transform: scale(1); }
.fail-icon {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 50%;
  background: var(--gold-soft); color: var(--gold); font-size: 30px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}
.fail-msg { font-size: var(--f-md); font-weight: 700; color: #1A1A1A; margin: 12px 0 18px; line-height: 1.6; word-break: break-all; }
.fail-btn {
  width: 100%; padding: 12px; border: none; border-radius: 26px;
  background: linear-gradient(90deg, var(--gold-light), var(--gold)); color: var(--red-deep);
  font-size: var(--f-md); font-weight: 800; letter-spacing: 2px; cursor: pointer;
}
.fail-btn:active { opacity: .9; }

/* ========== Toast ========== */
.toast {
  position: fixed; left: 50%; bottom: 22%; transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.82); color: #fff; padding: 11px 22px; border-radius: 30px;
  font-size: var(--f-sm); z-index: 300; opacity: 0; visibility: hidden; transition: all .25s; max-width: 80%; text-align: center;
}
.toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* loading */
.loader-page { position: fixed; inset: 0; z-index: 400; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.loader-page.hide { opacity: 0; visibility: hidden; transition: opacity .3s; }
.loader-coin {
  width: 56px; height: 56px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 70%, #BF6A00);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.4); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { margin-top: 14px; color: rgba(255,255,255,.8); font-size: var(--f-sm); letter-spacing: 2px; }
