/* ===== СТИЛИ МОДАЛЬНОГО ОКНА И АНИМИРОВАННОЙ КАРТОЧКИ ===== */

.achievement-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    will-change: opacity, visibility;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

html.dark-theme .achievement-modal-overlay,
body.dark-theme .achievement-modal-overlay {
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.achievement-modal-overlay.show {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
}

.achievement-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.achievement-modal-overlay.show .achievement-modal-content {
    opacity: 1;
}

.achievement-close-btn {
    position: absolute;
    top: -40px;
    right: -20px;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: #8B4FFF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100001;
    transition: color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.achievement-close-btn:hover {
    color: #9B5FFF;
}

.achievement-close-btn:active {
    color: #7B3FEE;
}

.achievement-close-btn svg {
    width: 24px;
    height: 24px;
    stroke-width: 3px;
}

.achievement-card-animated {
    position: relative;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    box-shadow: 
        0 8px 16px rgba(0, 0, 0, 0.15),
        0 16px 32px rgba(0, 0, 0, 0.2),
        0 32px 64px rgba(0, 0, 0, 0.25),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
    z-index: 10;
    opacity: 0;
}

.achievement-modal-overlay.show .achievement-card-animated {
    opacity: 1;
    animation: achievement-card-animation 5.6s 1;
}

html.dark-theme .achievement-card-animated,
body.dark-theme .achievement-card-animated {
    background-color: #2c2c2e;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

html.dark-theme .achievement-card-animated::after,
body.dark-theme .achievement-card-animated::after {
    background-image: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0),
        rgba(0, 0, 0, 0.6)
    ) !important;
    z-index: 2 !important;
}

html.dark-theme .achievement-card-inner::before,
body.dark-theme .achievement-card-inner::before {
    background-image: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0),
        rgba(255, 255, 255, 0.21),
        rgba(0, 0, 0, 0)
    ) !important;
}

.achievement-card-animated::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    background-image: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0),
        rgba(0, 0, 0, 0.6)
    );
    transform: translateX(200px) scale(1.5);
    filter: blur(10px);
    width: 200px;
    height: 100%;
    z-index: 2;
}

.achievement-modal-overlay.show .achievement-card-animated::after {
    animation: achievement-shadow 5.6s 1;
}

.achievement-card-inner::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100px;
    background-image: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0),
        rgba(255, 255, 255, 0.21),
        rgba(0, 0, 0, 0)
    );
    transform: translateX(-100px) scale(1.5) rotate(20deg);
    width: 80px;
    height: 100%;
    border-radius: 50%;
    z-index: 3;
}

.achievement-modal-overlay.show .achievement-card-inner::before {
    animation: achievement-light 5.6s 1;
}


.achievement-card-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    z-index: 2;
    background-color: rgba(141, 79, 255, 0.9);
    border-radius: 50%;
    overflow: hidden;
}

.achievement-card-inner.earned-achievement {
    background-color: rgba(141, 79, 255, 0.9);
}

.achievement-card-inner.locked-achievement {
    background-color: rgba(86, 76, 126, 0.45);
}

.achievement-modal-overlay.show .achievement-card-inner.earned-achievement {
    animation: earned-achievement-animation 5.6s 1;
}

.achievement-modal-overlay.show .achievement-card-inner.locked-achievement {
    animation: locked-achievement-animation 5.6s 1;
}

