* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans Thai', 'Montserrat', sans-serif;
    background: transparent;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* ═══════════════════════════════════════════
   Keyframes
   ═══════════════════════════════════════════ */

@keyframes bounceIn {
    0%   { transform: scale(0) rotate(-10deg); opacity: 0; }
    60%  { transform: scale(1.15) rotate(2deg); opacity: 1; }
    80%  { transform: scale(0.95) rotate(-1deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

@keyframes spinIn {
    0%   { transform: rotate(0deg) scale(0.8); opacity: 0.3; }
    50%  { transform: rotate(180deg) scale(1.1); opacity: 1; }
    100% { transform: rotate(360deg) scale(1); opacity: 1; }
}

@keyframes nameplateIn {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes borderGlow {
    0%, 100% {
        border-color: rgba(var(--accent, 255,200,0), 0.18);
        box-shadow:
            0 0 8px rgba(var(--accent, 255,200,0), 0.06),
            0 4px 16px rgba(0,0,0,0.45),
            inset 0 1px 0 rgba(255,255,255,0.04);
    }
    50% {
        border-color: rgba(var(--accent, 255,200,0), 0.4);
        box-shadow:
            0 0 14px rgba(var(--accent, 255,200,0), 0.14),
            0 4px 16px rgba(0,0,0,0.45),
            inset 0 1px 0 rgba(255,255,255,0.06);
    }
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 8px rgba(var(--accent, 255,200,0), 0.35), 0 1px 2px rgba(0,0,0,0.6); }
    50%      { text-shadow: 0 0 14px rgba(var(--accent, 255,200,0), 0.6), 0 1px 2px rgba(0,0,0,0.6); }
}

@keyframes shimmerSweep {
    0%        { left: -80%; }
    40%, 100% { left: 160%; }
}

@keyframes accentPulse {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 0.9; }
}

/* Seamless infinite marquee — track is 2 copies wide, scroll one full copy */
@keyframes marquee-scroll {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(-50%, 0, 0); }
}

/* ═══════════════════════════════════════════
   Layout
   ═══════════════════════════════════════════ */

.overlay-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.5s ease;
}

.skin-frame-container {
    position: relative;
    transition: width 0.5s, height 0.5s;
    animation: bounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both,
               float 4s ease-in-out infinite 1s;
}

.skin-frame {
    position: absolute;
    /* Use percentages so the bleed scales with the container size.
       top: -50% centers the 200%-tall frame vertically on the container.
       left: -52% mirrors the original -235px / 450px ≈ 52% offset. */
    top: -50%;
    left: -52%;
    width: 200%;
    height: 200%;
    z-index: 10;
    pointer-events: none;
    object-fit: contain;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
}

.skin-frame.spin-change {
    animation: spinIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ═══════════════════════════════════════════
   Skin Themes (CSS custom properties)
   ═══════════════════════════════════════════ */

/* Skin 1 — Gold/Bronze + Blue-Purple wings */
.skin-1 {
    --accent: 196, 154, 108;
    --title-color: #e8c896;
    --desc-color: #fff;
    --np-bg-from: rgba(22, 16, 8, 0.88);
    --np-bg-to:   rgba(14, 10, 5, 0.92);
    --np-border: rgba(196, 154, 108, 0.25);
    --accent-line: linear-gradient(90deg, transparent, rgba(232, 200, 150, 0.7), transparent);
}

/* Skin 2 — Red Phoenix (Was Ice Blue, now Red) */
.skin-2 {
    --accent: 196, 50, 68;
    --title-color: #e86070;
    --desc-color: #ffe8eb;
    --np-bg-from: rgba(24, 8, 12, 0.88);
    --np-bg-to:   rgba(16, 5, 8, 0.92);
    --np-border: rgba(196, 50, 68, 0.25);
    --accent-line: linear-gradient(90deg, transparent, rgba(232, 96, 112, 0.7), transparent);
}

/* Skin 3 — Gold + Purple crystal (Was Red, now Purple) */
.skin-3 {
    --accent: 139, 69, 186;
    --title-color: #c48adb;
    --desc-color: #f0e0ff;
    --np-bg-from: rgba(16, 8, 26, 0.88);
    --np-bg-to:   rgba(10, 4, 18, 0.92);
    --np-border: rgba(139, 69, 186, 0.25);
    --accent-line: linear-gradient(90deg, transparent, rgba(196, 138, 219, 0.7), transparent);
}

/* Skin 4 — Blue Wings (Was Purple, now Ice Blue) */
.skin-4 {
    --accent: 77, 168, 218;
    --title-color: #7ccef5;
    --desc-color: #e0f4ff;
    --np-bg-from: rgba(6, 14, 28, 0.88);
    --np-bg-to:   rgba(4, 10, 22, 0.92);
    --np-border: rgba(77, 168, 218, 0.25);
    --accent-line: linear-gradient(90deg, transparent, rgba(124, 206, 245, 0.7), transparent);
}

/* ═══════════════════════════════════════════
   Avatar
   ═══════════════════════════════════════════ */

.avatar {
    position: absolute;
    border-radius: 50%;
    object-fit: cover;
    z-index: 1;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(var(--accent, 255,195,0), 0.4);
    box-shadow: 0 0 10px rgba(var(--accent, 255,195,0), 0.2);
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(var(--accent, 255,195,0), 0.2), 0 0 16px rgba(var(--accent, 255,195,0), 0.06);
        border-color: rgba(var(--accent, 255,195,0), 0.35);
    }
    50% {
        box-shadow: 0 0 14px rgba(var(--accent, 255,195,0), 0.45), 0 0 28px rgba(var(--accent, 255,195,0), 0.1);
        border-color: rgba(var(--accent, 255,195,0), 0.65);
    }
}

