.greeting-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease, backdrop-filter 0.3s ease;
}

.greeting-modal {
    --modal-size: min(90vw, 90vh, 500px);
    width: var(--modal-size);
    height: var(--modal-size);
    
    background: 
        var(--greet-bg),
        radial-gradient(
            ellipse 140% 140% at 50% 0%, 
            color-mix(in srgb, var(--card) 95%, var(--span) 5%), 
            var(--bg) 60%
        );
    background-size: cover, auto;
    background-position: center, center;
    background-repeat: no-repeat, no-repeat;
    
    border: 1px solid color-mix(in srgb, var(--span) 20%, transparent);
    border-radius: var(--br-20, 20px);
    
    box-shadow: 
        0 20px 60px color-mix(in srgb, var(--bg) 80%, black 20%),
        0 0 0 1px var(--transparent-3-w, rgba(255,255,255,.03)) inset,
        0 0 40px color-mix(in srgb, var(--span) 12%, transparent);
    
    position: relative;
    padding: clamp(16px, calc(var(--modal-size) * .05), 24px);
    color: var(--text-default);
    transform: translateY(20px) scale(.96);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), 
                opacity 0.4s ease, 
                box-shadow 0.4s ease;
    overflow: hidden;
}

.greeting-modal::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        180deg, 
        color-mix(in srgb, var(--bg) 75%, transparent),
        color-mix(in srgb, var(--bg) 55%, transparent)
    );
    pointer-events: none;
    box-shadow: 
        inset 0 0 120px color-mix(in srgb, var(--bg) 80%, black 20%),
        inset 0 0 0 2px color-mix(in srgb, var(--span) 8%, transparent);
    z-index: 1;
}

.greeting-modal::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 10%;
    transform: translateX(-50%);
    width: 70%;
    height: 40%;
    background: radial-gradient(
        ellipse 60% 70% at 50% 50%, 
        color-mix(in srgb, var(--span) 28%, transparent), 
        transparent 65%
    );
    filter: blur(30px);
    pointer-events: none;
    z-index: 0;
    animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { 
        opacity: 0.6;
        transform: translateX(-50%) scale(1);
    }
    50% { 
        opacity: 1;
        transform: translateX(-50%) scale(1.1);
    }
}

.greeting-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: color-mix(in srgb, var(--card) 60%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--transparent-5-w, rgba(255,255,255,.05));
    color: var(--text-secondary);
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: var(--br-8, 8px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    line-height: 1;
}

.greeting-close:hover {
    background: color-mix(in srgb, var(--span) 20%, var(--card) 60%);
    color: var(--text-default);
    transform: rotate(90deg);
    border-color: color-mix(in srgb, var(--span) 30%, transparent);
}

.greeting-close:active {
    transform: rotate(90deg) scale(0.95);
}

.greeting-content {
    display: flex;
    flex-direction: column;
    gap: clamp(12px, calc(var(--modal-size) * .035), 18px);
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    position: relative;
    z-index: 2;
}

.greeting-icon { 
    display: none; 
}

.greeting-icon img {
    width: clamp(80px, calc(var(--modal-size) * .24), 140px);
    height: clamp(80px, calc(var(--modal-size) * .24), 140px);
    object-fit: contain;
    object-position: center;
    max-width: 100%;
    max-height: 100%;
    filter: drop-shadow(0 8px 24px color-mix(in srgb, var(--span) 40%, transparent));
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: auto;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.greeting-icon img:hover {
    transform: scale(1.05) rotate(2deg);
    filter: drop-shadow(0 12px 32px color-mix(in srgb, var(--span) 60%, transparent));
}

.greeting-title {
    font-size: clamp(20px, calc(var(--modal-size) * .065), 32px);
    font-weight: 700;
    margin-bottom: clamp(6px, calc(var(--modal-size) * .015), 10px);
    background: linear-gradient(
        135deg, 
        var(--text-default) 0%, 
        color-mix(in srgb, var(--span) 80%, white) 50%, 
        var(--span) 100%
    );
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 2px 8px color-mix(in srgb, var(--span) 25%, transparent);
    letter-spacing: 0.02em;
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.greeting-subtitle {
    font-size: clamp(13px, calc(var(--modal-size) * .038), 17px);
    color: var(--text-secondary);
    text-shadow: 0 2px 4px color-mix(in srgb, var(--bg) 60%, black 40%);
    line-height: 1.6;
    font-weight: 400;
}

.greeting-actions {
    margin-top: clamp(12px, calc(var(--modal-size) * .035), 20px);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.greeting-text {
    background: color-mix(in srgb, var(--card) 50%, transparent);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--br-16, 16px);
    padding: clamp(16px, calc(var(--modal-size) * .045), 24px);
    border: 1px solid var(--transparent-5-w, rgba(255,255,255,.05));
    box-shadow: 
        0 8px 32px color-mix(in srgb, var(--bg) 40%, transparent),
        inset 0 1px 0 var(--transparent-10-w, rgba(255,255,255,.1)),
        0 0 0 1px color-mix(in srgb, var(--span) 5%, transparent) inset;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.greeting-text::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        color-mix(in srgb, var(--span) 8%, transparent),
        transparent
    );
    transition: left 0.5s ease;
}

.greeting-text:hover::before {
    left: 100%;
}

.tg-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    background: linear-gradient(
        135deg, 
        var(--span), 
        color-mix(in srgb, var(--span) 70%, var(--orange) 30%)
    );
    color: var(--text-default);
    border-radius: var(--br-10, 10px);
    text-decoration: none;
    font-weight: 600;
    font-size: clamp(13px, calc(var(--modal-size) * .032), 15px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 4px 12px color-mix(in srgb, var(--span) 40%, transparent),
        0 0 0 1px var(--transparent-10-w, rgba(255,255,255,.1)) inset;
    border: none;
    position: relative;
    overflow: hidden;
}

.tg-button::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        transparent,
        color-mix(in srgb, white 20%, transparent),
        transparent
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tg-button:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 20px color-mix(in srgb, var(--span) 50%, transparent),
        0 0 0 1px var(--transparent-20-w, rgba(255,255,255,.2)) inset;
}

