/* Splash / loading — cinematic */
.loading, .error {
    text-align: center;
    padding: 40px 20px;
    font-size: 18px;
}
.loading { color: var(--primary); }
.error { color: var(--error); }

.app-loader {
    --loader-font: "Syne", "Segoe UI", system-ui, sans-serif;
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #04030a;
    color: #f8f5ff;
    opacity: 1;
    transition:
        opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.55s ease;
    will-change: opacity, transform, filter;
    isolation: isolate;
}

.app-loader.is-leaving {
    opacity: 0;
    transform: scale(1.08);
    filter: blur(16px) saturate(1.4);
    pointer-events: none;
}

/* —— Atmosphere —— */
.app-loader-bg {
    position: absolute;
    inset: -30%;
    pointer-events: none;
}

.app-loader-aurora {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 55% at 50% -10%, rgba(var(--primary-rgb, 147, 51, 234), 0.45), transparent 60%),
        radial-gradient(ellipse 60% 45% at 110% 80%, rgba(236, 72, 153, 0.22), transparent 55%),
        radial-gradient(ellipse 50% 40% at -10% 70%, rgba(56, 189, 248, 0.12), transparent 50%);
    animation: appLoaderAurora 8s ease-in-out infinite alternate;
    filter: saturate(1.2);
}

@keyframes appLoaderAurora {
    from { transform: scale(1) rotate(0deg); opacity: 0.85; }
    to { transform: scale(1.12) rotate(4deg); opacity: 1; }
}

.app-loader-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    mix-blend-mode: screen;
    animation: appLoaderOrb 9s ease-in-out infinite;
}

.app-loader-orb--a {
    width: min(85vw, 520px);
    height: min(85vw, 520px);
    top: -8%;
    left: 10%;
    background: radial-gradient(circle, rgba(var(--primary-rgb, 147, 51, 234), 0.7) 0%, transparent 68%);
}

.app-loader-orb--b {
    width: min(70vw, 420px);
    height: min(70vw, 420px);
    bottom: -12%;
    right: -18%;
    background: radial-gradient(circle, rgba(192, 132, 252, 0.5) 0%, transparent 70%);
    animation-delay: -2.8s;
    animation-duration: 11s;
}

.app-loader-orb--c {
    width: min(55vw, 300px);
    height: min(55vw, 300px);
    bottom: 22%;
    left: -16%;
    background: radial-gradient(circle, rgba(244, 114, 182, 0.35) 0%, transparent 70%);
    animation-delay: -5.4s;
    animation-duration: 13s;
}

@keyframes appLoaderOrb {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.55; }
    33% { transform: translate(4%, -6%) scale(1.1); opacity: 0.85; }
    66% { transform: translate(-3%, 3%) scale(0.95); opacity: 0.65; }
}

