/* ═══════════════════════════════════════════════════════════════════
   Happy Birthday 3D — Retro-Futurism / Cosmic Dark UI
   Design System (ui-ux-pro-max):
     Fonts   : Russo One (headings/btns) · Chakra Petch (body)
     Palette : #0F0F23 bg · #7C3AED primary · #A78BFA secondary
               #F43F5E accent/CTA · #E2E8F0 text · #F0A500 gold
     Effects : Neon glow · Scanline sheen · Glitch-hover
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Russo+One&family=Chakra+Petch:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    --bg: #0F0F23;
    --surface: #16162A;
    --primary: #7C3AED;
    --secondary: #A78BFA;
    --accent: #F43F5E;
    --gold: #F0A500;
    --gold-light: #FFD700;
    --text: #E2E8F0;
    --text-muted: #8B8BB0;
    --border: rgba(167, 139, 250, 0.2);
    --glow-purple: rgba(124, 58, 237, 0.5);
    --glow-gold: rgba(240, 165, 0, 0.55);
    --font-head: 'Russo One', 'Impact', sans-serif;
    --font-body: 'Chakra Petch', 'Segoe UI', sans-serif;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Canvas ────────────────────────────────────────────────── */
#birthday-canvas {
    display: block;
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

/* ══════════════════════════════════════════════════════════════
   LOADING SCREEN
   ══════════════════════════════════════════════════════════════ */
.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(124, 58, 237, 0.25) 0%, transparent 55%),
        radial-gradient(ellipse at 75% 80%, rgba(244, 63, 94, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(15, 10, 35, 1) 0%, #0F0F23 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.7s ease;
}

/* Starfield shimmer overlay */
.loading-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 15% 25%, rgba(255, 220, 100, 0.5) 0%, transparent 70%),
        radial-gradient(1px 1px at 55% 15%, rgba(167, 139, 250, 0.4) 0%, transparent 70%),
        radial-gradient(1px 1px at 80% 65%, rgba(100, 200, 255, 0.3) 0%, transparent 70%),
        radial-gradient(1px 1px at 38% 72%, rgba(255, 150, 100, 0.3) 0%, transparent 70%),
        radial-gradient(1px 1px at 92% 12%, rgba(255, 255, 200, 0.45) 0%, transparent 70%),
        radial-gradient(1px 1px at 65% 45%, rgba(200, 150, 255, 0.3) 0%, transparent 70%),
        radial-gradient(1px 1px at 22% 60%, rgba(255, 200, 150, 0.25) 0%, transparent 70%);
    pointer-events: none;
    animation: shimmer 4s ease-in-out infinite alternate;
}

/* Scanline overlay (retro-futurism) */
.loading-screen::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 3px,
            rgba(124, 58, 237, 0.018) 3px,
            rgba(124, 58, 237, 0.018) 4px);
    pointer-events: none;
}

@keyframes shimmer {
    0% {
        opacity: 0.4;
    }

    100% {
        opacity: 1.0;
    }
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-screen.hidden {
    display: none;
}

.loader-content {
    text-align: center;
    width: 320px;
    max-width: 90vw;
    position: relative;
    z-index: 1;
}

/* ── Loader icon (SVG cake) ─────────────────────────────────── */
.loader-icon-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 28px;
}

.loader-icon-wrap::before,
.loader-icon-wrap::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: ring-pulse 2.4s ease-in-out infinite;
}

.loader-icon-wrap::before {
    width: 96px;
    height: 96px;
    border: 1.5px solid rgba(124, 58, 237, 0.4);
    animation-delay: 0s;
}

.loader-icon-wrap::after {
    width: 128px;
    height: 128px;
    border: 1px solid rgba(240, 165, 0, 0.2);
    animation-delay: 0.9s;
}

@keyframes ring-pulse {

    0%,
    100% {
        opacity: 0.2;
        transform: translate(-50%, -50%) scale(0.94);
    }

    50% {
        opacity: 0.9;
        transform: translate(-50%, -50%) scale(1.08);
    }
}

.loader-icon {
    width: 68px;
    height: 68px;
    display: block;
    animation: loader-float 2s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(240, 165, 0, 0.7)) drop-shadow(0 0 40px rgba(124, 58, 237, 0.4));
    position: relative;
    z-index: 1;
}