.tg-button:hover::before {
    opacity: 1;
}

.tg-button:active {
    transform: translateY(0px);
    box-shadow: 
        0 2px 8px color-mix(in srgb, var(--span) 30%, transparent),
        0 0 0 1px var(--transparent-10-w, rgba(255,255,255,.1)) inset;
}

.greeting-overlay.is-open {
    opacity: 1;
}

.greeting-overlay.is-open .greeting-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
    animation: pulseGlow 6s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { 
        box-shadow: 
            0 20px 60px color-mix(in srgb, var(--bg) 80%, black 20%),
            0 0 0 1px var(--transparent-3-w, rgba(255,255,255,.03)) inset,
            0 0 35px color-mix(in srgb, var(--span) 12%, transparent);
    }
    50% { 
        box-shadow: 
            0 24px 80px color-mix(in srgb, var(--bg) 85%, black 15%),
            0 0 0 1px var(--transparent-5-w, rgba(255,255,255,.05)) inset,
            0 0 60px color-mix(in srgb, var(--span) 22%, transparent);
    }
}

.winter-decor {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.greeting-content, .greeting-close, .greeting-text {
    position: relative;
    z-index: 2;
}

.snowflake {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(
        circle at 30% 30%,
        rgba(255, 255, 255, 0.9),
        rgba(255, 255, 255, 0.6)
    );
    opacity: 0.6;
    filter: blur(0.5px);
    box-shadow:
        0 0 8px rgba(255, 255, 255, 0.4),
        0 0 16px rgba(255, 255, 255, 0.2);
}

.s1 {
    top: 10%;
    left: 12%;
    width: 10px;
    height: 10px;
    animation: snowFall1 12s ease-in-out infinite, snowPulse 3s ease-in-out infinite;
    will-change: transform, opacity;
}

.s2 {
    top: 20%;
    right: 15%;
    width: 7px;
    height: 7px;
    opacity: 0.5;
    animation: snowFall2 10s ease-in-out infinite, snowPulse 2.5s ease-in-out infinite;
    will-change: transform, opacity;
}

.s3 {
    bottom: 30%;
    left: 20%;
    width: 6px;
    height: 6px;
    opacity: 0.35;
    animation: snowFall3 14s ease-in-out infinite, snowPulse 3.2s ease-in-out infinite;
    will-change: transform, opacity;
}

.s4 {
    top: 35%;
    left: 70%;
    width: 5px;
    height: 5px;
    opacity: 0.45;
    animation: snowFall2 9s ease-in-out infinite, snowPulse 2.8s ease-in-out infinite;
    will-change: transform, opacity;
}

.s5 {
    top: 45%;
    left: 40%;
    width: 6px;
    height: 6px;
    opacity: 0.4;
    animation: snowFall1 15s ease-in-out infinite, snowPulse 3.5s ease-in-out infinite;
    will-change: transform, opacity;
}

@keyframes snowFall1 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(20px, 50px) rotate(90deg); }
    50% { transform: translate(30px, 100px) rotate(180deg); }
    75% { transform: translate(15px, 150px) rotate(270deg); }
}

@keyframes snowFall2 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-18px, 40px) rotate(-90deg); }
    50% { transform: translate(-28px, 80px) rotate(-180deg); }
    75% { transform: translate(-12px, 120px) rotate(-270deg); }
}

