* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #120c08; }
body { font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Serif CJK SC", sans-serif; color: #fff; }
body.hide-cursor, body.hide-cursor * { cursor: none !important; }

/* 1080×1920 设计稿，main.js 里整体等比缩放 */
#app { position: absolute; left: 50%; top: 50%; width: 1080px; height: 1920px; overflow: hidden; transform-origin: center; background: #1a120c; }
#stage { position: absolute; inset: 0; }
#ui { position: absolute; inset: 0; pointer-events: none; display: var(--ui, block); }

/* 中国风：楷体、朱红、描金、墨色 */
:root { --kai: "KaiTi", "STKaiti", "Kaiti SC", "楷体", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif; --zhu: #b3261e; --gold: #e2b75a; --ink: #231b16; --paper: #f3ead6; }
#ui { font-family: var(--kai); }

/* ---------- 榜首（墙上挂轴） ---------- */
#champ { position: absolute; left: 490px; top: 26px; width: 530px; height: 400px; padding: 18px 0 0; display: flex; flex-direction: column; align-items: center; color: var(--ink);
  background: linear-gradient(var(--paper), #eadcbf); border: solid #2f4a4a; border-width: 26px 22px; outline: 4px solid #c9a24d; outline-offset: -30px;
  box-shadow: inset 0 0 40px rgba(120,80,30,.18), 0 18px 30px rgba(0,0,0,.55); }
/* 上下两根轴杆 */
#champ::before, #champ::after { content: ''; position: absolute; left: -46px; right: -46px; height: 22px; border-radius: 11px; background: linear-gradient(#7a4a24, #3a1d0c 60%, #5a3216); box-shadow: 0 4px 6px rgba(0,0,0,.45); }
#champ::before { top: -40px; }
#champ::after { bottom: -40px; }
#champ .champ-av canvas { width: 226px; height: 226px; display: block; filter: drop-shadow(0 6px 10px rgba(0,0,0,.18)); }
/* "魁"字朱印 */
#champ .crown { position: absolute; top: 18px; left: 26px; width: 66px; height: 66px; display: grid; place-items: center; background: var(--zhu); color: var(--paper); font-size: 48px; font-weight: 700; border-radius: 6px; transform: rotate(-6deg); box-shadow: 0 0 0 3px rgba(179,38,30,.35); }
#champ .champ-name { margin-top: 0; font-size: 38px; line-height: 1.25; flex-shrink: 0; font-weight: 700; color: var(--zhu); max-width: 480px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#champ .champ-sub { flex-shrink: 0; font-size: 30px; font-weight: 700; color: var(--ink); letter-spacing: 2px; }
#champ .champ-sub b { color: #9a6a1f; }
#champ.new { animation: champ-new 1.4s cubic-bezier(.2,.8,.2,1); }
@keyframes champ-new { 0% { transform: scale(.85); filter: brightness(1.6); } 60% { transform: scale(1.04); } 100% { transform: none; filter: none; } }
.tag { font-style: normal; font-size: 20px; margin-left: 8px; padding: 2px 8px; border-radius: 6px; background: var(--zhu); color: #fff; vertical-align: middle; }

/* ---------- 作画顺序 ---------- */
#order { position: absolute; left: 0; top: 350px; width: 520px; white-space: nowrap; text-align: center; font-weight: 700; color: var(--gold); -webkit-text-stroke: 10px #2a0d0a; paint-order: stroke fill; line-height: 1.12; filter: drop-shadow(0 6px 4px rgba(0,0,0,.45)); }
#order .l1 { font-size: 76px; letter-spacing: 8px; }
#order .l2 { font-size: 84px; }

/* ---------- 剩余张数：朱漆牌匾 ---------- */
#remain { position: absolute; left: 60px; top: 566px; height: 82px; padding: 0 40px 0 34px; display: flex; align-items: center; gap: 26px; border-radius: 8px; background: linear-gradient(#7a2216, #3a0d08); border: 4px solid #c9a24d; box-shadow: 0 8px 16px rgba(0,0,0,.5), inset 0 0 0 4px #3a0d08, inset 0 0 0 6px rgba(201,162,77,.6); }
#remain .a { font-size: 54px; font-weight: 700; color: #f6e7c1; letter-spacing: 6px; }
#remain .b { font-size: 46px; font-weight: 700; color: var(--gold); }
#remain .b b { font-size: 58px; display: inline-block; min-width: 1.4em; text-align: center; }
#remain .b b.bump { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.35); color: #fff; } }

/* ---------- 正在作画：一条宣纸横幅 ---------- */
#now { position: absolute; left: 50%; top: 1790px; transform: translate(-50%, 20px); padding: 12px 40px; background: var(--paper); color: var(--ink); font-size: 38px; font-weight: 700; white-space: nowrap; opacity: 0; transition: .4s; border-top: 4px double var(--zhu); border-bottom: 4px double var(--zhu); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
#now b { color: var(--zhu); }
#now.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 小助手：书童 ---------- */
#helper { position: absolute; right: 10px; top: 1380px; width: 400px; height: 540px; }
#helper .mascot { position: absolute; right: 6px; bottom: 110px; width: 180px; height: 270px; animation: bob 2.6s ease-in-out infinite; filter: drop-shadow(0 8px 10px rgba(0,0,0,.3)); }
#helper .mascot .arm-r { transform-origin: 140px 175px; animation: wave 1.8s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px); } }
@keyframes wave { 50% { transform: rotate(-14deg); } }
#helper .bubble { position: absolute; right: 30px; bottom: 395px; width: 380px; padding: 20px 26px; border-radius: 6px; background: var(--paper); color: var(--ink); font-size: 33px; font-weight: 700; line-height: 1.4; border: 3px solid #8a5a2b; box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 6px rgba(179,38,30,.5), 0 10px 24px rgba(0,0,0,.3); opacity: 0; }
#helper .bubble::after { content: ''; position: absolute; right: 80px; bottom: -24px; border: 12px solid transparent; border-top: 16px solid #8a5a2b; }
#helper .bubble.pop { animation: pop .45s cubic-bezier(.2,1.4,.4,1) forwards; }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.9); } to { opacity: 1; transform: none; } }

/* ---------- 满屏掉落 ---------- */
#fall { position: absolute; inset: 0; overflow: hidden; }
#fall .drop { position: absolute; top: -200px; border-radius: 50%; border: 6px solid #c9a24d; box-shadow: 0 8px 18px rgba(0,0,0,.35); background: var(--paper); animation-name: drop; animation-timing-function: cubic-bezier(.45,0,.8,.6); animation-fill-mode: both; }
@keyframes drop { from { transform: translate(0, 0) rotate(0); } to { transform: translate(var(--d), 2200px) rotate(var(--r)); } }
#fall .fall-banner { position: absolute; left: 50%; top: 860px; transform: translateX(-50%); white-space: nowrap; font-size: 76px; font-weight: 700; color: #f6e7c1; -webkit-text-stroke: 10px var(--zhu); paint-order: stroke fill; animation: banner 4.2s cubic-bezier(.2,.9,.3,1) both; }
#fall .fall-banner b { color: var(--gold); }
@keyframes banner { 0% { opacity: 0; transform: translateX(-50%) scale(2.4); } 12% { opacity: 1; transform: translateX(-50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-60px); } }

#flag { position: absolute; left: 16px; top: 12px; font-size: 24px; color: rgba(255,255,255,.75); text-shadow: 0 1px 2px #000; }
#flag:empty { display: none; }

/* ---------- 调试面板 ---------- */
#debug { position: fixed; right: 8px; bottom: 8px; z-index: 10; display: flex; flex-wrap: wrap; gap: 6px; max-width: 380px; padding: 10px; border-radius: 10px; background: rgba(0,0,0,.75); font-size: 13px; }
#debug button, #debug input { padding: 6px 10px; border-radius: 6px; border: 0; font: inherit; }
#debug button { background: #ffd60a; color: #111; cursor: pointer; font-weight: 700; }
#debug #dbgmsg { width: 100%; color: #ccc; word-break: break-all; }

/* ---------- 模拟直播间界面（?room=1） ---------- */
#room { position: absolute; inset: 0; pointer-events: none; z-index: 5; font-size: 30px; }
.rav { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; background: #888; color: #fff; font-weight: 800; flex: none; }
.r-host { position: absolute; left: 20px; top: 70px; height: 88px; padding: 8px 10px 8px 8px; display: flex; align-items: center; gap: 12px; border-radius: 44px; background: rgba(0,0,0,.42); }
.r-host-t { display: flex; flex-direction: column; line-height: 1.15; }
.r-host-t b { font-size: 30px; }
.r-host-t span { font-size: 22px; color: rgba(255,255,255,.75); }
.r-host-t i { font-style: normal; }
.r-host button { margin-left: 6px; padding: 12px 26px; border: 0; border-radius: 30px; background: #fe2c55; color: #fff; font: 700 28px/1 inherit; }
.r-top { position: absolute; right: 20px; top: 78px; display: flex; align-items: center; gap: 10px; }
.r-viewers { display: flex; }
.r-viewers .rav { width: 60px; height: 60px; margin-left: -14px; border: 3px solid rgba(0,0,0,.3); font-size: 26px; }
.r-online { min-width: 90px; height: 60px; padding: 0 18px; display: flex; align-items: center; justify-content: center; border-radius: 30px; background: rgba(0,0,0,.42); font-size: 28px; }
.r-close { width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; font-size: 36px; color: rgba(255,255,255,.9); }
.r-tag { position: absolute; left: 24px; top: 172px; padding: 4px 14px; border-radius: 8px; background: rgba(254,44,85,.85); font-size: 22px; font-weight: 700; }
body.room #flag { display: none; }
body.room #now { top: 1010px; }

.r-gifts { position: absolute; left: 0; top: 1090px; width: 700px; }
.r-gifts .lane { height: 110px; margin-bottom: 14px; }
.gb { display: inline-flex; align-items: center; gap: 12px; height: 96px; padding: 0 20px 0 10px; border-radius: 0 48px 48px 0; background: linear-gradient(90deg, rgba(254,44,85,.85), rgba(255,140,90,.35)); animation: gb-in .35s cubic-bezier(.2,.9,.3,1.2) both; }
.gb.xl { background: linear-gradient(90deg, rgba(255,170,0,.9), rgba(255,220,90,.35)); }
.gb.fall { background: linear-gradient(90deg, rgba(150,60,255,.9), rgba(255,90,200,.4)); }
.gb.out { animation: gb-out .4s ease-in both; }
.gb .rav { width: 76px; height: 76px; border: 3px solid #fff; }
.gb-t { display: flex; flex-direction: column; line-height: 1.2; min-width: 160px; }
.gb-t b { font-size: 28px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gb-t span { font-size: 24px; color: rgba(255,255,255,.85); }
.gb-icon { width: 92px; height: 92px; display: block; margin-top: -16px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.3)); }
.gb-icon svg { width: 100%; height: 100%; }
.gb-n { font-style: italic; font-weight: 900; font-size: 64px; color: #ffe23d; -webkit-text-stroke: 6px #b4005a; paint-order: stroke fill; }
.gb-n.hit { animation: hit .35s cubic-bezier(.2,1.6,.4,1); }
@keyframes gb-in { from { transform: translateX(-110%); } to { transform: none; } }
@keyframes gb-out { to { transform: translateX(-110%); opacity: 0; } }
@keyframes hit { from { transform: scale(1.8); } }

.r-chat { position: absolute; left: 20px; bottom: 140px; width: 660px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; -webkit-mask-image: linear-gradient(transparent, #000 22%); mask-image: linear-gradient(transparent, #000 22%); }
.r-chat .line { max-width: 100%; padding: 8px 18px; border-radius: 26px; background: rgba(0,0,0,.36); font-size: 28px; line-height: 1.35; animation: line-in .3s ease-out; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.r-chat .lv { display: inline-block; min-width: 40px; margin-right: 8px; padding: 0 8px; border-radius: 12px; background: linear-gradient(90deg, #5aa9ff, #7b6cff); font-size: 20px; font-weight: 800; text-align: center; vertical-align: 3px; }
.r-chat .nm { color: #a9d4ff; margin-right: 10px; }
.r-chat .dim { color: rgba(255,255,255,.75); }
.r-chat .g { color: #ffd166; }
.r-chat .sys { color: #8ff0c8; }
.r-chat .sysline { border-radius: 16px; }
@keyframes line-in { from { opacity: 0; transform: translateY(20px); } }

.r-hearts { position: absolute; right: 70px; bottom: 140px; width: 10px; height: 10px; }
.r-hearts .fh { position: absolute; left: 0; bottom: 0; font-size: 56px; animation: heart 3s ease-out both; }
@keyframes heart { 0% { transform: translate(0,0) scale(.3); opacity: 0; } 12% { opacity: 1; transform: translate(0,-60px) scale(var(--s)); } 100% { transform: translate(var(--x), -620px) scale(var(--s)); opacity: 0; } }

.r-bar { position: absolute; left: 20px; right: 20px; bottom: 30px; height: 88px; display: flex; gap: 18px; align-items: center; }
.r-input { flex: 1; height: 88px; padding: 0 34px; display: flex; align-items: center; border-radius: 44px; background: rgba(0,0,0,.4); color: rgba(255,255,255,.7); font-size: 30px; }
.r-btn { width: 88px; height: 88px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(0,0,0,.4); font-size: 42px; }
.r-btn.heart { color: #fe2c55; }