.app-loader-rays {
    position: absolute;
    inset: -40%;
    background: conic-gradient(
        from 0deg at 50% 50%,
        transparent 0deg,
        rgba(var(--primary-rgb, 147, 51, 234), 0.07) 20deg,
        transparent 40deg,
        transparent 180deg,
        rgba(192, 132, 252, 0.06) 200deg,
        transparent 230deg,
        transparent 360deg
    );
    animation: appLoaderRays 28s linear infinite;
    opacity: 0.7;
    mask-image: radial-gradient(circle at 50% 48%, #000 0%, transparent 58%);
    -webkit-mask-image: radial-gradient(circle at 50% 48%, #000 0%, transparent 58%);
}

@keyframes appLoaderRays {
    to { transform: rotate(360deg); }
}

.app-loader-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse 65% 55% at 50% 48%, #000 15%, transparent 72%);
    -webkit-mask-image: radial-gradient(ellipse 65% 55% at 50% 48%, #000 15%, transparent 72%);
    opacity: 0.55;
    animation: appLoaderGrid 16s linear infinite;
    transform: perspective(600px) rotateX(52deg) scale(1.4);
    transform-origin: 50% 30%;
}

@keyframes appLoaderGrid {
    from { background-position: 0 0; }
    to { background-position: 0 56px; }
}

.app-loader-vignette {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 60% at 50% 45%, transparent 30%, rgba(4, 3, 10, 0.75) 100%),
        linear-gradient(180deg, rgba(4, 3, 10, 0.35) 0%, transparent 25%, transparent 70%, rgba(4, 3, 10, 0.55) 100%);
}

.app-loader-noise {
    position: absolute;
    inset: 0;
    opacity: 0.05;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app-loader-sparks {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.app-loader-spark {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 10px 2px rgba(var(--primary-light-rgb, 192, 132, 252), 0.8);
    opacity: 0;
    animation: appLoaderSpark 3.8s ease-in-out infinite;
}

.app-loader-sparks .app-loader-spark:nth-child(1) { top: 18%; left: 22%; animation-delay: 0s; }
.app-loader-sparks .app-loader-spark:nth-child(2) { top: 28%; left: 78%; animation-delay: 0.6s; width: 2px; height: 2px; }
.app-loader-sparks .app-loader-spark:nth-child(3) { top: 62%; left: 14%; animation-delay: 1.1s; }
.app-loader-sparks .app-loader-spark:nth-child(4) { top: 72%; left: 84%; animation-delay: 1.7s; width: 2px; height: 2px; }
.app-loader-sparks .app-loader-spark:nth-child(5) { top: 42%; left: 8%; animation-delay: 2.2s; }
.app-loader-sparks .app-loader-spark:nth-child(6) { top: 38%; left: 92%; animation-delay: 0.35s; }
.app-loader-sparks .app-loader-spark:nth-child(7) { top: 82%; left: 48%; animation-delay: 1.4s; width: 2px; height: 2px; }
.app-loader-sparks .app-loader-spark:nth-child(8) { top: 12%; left: 55%; animation-delay: 2.8s; }

@keyframes appLoaderSpark {
    0%, 100% { opacity: 0; transform: scale(0.4) translateY(0); }
    20% { opacity: 1; transform: scale(1.2) translateY(-6px); }
    55% { opacity: 0.7; transform: scale(1) translateY(-14px); }
    80% { opacity: 0; transform: scale(0.3) translateY(-22px); }
}

/* —— Content —— */
.app-loader-inner {
    position: relative;
    z-index: 2;
    width: min(100%, 360px);
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: appLoaderEnter 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes appLoaderEnter {
    from {
        opacity: 0;
        transform: translateY(28px) scale(0.92);
        filter: blur(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

.app-loader-halo {
    position: absolute;
    top: 18px;
    left: 50%;
    width: 220px;
    height: 220px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--primary-rgb, 147, 51, 234), 0.35) 0%, transparent 68%);
    filter: blur(18px);
    animation: appLoaderHalo 2.6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes appLoaderHalo {
    0%, 100% { opacity: 0.55; transform: translateX(-50%) scale(0.92); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.08); }
}

.app-loader-mark {
    position: relative;
    width: 118px;
    height: 118px;
    margin-bottom: 30px;
    display: grid;
    place-items: center;
}

.app-loader-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
}

.app-loader-ring--spin {
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(var(--primary-rgb, 147, 51, 234), 0.05) 30deg,
        #fff 95deg,
        rgba(var(--primary-light-rgb, 192, 132, 252), 1) 130deg,
        transparent 175deg,
        transparent 360deg
    );
    mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
    animation: appLoaderSpin 1.15s linear infinite;
    filter: drop-shadow(0 0 8px rgba(var(--primary-rgb, 147, 51, 234), 0.75));
}

.app-loader-ring--counter {
    inset: -10px;
    background: conic-gradient(
        from 180deg,
        transparent 0deg,
        rgba(244, 114, 182, 0.55) 50deg,
        transparent 100deg,
        transparent 360deg
    );
    mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1px));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1px));
    animation: appLoaderSpinRev 2.4s linear infinite;
    opacity: 0.85;
}

.app-loader-ring--dash {
    inset: -22px;
    border: 1.5px dashed rgba(255, 255, 255, 0.14);
    background: none;
    animation: appLoaderSpin 12s linear infinite;
    opacity: 0.7;
}

