:root {
    --font: 'Be Vietnam Pro', 'Segoe UI', system-ui, sans-serif;
    --pink: #ff4fa3;
    --cyan: #22d3ee;
    --violet: #a78bfa;
    --gold: #fbbf24;
    --glass: rgba(8, 6, 28, 0.55);
    --glass-border: rgba(255, 255, 255, 0.14);
    --text: #f8fafc;
    --muted: #b8b3d9;
    --safe-top: 10vh;
    --safe-bottom: 8vh;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #05060f; color: var(--text); font-family: var(--font); overflow: hidden; }
body { -webkit-font-smoothing: antialiased; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }

/* ---------- idol labels & speech bubbles ---------- */
.idol-label { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; transform: translateY(-100%); pointer-events: none; transition: opacity 0.4s; }
.idol-name { font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: #fff; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c) 55%, transparent); border: 1px solid color-mix(in srgb, var(--c) 80%, white); box-shadow: 0 0 14px var(--c); opacity: 0.85; }
.idol-bubble { max-width: 260px; padding: 8px 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.94); color: #1b1038; font-size: 15px; font-weight: 600; line-height: 1.3; text-align: center; opacity: 0; transform: translateY(8px) scale(0.85); transition: opacity 0.25s, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); box-shadow: 0 0 24px color-mix(in srgb, var(--c) 70%, transparent); position: relative; }
.idol-bubble::after { content: ''; position: absolute; left: 50%; bottom: -7px; width: 14px; height: 14px; background: rgba(255, 255, 255, 0.94); transform: translateX(-50%) rotate(45deg); border-radius: 3px; }
.idol-bubble.show { opacity: 1; transform: translateY(0) scale(1); }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; transition: opacity 0.3s; }
.hud.hidden { opacity: 0; }
.hidden { display: none !important; }

.hud-top { position: absolute; top: 18px; left: 22px; right: 22px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.hud-brand h1 { margin: 2px 0 0; font-size: 30px; font-weight: 900; letter-spacing: 0.08em; line-height: 1; background: linear-gradient(90deg, #fff, var(--pink), var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 14px rgba(255, 79, 163, 0.55)); }
.hud-brand p { margin: 4px 0 0; font-size: 12px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.hud-live { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 0.18em; padding: 3px 9px; border-radius: 6px; background: #ff2d55; color: #fff; box-shadow: 0 0 16px rgba(255, 45, 85, 0.7); animation: blink 1.6s infinite; }
.hud-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(10px); font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pill i { font-style: normal; font-size: 14px; }
.pill.pop { animation: pop 0.4s; }
.hud-status { position: absolute; top: 92px; right: 22px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; color: var(--muted); padding: 3px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); }
.hud-status.live { color: #4ade80; }
.hud-status.busy { color: var(--gold); }
.hud-status.socket-down { color: #f87171; }

.hud-goal { position: absolute; top: 96px; left: 22px; width: min(360px, 42vw); padding: 10px 14px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(10px); }
.goal-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; margin-bottom: 7px; }
.goal-head span:last-child { font-variant-numeric: tabular-nums; color: var(--gold); }
.goal-track { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.goal-bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--cyan), var(--pink), var(--gold)); box-shadow: 0 0 14px var(--pink); transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1); }
.hud-goal.done .goal-bar { animation: shimmer 1.2s infinite; }

.hud-toasts { position: absolute; top: 150px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { padding: 7px 16px; border-radius: 999px; background: var(--glass); border: 1px solid color-mix(in srgb, var(--c) 60%, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 45%, transparent); font-size: 14px; font-weight: 700; animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); backdrop-filter: blur(10px); white-space: nowrap; }
.toast.out { animation: toastOut 0.45s forwards; }

.hud-board-wrap { position: absolute; right: 22px; top: 126px; width: min(300px, 36vw); padding: 10px 12px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(10px); }
.hud-board-title { font-size: 11px; font-weight: 800; letter-spacing: 0.2em; color: var(--gold); margin-bottom: 6px; }
.hud-board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.hud-board li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.hud-board li b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-board li em { font-style: normal; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.hud-board li img, .hud-ticker img.avatar, .hud-feed img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(255, 255, 255, 0.4); }
.avatar-fallback { width: 24px; height: 24px; border-radius: 50%; background: linear-gradient(135deg, var(--pink), var(--violet)); flex-shrink: 0; }
.hud-board .medal { width: 20px; text-align: center; }
.hud-board li.rank-1 b { color: #fff3b0; }
.hud-board li.empty { color: var(--muted); font-size: 12px; }

.hud-gifts { position: absolute; right: 22px; top: 260px; width: min(300px, 36vw); padding: 10px 12px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(10px); }
.hud-gifts-title { font-size: 11px; font-weight: 800; letter-spacing: 0.2em; color: var(--pink); margin-bottom: 6px; }
.hud-gifts ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.hud-gifts li { display: grid; grid-template-columns: 26px 1fr auto auto; align-items: center; gap: 6px; font-size: 12.5px; line-height: 1.2; padding: 3px 6px; border-radius: 8px; transition: background 0.3s, transform 0.3s; }
.hud-gifts li .emoji { font-size: 18px; text-align: center; }
.hud-gifts li .names b { display: block; font-size: 13px; }
.hud-gifts li .names span { color: var(--muted); font-size: 11px; }
.hud-gifts li .coins { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-gifts li .effect { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); white-space: nowrap; }
.hud-gifts li .effect.tier-spark { color: #f9a8d4; }
.hud-gifts li .effect.tier-heart { color: var(--pink); }
.hud-gifts li .effect.tier-party { color: var(--gold); }
.hud-gifts li .effect.tier-cutscene { color: #e879f9; }
.hud-gifts li .effect.tier-ultimate { color: #fff1a8; background: rgba(251, 191, 36, 0.25); }
.hud-gifts li.hit { background: linear-gradient(90deg, rgba(255, 79, 163, 0.55), rgba(167, 139, 250, 0.35)); transform: scale(1.04); animation: pop 0.5s; }

.hud-ticker { position: absolute; left: 22px; bottom: calc(var(--safe-bottom) + 30px); margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column-reverse; gap: 6px; width: min(340px, 44vw); }
.hud-ticker li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(10px); animation: slideIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); transition: opacity 1s; }
.hud-ticker li.fade { opacity: 0.35; }
.hud-ticker .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.hud-ticker .who b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-ticker .who span { font-size: 11px; color: var(--muted); }
.hud-ticker img.gift { width: 34px; height: 34px; object-fit: contain; }
.hud-ticker .gift-emoji { font-size: 24px; }
.hud-ticker .amount { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.hud-ticker .amount b { font-size: 16px; color: #fff; }
.hud-ticker .amount span { font-size: 11px; color: var(--gold); font-weight: 700; }
.hud-ticker li.tier-party { border-color: rgba(251, 191, 36, 0.6); box-shadow: 0 0 18px rgba(251, 191, 36, 0.35); }
.hud-ticker li.tier-cutscene { border-color: rgba(232, 121, 249, 0.7); box-shadow: 0 0 22px rgba(232, 121, 249, 0.45); }
.hud-ticker li.tier-ultimate { border-color: #fff1a8; box-shadow: 0 0 28px rgba(255, 241, 168, 0.6); background: linear-gradient(135deg, rgba(120, 60, 0, 0.6), rgba(60, 10, 60, 0.6)); }

.hud-combo { position: absolute; left: 22px; bottom: calc(var(--safe-bottom) + 30px + 5 * 58px); display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 14px; background: linear-gradient(135deg, rgba(255, 79, 163, 0.75), rgba(167, 139, 250, 0.75)); border: 1px solid rgba(255, 255, 255, 0.5); box-shadow: 0 0 24px rgba(255, 79, 163, 0.6); opacity: 0; transform: scale(0.8); transition: opacity 0.2s, transform 0.2s; }
.hud-combo.show { opacity: 1; transform: scale(1); }
.hud-combo.bump { animation: bump 0.25s; }
.hud-combo img { width: 40px; height: 40px; object-fit: contain; }
.hud-combo b { display: block; font-size: 26px; line-height: 1; }
.hud-combo span { font-size: 12px; font-weight: 600; }

.hud-feed { position: absolute; right: 22px; bottom: calc(var(--safe-bottom) + 30px); margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; width: min(320px, 40vw); }
.hud-feed li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; background: rgba(8, 6, 28, 0.45); border: 1px solid var(--glass-border); font-size: 13px; animation: slideInRight 0.35s; transition: opacity 1s; }
.hud-feed li.fade { opacity: 0.3; }
.hud-feed li b { color: var(--cyan); white-space: nowrap; }
.hud-feed li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hud-banner { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%) scale(0.6); opacity: 0; text-align: center; padding: 22px 40px; border-radius: 26px; background: radial-gradient(ellipse at center, rgba(10, 6, 30, 0.85), rgba(10, 6, 30, 0.55)); border: 2px solid color-mix(in srgb, var(--c) 75%, white); box-shadow: 0 0 60px color-mix(in srgb, var(--c) 60%, transparent), inset 0 0 40px color-mix(in srgb, var(--c) 20%, transparent); transition: opacity 0.35s, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); max-width: 86vw; }
.hud-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.hud-banner .headline { font-size: 22px; font-weight: 800; letter-spacing: 0.3em; color: var(--c); text-shadow: 0 0 20px var(--c); }
.hud-banner .nick { font-size: 52px; font-weight: 900; line-height: 1.1; margin: 6px 0 10px; background: linear-gradient(90deg, #fff, var(--c)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 18px var(--c)); max-width: 80vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-banner .gift-row { display: flex; align-items: center; justify-content: center; gap: 14px; }
.hud-banner .gift-row img { width: 72px; height: 72px; object-fit: contain; filter: drop-shadow(0 0 12px var(--c)); animation: float 1.6s ease-in-out infinite; }
.hud-banner .gift-emoji { font-size: 56px; }
.hud-banner .gift-row b { display: block; font-size: 26px; }
.hud-banner .gift-row span { font-size: 18px; font-weight: 700; color: var(--gold); }
.hud-banner .pre { font-size: 40px; font-weight: 900; letter-spacing: 0.25em; color: var(--c); text-shadow: 0 0 30px var(--c); animation: blink 0.5s infinite; }
.hud-queue { position: absolute; left: 50%; top: calc(34% + 150px); transform: translateX(-50%); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; color: var(--muted); }

.hud-track { position: absolute; left: 22px; bottom: 16px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); padding: 4px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); }
.hud-track.pop { animation: pop 0.5s; }
.hud-audio { position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%); padding: 10px 18px; border-radius: 999px; background: rgba(255, 45, 85, 0.85); color: #fff; font-size: 15px; font-weight: 800; box-shadow: 0 0 24px rgba(255, 45, 85, 0.7); animation: blink 1.4s infinite; white-space: nowrap; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: rgba(5, 6, 15, 0.92); text-align: center; padding: 24px; transition: opacity 0.4s; }
.overlay.hidden { opacity: 0; pointer-events: none; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.15); border-top-color: var(--pink); animation: spin 0.9s linear infinite; }
.gate { background: rgba(5, 6, 15, 0.6); cursor: pointer; z-index: 15; }
.gate-card { padding: 30px 40px; border-radius: 24px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(14px); max-width: 520px; }
.gate-logo { font-size: 44px; font-weight: 900; letter-spacing: 0.12em; background: linear-gradient(90deg, #fff, var(--pink), var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.gate-card p { margin: 10px 0 0; font-size: 16px; }
.gate-hint { font-size: 12px !important; color: var(--muted); line-height: 1.6; }
.gate-hint code { background: rgba(255, 255, 255, 0.12); padding: 1px 6px; border-radius: 6px; }

body.clean #gate, body.clean #hud-status { display: none; }

/* ---------- portrait (9:16 TikTok capture) ---------- */
@media (max-aspect-ratio: 1/1) {
    :root { --safe-top: 12vh; --safe-bottom: 28vh; }
    .hud-top { top: calc(var(--safe-top)); left: 16px; right: 16px; flex-direction: column; align-items: flex-start; gap: 10px; }
    .hud-brand h1 { font-size: 34px; }
    .hud-stats { justify-content: flex-start; }
    .hud-status { top: calc(var(--safe-top) - 24px); right: 16px; }
    .hud-goal { top: calc(var(--safe-top) + 118px); left: 16px; width: calc(100% - 32px); }
    .hud-toasts { top: calc(var(--safe-top) + 190px); }
    .hud-board-wrap { right: 16px; top: calc(var(--safe-top) + 230px); width: min(280px, 60vw); }
    .hud-ticker { left: 16px; bottom: calc(var(--safe-bottom) + 10px); width: min(330px, 70vw); }
    .hud-combo { left: 16px; bottom: calc(var(--safe-bottom) + 10px + 5 * 58px); }
    .hud-feed { display: none; }
    .hud-gifts { right: 16px; top: auto; bottom: calc(var(--safe-bottom) + 10px); width: min(265px, 56vw); padding: 8px 10px; }
    .hud-gifts li { font-size: 11.5px; gap: 5px; grid-template-columns: 22px 1fr auto; padding: 2px 4px; }
    .hud-gifts li .emoji { font-size: 15px; }
    .hud-gifts li .names b { display: inline; font-size: 12px; }
    .hud-gifts li .names span { font-size: 11px; }
    .hud-gifts li .names span::before { content: ' · '; }
    .hud-gifts li .effect { display: none; }
    .hud-ticker { width: min(240px, 44vw); }
    .hud-track { left: 16px; bottom: calc(var(--safe-bottom) - 26px); }
    .hud-banner { top: 42%; padding: 18px 26px; }
    .hud-banner .nick { font-size: 40px; }
    .hud-queue { top: calc(42% + 140px); }
}

/* ---------- minimal HUD: gift menu only, pinned to the top-right ---------- */
.hud.mode-gifts > *:not(#hud-gifts):not(#hud-banner):not(#hud-audio) { display: none !important; }
.hud.mode-gifts .hud-gifts { top: 14px; right: 14px; bottom: auto; left: auto; width: min(300px, 44vw); }
@media (max-aspect-ratio: 1/1) {
    .hud.mode-gifts .hud-gifts { top: 12px; right: 10px; bottom: auto; width: min(250px, 50vw); padding: 8px 9px; }
    .hud.mode-gifts .hud-gifts li { font-size: 11px; gap: 4px; padding: 2px 3px; grid-template-columns: 20px 1fr auto; }
    .hud.mode-gifts .hud-gifts li .names b { font-size: 12px; }
    .hud.mode-gifts .hud-gifts li .emoji { font-size: 15px; }
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes shimmer { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.6); } }
