:root {
  --red: #b3262a;
  --red-deep: #8e1418;
  --gold: #e2b54c;
  --gold-soft: #f6d98c;
  --paper: #f8eedc;
  --ink: #2b1b14;
  --kai: "STKaiti", "KaiTi", "Kaiti SC", "楷体", serif;
  --song: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #3a0d0f; overflow: hidden; }
body { font-family: var(--song); color: var(--ink); user-select: none; -webkit-user-select: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }

#app {
  position: relative;
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 225, 160, .55), transparent 60%),
    radial-gradient(circle at 15% 85%, rgba(214, 120, 110, .18), transparent 40%),
    linear-gradient(180deg, #fbf1df 0%, #f3e0c2 100%);
}

.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- 首页 ---------- */
#home { align-items: center; padding: calc(14px + env(safe-area-inset-top)) 18px calc(12px + env(safe-area-inset-bottom)); }

.grand-box {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(100deg, #8e1418, #c7372e 60%, #8e1418);
  color: #fff4d6;
  box-shadow: 0 6px 18px rgba(142, 20, 24, .35), inset 0 0 0 1.5px rgba(246, 217, 140, .6);
  position: relative; overflow: hidden;
  text-align: left;
}
.grand-box::after {
  content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .35), transparent);
  animation: shine 3.2s infinite;
}
@keyframes shine { 0% { left: -60%; } 60%, 100% { left: 130%; } }
.gb-seal {
  flex: none; width: 42px; height: 42px; border-radius: 10px;
  display: grid; place-items: center;
  font: bold 26px var(--kai); color: #8e1418;
  background: linear-gradient(135deg, #ffe7a6, #e2b54c);
  animation: wobble 2.4s ease-in-out infinite;
}
@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) scale(1.06); } }
.gb-text { flex: 1; display: flex; flex-direction: column; }
.gb-text b { font: bold 18px var(--kai); letter-spacing: 2px; }
.gb-text small { font-size: 12px; opacity: .9; margin-top: 2px; }
.gb-arrow { font-size: 26px; opacity: .8; }

.title { position: relative; align-self: stretch; margin: 18px 0 0; text-align: center; line-height: 1; }
.shop-seal {
  position: absolute; right: 2px; top: -6px;
  width: 34px; height: 34px; display: grid; place-items: center;
  font: bold 11px/1.15 var(--kai); font-style: normal; letter-spacing: 1px; color: #fff4d6;
  background: #b3262a; border-radius: 4px; transform: rotate(8deg); opacity: .82;
  box-shadow: inset 0 0 0 1.5px #fff4d6, 0 0 0 1px #b3262a;
}
.title span { display: block; font: bold 46px var(--kai); color: var(--red); letter-spacing: 6px; text-shadow: 0 2px 0 #fff, 0 4px 12px rgba(179, 38, 42, .25); }
.title small { display: block; margin-top: 10px; font: 15px var(--kai); color: #8a5a2b; letter-spacing: 3px; }

.avatar-wrap { position: relative; margin-top: 6px; flex: 1; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.halo { position: absolute; width: 230px; height: 230px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 220, 140, .7), rgba(255, 220, 140, 0) 70%); animation: pulse 3s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(.92); opacity: .8; } 50% { transform: scale(1.05); opacity: 1; } }
#homeAvatar { position: relative; animation: float 3.4s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.rank-badge {
  position: relative; margin-top: -6px;
  padding: 5px 18px; border-radius: 999px;
  background: #fff8ea; border: 1.5px solid var(--gold);
  font: bold 18px var(--kai); color: var(--red-deep); letter-spacing: 2px;
  box-shadow: 0 3px 10px rgba(120, 60, 20, .15);
}