@keyframes loader-float {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-12px) scale(1.05);
    }
}

.loader-title {
    font-family: var(--font-head);
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--secondary);
    margin-bottom: 24px;
    animation: text-pulse 3s ease-in-out infinite alternate;
    text-shadow: 0 0 14px rgba(167, 139, 250, 0.5);
}

@keyframes text-pulse {
    0% {
        color: var(--text-muted);
        text-shadow: none;
    }

    100% {
        color: var(--secondary);
        text-shadow: 0 0 14px rgba(167, 139, 250, 0.6);
    }
}

.loader-bar-track {
    width: 100%;
    height: 3px;
    background: rgba(124, 58, 237, 0.15);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 10px;
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.15);
}

.loader-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--gold), var(--accent));
    border-radius: 2px;
    transition: width 0.18s ease;
    box-shadow: 0 0 12px var(--glow-gold);
}

.loader-percent {
    font-family: var(--font-head);
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.12em;
}

/* ══════════════════════════════════════════════════════════════
   ACTION BUTTON — Retro-Futurism: neon border + scanline sheen
   ══════════════════════════════════════════════════════════════ */
.overlay-ui {
    position: fixed;
    bottom: 44px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}

.action-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 38px;
    background: linear-gradient(135deg, #1a0d3a 0%, #2d1060 50%, #1a0d3a 100%);
    background-size: 200% 200%;
    color: var(--secondary);
    border: 1.5px solid var(--primary);
    border-radius: 6px;
    font-family: var(--font-head);
    font-size: 0.92rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow:
        0 0 14px var(--glow-purple),
        0 0 30px rgba(124, 58, 237, 0.2),
        inset 0 1px 0 rgba(167, 139, 250, 0.12);
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: btn-breathe 3.5s ease-in-out infinite, gradient-drift 8s ease infinite;
    -webkit-appearance: none;
    appearance: none;
    overflow: hidden;
    outline: none;
}

/* Corner accents (retro-futurism) */
.action-btn::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border-radius: 6px;
    background:
        linear-gradient(135deg, var(--primary) 0%, transparent 30%) top left / 14px 14px no-repeat,
        linear-gradient(225deg, var(--primary) 0%, transparent 30%) top right / 14px 14px no-repeat,
        linear-gradient(315deg, var(--primary) 0%, transparent 30%) bottom right / 14px 14px no-repeat,
        linear-gradient(45deg, var(--primary) 0%, transparent 30%) bottom left / 14px 14px no-repeat;
    opacity: 0.6;
    pointer-events: none;
}

/* Scanline sheen sweep */
.action-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -120%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(167, 139, 250, 0.18), transparent);
    animation: sheen-sweep 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes sheen-sweep {
    0% {
        left: -120%;
    }

    45% {
        left: 160%;
    }

    100% {
        left: 160%;
    }
}

@keyframes btn-breathe {

    0%,
    100% {
        box-shadow: 0 0 14px var(--glow-purple), 0 0 28px rgba(124, 58, 237, 0.15);
    }

    50% {
        box-shadow: 0 0 22px rgba(124, 58, 237, 0.8), 0 0 50px rgba(124, 58, 237, 0.3);
    }
}

@keyframes gradient-drift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.action-btn:hover {
    transform: scale(1.06) translateY(-2px);
    color: var(--gold-light);
    border-color: var(--gold);
    box-shadow:
        0 0 20px var(--glow-gold),
        0 0 50px rgba(240, 165, 0, 0.25),
        inset 0 1px 0 rgba(255, 215, 0, 0.15);
    animation: btn-breathe-hover 1.5s ease-in-out infinite;
}

@keyframes btn-breathe-hover {

    0%,
    100% {
        box-shadow: 0 0 20px var(--glow-gold), 0 0 50px rgba(240, 165, 0, 0.2);
        transform: scale(1.06) translateY(-2px) skewX(0deg);
    }

    15% {
        transform: scale(1.06) translateY(-2px) skewX(-0.4deg);
    }

    30% {
        transform: scale(1.06) translateY(-2px) skewX(0.4deg);
    }

    45% {
        transform: scale(1.06) translateY(-2px) skewX(0deg);
    }

    50% {
        box-shadow: 0 0 28px rgba(240, 165, 0, 0.9), 0 0 70px rgba(240, 165, 0, 0.35);
    }
}