@keyframes snowFall3 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(16px, 60px) rotate(120deg); }
    50% { transform: translate(24px, 120px) rotate(240deg); }
    75% { transform: translate(10px, 180px) rotate(360deg); }
}

@keyframes snowPulse {
    0%, 100% { opacity: inherit; transform: scale(1) rotate(0deg); }
    50% { opacity: calc(var(--base-opacity, 0.6) * 0.7); transform: scale(0.9) rotate(180deg); }
}

.winter-decor::before, 
.winter-decor::after {
    content: "";
    position: absolute;
    width: 140px;
    height: 140px;
    opacity: 0.08;
    pointer-events: none;
    background: radial-gradient(
        circle at center, 
        color-mix(in srgb, var(--span) 30%, transparent) 0 1px, 
        transparent 2px
    ) repeat;
    background-size: 20px 20px;
    filter: blur(0.5px);
}

.winter-decor::before { 
    top: 0; 
    left: 0;
    background-position: 0 0;
}

.winter-decor::after { 
    bottom: 0; 
    right: 0;
    background-position: 10px 10px;
}

.snowman-row {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    animation: snowmanFloat 4s ease-in-out infinite;
    will-change: transform;
}

.snowman {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: radial-gradient(
        circle at 35% 35%,
        rgba(255, 255, 255, 0.95),
        rgba(255, 255, 255, 0.8),
        rgba(200, 220, 255, 0.9)
    );
    box-shadow:
        inset -3px -3px 12px rgba(0, 0, 0, 0.1),
        0 6px 16px rgba(255, 255, 255, 0.3),
        0 0 20px rgba(255, 255, 255, 0.2);
    position: relative;
    animation: snowmanGlow 3.5s ease-in-out infinite;
}

.snowman::before {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: radial-gradient(
        circle at 30% 30%,
        rgba(255, 255, 255, 0.3),
        transparent 60%
    );
    opacity: 0.6;
}

.snowman.m1 {
    transform: scale(1.1);
    animation-delay: 0s;
}

.snowman.m2 {
    transform: scale(0.9);
    animation-delay: 0.5s;
}

.snowman.m3 {
    transform: scale(1.05);
    animation-delay: 1s;
}

@keyframes snowmanFloat {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-6px); }
}

@keyframes snowmanGlow {
    0%, 100% {
        box-shadow:
            inset -3px -3px 12px rgba(0, 0, 0, 0.1),
            0 6px 16px rgba(255, 255, 255, 0.3),
            0 0 20px rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow:
            inset -3px -3px 12px rgba(0, 0, 0, 0.1),
            0 8px 24px rgba(255, 255, 255, 0.4),
            0 0 32px rgba(255, 255, 255, 0.3);
    }
}

.trees {
    position: absolute;
    bottom: 14px;
    right: 18px;
    display: flex;
    gap: 14px;
}

.tree {
    position: relative;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 24px solid #2d5016;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.tree::before {
    content: "";
    position: absolute;
    top: -10px;
    left: -6px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 18px solid #3d6b1f;
}

.tree::after {
    content: "";
    position: absolute;
    top: -18px;
    left: -4px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 12px solid #4d7b28;
    animation: treeGlow 2s ease-in-out infinite;
}

.tree.t2 {
    border-bottom-width: 18px;
    border-left-width: 6px;
    border-right-width: 6px;
}

.tree.t2::before {
    border-bottom-width: 14px;
    border-left-width: 5px;
    border-right-width: 5px;
    left: -5px;
}

.tree.t2::after {
    border-bottom-width: 10px;
    border-left-width: 3px;
    border-right-width: 3px;
    left: -3px;
    top: -14px;
}

@keyframes flame { 
    0%, 100% { transform: translateX(-50%) translateY(0) scale(1); } 
    50% { transform: translateX(-50%) translateY(-3px) scale(1.15); } 
}

@keyframes flicker { 
    0%, 100% { opacity: 1; } 
    50% { opacity: 0.85; } 
}

@keyframes glowFlicker {
    0%, 100% {
        opacity: 0.7;
        transform: translateX(-50%) scaleX(1);
    }
    50% {
        opacity: 0.5;
        transform: translateX(-50%) scaleX(1.15);
    }
}

@keyframes treeGlow {
    0%, 100% {
        filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.8));
    }
}

.snowfall {
    position: absolute;
    left: -30%;
    right: -30%;
    height: 100%;
    top: 0;
    background: radial-gradient(
        ellipse 10% 20% at 20% 10%,
        rgba(255,255,255,0.8),
        transparent 70%
    ), radial-gradient(
        ellipse 8% 15% at 80% 20%,
        rgba(255,255,255,0.6),
        transparent 70%
    ), radial-gradient(
        ellipse 12% 25% at 50% 30%,
        rgba(255,255,255,0.7),
        transparent 70%
    );
    filter: blur(1px);
    opacity: 0.3;
    will-change: transform, opacity;
}