.progress { width: 86%; margin-top: 10px; text-align: center; }
.bar { height: 8px; border-radius: 99px; background: rgba(120, 70, 30, .15); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #e2b54c, #d2363c); transition: width .6s; }
.progress p { margin: 6px 0 0; font-size: 13px; color: #8a5a2b; }

.btn {
  padding: 11px 22px; border-radius: 999px;
  font: bold 17px var(--kai); letter-spacing: 2px;
  background: #fff8ea; color: var(--red-deep);
  border: 1.5px solid var(--gold);
  box-shadow: 0 3px 0 #c89a46;
  transition: transform .08s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c89a46; }
a.btn { display: inline-block; text-decoration: none; }
.btn.primary { background: linear-gradient(180deg, #d2363c, #a61e23); color: #fff4d6; border-color: #f6d98c; box-shadow: 0 4px 0 #6e0f12, 0 8px 20px rgba(166, 30, 35, .35); }
.btn.primary:active { box-shadow: 0 1px 0 #6e0f12; }
.btn.gold { background: linear-gradient(180deg, #f6d98c, #e2b54c); color: #6e0f12; border-color: #fff3c4; box-shadow: 0 4px 0 #a8761c; }
.btn.ghost { background: transparent; box-shadow: none; border-style: dashed; }
.btn.big { margin-top: 16px; width: 78%; padding: 15px 0; font-size: 22px; letter-spacing: 4px; animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
.level-tip { margin: 8px 0 0; font-size: 12px; color: #a0703c; min-height: 16px; }

.home-nav { display: flex; gap: 8px; width: 100%; margin-top: 14px; }
.home-nav button {
  flex: 1; position: relative; padding: 9px 0 8px; border-radius: 12px;
  background: rgba(255, 250, 238, .8); border: 1px solid rgba(200, 154, 70, .55);
  font: 15px var(--kai); color: #6b3a1f; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.home-nav i { font: bold 18px var(--kai); font-style: normal; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff4d6; background: var(--red); }
.home-nav em { position: absolute; top: 4px; right: 10px; font-style: normal; font-size: 11px; color: #a0703c; }
.home-nav em.dot { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #d2363c; color: #fff; display: none; place-items: center; }
.home-nav em.dot.on { display: grid; }
.shop { margin-top: 10px; font-size: 12px; color: #a0703c; letter-spacing: 1px; }

/* ---------- 关卡 ---------- */
.hud { flex: none; display: flex; align-items: center; padding: calc(8px + env(safe-area-inset-top)) 10px 4px; }
.icon { width: 40px; height: 40px; border-radius: 50%; font-size: 26px; line-height: 1; color: var(--red-deep); background: rgba(255, 250, 238, .85); border: 1px solid rgba(200, 154, 70, .6); }
.icon.off { opacity: .4; }
.hud-mid { flex: 1; text-align: center; display: flex; flex-direction: column; }
.hud-mid b { font: bold 21px var(--kai); color: var(--red-deep); letter-spacing: 2px; }
.hud-mid span { font-size: 12px; color: #8a5a2b; margin-top: 2px; }
.hud-mid .hard { color: #fff; background: #d2363c; border-radius: 4px; padding: 0 4px; margin-left: 4px; }
#board { flex: 1; width: 100%; min-height: 0; touch-action: none; display: block; }
.props { flex: none; display: flex; justify-content: center; gap: 14px; padding: 6px 12px calc(12px + env(safe-area-inset-bottom)); }
.props button {
  position: relative; width: 92px; padding: 7px 0 6px; border-radius: 14px;
  background: linear-gradient(180deg, #fffaf0, #f3e2c0); border: 1.5px solid #d9b06a;
  box-shadow: 0 3px 0 #b98a4a; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.props button:active { transform: translateY(2px); box-shadow: 0 1px 0 #b98a4a; }
.props button.used { opacity: .45; }
.props i { font: bold 20px var(--kai); font-style: normal; color: var(--red); }
.props span { font: 13px var(--kai); color: #6b3a1f; }
.props em { position: absolute; top: -7px; right: -5px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; font-style: normal; font-size: 12px; line-height: 22px; color: #fff; background: #d2363c; border: 1.5px solid #fff; }
.props em.plus { background: #3c9a6a; }

/* ---------- 弹窗 ---------- */
.modal { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(40, 10, 8, .62); backdrop-filter: blur(2px); }
.modal.hidden { display: none; }
.sheet {
  width: 100%; max-height: 92%; overflow: auto;
  padding: 22px 18px 18px; border-radius: 20px;
  background: linear-gradient(180deg, #fffaf0, #f6e6c8);
  border: 2px solid var(--gold); box-shadow: 0 20px 50px rgba(0, 0, 0, .4);
  text-align: center; animation: pop .28s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sheet h2 { margin: 4px 0 6px; font: bold 26px var(--kai); color: var(--red-deep); letter-spacing: 2px; }
.sheet h3 { margin: 14px 0 8px; font: bold 17px var(--kai); color: #6b3a1f; }
.sheet p { margin: 6px 0; font-size: 14px; color: #6b3a1f; line-height: 1.6; }
.sheet .muted { font-size: 12px; color: #a0703c; }
.btns { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.btns .btn { flex: 1; min-width: 120px; }
.stack-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.seal { display: inline-grid; place-items: center; width: 68px; height: 68px; border-radius: 12px; transform: rotate(-8deg); font: bold 26px var(--kai); color: #fff4d6; background: var(--red); box-shadow: inset 0 0 0 3px #fff4d6, 0 0 0 2px var(--red); animation: stamp .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes stamp { from { transform: rotate(-8deg) scale(2.4); opacity: 0; } to { transform: rotate(-8deg) scale(1); opacity: 1; } }
.seal.grey { background: #6b6b6b; box-shadow: inset 0 0 0 3px #eee, 0 0 0 2px #6b6b6b; }

.shijian {
  margin: 12px auto 4px; padding: 18px 16px; max-width: 300px;
  border-radius: 6px; text-align: center;
  background: repeating-linear-gradient(90deg, rgba(180, 120, 60, .06) 0 1px, transparent 1px 28px), #fff8e8;
  border: 1px solid #d9b06a; box-shadow: 0 6px 16px rgba(120, 60, 20, .15);
  animation: unfold .5s ease-out;
}
@keyframes unfold { from { transform: scaleY(.2); opacity: 0; } to { transform: scaleY(1); opacity: 1; } }
.shijian .tag { display: inline-block; font: bold 13px var(--kai); color: #fff; background: var(--red); border-radius: 4px; padding: 1px 6px; }
.shijian .txt { margin: 10px 0 6px; font: 19px/1.7 var(--kai); color: var(--ink); }
.shijian.wen .txt { font-size: 15px; text-align: left; }
.shijian .src { font-size: 12px; color: #a0703c; }

.coupon {
  display: flex; align-items: stretch; margin: 10px auto; max-width: 320px; text-align: left;
  border-radius: 12px; overflow: hidden; background: #fff; box-shadow: 0 4px 12px rgba(120, 30, 20, .18);
  animation: unfold .45s ease-out;
}
.coupon .amt { flex: none; width: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(160deg, #d2363c, #8e1418); color: #fff4d6; border-right: 2px dashed #fff4d6; }
.coupon .amt b { font: bold 34px var(--kai); line-height: 1; }
.coupon .amt b small { font-size: 14px; }
.coupon .amt span { font-size: 11px; margin-top: 4px; }
.coupon.grand .amt { background: linear-gradient(160deg, #e2b54c, #a8761c); color: #5a0c0f; }
.coupon.grand .amt b { font-size: 22px; }
.coupon .info { flex: 1; padding: 10px 12px; }
.coupon .info b { display: block; font: bold 15px var(--kai); color: var(--red-deep); }
.coupon .info small { display: block; font-size: 11px; color: #8a5a2b; margin-top: 3px; line-height: 1.5; }
.coupon .info code { display: inline-block; margin-top: 4px; font: bold 13px monospace; letter-spacing: 1px; color: var(--ink); background: #f6e6c8; padding: 1px 6px; border-radius: 4px; }
.coupon.used { filter: grayscale(1); opacity: .55; }
.coupon .info .redeem { margin-top: 6px; padding: 4px 12px; font-size: 13px; }

.teaser { margin-top: 12px; padding: 8px 10px; border-radius: 10px; background: rgba(179, 38, 42, .08); font-size: 13px; color: #8e1418; }
.teaser b { font: bold 15px var(--kai); letter-spacing: 2px; }

.boxes { display: flex; justify-content: center; gap: 12px; margin: 16px 0 6px; }
.gift {
  width: 86px; height: 92px; border-radius: 12px; position: relative;
  background: linear-gradient(180deg, #d2363c, #8e1418); box-shadow: 0 6px 0 #5a0c0f, 0 10px 20px rgba(0, 0, 0, .25);
  display: grid; place-items: center; font: bold 30px var(--kai); color: #f6d98c;
  animation: wobble 1.6s ease-in-out infinite;
}
.gift:nth-child(2) { animation-delay: .2s; }
.gift:nth-child(3) { animation-delay: .4s; }
.gift::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 12px; transform: translateX(-50%); background: #e2b54c; opacity: .9; }
.gift span { position: relative; }
.gift.open { animation: none; background: #fff8e8; box-shadow: 0 0 0 2px #e2b54c, 0 0 24px rgba(255, 210, 120, .9); color: var(--red-deep); font-size: 15px; padding: 6px; line-height: 1.3; }
.gift.open::before { display: none; }
.gift.other { opacity: .5; transform: scale(.92); }

.path-list { text-align: left; margin-top: 8px; }
.path-item { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-bottom: 1px dashed rgba(160, 112, 60, .35); }
.path-item canvas { flex: none; }
.path-item .ph { flex: none; width: 52px; height: 57px; border-radius: 10px; display: grid; place-items: center; background: rgba(120, 70, 30, .12); font: bold 24px var(--kai); color: #a0703c; }
.path-item b { font: bold 17px var(--kai); color: var(--red-deep); }
.path-item small { display: block; font-size: 12px; color: #8a5a2b; margin-top: 2px; }
.path-item.now { background: rgba(226, 181, 76, .2); border-radius: 10px; }

.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.card-cell { aspect-ratio: 3/4; border-radius: 6px; padding: 6px; display: flex; flex-direction: column; justify-content: center; font: 13px/1.45 var(--kai); color: var(--ink); background: #fff8e8; border: 1px solid #d9b06a; overflow: hidden; }
.card-cell.lock { background: rgba(120, 70, 30, .1); color: #a0703c; font-size: 22px; border-style: dashed; }
.card-cell small { font-size: 10px; color: #a0703c; margin-top: 4px; }

.poster { width: 100%; max-width: 320px; border-radius: 10px; box-shadow: 0 8px 20px rgba(0, 0, 0, .3); }
.field { width: 100%; margin-top: 10px; padding: 11px 14px; border-radius: 10px; border: 1.5px solid #d9b06a; background: #fff; font: 18px var(--kai); text-align: center; outline: none; }
.big-code { margin: 14px 0; font: bold 24px monospace; letter-spacing: 2px; color: var(--red-deep); padding: 12px; border: 2px dashed var(--red); border-radius: 10px; background: #fff; }
.near-miss { font: bold 20px var(--kai); color: var(--red); }

.toast { position: absolute; left: 50%; top: 18%; z-index: 20; transform: translate(-50%, -10px); max-width: 80%; padding: 10px 18px; border-radius: 999px; background: rgba(43, 27, 20, .88); color: #fff4d6; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.dev { position: absolute; right: 8px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 9; padding: 6px 12px; border-radius: 999px; font-size: 12px; background: #2b1b14; color: #fff; opacity: .75; }

/* ---------- 全国喜报 / 飘屏 / 榜单 ---------- */
.ticker { width: 100%; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; background: rgba(142, 20, 24, .9); box-shadow: 0 2px 8px rgba(120, 20, 20, .25); color: #fff4d6; font-size: 12.5px; }
.ticker.hidden { display: none; }
.ticker > i { flex: none; font: bold 12px var(--kai); font-style: normal; padding: 2px 7px; border-radius: 999px; color: var(--red-deep); background: linear-gradient(#ffe7a6, #e2b54c); }
.ticker-win { flex: 1; overflow: hidden; white-space: nowrap; -webkit-mask: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); mask: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.ticker-in { display: inline-block; padding-left: 100%; animation: marquee linear infinite; }
.ticker-in span { margin-right: 36px; }
.ticker-in b { color: #ffd77a; font-weight: bold; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }

.danmu { position: absolute; left: 0; right: 0; top: calc(60px + env(safe-area-inset-top)); height: 64px; overflow: hidden; pointer-events: none; z-index: 5; }
.danmu div { position: absolute; left: 100%; white-space: nowrap; padding: 5px 14px 5px 5px; border-radius: 999px; font-size: 13px; color: #fff4d6; background: linear-gradient(90deg, rgba(179, 38, 42, .95), rgba(142, 20, 24, .85)); box-shadow: 0 0 0 1.5px #e2b54c, 0 4px 12px rgba(0, 0, 0, .2); animation: fly 9s linear forwards; }
.danmu div i { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; border-radius: 50%; font: bold 12px var(--kai); font-style: normal; color: var(--red-deep); background: #ffd77a; }
.danmu div b { color: #ffd77a; }
.danmu div.me { background: linear-gradient(90deg, #d79b2b, #b3262a); }
@keyframes fly { from { transform: translateX(0); } to { transform: translateX(calc(-100vw - 100%)); } }

.rankline { margin: 10px 0 4px; padding: 10px; border-radius: 12px; background: linear-gradient(#fff6df, #ffeec8); border: 1px solid rgba(226, 181, 76, .7); font-size: 13px; color: #6b3a1f; line-height: 1.7; }
.rankline .big { display: block; font: bold 22px var(--kai); color: var(--red); letter-spacing: 1px; }
.rankline .big b { font-size: 30px; }
.rankline small { display: block; font-size: 12px; color: #a0703c; }
.name-row { display: flex; gap: 8px; margin-top: 8px; }
.name-row .field { flex: 1; margin: 0; }
.name-row .btn { flex: none; padding: 0 14px; }

.board-list { max-height: 46vh; overflow-y: auto; margin: 10px 0; text-align: left; }
.board-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px dashed rgba(200, 154, 70, .45); font-size: 14px; color: #6b3a1f; }
.board-row .pos { width: 28px; text-align: center; font: bold 17px var(--kai); color: #a0703c; }
.board-row:nth-child(1) .pos { color: #d29a16; font-size: 21px; }
.board-row:nth-child(2) .pos { color: #8f9aa6; font-size: 20px; }
.board-row:nth-child(3) .pos { color: #b86b3a; font-size: 19px; }
.board-row .nm { flex: 1; font: bold 15px var(--kai); color: var(--red-deep); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .nm small { display: block; font: 11px sans-serif; color: #a0703c; }
.board-row .lv { font-size: 13px; }
.board-row.me { background: rgba(226, 181, 76, .22); border-radius: 10px; }
.board-stats { display: flex; justify-content: space-around; margin-top: 8px; }
.board-stats div { font-size: 12px; color: #a0703c; }
.board-stats b { display: block; font: bold 22px var(--kai); color: var(--red); }
.coupon.pending { opacity: .8; border-style: dashed; }
.coupon.pending .amt { filter: saturate(.55); }

.coupon .info small.scope { display: inline-block; margin-top: 4px; padding: 0 6px; border-radius: 4px; font-size: 12px; font-weight: bold; color: #fff; background: var(--red); }
