/* 红包雨抽奖 · 移动端页面样式（零依赖，纯 CSS 绘制红包） */
:root {
  --gold: #ffd879;
  --gold-deep: #d79a24;
  --red-deep: #5c0710;
  --ink: #5c1210;
  --paper: #fff6e6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: #fff4e2;
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 214, 130, .35), transparent 46%),
    linear-gradient(180deg, #a5121f 0%, #810b18 48%, #56060f 100%);
  overflow-x: hidden;
}

/* ---------- 背景装饰 ---------- */
.decor { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.glow {
  position: absolute; top: -190px; left: 50%; width: 520px; height: 520px;
  transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 196, 92, .32) 0%, rgba(255, 196, 92, 0) 68%);
}
.cloud { position: absolute; width: 190px; height: 60px; border: 2px solid rgba(255, 216, 140, .16); border-radius: 60px; }
.cloud::after { content: ""; position: absolute; width: 90px; height: 90px; border: 2px solid rgba(255, 216, 140, .12); border-radius: 50%; left: 42px; top: -42px; }
.cloud-a { top: 22%; left: -70px; }
.cloud-b { bottom: 16%; right: -80px; transform: rotate(180deg); }
.dot { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 220, 150, .55); box-shadow: 0 0 12px rgba(255, 210, 130, .8); animation: twinkle 3.2s ease-in-out infinite; }
.d1 { top: 12%; left: 14%; } .d2 { top: 30%; right: 18%; animation-delay: .6s; }
.d3 { top: 52%; left: 8%; animation-delay: 1.2s; } .d4 { top: 68%; right: 12%; animation-delay: 1.8s; }
.d5 { top: 84%; left: 24%; animation-delay: 2.4s; } .d6 { top: 42%; right: 34%; animation-delay: .3s; }
@keyframes twinkle { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.4); } }