.action-btn:active {
    transform: scale(0.97);
}

/* ── LightUp State — gold neon override ──────────────────────── */
.action-btn.btn--lit {
    background: linear-gradient(135deg, #2e1800 0%, #5a3000 50%, #2e1800 100%);
    border-color: var(--gold);
    color: var(--gold-light);
    box-shadow:
        0 0 20px var(--glow-gold),
        0 0 55px rgba(255, 160, 0, 0.3),
        inset 0 1px 0 rgba(255, 215, 0, 0.2);
    animation: btn-breathe-lit 2s ease-in-out infinite, gradient-drift 5s ease infinite;
}

@keyframes btn-breathe-lit {

    0%,
    100% {
        box-shadow: 0 0 20px var(--glow-gold), 0 0 50px rgba(255, 150, 0, 0.2);
    }

    50% {
        box-shadow: 0 0 35px rgba(255, 215, 0, 0.9), 0 0 80px rgba(255, 180, 0, 0.4);
    }
}

/* Icon inside button */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.btn-label {
    position: relative;
}

/* ══════════════════════════════════════════════════════════════
   CANDLE PROGRESS INDICATOR
   ══════════════════════════════════════════════════════════════ */
.candle-progress {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: rgba(15, 15, 35, 0.88);
    border: 1px solid rgba(167, 139, 250, 0.25);
    border-radius: 40px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45), 0 0 20px rgba(124, 58, 237, 0.12);
    pointer-events: none;
    animation: progress-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes progress-appear {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(12px) scale(0.94);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

.candle-progress-label {
    font-family: var(--font-head);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.candle-dots {
    display: flex;
    gap: 10px;
    align-items: center;
}

.candle-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid rgba(167, 139, 250, 0.3);
    background: rgba(124, 58, 237, 0.06);
    position: relative;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.candle-dot::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 1.5px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 1px;
    transition: background 0.3s ease;
}

.candle-dot.lit {
    background: radial-gradient(circle at 50% 40%, #fff5c0, #FFD700, #FF8800);
    border-color: var(--gold-light);
    box-shadow: 0 0 10px var(--glow-gold), 0 0 24px rgba(255, 180, 0, 0.4);
    animation: candle-flicker 1.8s ease-in-out infinite;
}

.candle-dot.lit::before {
    background: #111;
    height: 5px;
}

@keyframes candle-flicker {

    0%,
    100% {
        box-shadow: 0 0 8px var(--glow-gold), 0 0 20px rgba(255, 180, 0, 0.35);
        opacity: 1;
    }

    25% {
        box-shadow: 0 0 14px rgba(255, 220, 0, 0.9), 0 0 32px rgba(255, 180, 0, 0.5);
        opacity: 0.92;
    }

    50% {
        box-shadow: 0 0 6px var(--glow-gold), 0 0 16px rgba(255, 150, 0, 0.3);
        opacity: 1;
    }

    75% {
        box-shadow: 0 0 12px rgba(255, 215, 0, 0.85), 0 0 28px rgba(255, 160, 0, 0.45);
        opacity: 0.95;
    }
}

/* ══════════════════════════════════════════════════════════════
   MESSAGE OVERLAY
   ══════════════════════════════════════════════════════════════ */
.message-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(10, 8, 25, 0.88);
    backdrop-filter: blur(8px) saturate(1.3);
    -webkit-backdrop-filter: blur(8px) saturate(1.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-scroll {
    text-align: center;
    max-width: 560px;
    padding: 52px 36px;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(124, 58, 237, 0.12) 0%, transparent 60%),
        rgba(18, 14, 40, 0.6);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow:
        0 8px 48px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(124, 58, 237, 0.1),
        inset 0 1px 0 rgba(167, 139, 250, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    overflow: hidden;
}

/* Corner accent lines */
.message-scroll::before,
.message-scroll::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
}

.message-scroll::before {
    top: 10px;
    left: 10px;
    border-top: 1.5px solid var(--primary);
    border-left: 1.5px solid var(--primary);
    border-radius: 2px 0 0 0;
}

.message-scroll::after {
    bottom: 10px;
    right: 10px;
    border-bottom: 1.5px solid var(--primary);
    border-right: 1.5px solid var(--primary);
    border-radius: 0 0 2px 0;
}

.message-scroll .msg-line {
    font-family: var(--font-body);
    font-size: 1.25rem;
    font-weight: 400;
    line-height: 1.7;
    color: var(--text);
    opacity: 0;
    animation: msgFadeUp 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    letter-spacing: 0.02em;
}

.message-scroll .msg-line.emphasis {
    font-family: var(--font-head);
    color: var(--gold-light);
    font-size: 1.6rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 160, 0, 0.3);
}

@keyframes msgFadeUp {
    from {
        opacity: 0;
        transform: translateY(22px) scale(0.97);
        filter: blur(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0px);
    }
}

/* Skip button — ghost style */
.skip-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 32;
    padding: 8px 20px;
    background: transparent;
    border: 1px solid rgba(167, 139, 250, 0.3);
    border-radius: 4px;
    font-family: var(--font-head);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    animation: skip-appear 0.5s 0.8s both;
}

@keyframes skip-appear {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

.skip-btn:hover {
    color: var(--secondary);
    border-color: var(--secondary);
    box-shadow: 0 0 10px rgba(167, 139, 250, 0.25);
}

/* ══════════════════════════════════════════════════════════════
   MESSAGE NAVIGATION (prev/next)
   ══════════════════════════════════════════════════════════════ */
.msg-nav {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 35;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    background: rgba(15, 15, 35, 0.85);
    border: 1px solid rgba(167, 139, 250, 0.25);
    border-radius: 40px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45), 0 0 20px rgba(124, 58, 237, 0.12);
    animation: progress-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.msg-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid rgba(167, 139, 250, 0.35);
    background: rgba(124, 58, 237, 0.08);
    color: var(--secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    padding: 0;
}

.msg-nav-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
}

.msg-nav-btn:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.4);
    color: var(--text);
}