.snowfall.f1 {
    animation: snowfallDrift1 20s linear infinite;
}

.snowfall.f2 {
    opacity: 0.2;
    animation: snowfallDrift2 28s linear infinite;
}

@keyframes snowfallDrift1 {
    0% { transform: translateX(-20%) translateY(-10%); }
    100% { transform: translateX(20%) translateY(10%); }
}

@keyframes snowfallDrift2 {
    0% { transform: translateX(15%) translateY(-5%); }
    100% { transform: translateX(-15%) translateY(5%); }
}

.greeting-icon img[src$=".svg"] {
    width: clamp(80px, calc(var(--modal-size) * .24), 140px);
    height: clamp(80px, calc(var(--modal-size) * .24), 140px);
    image-rendering: auto;
}

.greeting-icon img[src$=".gif"] {
    image-rendering: auto;
}

.greeting-icon img[src$=".webp"] {
    image-rendering: -webkit-optimize-contrast;
}

.greeting-icon img[data-loading="true"] {
    opacity: 0.6;
    background: linear-gradient(
        90deg, 
        color-mix(in srgb, var(--card) 80%, var(--span) 5%), 
        color-mix(in srgb, var(--card) 90%, var(--span) 10%), 
        color-mix(in srgb, var(--card) 80%, var(--span) 5%)
    );
    background-size: 200% 100%;
    animation: imageLoading 1.8s ease-in-out infinite;
}

@keyframes imageLoading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.greeting-icon img[data-error="true"] {
    background: var(--card);
    border: 2px dashed color-mix(in srgb, var(--text-secondary) 40%, transparent);
    border-radius: var(--br-8, 8px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.greeting-icon img[data-error="true"]::after {
    content: "📷";
    font-size: 28px;
    filter: grayscale(1) opacity(0.5);
}

@media (max-width: 768px) {
    .greeting-modal {
        --modal-size: min(92vw, 92vh, 480px);
    }
    
    .greeting-text {
        padding: clamp(14px, calc(var(--modal-size) * .04), 20px);
    }
    
    .tg-button {
        padding: 10px 18px;
        font-size: clamp(12px, calc(var(--modal-size) * .03), 14px);
    }
    
    .winter-decor {
        opacity: 0.5;
    }
}

@media (max-width: 480px) {
    .greeting-modal {
        --modal-size: min(95vw, 95vh, 420px);
        padding: clamp(14px, calc(var(--modal-size) * .045), 20px);
    }
    
    .greeting-content {
        gap: clamp(10px, calc(var(--modal-size) * .03), 14px);
    }
    
    .greeting-icon img {
        width: clamp(70px, calc(var(--modal-size) * .2), 100px);
        height: clamp(70px, calc(var(--modal-size) * .2), 100px);
    }
    
    .greeting-title {
        font-size: clamp(18px, calc(var(--modal-size) * .058), 24px);
    }
    
    .greeting-subtitle {
        font-size: clamp(12px, calc(var(--modal-size) * .034), 15px);
    }
    
    .tg-button {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .greeting-close {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
    
    .winter-decor {
        opacity: 0.3;
    }
    
    .snowflake, .snowman, .tree {
        animation: none !important;
    }
    
    .snowman-row, .trees {
        display: none;
    }
}

@media (max-width: 360px) {
    .greeting-modal {
        --modal-size: min(98vw, 98vh, 360px);
    }
    
    .greeting-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .tg-button {
        width: 100%;
    }
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .greeting-icon img {
        image-rendering: -webkit-optimize-contrast;
    }
}

@media (prefers-reduced-motion: reduce) {
    .greeting-modal,
    .greeting-overlay,
    .greeting-close,
    .tg-button,
    .greeting-text,
    .greeting-icon img {
        transition: none !important;
        animation: none !important;
    }
    
    .winter-decor,
    .snowflake,
    .snowman,
    .tree,
    .snowfall {
        animation: none !important;
    }
    
    .greeting-overlay.is-open .greeting-modal {
        animation: none !important;
    }
}

@media (prefers-color-scheme: dark) {
    .greeting-overlay {
        background: color-mix(in srgb, var(--bg-modal) 95%, black 5%);
    }
}

.greeting-close:focus-visible {
    outline: 2px solid var(--span);
    outline-offset: 2px;
}

.tg-button:focus-visible {
    outline: 2px solid var(--span);
    outline-offset: 3px;
}

@media (prefers-contrast: high) {
    .greeting-modal {
        border-width: 2px;
    }
    
    .greeting-text {
        border-width: 2px;
    }
    
    .tg-button {
        border: 2px solid var(--span);
    }
}

@media print {
    .greeting-overlay {
        display: none !important;
    }
}