/* ---------- 布局 ---------- */
.shell {
  position: relative; z-index: 1; min-height: 100%;
  max-width: 460px; margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; letter-spacing: .5px; color: #ffe9bd; }
.brand-mark { width: 16px; height: 16px; border-radius: 4px; background: linear-gradient(135deg, #ffe6a8, #e0a034); box-shadow: 0 0 12px rgba(255, 210, 130, .6); transform: rotate(45deg); }
.who { display: flex; align-items: center; gap: 6px; font-size: 11px; min-width: 0; }
.mode-tag { padding: 3px 8px; border-radius: 20px; background: rgba(255, 216, 121, .18); border: 1px solid rgba(255, 216, 121, .4); color: #ffe0a0; white-space: nowrap; }
.identity { color: rgba(255, 236, 205, .7); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { flex: 1; display: flex; align-items: center; }
.footer { text-align: center; font-size: 11px; color: rgba(255, 225, 185, .45); margin-top: 20px; letter-spacing: 1px; }

.view { display: none; width: 100%; }
.view.active { display: block; }
.view.active.center { display: flex; }

/* ---------- 卡片 ---------- */
.card {
  position: relative; width: 100%;
  background: linear-gradient(158deg, #fffaf0 0%, #fff1d8 100%);
  color: var(--ink); border-radius: 22px;
  padding: 34px 24px 28px;
  box-shadow: 0 22px 60px rgba(30, 0, 0, .32), inset 0 0 0 1px rgba(255, 255, 255, .72);
  border: 1px solid rgba(255, 222, 160, .8);
}
.card::before {
  content: ""; position: absolute; inset: 8px; border-radius: 16px;
  border: 1px solid rgba(196, 133, 40, .22); pointer-events: none;
}
.card.center { flex-direction: column; align-items: center; text-align: center; }
.card h1 { margin: 6px 0 14px; font-size: 24px; line-height: 1.35; font-weight: 900; letter-spacing: .5px; }
.desc { font-size: 13px; line-height: 1.85; color: #8a5040; margin: 0 0 12px; }
.desc strong { color: #b62a1c; }
.muted { font-size: 13px; color: #9a7362; }
.ribbon {
  position: absolute; top: -13px; left: 26px; padding: 5px 14px; border-radius: 20px;
  font-size: 11px; font-weight: 700; color: #fff6df;
  background: linear-gradient(135deg, #e0452c, #b81d20);
  box-shadow: 0 6px 14px rgba(160, 25, 20, .3);
}
.rules { list-style: none; padding: 14px 16px; margin: 4px 0 20px; background: rgba(214, 154, 36, .09); border-radius: 12px; }
.rules li { position: relative; padding-left: 16px; font-size: 12px; line-height: 2; color: #8a5040; }
.rules li::before { content: ""; position: absolute; left: 2px; top: 11px; width: 5px; height: 5px; border-radius: 50%; background: #d79a24; }
.rules strong { color: #b62a1c; }

/* ---------- 统计 ---------- */
.stats { display: flex; gap: 8px; margin: 0 0 20px; }
.stat { flex: 1; text-align: center; padding: 10px 4px; border-radius: 12px; background: rgba(196, 133, 40, .1); }
.stat b { display: block; font-size: 20px; font-weight: 900; color: #b62a1c; line-height: 1.2; }
.stat span { display: block; font-size: 10px; color: #9a7362; margin-top: 3px; }

/* ---------- 按钮 ---------- */
.btn-primary {
  display: block; width: 100%; border: 0; border-radius: 30px; padding: 15px 20px;
  font-size: 16px; font-weight: 800; letter-spacing: 2px; color: #6d1509; cursor: pointer;
  background: linear-gradient(180deg, #ffe9a8 0%, #f7c65a 45%, #e5a437 100%);
  box-shadow: 0 10px 22px rgba(180, 105, 20, .35), inset 0 1px 0 rgba(255, 255, 255, .8);
  transition: transform .12s ease, filter .12s ease;
}
.btn-primary:active { transform: translateY(2px); filter: brightness(.96); }
.btn-ghost {
  margin-top: 16px; padding: 10px 18px; border-radius: 24px; cursor: pointer;
  border: 1px solid rgba(180, 105, 20, .35); background: transparent;
  color: #9a5a20; font-size: 12px;
}
.btn-mini { padding: 5px 12px; border-radius: 16px; border: 1px solid rgba(180, 105, 20, .4); background: #fff; color: #9a5a20; font-size: 11px; cursor: pointer; }
.btn-share { display: block; width: 100%; margin-top: 10px; padding: 8px 16px; font-size: 11px; letter-spacing: .5px; }

/* ---------- 演示模式 ---------- */
.demo-panel { margin-top: 18px; padding-top: 14px; border-top: 1px dashed rgba(180, 105, 20, .3); }
.demo-row { font-size: 12px; color: #8a5040; }
.demo-row b { color: #b62a1c; }
.demo-input-row { display: flex; gap: 8px; margin-top: 10px; }
.demo-input-row input {
  flex: 1; min-width: 0; padding: 8px 12px; border-radius: 18px; font-size: 12px;
  border: 1px solid rgba(180, 105, 20, .32); background: rgba(255, 255, 255, .8); color: var(--ink);
  outline: none;
}
.demo-input-row input:focus { border-color: #d79a24; }
.demo-tip { font-size: 11px; line-height: 1.6; color: #a98b76; margin: 8px 0 0; text-align: left; }

/* ---------- 结果页 ---------- */
.crest {
  width: 62px; height: 62px; border-radius: 50%; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 900; color: #fff6df;
  background: linear-gradient(150deg, #e0452c, #a5121f);
  box-shadow: 0 10px 24px rgba(150, 20, 20, .3);
}
.result-title { font-size: 26px; font-weight: 900; letter-spacing: 2px; margin: 4px 0 18px; color: #b62a1c; }
.result-title.lose { color: #8a6a58; margin-bottom: 12px; }
.number-badge {
  width: 148px; height: 148px; border-radius: 50%; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 66px; font-weight: 900; color: #7a1210; letter-spacing: -2px;
  background: radial-gradient(circle at 34% 26%, #fff6cf 0%, #f9d271 42%, #e0a636 75%, #b97c1c 100%);
  border: 5px solid #fff3cd;
  box-shadow: 0 14px 30px rgba(170, 105, 20, .34), inset 0 2px 8px rgba(255, 255, 255, .8);
  text-shadow: 0 2px 0 rgba(255, 255, 255, .5);
}
.result-sub { font-size: 13px; font-weight: 700; color: #9a5a20; letter-spacing: 2px; margin-bottom: 14px; }
.lose-mark {
  width: 118px; height: 118px; border-radius: 50%; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; letter-spacing: 2px; color: #a9896f;
  border: 4px dashed rgba(169, 137, 111, .5); background: rgba(169, 137, 111, .06);
}
.result-note { font-size: 12px; line-height: 1.8; color: #8a5040; margin: 0 0 4px; }
.result-foot { font-size: 11px; color: #a98b76; margin: 16px 0 0; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(196, 133, 40, .25); border-top-color: #c48528; animation: spin .8s linear infinite; margin-bottom: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 游戏层 ---------- */
.play-view { position: fixed; inset: 0; z-index: 20; overflow: hidden; background: linear-gradient(180deg, #a5121f 0%, #7c0a16 60%, #56060f 100%); }
.play-view.active { display: block; }
.hud { position: absolute; top: 0; left: 0; right: 0; z-index: 22; padding: calc(16px + env(safe-area-inset-top)) 20px 12px; background: linear-gradient(180deg, rgba(70, 4, 12, .72), transparent); }
.hud-top { display: flex; align-items: baseline; justify-content: space-between; font-size: 12px; color: #ffe9bd; letter-spacing: 1px; }
.timer { font-size: 34px; font-weight: 900; color: #ffe08a; text-shadow: 0 3px 12px rgba(255, 170, 60, .6); font-variant-numeric: tabular-nums; }
.progress { height: 7px; border-radius: 8px; background: rgba(255, 255, 255, .18); overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; width: 0; border-radius: 8px; background: linear-gradient(90deg, #ffd879, #ff8a4a); box-shadow: 0 0 10px rgba(255, 190, 90, .8); }
.play-tip { position: absolute; bottom: calc(22px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; font-size: 11px; color: rgba(255, 226, 180, .6); letter-spacing: 1px; z-index: 22; }
.rain { position: absolute; inset: 0; overflow: hidden; }

/* 红包：外层负责下落，内层负责点中爆开，互不干扰 */
.packet {
  position: absolute; top: -100px; width: 66px; height: 88px;
  animation: fall var(--dur, 2s) linear var(--delay, 0s) forwards;
  will-change: transform; cursor: pointer; touch-action: manipulation;
}
@keyframes fall {
  0%   { transform: translateY(0) rotate(-8deg) scale(var(--scale, 1)); opacity: 0; }
  10%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateY(calc(100vh + 220px)) rotate(12deg) scale(var(--scale, 1)); opacity: 0; }
}
.packet-inner {
  position: relative; width: 100%; height: 100%; border-radius: 9px;
  background: linear-gradient(155deg, #ff7057 0%, #e42834 46%, #a90d1c 100%);
  box-shadow: 0 9px 18px rgba(30, 0, 0, .35), inset 0 -9px 14px rgba(0, 0, 0, .2), inset 0 2px 4px rgba(255, 255, 255, .38);
  transform-origin: center;
}
.packet-inner::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 34px;
  border-radius: 9px 9px 52% 52% / 9px 9px 62% 62%;
  background: linear-gradient(180deg, #ff9a7a 0%, #ea4038 100%);
  box-shadow: 0 2px 0 rgba(255, 220, 160, .55);
}
.packet-inner::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 8px; height: 2px;
  border-radius: 2px; background: rgba(255, 214, 140, .45);
}
.coin {
  position: absolute; left: 50%; top: 36px; transform: translateX(-50%);
  width: 36px; height: 36px; border-radius: 50%; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; color: #9b2410;
  background: radial-gradient(circle at 34% 28%, #fff3c0 0%, #f6c957 55%, #d79a24 100%);
  box-shadow: 0 2px 7px rgba(0, 0, 0, .3), inset 0 1px 2px rgba(255, 255, 255, .9);
}
.packet-inner.pop { animation: pop .34s ease-out forwards; }
@keyframes pop {
  0%   { transform: scale(1); filter: brightness(1); }
  45%  { transform: scale(1.28); filter: brightness(1.65); }
  100% { transform: scale(1.75); opacity: 0; filter: brightness(2); }
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; top: 50%; z-index: 99; transform: translate(-50%, -50%) scale(.95);
  max-width: 76%; padding: 12px 18px; border-radius: 12px; text-align: center;
  background: rgba(38, 6, 8, .9); color: #ffe9bd; font-size: 13px; line-height: 1.6;
  white-space: pre-line; word-break: break-all;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
}
.toast.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast.pick { pointer-events: auto; user-select: text; -webkit-user-select: text; cursor: text; }

/* ---------- 多活动 / 奖品 / 名单 ---------- */
.subtitle { font-size: 12px; color: #b0835b; letter-spacing: 1px; margin: -8px 0 12px; }
.btn-wide { display: block; width: 100%; }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; filter: grayscale(.35); }
.preview-tag {
  margin: -10px 0 14px; padding: 7px 12px; border-radius: 10px; text-align: center;
  font-size: 11px; letter-spacing: 1px; color: #ffe3a5;
  background: rgba(255, 216, 121, .12); border: 1px dashed rgba(255, 216, 121, .5);
}
.prize-box { margin: 0 0 18px; padding: 12px 14px; border-radius: 12px; background: rgba(196, 133, 40, .08); border: 1px solid rgba(196, 133, 40, .18); }
.prize-title { font-size: 11px; font-weight: 800; letter-spacing: 2px; color: #a05b1c; margin-bottom: 8px; }
.prize-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px dashed rgba(180, 105, 20, .18); }
.prize-item:first-of-type { border-top: 0; }
.prize-dot { flex: none; width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 32% 28%, #fff3c0, #e0a636); box-shadow: inset 0 1px 2px #fff; }
.prize-img { flex: none; width: 28px; height: 28px; object-fit: contain; border-radius: 6px; }
.prize-meta { min-width: 0; display: flex; flex-direction: column; }
.prize-meta b { font-size: 12px; color: #7a3018; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prize-meta small { font-size: 10px; color: #a98b76; margin-top: 2px; }
.activity-switch { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 11px; color: #a98b76; }
.activity-switch select { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 10px; border: 1px solid rgba(180, 105, 20, .32); background: #fff; color: #7a3018; font-size: 12px; outline: none; }
.result-prize { font-size: 13px; font-weight: 800; color: #9a5a20; letter-spacing: 1px; margin: -8px 0 12px; }
.number-badge.badge-text { font-size: 26px; letter-spacing: 0; padding: 0 10px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.list-head h1 { margin: 0 0 6px; }
.list-tip { font-size: 11px; color: #a98b76; margin: 0 0 14px; }
.winners-list { max-height: 46vh; overflow-y: auto; }
.winner-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px dashed rgba(180, 105, 20, .22); }
.winner-no { flex: none; width: 24px; font-size: 11px; color: #c09a70; font-weight: 800; }
.winner-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.winner-meta b { font-size: 12px; color: #7a3018; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.winner-meta small { font-size: 10px; color: #a98b76; margin-top: 2px; }
.winner-num { flex: none; min-width: 38px; padding: 5px 8px; border-radius: 10px; text-align: center; font-size: 13px; font-weight: 900; color: #8a2b12; background: linear-gradient(180deg, #ffe9a8, #f0c05a); }
.empty { padding: 34px 10px; text-align: center; font-size: 12px; color: #a98b76; }

@media (max-height: 640px) {
  .card { padding: 26px 20px 22px; }
  .card h1 { font-size: 21px; }
  .number-badge { width: 120px; height: 120px; font-size: 52px; }
  .number-badge.badge-text { font-size: 22px; }
  .winners-list { max-height: 38vh; }
}