.app-loader-core {
    position: absolute;
    inset: 14px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
        radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.18), transparent 42%),
        linear-gradient(160deg, rgba(40, 28, 70, 0.92), rgba(12, 8, 24, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow:
        0 0 0 1px rgba(var(--primary-rgb, 147, 51, 234), 0.28),
        0 24px 60px rgba(0, 0, 0, 0.55),
        0 0 40px rgba(var(--primary-rgb, 147, 51, 234), 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: appLoaderPulse 2.8s ease-in-out infinite;
}

.app-loader-core::before {
    content: '';
    position: absolute;
    inset: -40%;
    background: linear-gradient(
        115deg,
        transparent 40%,
        rgba(255, 255, 255, 0.18) 48%,
        rgba(255, 255, 255, 0.35) 50%,
        rgba(255, 255, 255, 0.12) 52%,
        transparent 60%
    );
    animation: appLoaderSheen 2.8s ease-in-out infinite;
    pointer-events: none;
}

.app-loader-ghost {
    position: relative;
    z-index: 1;
    width: 64px;
    height: 64px;
    object-fit: contain;
    object-position: center;
    user-select: none;
    -webkit-user-drag: none;
    animation: appLoaderGhost 2.4s ease-in-out infinite;
    filter:
        drop-shadow(0 0 14px rgba(224, 247, 250, 0.45))
        drop-shadow(0 8px 18px rgba(var(--primary-rgb, 147, 51, 234), 0.35));
}

@keyframes appLoaderGhost {
    0%, 100% {
        transform: translateY(2px) rotate(-3deg) scale(1);
    }
    25% {
        transform: translateY(-5px) rotate(2deg) scale(1.04);
    }
    50% {
        transform: translateY(-8px) rotate(3deg) scale(1.06);
    }
    75% {
        transform: translateY(-3px) rotate(-1deg) scale(1.03);
    }
}

@keyframes appLoaderSheen {
    0%, 55% { transform: translateX(-30%) rotate(18deg); opacity: 0; }
    65% { opacity: 1; }
    100% { transform: translateX(40%) rotate(18deg); opacity: 0; }
}

@keyframes appLoaderSpin { to { transform: rotate(360deg); } }
@keyframes appLoaderSpinRev { to { transform: rotate(-360deg); } }

@keyframes appLoaderPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

.app-loader-letter {
    position: relative;
    z-index: 1;
    font-family: var(--loader-font);
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 1;
    background: linear-gradient(165deg, #ffffff 5%, #f3e8ff 40%, #c084fc 78%, #e879f9 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 18px rgba(var(--primary-rgb, 147, 51, 234), 0.55));
}

.app-loader-brand {
    position: relative;
    margin: 0 0 10px;
    font-family: var(--loader-font);
    font-size: clamp(28px, 8vw, 38px);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.05;
    color: #fff;
    text-wrap: balance;
}

.app-loader-brand-char {
    display: inline-block;
    opacity: 0;
    transform: translateY(12px);
    animation: appLoaderChar 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes appLoaderChar {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-loader-brand-shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        100deg,
        transparent 20%,
        rgba(255, 255, 255, 0.55) 45%,
        transparent 70%
    );
    mix-blend-mode: soft-light;
    transform: translateX(-120%);
    animation: appLoaderBrandShine 2.6s ease-in-out 0.8s infinite;
    pointer-events: none;
}

@keyframes appLoaderBrandShine {
    0%, 40% { transform: translateX(-120%); }
    70%, 100% { transform: translateX(120%); }
}

.app-loader-tag {
    margin: 0 0 30px;
    max-width: 260px;
    font-family: var(--loader-font);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    color: rgba(243, 240, 255, 0.58);
    letter-spacing: 0.01em;
    animation: appLoaderFadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.35s both;
}

@keyframes appLoaderFadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.app-loader-progress {
    width: min(100%, 220px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: appLoaderFadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.5s both;
}

.app-loader-track {
    position: relative;
    width: 100%;
    height: 4px;
    border-radius: 99px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.app-loader-bar {
    position: absolute;
    inset: 0 auto 0 0;
    width: 42%;
    border-radius: inherit;
    background: linear-gradient(
        90deg,
        rgba(var(--primary-rgb, 147, 51, 234), 0.15),
        rgba(var(--primary-light-rgb, 192, 132, 252), 1) 55%,
        #fff
    );
    box-shadow:
        0 0 18px rgba(var(--primary-rgb, 147, 51, 234), 0.85),
        0 0 4px #fff;
    animation: appLoaderBar 1.25s cubic-bezier(0.45, 0, 0.2, 1) infinite;
}

@keyframes appLoaderBar {
    0% { left: -45%; width: 32%; }
    50% { width: 48%; }
    100% { left: 108%; width: 28%; }
}

.app-loader-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--loader-font);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(243, 240, 255, 0.42);
}

.app-loader-dots span {
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(var(--primary-light-rgb, 192, 132, 252), 0.9);
    animation: appLoaderDot 1.1s ease-in-out infinite;
}
.app-loader-dots span:nth-child(2) { animation-delay: 0.15s; }
.app-loader-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes appLoaderDot {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
    .app-loader *,
    .app-loader *::before {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .app-loader-brand-char {
        opacity: 1;
        transform: none;
    }
}

.newyear-loader {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #04030a;
}