.msg-nav-btn:active {
    transform: scale(0.9);
}

.msg-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.msg-nav-btn:disabled:hover {
    background: rgba(124, 58, 237, 0.08);
    border-color: rgba(167, 139, 250, 0.35);
    box-shadow: none;
}

.msg-counter {
    font-family: var(--font-head);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    min-width: 60px;
    text-align: center;
    user-select: none;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .action-btn {
        padding: 12px 28px;
        font-size: 0.82rem;
        letter-spacing: 0.08em;
    }

    .overlay-ui {
        bottom: 28px;
    }

    .message-scroll {
        max-width: 94vw;
        padding: 36px 20px;
        border-radius: 16px;
    }

    .message-scroll .msg-line {
        font-size: 1.08rem;
    }

    .message-scroll .msg-line.emphasis {
        font-size: 1.35rem;
    }

    .candle-progress {
        padding: 10px 20px;
        gap: 8px;
    }

    .candle-dot {
        width: 24px;
        height: 24px;
    }

    .candle-progress-label {
        font-size: 0.62rem;
    }

    .skip-btn {
        bottom: 16px;
        right: 16px;
    }

    .msg-nav {
        padding: 8px 16px;
        gap: 12px;
        bottom: 20px;
    }

    .msg-nav-btn {
        width: 32px;
        height: 32px;
    }

    .msg-counter {
        font-size: 0.65rem;
        min-width: 50px;
    }
}

@media (max-width: 380px) {
    .action-btn {
        padding: 10px 22px;
        font-size: 0.76rem;
    }

    .loader-content {
        width: 260px;
    }

    .loader-icon {
        width: 56px;
        height: 56px;
    }

    .loader-title {
        font-size: 0.8rem;
    }

    .candle-dot {
        width: 20px;
        height: 20px;
    }
}

/* Reduced motion — respect accessibility */
@media (prefers-reduced-motion: reduce) {

    .loader-icon,
    .action-btn,
    .candle-dot,
    .msg-line {
        animation-duration: 0.001ms !important;
    }
}