* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #0b1430; }
body {
  display: flex; align-items: center; justify-content: center;
  font-family: "PingFang SC", "Microsoft YaHei", "Heiti SC", "Noto Sans SC", sans-serif;
  color: #fff; user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; user-select: text; -webkit-user-select: text; }

:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --outline: #173a73;
}

/* Laid out at a fixed 414×736 (9:16) and scaled to the window with CSS zoom (--z, set by index.html), so every
   client — and the live stream — shows exactly the same picture. */
#app {
  --appw: 414px;
  --logo-w: calc(var(--appw) * 0.56);
  --lobby-top: calc(var(--safe-t) + 44px + var(--logo-w) * 0.734);
  position: relative; flex: none; overflow: hidden;
  width: 414px; height: 736px; zoom: var(--z, 1);
}

.screen { position: absolute; inset: 0; display: none; overflow: hidden; }
.screen.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.bg-blue { background: #1aa3ff url(../assets/bg_menu.jpg) center / cover no-repeat; }
.clouds {
  position: absolute; left: -10%; right: -10%; bottom: -2px; height: 90px; pointer-events: none; z-index: 0;
  background:
    radial-gradient(circle at 8% 100%, #f2f5ff 60px, transparent 61px),
    radial-gradient(circle at 25% 110%, #eef2ff 70px, transparent 71px),
    radial-gradient(circle at 48% 120%, #f2f5ff 60px, transparent 61px),
    radial-gradient(circle at 72% 105%, #eaeeff 75px, transparent 76px),
    radial-gradient(circle at 94% 100%, #f2f5ff 65px, transparent 66px);
}

.toon {
  text-shadow: 2px 0 var(--outline), -2px 0 var(--outline), 0 2px var(--outline), 0 -2px var(--outline),
    1.5px 1.5px var(--outline), -1.5px 1.5px var(--outline), 1.5px -1.5px var(--outline), -1.5px -1.5px var(--outline), 0 4px 0 var(--outline);
}

/* ---------- buttons ---------- */
.btn {
  position: relative; height: 52px; padding: 0 22px; border-radius: 26px; font-size: 19px; font-weight: 900; letter-spacing: 1px;
  border: 3px solid #173a73; box-shadow: 0 5px 0 #173a73, inset 0 -6px 0 rgba(0,0,0,.12), inset 0 4px 0 rgba(255,255,255,.45);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #173a73, inset 0 -6px 0 rgba(0,0,0,.12); }
.btn:disabled { filter: grayscale(.8) brightness(.9); }
.btn-yellow { background: linear-gradient(#ffe55c, #ffc21a); color: #6b3500; text-shadow: 0 1px 0 rgba(255,255,255,.6); }
.btn-blue { background: linear-gradient(#5fd0ff, #2a8ef0); text-shadow: 0 2px 0 #1b5aa8; }
.btn-red { background: linear-gradient(#ff8a7a, #f0433a); text-shadow: 0 2px 0 #9a1f1a; }

/* ---------- loading ---------- */
.loading-logo { position: absolute; left: 50%; top: 20%; width: 82%; transform: translateX(-50%); animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 8px 10px rgba(0,40,120,.35)); }
@keyframes bob { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -8px); } }
.loading-age { position: absolute; right: 14px; top: calc(14px + var(--safe-t)); width: 52px; padding: 4px 0; background: #fff; border: 2px solid #2b9a4b; border-radius: 6px; color: #2b9a4b; text-align: center; font-size: 9px; font-weight: 700; }
.loading-age b { display: block; margin: 0 4px 3px; padding: 3px 0; background: #2b9a4b; color: #fff; font-size: 17px; border-radius: 3px; }
.loading-bottom { position: absolute; left: 8%; right: 8%; bottom: calc(60px + var(--safe-b)); text-align: center; z-index: 1; }
.loading-pct { font-size: 22px; font-weight: 900; margin-bottom: 10px; text-shadow: 0 2px 0 rgba(0,40,120,.4); }
.progress { height: 18px; border-radius: 9px; background: #0d4c86; border: 2px solid #0b2a4f; overflow: hidden; box-shadow: inset 0 3px 4px rgba(0,0,0,.35); }
.progress-fill {
  width: 0; height: 100%; border-radius: 9px; transition: width .2s;
  background: repeating-linear-gradient(-45deg, #ffcd1f 0 10px, #ffb800 10px 20px);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.45); animation: stripes .6s linear infinite;
}
@keyframes stripes { from { background-position: 0 0; } to { background-position: 28px 0; } }
.notice { margin-top: 26px; font-size: 11px; line-height: 1.7; color: #33427a; font-weight: 600; position: relative; z-index: 2; }
.loading-msg { min-height: 20px; margin-bottom: 8px; font-size: 14px; font-weight: 800; text-shadow: 0 1px 2px rgba(0,30,80,.6); }
.loading-msg.error { color: #ffe34d; background: rgba(160,20,20,.75); border-radius: 10px; padding: 6px 10px; text-shadow: none; }

/* ---------- menu ---------- */
.topbar { position: absolute; left: 0; right: 0; top: calc(10px + var(--safe-t)); display: flex; align-items: center; gap: 10px; padding: 0 12px; z-index: 2; }
.rank { display: flex; flex-direction: column; align-items: center; }
.badge { position: relative; width: 66px; height: 60px; }
.badge img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(0,0,0,.25)); }
.badge span { position: absolute; left: 0; right: 0; top: 52%; transform: translateY(-50%); text-align: center; font-size: 13px; font-weight: 900; text-shadow: 0 1px 2px #000; }
.stars { display: flex; gap: 2px; margin-top: -4px; font-size: 13px; }
.stars i { color: #193266; font-style: normal; text-shadow: 0 1px 0 rgba(255,255,255,.3); }
.stars i.on { color: #ffcf2e; text-shadow: 0 0 4px #ff9a00, 0 1px 0 #9a5a00; }
.coins { display: flex; align-items: center; height: 34px; padding: 0 4px 0 4px; border-radius: 17px; background: rgba(10,40,90,.55); font-size: 18px; font-weight: 900; min-width: 100px; }
.coins span { margin-right: 10px; }
.coin-ico { width: 30px; height: 30px; margin-right: 10px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fffbd0, #ffd83a 45%, #e6a000); border: 2.5px solid #b97700; position: relative; }
.coin-ico::after { content: "★"; position: absolute; inset: 0; display: grid; place-items: center; color: #d48b00; font-size: 14px; }
.icon-btn { margin-left: auto; width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.85); box-shadow: 0 3px 0 rgba(0,40,120,.35); display: grid; place-items: center; font-size: 20px; }
.icon-btn::before { content: "🔊"; }
.icon-btn.muted::before { content: "🔇"; }

.menu-logo { position: absolute; left: 50%; top: calc(58px + var(--safe-t)); width: var(--logo-w); transform: translateX(-50%); filter: drop-shadow(0 6px 8px rgba(0,40,120,.35)); z-index: 1; }

@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- lobby stage ---------- */
.shop-btn {
  position: absolute; right: 10px; top: calc(var(--lobby-top) + 30px); z-index: 3; width: 62px; height: 62px; border-radius: 16px; overflow: hidden;
  border: 3px solid #173a73; box-shadow: 0 4px 0 #173a73, 0 8px 14px rgba(0,30,90,.35); transition: transform .1s; animation: shopBob 2.6s ease-in-out infinite;
}
.shop-btn:active { transform: scale(.92); }
.shop-btn img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.shop-btn span { position: absolute; left: 0; right: 0; bottom: 0; padding: 1px 0 2px; font-size: 13px; font-weight: 900; text-align: center; background: linear-gradient(transparent, rgba(10,30,80,.85) 45%);
  text-shadow: 1px 0 #173a73, -1px 0 #173a73, 0 1px #173a73, 0 -1px #173a73; }
@keyframes shopBob { 0%,100% { translate: 0 0; } 50% { translate: 0 -4px; } }

/* Live-room gift guide (floating, draggable; position saved as a fraction of the screen). Shared by lobby and game. */
.gift-bar { position: absolute; left: 8px; top: calc(var(--safe-t) + 180px); z-index: 40; display: none; flex-direction: column; gap: 3px; touch-action: none; cursor: grab;
  padding: 5px; border-radius: 12px; background: linear-gradient(180deg, rgba(30,36,72,.92), rgba(12,14,30,.92)); box-shadow: inset 0 0 0 1px rgba(255,210,63,.35), 0 6px 16px rgba(0,0,0,.5); }
#app[data-scr="scr-lobby"] .gift-bar, #app[data-scr="scr-game"] .gift-bar { display: flex; }
.gb-row { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px 0 3px; border-radius: 7px; background: rgba(0,0,0,.35); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); font-size: 13px; font-weight: 800; color: #fff4d6; white-space: nowrap; text-shadow: 0 1px 2px #000; }
.gb-row img { flex: none; width: 26px; height: 26px; object-fit: contain; }
.gb-row span { display: inline-block; }
.gb-head { box-shadow: inset 0 0 0 1px rgba(255,210,63,.45); }
.gift-bar:not(.open) .gb-head span { animation: gbIn .3s ease-out; }
.gb-arr { margin-left: 4px; border: 5px solid transparent; border-bottom: 6px solid #ffd23f; border-top: 0; transition: transform .2s; }
.gift-bar.open .gb-arr { transform: rotate(180deg); }
@keyframes gbIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card-tags { position: absolute; left: 10px; top: calc(var(--lobby-top) + 30px); z-index: 3; display: flex; flex-direction: column; gap: 6px; }
.card-tag { position: relative; display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px 0 2px; border-radius: 15px; background: rgba(8,40,95,.62);
  box-shadow: inset 0 0 0 2px #ffc21a; font-size: 12px; font-weight: 900; white-space: nowrap; }
.card-tag img { width: 28px; height: 28px; object-fit: contain; }
.card-tag b { color: #ffe34d; }
.card-tag::before { content: "限时"; position: absolute; left: 18px; top: -7px; padding: 0 4px; border-radius: 6px; background: #f0433a; font-size: 9px; line-height: 13px; }

.lobby-main { position: absolute; left: 0; right: 0; top: var(--lobby-top); bottom: calc(var(--safe-b) + 22%); z-index: 2; display: flex; flex-direction: column; justify-content: flex-start; gap: 6px; }
.menu-sub { align-self: center; padding: 3px 16px; border-radius: 14px; background: rgba(8,40,95,.45); font-size: 13px; font-weight: 900; letter-spacing: 2px; text-shadow: 0 1px 2px rgba(0,30,80,.6); }
.menu-sub b { color: #ffe34d; font-size: 15px; }
.stage { position: relative; margin-top: -24px; width: 100%; flex: 1 1 0; min-height: 0; max-height: calc(var(--appw) * 0.9); }
.stage canvas { width: 100%; height: 100%; display: block; }

.lobby-bottom { position: relative; margin: 0 5%; z-index: 3; display: flex; flex-direction: column; gap: 10px; }
.host-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.host-bar.hide { display: none; }
.bot-ctrl.hide { display: none; }
.mode-tag { align-self: center; padding: 4px 14px; border-radius: 14px; background: rgba(8,40,95,.5); font-size: 13px; font-weight: 800; }
.mode-tag:empty { display: none; }
.mode-tag b { color: #ffe34d; }
.seg { display: flex; padding: 3px; border-radius: 16px; background: rgba(8,40,95,.5); }
.seg button { padding: 5px 12px; border-radius: 13px; font-weight: 800; font-size: 13px; }
.seg button.on { background: linear-gradient(#ffe55c, #ffc21a); color: #6b3500; }
.bot-ctrl { display: flex; align-items: center; gap: 6px; padding: 3px; border-radius: 16px; background: rgba(8,40,95,.5); font-weight: 900; font-size: 13px; }
.bot-ctrl button { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(#5fd0ff, #2a8ef0); font-size: 18px; font-weight: 900; line-height: 26px; }
.bot-ctrl button:disabled { filter: grayscale(.8); opacity: .6; }
.lobby-btns { display: grid; grid-template-columns: 1fr 1.8fr; gap: 12px; }
.lobby-btns .btn { width: 100%; }
.lobby-btns.solo { grid-template-columns: 1fr; }
.lobby-btns.solo #btn-leave { display: none; }
#btn-main.pulse:not(:disabled) { animation: mainPulse 1.4s ease-in-out infinite; }
@keyframes mainPulse { 50% { transform: scale(1.04); } }

/* ---------- game / HUD ---------- */
#scr-game { background: #eef2f7; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: none; }
.hud-left { position: absolute; left: 10px; top: calc(10px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.pill { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px 0 6px; border-radius: 16px; background: rgba(60,72,100,.72); font-weight: 900; font-size: 18px; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
.pill.time { min-width: 86px; }
.pill.time.warn { background: rgba(230,50,50,.85); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.clock-ico, .skull-ico, .crown-ico { width: 22px; height: 22px; display: inline-block; background-size: contain; background-repeat: no-repeat; background-position: center; }
.clock-ico { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10' fill='%23fff'/%3E%3Ccircle cx='12' cy='12' r='8' fill='%235ec8ff'/%3E%3Cpath d='M12 7v5l3 2' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' fill='none'/%3E%3C/svg%3E"); }
.skull-ico, .feed .sk { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2C7 2 3.5 5.6 3.5 10c0 2.6 1.2 4.5 3 5.6V19a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1v-3.4c1.8-1.1 3-3 3-5.6C20.5 5.6 17 2 12 2z' fill='%23fff'/%3E%3Ccircle cx='8.7' cy='11' r='2.2' fill='%233a4566'/%3E%3Ccircle cx='15.3' cy='11' r='2.2' fill='%233a4566'/%3E%3Cpath d='M10 20v-3M14 20v-3' stroke='%233a4566' stroke-width='1.5'/%3E%3C/svg%3E"); }
.crown-ico { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 18 2 7l5.5 4L12 4l4.5 7L22 7l-1 11z' fill='%23ffcf2e' stroke='%23a06a00' stroke-width='1.4' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.mini { width: 86px; height: 86px; margin-top: 2px; }

.exit-btn { pointer-events: auto !important; position: absolute; left: 50%; top: calc(10px + var(--safe-t)); transform: translateX(-50%); width: 36px; height: 32px; border-radius: 10px; background: rgba(60,72,100,.6); }
.exit-btn::before, .exit-btn::after { content: ""; position: absolute; top: 9px; width: 4px; height: 14px; border-radius: 2px; background: #fff; }
.exit-btn::before { left: 13px; }
.exit-btn::after { right: 13px; }

.lb-panel { position: absolute; right: 8px; top: calc(10px + var(--safe-t)); width: 46%; max-width: 200px; }
.lb-title { display: flex; align-items: center; gap: 4px; justify-content: flex-end; padding-right: 4px; font-weight: 900; font-size: 13px; color: #3c4664; text-shadow: 0 1px 0 #fff; margin-bottom: 3px; }
#hud-lb { list-style: none; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
#hud-lb li { display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px; background: rgba(60,72,100,.68); font-size: 12px; font-weight: 800; width: 100%; }
#hud-lb li .rk { width: 26px; color: #dfe6ff; font-weight: 900; }
#hud-lb li.r1 .rk { color: #ffd23a; }
#hud-lb li.r2 .rk { color: #e3ecff; }
#hud-lb li.r3 .rk { color: #ffb27a; }
#hud-lb li .nm { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#hud-lb li .sc { font-variant-numeric: tabular-nums; }
#hud-lb li.me { background: rgba(30,110,255,.85); }

.feed { position: absolute; left: 50%; top: calc(56px + var(--safe-t)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; width: 60%; }
.feed-item { padding: 3px 12px; border-radius: 12px; background: rgba(40,50,75,.6); font-size: 12px; font-weight: 700; white-space: nowrap; animation: feedIn .3s ease; transition: opacity .5s, transform .5s; }
.feed-item b { color: #ffe34d; }
.feed-item.out { opacity: 0; transform: translateY(-6px); }
.feed .sk { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; background-size: contain; }
@keyframes feedIn { from { opacity: 0; transform: scale(.8); } }

.hud-center { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: 90px; font-weight: 900; opacity: 0; color: #fff; --outline: #173a73;
  text-shadow: 4px 0 var(--outline), -4px 0 var(--outline), 0 4px var(--outline), 0 -4px var(--outline), 3px 3px var(--outline), -3px 3px var(--outline), 3px -3px var(--outline), -3px -3px var(--outline), 0 8px 0 var(--outline); }
.hud-center.show { animation: bigIn 1s ease forwards; }
.hud-center.go { color: #ffe34d; font-size: 72px; }
.hud-center.final { color: #ff3b3b; --outline: #fff; font-size: 64px; top: 20%; text-shadow: 3px 0 #fff, -3px 0 #fff, 0 3px #fff, 0 -3px #fff, 0 6px 8px rgba(0,0,0,.25); }
.hud-center.timeup { opacity: 1; font-size: 54px; top: 38%; color: #fff; animation: timeup .6s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes bigIn { 0% { opacity: 0; transform: scale(2.2); } 20% { opacity: 1; transform: scale(1); } 75% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.8); } }
@keyframes timeup { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: scale(1); } }

.hud-msg { position: absolute; left: 0; right: 0; top: 42%; text-align: center; font-size: 46px; font-weight: 900; opacity: 0; }
.hud-msg.show { animation: msgIn 1.4s ease forwards; }
.hud-msg.kill { color: #ff5a3c; text-shadow: 3px 0 #fff, -3px 0 #fff, 0 3px #fff, 0 -3px #fff, 2px 2px #fff, -2px -2px #fff, 0 6px 10px rgba(160,0,0,.4); }
.hud-msg.item { color: #2a8ef0; font-size: 34px; text-shadow: 3px 0 #fff, -3px 0 #fff, 0 3px #fff, 0 -3px #fff, 2px 2px #fff, -2px -2px #fff, 0 6px 10px rgba(0,60,160,.3); }
@keyframes msgIn { 0% { opacity: 0; transform: scale(.4) rotate(-8deg); } 18% { opacity: 1; transform: scale(1.15) rotate(2deg); } 30% { transform: scale(1) rotate(0); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); } }

.hud-fx { position: absolute; left: 10px; top: calc(170px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; }
.hud-fx .fx { position: relative; width: 40px; height: 40px; }
.hud-fx img { width: 100%; height: 100%; }
.hud-fx span { position: absolute; right: -4px; bottom: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: #173a73; font-size: 12px; font-weight: 900; text-align: center; line-height: 20px; }

.hud-score { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); padding: 4px 14px; border-radius: 14px; background: rgba(60,72,100,.55); font-size: 13px; font-weight: 800; white-space: nowrap; }

.death { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; background: rgba(20,30,60,.25); opacity: 0; transition: opacity .3s; }
.death::before { content: ""; flex: 1; }
.death::after { content: ""; flex: 2; }
.death.show { opacity: 1; }
.death-card { text-align: center; padding: 18px 30px; border-radius: 18px; background: rgba(30,40,70,.75); transform: scale(.8); transition: transform .3s cubic-bezier(.2,1.6,.4,1); }
.death.show .death-card { transform: scale(1); }
.death-title { font-size: 30px; font-weight: 900; color: #ff6b5a; }
.death-by { margin-top: 6px; font-size: 15px; font-weight: 700; }
.death-count { margin-top: 10px; font-size: 20px; font-weight: 900; color: #ffe34d; }
.revive-btn { pointer-events: auto; margin-top: 14px; height: 44px; font-size: 17px; display: inline-flex; align-items: center; gap: 6px; }
.revive-btn.hide { display: none; }
.revive-btn.poor { filter: grayscale(.8) brightness(.9); }

.joy { position: absolute; left: 24%; top: 72%; width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%;
  background: radial-gradient(circle, rgba(120,190,255,.25) 0 55%, rgba(80,160,255,.35) 56% 100%); border: 3px solid rgba(255,255,255,.65);
  box-shadow: 0 0 0 6px rgba(120,190,255,.18), inset 0 0 20px rgba(60,140,255,.3); transition: opacity .2s; }
.joy.idle { opacity: .55; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; border-radius: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #ffffff, #b8dcff 40%, #4d8fe0 100%); border: 3px solid rgba(255,255,255,.9); box-shadow: 0 4px 10px rgba(0,40,120,.35); }
.boost-btn { pointer-events: auto !important; position: absolute; right: 7%; bottom: calc(23% + var(--safe-b)); width: 84px; height: 84px; border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #b4c6ff, #4a63e0 55%, #2b3aa8); border: 4px solid rgba(255,255,255,.9); box-shadow: 0 6px 0 rgba(30,40,120,.45), 0 0 0 6px rgba(90,120,255,.2); transition: transform .08s; }
.boost-btn i { position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M13.5 2 5 13.5h6L9.5 22 19 9.5h-6.2z' fill='%23ffd23a' stroke='%23a05a00' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E") center / 56% no-repeat; }
.boost-btn.active { transform: scale(.92); box-shadow: 0 2px 0 rgba(30,40,120,.45), 0 0 0 10px rgba(255,210,60,.35), 0 0 30px rgba(255,200,40,.7); }
.boost-btn.disabled { filter: grayscale(.9); opacity: .6; }
.boost-btn.turbo { outline: 4px solid #ffc21a; outline-offset: 3px; }
/* Mouse users aim with the pointer, so the idle touch joystick is hidden. */
@media (hover: hover) and (pointer: fine) { .joy.idle { display: none; } }
/* Spectators have no snake to control. */
.hud.watching .joy, .hud.watching .boost-btn, .hud.watching .death { display: none; }
.boost-btn.turbo::after { content: "无限"; position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); padding: 0 6px; border-radius: 8px; background: #f0433a; font-size: 11px; font-weight: 900; line-height: 16px; white-space: nowrap; }

/* ---------- results ---------- */
.result-wrap { position: absolute; left: 5%; right: 5%; top: calc(24px + var(--safe-t)); bottom: calc(var(--safe-b) + 22%); display: flex; flex-direction: column; z-index: 2; }
.result-ribbon, .panel-ribbon {
  align-self: center; position: relative; padding: 6px 40px; font-size: 22px; font-weight: 900; letter-spacing: 2px;
  background: linear-gradient(#5fd0ff, #2a8ef0); border: 3px solid #173a73; border-radius: 12px; box-shadow: 0 4px 0 #173a73; text-shadow: 0 2px 0 #173a73;
}
.result-me { margin: 14px 0 10px; text-align: center; }
.result-me .big { font-size: 46px; font-weight: 900; color: #ffe34d; --outline: #7a3a00; }
.result-me .sub { font-size: 14px; font-weight: 700; opacity: .9; }
.result-list { flex: 1; min-height: 0; overflow-y: auto; list-style: none; display: flex; flex-direction: column; gap: 7px; padding: 4px 2px; }
.result-list li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 14px; background: rgba(255,255,255,.92); color: #173a73; border: 3px solid #173a73; box-shadow: 0 3px 0 #173a73; animation: slideIn .35s ease both; }
.result-list li.me { background: linear-gradient(#fff6c2, #ffe066); }
.result-list li.left { opacity: .55; }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } }
.result-list .medal { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; font-weight: 900; font-size: 15px; background: #c9d3ea; color: #3a4566; }
.result-list .m1 { background: radial-gradient(circle at 35% 30%, #fff6b0, #ffc61a); color: #7a4a00; box-shadow: 0 0 0 2px #b88400; }
.result-list .m2 { background: radial-gradient(circle at 35% 30%, #fff, #c5d0e6); color: #4a5470; box-shadow: 0 0 0 2px #8792ad; }
.result-list .m3 { background: radial-gradient(circle at 35% 30%, #ffe0c0, #e8955a); color: #6b3000; box-shadow: 0 0 0 2px #a85a20; }
.result-list canvas { width: 34px; height: 34px; flex: none; }
.result-list .ava { width: 34px; height: 34px; flex: none; border-radius: 50%; object-fit: cover; border: 2px solid #173a73; }
.result-list .nm { flex: 1; min-width: 0; font-weight: 900; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-list .st { text-align: right; font-size: 12px; font-weight: 700; color: #4a5a85; line-height: 1.3; }
.result-list .st b { font-size: 16px; color: #173a73; }
.reward { display: flex; justify-content: center; gap: 12px; margin: 12px 0; }
.reward div { display: flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 16px; background: rgba(8,40,95,.5); font-weight: 900; font-size: 16px; }
.reward .coin-ico { width: 24px; height: 24px; margin: 0; }
.reward .coin-ico::after { font-size: 11px; }
.reward .tp { color: #ffe34d; }
.result-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- modals ---------- */
.modal { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; padding: calc(var(--safe-t) + 40px) 0 20px; background: rgba(5,15,40,.6); z-index: 50; }
.modal.show { display: flex; animation: fadeIn .2s ease; }
.modal::before { content: ""; flex: 1; }
.modal::after { content: ""; flex: 2; }
.panel { position: relative; flex: none; width: 88%; padding: 34px 18px 20px; border-radius: 22px; background: linear-gradient(#e9f4ff, #c7defa); border: 4px solid #173a73; box-shadow: 0 8px 0 #173a73, 0 20px 40px rgba(0,0,0,.4); color: #173a73; animation: pop .3s cubic-bezier(.2,1.6,.4,1); }
.panel-ribbon { position: absolute; top: -24px; left: 50%; transform: translateX(-50%); white-space: nowrap; color: #fff; }
.close { position: absolute; right: -12px; top: -14px; width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(#ff8a7a, #f0433a); border: 3px solid #fff; color: #fff; font-size: 26px; font-weight: 900; line-height: 30px; box-shadow: 0 3px 0 #8a1d17; }
.skins-panel { max-height: 70%; display: flex; flex-direction: column; }
.skin-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 4px; }
.skin-item { position: relative; border-radius: 14px; background: #fff; border: 3px solid #a9c2e6; padding: 6px 4px 6px; text-align: center; }
.skin-item.equipped { border-color: #ffb21f; box-shadow: 0 0 0 3px rgba(255,178,31,.4); background: #fffbe6; }
.skin-item canvas { width: 100%; aspect-ratio: 1.15; display: block; }
.skin-item .nm { font-weight: 900; font-size: 14px; }
.skin-item .pr { margin-top: 4px; height: 24px; border-radius: 12px; font-size: 12px; font-weight: 900; display: flex; align-items: center; justify-content: center; gap: 3px; background: linear-gradient(#ffe55c, #ffc21a); color: #6b3500; }
.skin-item .pr.own { background: linear-gradient(#5fd0ff, #2a8ef0); color: #fff; }
.skin-item .pr.eq { background: #3fbf6a; color: #fff; }
.skin-item .pr .coin-ico { width: 14px; height: 14px; margin: 0; border-width: 1.5px; }
.skin-item .pr .coin-ico::after { display: none; }
.skin-item.locked canvas { filter: saturate(.75); }
.confirm-panel { text-align: center; font-weight: 800; font-size: 17px; }
.confirm-panel small { font-size: 13px; color: #5a6a95; font-weight: 700; }
.confirm-panel .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.skin-item { --rc: #a9c2e6; border-color: var(--rc); }
.skin-item.legend { animation: legendGlow 1.6s ease-in-out infinite; }
@keyframes legendGlow { 50% { box-shadow: 0 0 10px 2px rgba(255,163,26,.75); } }

/* Slide-in notice after a gift */
.gift-fx { position: absolute; left: 8px; top: 23%; z-index: 60; max-width: 78%; display: none; align-items: center; gap: 8px;
  padding: 4px 14px 4px 4px; border-radius: 26px; background: rgba(0,0,0,.6); pointer-events: none; }
.gift-fx.show { display: flex; animation: giftSlide 2.6s ease-out both; }
.gf-ico { flex: none; width: 44px; height: 44px; object-fit: contain; }
.gf-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.gf-t { font-size: 13px; font-weight: 800; white-space: nowrap; }
.gf-r { display: flex; align-items: center; gap: 4px; font-size: 15px; font-weight: 900; color: #ffd23f; }
.gf-item { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 900; }
.gf-item img { width: 22px; height: 22px; object-fit: contain; }
.gf-note { font-size: 10px; font-weight: 700; color: rgba(255,255,255,.6); white-space: nowrap; }
@keyframes giftSlide { 0% { opacity: 0; transform: translateX(-110%); } 12% { opacity: 1; transform: none; } 85% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateX(-20px); } }

.toast { position: absolute; left: 50%; top: 18%; transform: translate(-50%, -10px); padding: 10px 20px; border-radius: 20px; background: rgba(20,30,60,.88); font-weight: 800; font-size: 15px; opacity: 0; transition: all .25s; z-index: 100; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