/* ═══════════════════════════════════════════
   Nameplate — premium compact pill
   ═══════════════════════════════════════════ */

.nameplate {
    position: absolute;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 8px 32px 10px;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(
        180deg,
        var(--np-bg-from, rgba(8, 4, 18, 0.88)) 0%,
        var(--np-bg-to, rgba(14, 8, 28, 0.92)) 100%
    );
    border: 1px solid var(--np-border, rgba(255,200,0, 0.2));
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    animation: nameplateIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both 0.3s,
               borderGlow 3s ease-in-out infinite 1s;
}

/* Thin accent line at top of nameplate */
.nameplate::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: var(--accent-line, linear-gradient(90deg, transparent, rgba(255,215,0,0.7), transparent));
    animation: accentPulse 3s ease-in-out infinite 1s;
    pointer-events: none;
}

/* Shimmer sweep across nameplate */
.nameplate::after {
    content: '';
    position: absolute;
    top: 0;
    left: -80%;
    width: 40%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(var(--accent, 255,215,0), 0.04),
        transparent
    );
    animation: shimmerSweep 5s ease-in-out infinite 2s;
    pointer-events: none;
}

/* ── Labels ── */

.np-label {
    position: relative;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.3s;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Hide label when empty */
.np-label:empty,
.np-label.hidden {
    display: none !important;
}

#title-label {
    color: var(--title-color, #fff);
    font-weight: 600;
    font-size: 40px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

#desc-label {
    color: var(--title-color, #fff);
    font-weight: 900;
    font-size: 42px;
    letter-spacing: 0.12em;
    animation: titleGlow 3s ease-in-out infinite 1s;
    padding: 40px 40px;
    border: none;
    border-radius: 0;
    background: var(--desc-frame) center / 100% 100% no-repeat;
    box-shadow: none;
    outline: none;
}

/* Map SVG frames to skins */
.skin-1 { --desc-frame: url('{{FRAME1_SVG}}'); }
.skin-2 { --desc-frame: url('{{FRAME2_SVG}}'); }
.skin-3 { --desc-frame: url('{{FRAME3_SVG}}'); }
.skin-4 { --desc-frame: url('{{FRAME1_SVG}}'); }

/* ═══════════════════════════════════════════
   Orientation — Vertical
   ═══════════════════════════════════════════ */

.skin-frame-container.vertical {
    width: clamp(200px, 45vh, 450px);
    height: clamp(200px, 45vh, 450px);
}

.vertical .avatar {
    width: 50%;
    height: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Nameplate becomes invisible container in vertical (same as horizontal) */
.vertical .nameplate {
    top: calc(100% - 100px);
    left: 0;
    right: 0;
    margin: 0 auto;
    width: auto;
    height: auto;
    min-width: auto;
    background: none;
    border: none;
    border-radius: 999px;
    padding: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    overflow: visible;
    animation: none;
    gap: 0;
}

.vertical .nameplate::before,
.vertical .nameplate::after {
    display: none;
}

.vertical #title-label,
.vertical #title-label.marquee {
    order: -1;
    display: block;
    width: 200px;
    height: 62px;
    margin: 3px auto;
    text-align: center;
    overflow: hidden;
}

.vertical #title-label .marquee-viewport {
    padding: 5px 10px;
}

.vertical #desc-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-width: clamp(200px, 45vh, 450px);
    max-width: 600px;
    margin: 3px 10px 10px 10px;
    text-align: center;
    /* Use aspect-ratio to keep frame shape perfectly intact */
    padding: 0 40px;
    aspect-ratio: 3.5 / 1;
    background-size: 100% 100%;
}

/* Clip marquee text within desc-label frame */
#desc-label.marquee {
    overflow: hidden;
}

.vertical #desc-label.marquee {
    width: clamp(200px, 45vh, 450px);
}

/* Each label gets its own pill in vertical */
.vertical .np-label {
    position: relative;
    width: auto;
    overflow: hidden;
    background: linear-gradient(180deg, var(--np-bg-from, rgba(8,4,18,0.88)), var(--np-bg-to, rgba(14,8,28,0.92)));
    padding: 5px 22px;
    border-radius: 999px;
    border: 1px solid var(--np-border, rgba(255,200,0, 0.2));
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    box-shadow:
        0 0 8px rgba(var(--accent, 255,200,0), 0.06),
        0 4px 12px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.04);
    animation: borderGlow 3s ease-in-out infinite 1s;
    margin: 3px auto;
    display: block;
}

