/* 泡泡魔法夜:場地是夜晚(暗紫),介面卡片保持明亮可愛 */
:root {
  --ink: #2a1a3e; --paper: #fffdf8; --yellow: #ffd34d; --blue: #4a97dd; --purple: #9f6bff;
  --font: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: #0b0618; color: var(--ink); font-family: var(--font); -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font-family: inherit; cursor: pointer; color: var(--ink); }

/* ---------- HUD ---------- */
#hud { position: fixed; left: 0; right: 0; top: 0; z-index: 5; pointer-events: none; padding: calc(10px + var(--st)) 12px 0; }
#hud[hidden] { display: none; }
.top { display: flex; align-items: center; gap: 10px; }
.hearts { display: flex; gap: 3px; }
.hearts i { width: 22px; height: 20px; background: #4a3466; clip-path: path("M11 19 C4 13 0 10 0 5.5 C0 2.5 2.4 0 5.5 0 C7.8 0 9.6 1.3 11 3.2 C12.4 1.3 14.2 0 16.5 0 C19.6 0 22 2.5 22 5.5 C22 10 18 13 11 19 Z"); }
.hearts i.on { background: #ff5f8f; filter: drop-shadow(0 0 4px #ff8fb0); }
.mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#time { font: 900 20px/1 var(--font); color: #fff; text-shadow: 0 2px 0 #2a1240, 0 0 10px #b98cff; font-variant-numeric: tabular-nums; }
.xp { position: relative; width: min(52vw, 280px); height: 16px; background: rgba(20, 8, 40, 0.75); border: 2px solid #c9a8ff; border-radius: 99px; overflow: hidden; box-shadow: 0 0 10px rgba(185, 140, 255, 0.6); }
.xp i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #6fe8ff, #a77dff); box-shadow: 0 0 10px #8ff0ff; transition: width 0.15s; }
.xp span { position: absolute; inset: 0; text-align: center; font: 900 11px/12px var(--font); color: #fff; text-shadow: 0 1px 0 #2a1240; }
.pill { background: rgba(20, 8, 40, 0.75); border: 2px solid #c9a8ff; border-radius: 99px; padding: 3px 10px; color: #fff; font-weight: 900; font-size: 15px; }
.mute { position: fixed; z-index: 6; right: 12px; bottom: calc(14px + var(--sb)); width: 44px; height: 44px; border-radius: 50%; border: 2px solid #c9a8ff; background: rgba(20, 8, 40, 0.7); font-size: 20px; padding: 0; }
.banner { position: fixed; z-index: 7; left: 50%; top: calc(64px + var(--st)); transform: translate(-50%, -20px); opacity: 0; transition: 0.25s; pointer-events: none; white-space: nowrap;
  background: linear-gradient(180deg, #fff, #f3e9ff); border: 3px solid var(--ink); border-radius: 999px; padding: 6px 16px; font-weight: 900; font-size: 16px; box-shadow: 0 0 18px rgba(185, 140, 255, 0.8); }
.banner.show { opacity: 1; transform: translate(-50%, 0); }
.banner.boss { background: linear-gradient(180deg, #ffe680, #ffc83a); box-shadow: 0 0 24px rgba(255, 200, 60, 0.9); }
.joy { position: fixed; z-index: 4; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; border: 3px solid rgba(201, 168, 255, 0.7); background: rgba(160, 120, 255, 0.12); pointer-events: none; }
.joy[hidden] { display: none; }
.joy i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #c9a8ff); box-shadow: 0 0 14px #b98cff; transform: translate(-50%, -50%); }
/* 大爆炸白光、被黏到的紅框 */
#flash { position: fixed; inset: 0; z-index: 3; pointer-events: none; background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(220, 180, 255, 0.5) 45%, transparent 75%); opacity: 0; }
#flash.on { animation: flash 0.35s ease-out; }
@keyframes flash { 0% { opacity: var(--a, 0.6); } 100% { opacity: 0; } }
#hurtFx { position: fixed; inset: 0; z-index: 3; pointer-events: none; box-shadow: inset 0 0 90px 30px rgba(255, 60, 120, 0.85); opacity: 0; }
#hurtFx.on { animation: flash 0.6s ease-out; --a: 1; }

/* ---------- 畫面卡片 ---------- */
.screen { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--st)) 16px calc(16px + var(--sb)); background: radial-gradient(circle at 50% 40%, rgba(60, 20, 110, 0.2), rgba(11, 6, 24, 0.55)); overflow-y: auto; }
.screen[hidden] { display: none; }
#start { align-items: flex-end; }
.card { width: min(420px, 100%); background: var(--paper); border: 4px solid var(--ink); border-radius: 28px; padding: 20px 18px 16px; box-shadow: 0 7px 0 var(--ink), 0 0 40px rgba(185, 140, 255, 0.55); text-align: center; margin: auto; overflow: hidden; }
#start .card { margin: auto auto 0; }
.tag { margin: 0 0 12px; font-weight: 800; color: #6a5a80; font-size: 15px; }
.heroes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.hero { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px; border: 3px solid #e3d8f2; border-radius: 16px; background: #fff; font-weight: 900; font-size: 18px; }
.hero.on { border-color: var(--ink); background: #f3e9ff; box-shadow: 0 3px 0 var(--ink); }
.face { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--ink); }
.face.t { background: #fddf22; } .face.q { background: #f4f7fb; }
.big { width: 100%; background: var(--yellow); border: 4px solid var(--ink); border-radius: 18px; padding: 13px; font-size: 24px; font-weight: 900; box-shadow: 0 3px 0 var(--ink); }
.big:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.big.alt { background: #fff; font-size: 19px; padding: 10px; }
.btns { display: grid; gap: 8px; }
.how { margin: 12px 0 4px; font-size: 14px; font-weight: 700; color: #6a5a80; line-height: 1.5; }
.best { margin: 6px 0; font-weight: 900; color: var(--purple); }
.note { margin: 6px 0 0; font-size: 11px; color: #9a8fb0; }

/* ---------- 標題字:圓體粗體、每個字微歪 ---------- */
.logo { font-family: "Chiron GoRound TC", var(--font); font-weight: 900; line-height: 1.1; margin: 0 0 8px; font-size: 44px; color: #b98cff; }
.logo span { display: inline-block; margin: 0 1px; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); transform: rotate(var(--r, 0deg)) translateY(var(--y, 0)); }
.logo span:nth-of-type(1) { --r: -6deg; --y: 2px; color: #8fd4ff; }
.logo span:nth-of-type(2) { --r: 4deg; --y: -3px; color: #8fd4ff; }
.logo span:nth-of-type(3) { --r: -3deg; --y: 1px; }
.logo span:nth-of-type(4) { --r: 6deg; --y: -2px; color: #d6b8ff; }
.logo span:nth-of-type(5) { --r: -4deg; --y: 2px; color: #ffd34d; }
.logo small { display: block; font-size: 0.42em; letter-spacing: 7px; margin-bottom: 2px; color: #ffd34d; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); }

/* ---------- 選卡:畫面變暗、三張發光的卡跳出來 ---------- */
.pick { position: fixed; inset: 0; z-index: 9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 16px; background: radial-gradient(circle, rgba(40, 14, 80, 0.75), rgba(5, 2, 12, 0.92)); animation: fadein 0.25s both; }
.pick[hidden] { display: none; }
.pick h2 { margin: 0; color: #fff; font-size: 26px; font-weight: 900; text-shadow: 0 0 16px #b98cff, 0 3px 0 #2a1240; animation: pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.cards { display: flex; gap: 10px; width: min(560px, 100%); }
.pc { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px 14px; border-radius: 18px; border: 3px solid var(--rc);
  background: linear-gradient(180deg, #2e1a52, #1a0e30); color: #fff; box-shadow: 0 0 18px var(--rc), inset 0 0 18px rgba(255, 255, 255, 0.08); overflow: hidden; animation: cardin 0.5s var(--d) cubic-bezier(0.3, 1.5, 0.5, 1) both; }
.pc::before { content: ""; position: absolute; inset: -40%; background: conic-gradient(from 0deg, transparent 0 70%, var(--rc) 85%, transparent 100%); animation: spin 2.4s linear infinite; opacity: 0.35; }
.pc::after { content: ""; position: absolute; inset: 3px; border-radius: 14px; background: linear-gradient(180deg, #2e1a52, #1a0e30); z-index: 0; }
.pc > * { position: relative; z-index: 1; }
.pc .rar { font-size: 11px; font-weight: 900; color: var(--rc); letter-spacing: 2px; }
.pc .ic { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 14px; font-size: 32px; background: radial-gradient(circle, rgba(255, 255, 255, 0.25), transparent 70%); border: 2px solid var(--rc); text-shadow: 0 0 12px var(--rc); }
.pc b { font-size: 16px; line-height: 1.2; }
.pc small { font-size: 12px; color: #d8c8f0; line-height: 1.35; font-weight: 700; }
.pc.r3 { box-shadow: 0 0 30px var(--rc), 0 0 60px rgba(255, 200, 60, 0.5); }
.pc:active { transform: scale(0.96); }
@keyframes cardin { from { opacity: 0; transform: translateY(40px) scale(0.6) rotate(-6deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } }
@keyframes fadein { from { opacity: 0; } }

/* ---------- 結算:光芒 + 勳章 + 緞帶(和泡泡塔防同一套) ---------- */
.endhero { position: relative; height: 236px; margin: -6px -8px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; --c1: #ffe680; --c2: #f5b400; --glow: rgba(255, 200, 40, 0.75); }
.endhero.bronze { --c1: #ffd2a6; --c2: #cd7f32; --glow: rgba(230, 140, 60, 0.6); }
.endhero.silver { --c1: #ffffff; --c2: #9fb3c8; --glow: rgba(150, 200, 255, 0.75); }
.endhero.rainbow { --c1: #ffe1f2; --c2: #9f7bff; --glow: rgba(255, 120, 200, 0.8); }
.endhero .rays { position: absolute; left: 50%; top: 44%; width: 330px; height: 330px; margin: -165px 0 0 -165px; border-radius: 50%; background: repeating-conic-gradient(from 0deg, var(--glow) 0 7deg, transparent 7deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 18%, transparent 68%); mask: radial-gradient(circle, #000 18%, transparent 68%); animation: spin 14s linear infinite, fadein 0.6s both; }
.endhero .halo { position: absolute; left: 50%; top: 44%; width: 190px; height: 190px; margin: -95px 0 0 -95px; border-radius: 50%; background: radial-gradient(circle, #fff 0 30%, var(--glow) 55%, transparent 72%); animation: halopulse 1.8s ease-in-out infinite, fadein 0.6s both; }
@keyframes halopulse { 50% { transform: scale(1.12); opacity: 0.8; } }
.endhero .badge { position: relative; isolation: isolate; width: 140px; height: 150px; margin-top: -14px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); background: linear-gradient(160deg, #fff 0%, var(--c1) 30%, var(--c2) 100%); animation: badgepop 0.7s 0.15s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.endhero.rainbow .badge { background: linear-gradient(160deg, #fff 0%, #ffd0e8 22%, #ffb347 42%, #8fe07a 60%, #6fc8ff 78%, #a98bff 100%); }
.endhero .badge::before { content: ""; position: absolute; inset: 9px; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); background: linear-gradient(180deg, #3b2a6b, #1d1244); z-index: -1; }
.endhero .badge b { font-size: 42px; font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 16px var(--glow); font-variant-numeric: tabular-nums; }
.endhero .badge small { font-size: 15px; font-weight: 900; color: var(--c1); letter-spacing: 2px; margin-bottom: 4px; }
.endhero.done .badge b { animation: numglow 0.5s; }
@keyframes badgepop { from { transform: scale(0) rotate(-25deg); } }
@keyframes numglow { 40% { transform: scale(1.25); text-shadow: 0 0 30px #fff, 0 0 40px var(--glow); } }
.endhero .badge::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.75) 50%, transparent 65%); transform: translateX(-120%); animation: sweep 2.6s 1.2s ease-in-out infinite; }
@keyframes sweep { 35%, 100% { transform: translateX(120%); } }
.endhero .ribbon { position: relative; z-index: 2; margin-top: -16px; padding: 7px 26px 8px; font-size: 21px; font-weight: 900; color: #fff; white-space: nowrap; background: linear-gradient(180deg, #b98cff, #7a4fd8);
  border: 3px solid var(--ink); border-radius: 10px; box-shadow: 0 4px 0 var(--ink); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); animation: ribbonin 0.55s 0.55s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
.endhero.gold .ribbon { background: linear-gradient(180deg, #ffb84d, #f08a00); }
.endhero.silver .ribbon { background: linear-gradient(180deg, #7fc4ff, #3f86d8); }
.endhero.bronze .ribbon { background: linear-gradient(180deg, #e8a36a, #b9672e); }
.endhero.rainbow .ribbon { background: linear-gradient(90deg, #ff5fa8, #ffa040, #5fc070, #4aa3ff, #9f7bff); }
.endhero.record .ribbon { background: linear-gradient(90deg, #ff5fa8, #ffb800, #ff5fa8); background-size: 200% 100%; animation: ribbonin 0.55s 0.55s cubic-bezier(0.3, 1.5, 0.5, 1) both, shimmer 1.4s linear infinite; }
@keyframes ribbonin { from { transform: scale(0.2) translateY(20px); opacity: 0; } }
@keyframes shimmer { to { background-position: -200% 0; } }
.endhero .sparks { position: absolute; inset: 0; pointer-events: none; }
.endhero .sparks i { position: absolute; width: 18px; height: 18px; margin: -9px; background: #fff; clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); animation: twinkle 1.6s var(--d) ease-in-out infinite both; }
.endhero .sparks i:nth-child(3n) { background: #ffe680; } .endhero .sparks i:nth-child(4n) { background: #d6b8ff; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(0) rotate(0); } 50% { opacity: 1; transform: scale(var(--s)) rotate(90deg); } }
.stats { list-style: none; padding: 0; margin: 4px 0 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats li { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 4px 7px; background: linear-gradient(180deg, #f6f0ff, #ebe0ff); border: 2.5px solid #dccbfa; border-radius: 16px; animation: tilein 0.4s var(--d) cubic-bezier(0.3, 1.5, 0.5, 1) both; }
.stats .ic { font-size: 22px; line-height: 1; }
.stats b { font-size: 24px; line-height: 1.15; color: #7a4fd8; }
.stats small { font-size: 13px; color: #6a5a80; font-weight: 800; }
@keyframes tilein { from { opacity: 0; transform: translateY(14px) scale(0.85); } }
.hot { position: relative; overflow: hidden; }
.hot::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.8) 50%, transparent 65%); transform: translateX(-120%); animation: sweep 2.4s 1.6s ease-in-out infinite; }