#modal-achievement-icon {
    width: 130px;
    height: 130px;
    object-fit: contain;
    filter: brightness(1.2) contrast(1.1) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.achievement-card-name {
    display: block;
    font-family: 'Soyuz Grotesk', 'BaseFont', 'SF Pro', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    text-align: center;
    margin-top: 20px;
    max-width: 220px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.achievement-modal-overlay.show .achievement-card-name {
    opacity: 1;
    animation: achievement-text-animation 5.6s 1;
}

html.dark-theme .achievement-card-name,
body.dark-theme .achievement-card-name {
    color: #ffffff !important;
}

html.app-force-light .achievement-card-name,
body.app-force-light .achievement-card-name {
    color: #ffffff !important;
}

html:not(.dark-theme) .achievement-card-name,
body:not(.dark-theme) .achievement-card-name {
    color: #ffffff !important;
}

/* ===== СТИЛИ ЗАГОЛОВКА ПОЗДРАВЛЕНИЯ ===== */
.achievement-congratulations {
    text-align: center;
    margin-bottom: 30px;
    opacity: 0;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    visibility: hidden;
}

.achievement-congratulations.show {
    opacity: 1;
    visibility: visible;
}

.achievement-congratulations h2 {
    font-family: 'Soyuz Grotesk', 'BaseFont', 'SF Pro', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 10px 0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.achievement-congratulations p {
    font-family: 'Soyuz Grotesk', 'BaseFont', 'SF Pro', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

/* ===== СПЕЦИАЛЬНЫЕ РАЗМЕРЫ ДЛЯ МОДАЛЬНОГО ОКНА ===== */
#modal-achievement-icon[src*="Beginner.png"],
#modal-achievement-icon[src*="Favorite-meditations.png"],
#modal-achievement-icon[src*="My-rhythm.png"] {
    width: 160px !important;
    height: 160px !important;
}

#modal-achievement-icon[src*="dbt-card.svg"] {
    width: 90px !important;
    height: 90px !important;
}

/* ===== ЭФФЕКТ SPARKLES ===== */
.plus-element {
    position: absolute;
    pointer-events: none;
    opacity: 1;
    animation: plus-fall var(--fall-duration, 5s) var(--fall-delay, 0s) linear forwards;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translate3d(0, 0, 0);
}

.plus-element.tiny {
    width: 6px;
    height: 6px;
    filter: drop-shadow(0 0 2px rgba(138, 43, 226, 0.5));
}

.plus-element.small {
    width: 10px;
    height: 10px;
    filter: drop-shadow(0 0 4px rgba(138, 43, 226, 0.6));
}

.plus-element.semi-medium {
    width: 13px;
    height: 13px;
    filter: drop-shadow(0 0 5px rgba(138, 43, 226, 0.65));
}

.plus-element.icon-mini {
    width: 17px;
    height: 17px;
    filter: drop-shadow(0 0 4px rgba(141, 79, 255, 0.8));
}

.plus-element.medium {
    width: 15px;
    height: 15px;
    filter: drop-shadow(0 0 6px rgba(138, 43, 226, 0.7));
}

.plus-element.large {
    width: 20px;
    height: 20px;
    filter: drop-shadow(0 0 8px rgba(138, 43, 226, 0.8));
}

.plus-element.orange {
    filter: hue-rotate(30deg) brightness(1.1) saturate(1.2);
}

.plus-element.twinkle-strong {
    animation: plus-fall var(--fall-duration, 5s) var(--fall-delay, 0s) linear forwards,
               sparkle-twinkle-strong 1s ease-in-out infinite;
}

.plus-element.twinkle-soft {
    animation: plus-fall var(--fall-duration, 5s) var(--fall-delay, 0s) linear forwards,
               sparkle-twinkle-soft 1s ease-in-out infinite;
}

/* ===== KEYFRAME АНИМАЦИИ ===== */

@keyframes achievement-card-animation {
    0% {
        transform: translateZ(0px);
    }
    25% {
        transform: translateX(-8px) rotateY(-15deg);
    }
    100% {
        transform: translateZ(0px);
    }
}

@keyframes achievement-text-animation {
    0% {
        transform: translateZ(0px);
    }
    25% {
        transform: translateX(-8px) rotateY(-15deg);
    }
    100% {
        transform: translateZ(0px);
    }
}

@keyframes achievement-light {
    25% {
        transform: translateX(350px) scale(1.5) rotate(25deg);
    }
    50% {
        transform: translateX(-100px) scale(1.5) rotate(25deg);
    }
}

@keyframes achievement-shadow {
    35% {
        transform: translateX(200px) scale(1.5);
    }
    /* 75% {
        transform: translateX(0px) scale(1.5);
    } */
}

@keyframes earned-achievement-animation {
    0% {
        background-color: rgba(120, 60, 200, 0.75);
    }
    10% {
        background-color: rgba(130, 70, 220, 0.8);
    }
    15%, 25% {
        background-color: rgba(140, 80, 240, 0.85);
    }
    35% {
        background-color: rgba(150, 90, 255, 0.9);
    }
    40% {
        background-color: rgba(160, 100, 255, 0.93);
    }
    50% {
        background-color: rgba(170, 110, 255, 0.95);
    }
    55%, 75% {
        background-color: rgba(160, 100, 255, 0.93);
    }
    85% {
        background-color: rgba(140, 80, 240, 0.85);
    }
    100% {
        background-color: rgba(120, 60, 200, 0.75);
    }
}

@keyframes locked-achievement-animation {
    0% {
        background-color: rgba(86, 76, 126, 0.45);
    }
    10% {
        background-color: rgba(90, 80, 130, 0.5);
    }
    15%, 25% {
        background-color: rgba(95, 85, 135, 0.52);
    }
    35% {
        background-color: rgba(100, 90, 140, 0.55);
    }
    40% {
        background-color: rgba(105, 95, 145, 0.58);
    }
    50% {
        background-color: rgba(110, 100, 150, 0.6);
    }
    55%, 75% {
        background-color: rgba(105, 95, 145, 0.58);
    }
    85% {
        background-color: rgba(95, 85, 135, 0.52);
    }
    100% {
        background-color: rgba(86, 76, 126, 0.45);
    }
}

html.dark-theme .achievement-card-inner.earned-achievement,
body.dark-theme .achievement-card-inner.earned-achievement {
    background-color: rgba(141, 79, 255, 0.53) !important;
}

html.dark-theme .achievement-card-inner.locked-achievement,
body.dark-theme .achievement-card-inner.locked-achievement {
    background-color: rgba(86, 76, 126, 0.6);
}

html.dark-theme .achievement-modal-overlay.show .achievement-card-inner.earned-achievement,
body.dark-theme .achievement-modal-overlay.show .achievement-card-inner.earned-achievement {
    animation: earned-achievement-dark-animation 5.6s 1;
}

html.dark-theme .achievement-modal-overlay.show .achievement-card-inner.locked-achievement,
body.dark-theme .achievement-modal-overlay.show .achievement-card-inner.locked-achievement {
    animation: locked-achievement-dark-animation 5.6s 1;
}

@keyframes earned-achievement-dark-animation {
    0% {
        background-color: rgba(141, 79, 255, 0.53);
    }
    10% {
        background-color: rgba(145, 85, 255, 0.58);
    }
    15%, 25% {
        background-color: rgba(150, 90, 255, 0.62);
    }
    35% {
        background-color: rgba(155, 95, 255, 0.65);
    }
    40% {
        background-color: rgba(160, 100, 255, 0.68);
    }
    50% {
        background-color: rgba(165, 105, 255, 0.7);
    }
    55%, 75% {
        background-color: rgba(160, 100, 255, 0.68);
    }
    85% {
        background-color: rgba(150, 90, 255, 0.62);
    }
    100% {
        background-color: rgba(141, 79, 255, 0.53);
    }
}

@keyframes locked-achievement-dark-animation {
    0% {
        background-color: rgba(86, 76, 126, 0.6);
    }
    10% {
        background-color: rgba(100, 90, 140, 0.65);
    }
    15%, 25% {
        background-color: rgba(110, 100, 150, 0.7);
    }
    35% {
        background-color: rgba(115, 105, 155, 0.72);
    }
    40% {
        background-color: rgba(120, 110, 160, 0.75);
    }
    50% {
        background-color: rgba(125, 115, 165, 0.77);
    }
    55%, 75% {
        background-color: rgba(120, 110, 160, 0.75);
    }
    85% {
        background-color: rgba(105, 95, 145, 0.68);
    }
    100% {
        background-color: rgba(86, 76, 126, 0.6);
    }
}

@keyframes plus-fall {
    0% {
        transform: translate3d(-50%, -50%, 0) scale3d(1, 1, 1);
        opacity: 1;
    }
    100% {
        transform: translate3d(
            calc(-50% + var(--final-x, 0px)),
            calc(-50% + var(--final-y, 0px)),
            0
        ) scale3d(0.3, 0.3, 1);
        opacity: 0;
    }
}

@keyframes sparkle-twinkle-strong {
    0% {
        opacity: 1;
    }
    30% {
        opacity: 1;
    }
    50% {
        opacity: 0.1;
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 1;
    }
}

@keyframes sparkle-twinkle-soft {
    0% {
        opacity: 1;
    }
    30% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 1;
    }
}

/* Адаптация для мобильных устройств */
@media (max-width: 480px) {
    .achievement-card-animated {
        width: 180px;
        height: 180px;
    }
    
    #modal-achievement-icon {
        width: 120px;
        height: 120px;
    }
    
    .achievement-close-btn {
        width: 35px;
        height: 35px;
        top: -140px;
        right: -75px;
    }
    
    .achievement-close-btn svg {
        width: 20px;
        height: 20px;
        stroke-width: 2.5px;
    }
    
    .achievement-congratulations h2 {
        font-size: 24px;
    }
    
    .achievement-congratulations p {
        font-size: 14px;
    }
}