/* Accent line on vertical pills */
.vertical .np-label::before {
    content: '';
    position: absolute;
    top: 0;
    left: 15%;
    right: 15%;
    height: 1px;
    background: var(--accent-line, linear-gradient(90deg, transparent, rgba(255,215,0,0.7), transparent));
    animation: accentPulse 3s ease-in-out infinite 1s;
    pointer-events: none;
}

/* Shimmer on vertical pills */
.vertical .np-label::after {
    content: '';
    position: absolute;
    top: 0;
    left: -80%;
    width: 40%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(var(--accent, 255,215,0), 0.04),
        transparent
    );
    animation: shimmerSweep 5s ease-in-out infinite 2s;
    pointer-events: none;
}

/* ═══════════════════════════════════════════
   Orientation — Horizontal (split pill badges)
   ═══════════════════════════════════════════ */

.skin-frame-container.horizontal {
    width: clamp(200px, 45vh, 450px);
    height: clamp(200px, 45vh, 450px);
}

.horizontal .avatar {
    width: 50%;
    height: 50%;
    top: 50%;
    left: 51%;
    transform: translate(-50%, -50%);
}

/* Nameplate becomes invisible container in horizontal */
.horizontal .nameplate {
    inset: 0;
    width: auto;
    height: auto;
    min-width: auto;
    background: none;
    border: none;
    border-radius: 999px;
    padding: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    overflow: visible;
    animation: none;
    gap: 0;
    z-index: auto;
}

.horizontal .nameplate::before,
.horizontal .nameplate::after {
    display: none;
}

/* Each label gets its own compact pill */
.horizontal .np-label {
    position: absolute;
    width: auto;
    overflow: hidden;
    background: linear-gradient(180deg, var(--np-bg-from, rgba(8,4,18,0.88)), var(--np-bg-to, rgba(14,8,28,0.92)));
    padding: 5px 22px;
    border-radius: 999px;
    border: 1px solid var(--np-border, rgba(255,200,0, 0.2));
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    box-shadow:
        0 0 8px rgba(var(--accent, 255,200,0), 0.06),
        0 4px 12px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.04);
    animation: borderGlow 3s ease-in-out infinite 1s;
}

/* Accent line on horizontal pills */
.horizontal .np-label::before {
    content: '';
    position: absolute;
    top: 0;
    left: 15%;
    right: 15%;
    height: 1px;
    background: var(--accent-line, linear-gradient(90deg, transparent, rgba(255,215,0,0.7), transparent));
    animation: accentPulse 3s ease-in-out infinite 1s;
    pointer-events: none;
}

/* Shimmer on horizontal pills */
.horizontal .np-label::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -80%;
    width: 40%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(var(--accent, 255,215,0), 0.04),
        transparent
    );
    animation: shimmerSweep 5s ease-in-out infinite 2s;
    pointer-events: none;
}

/* Description — premium badge to the right of frame (behind it) */
.horizontal #desc-label {
    display: flex;
    align-items: center;
    justify-content: center;
    left: 72%;
    top: 50%;
    transform: translateY(-50%);
    width: fit-content;
    min-width: 450px;
    max-width: 700px;
    font-size: 47px;
    z-index: -1;
    /* Use padding only for left offset, let aspect-ratio control height */
    padding: 0 30px 0 6rem;
    aspect-ratio: 3.5 / 1;
    background-size: 100% 100%;
}

/* Description marquee when text overflows */
.horizontal #desc-label.marquee {
    white-space: nowrap;
    width: 420px;
}

/* Title — simple pill below the frame */
.horizontal #title-label,
.horizontal #title-label.marquee {
    bottom: -5px;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 200px;
    height: 62px;
    font-size: 40px;
    z-index: 20;
    overflow: hidden;
}

/* Title marquee when text overflows */
.horizontal #title-label.marquee {
    white-space: nowrap;
}

.horizontal #title-label .marquee-viewport {
    padding: 0 10px;
}

/* ═══════════════════════════════════════════
   Marquee for long text
   ═══════════════════════════════════════════ */

.np-label.marquee {
    white-space: nowrap;
    text-overflow: clip;
}

.marquee-viewport {
    overflow: hidden;
    width: 100%;
    /* Isolate from parent animations to prevent repaint jitter */
    contain: layout style paint;
    transform: translateZ(0);
    isolation: isolate;
    padding: 0 10px;
}

.np-label.marquee .marquee-track {
    display: inline-flex;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translate3d(0, 0, 0);
    transition: none !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    isolation: isolate;
}

/* Disable heavy repaint animations on labels while marquee is active */
.np-label.marquee {
    animation: none !important;
}

.np-label.marquee::before,
.np-label.marquee::after {
    animation: none !important;
}

/* ═══════════════════════════════════════════
   Particles
   ═══════════════════════════════════════════ */

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
}
