:root {
    --bg-gradient: linear-gradient(261.19deg, #3A704C 4.38%, #9BCBB3 95.11%);
    --btn-yellow: #FFFF00;
    --btn-shadow: #A3A310;
    --text-color: #5A5A02;
}

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

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-gradient);
    position: relative;
    isolation: isolate;
    font-family: 'Montserrat', sans-serif;
}

.app-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 5;
}

.telegram-cta {
    position: absolute;
    top: 20px;
    right: 20px;
    width: clamp(360px, 35vw, 550px);
    height: auto;
    min-width: 280px;
    min-height: 110px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    cursor: pointer;
    transition: all 0.3s ease;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.telegram-cta img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

@keyframes telegram-pulse {
    0% {
        filter: drop-shadow(0 0 20px rgba(0, 150, 255, 0.7)) 
                drop-shadow(0 0 40px rgba(0, 150, 255, 0.5))
                drop-shadow(0 0 60px rgba(0, 150, 255, 0.3));
    }
    50% {
        filter: drop-shadow(0 0 30px rgba(0, 150, 255, 0.9)) 
                drop-shadow(0 0 55px rgba(0, 150, 255, 0.7))
                drop-shadow(0 0 80px rgba(0, 150, 255, 0.5));
    }
    100% {
        filter: drop-shadow(0 0 20px rgba(0, 150, 255, 0.7)) 
                drop-shadow(0 0 40px rgba(0, 150, 255, 0.5))
                drop-shadow(0 0 60px rgba(0, 150, 255, 0.3));
    }
}

.telegram-cta:hover {
    transform: scale(1.08);
    animation: telegram-pulse 1.5s ease-in-out infinite;
}

/* --- Decor --- */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: var(--bg-gradient);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("assets/extracted/image0_1_35.png");
    background-size: cover;
    background-position: center;
    mix-blend-mode: soft-light;
    opacity: 0.45;
    pointer-events: none;
    z-index: 1;
}

/* Финальные позиции свечей - адаптивное позиционирование */
.decor-candles-top {
    position: fixed;
    width: 40%;
    height: auto;
    right: 0;
    top: 0;
    opacity: 0.8;
    transform: scaleX(1);
    z-index: 2;
    pointer-events: none;
    filter: brightness(1.1) contrast(1.2);
}

.decor-candles-bottom {
    position: fixed;
    width: 50%;
    height: auto;
    left: 0;
    bottom: 0;
    opacity: 0.8;
    transform: scaleX(1);
    z-index: 2;
    pointer-events: none;
    filter: brightness(1.1) contrast(1.2);
}

/* --- Logo --- */
.logo-container {
    position: absolute;
    top: 5%;
    left: 5%;
    width: 15vw;
    min-width: 150px;
    max-width: 300px;
    z-index: 10;
}

.logo-img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* --- Illustration (Laptop) --- */
.illustration-container {
    position: absolute;
    bottom: -2vh;
    /* Небольшой сдвиг вниз, чтобы убрать зазор */
    right: 1vw;
    width: 34vw;
    /* ближе к краю, но без выхода за границы */
    min-width: 320px;
    max-width: 680px;
    z-index: 10;
}

.laptop-img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* --- Controls (Button) --- */
.controls-container {
    position: absolute;
    bottom: 10%;
    left: 10%;
    z-index: 20;
}

.generation-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 30vw;
    min-width: 280px;
    max-width: 450px;
    height: clamp(60px, 8vh, 100px);
    /* Адаптивная высота */
    transition: transform 0.1s;
}

.generation-btn:hover .btn-content {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    box-shadow: 0 10px 0 var(--btn-shadow),
        inset 0 2px 10px rgba(255, 255, 255, 0.5),
        0 0 30px rgba(255, 215, 0, 0.6),
        0 0 60px rgba(255, 165, 0, 0.4),
        0 0 100px rgba(255, 215, 0, 0.2);
    filter: brightness(1.15);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 10px 0 var(--btn-shadow),
            inset 0 2px 10px rgba(255, 255, 255, 0.5),
            0 0 30px rgba(255, 215, 0, 0.6),
            0 0 60px rgba(255, 165, 0, 0.4),
            0 0 100px rgba(255, 215, 0, 0.2);
    }

    50% {
        box-shadow: 0 10px 0 var(--btn-shadow),
            inset 0 2px 10px rgba(255, 255, 255, 0.7),
            0 0 40px rgba(255, 215, 0, 0.8),
            0 0 80px rgba(255, 165, 0, 0.6),
            0 0 120px rgba(255, 215, 0, 0.3);
    }

    100% {
        box-shadow: 0 10px 0 var(--btn-shadow),
            inset 0 2px 10px rgba(255, 255, 255, 0.5),
            0 0 30px rgba(255, 215, 0, 0.6),
            0 0 60px rgba(255, 165, 0, 0.4),
            0 0 100px rgba(255, 215, 0, 0.2);
    }
}

.generation-btn:active {
    transform: scale(0.98);
}

.btn-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--btn-yellow);
    border-radius: 20px;
    box-shadow: 0 10px 0 var(--btn-shadow),
        inset 0 2px 10px rgba(255, 255, 255, 0.5);

    display: flex;
    align-items: center;
    justify-content: center;

    color: var(--text-color);
    font-family: 'Montserrat', sans-serif;
    font-weight: 800;
    font-size: clamp(20px, 2.5vw, 40px);
    /* Адаптивный шрифт */
    letter-spacing: 2px;
}

.btn-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 110%;
    height: 110%;
    background: radial-gradient(circle, rgba(255, 255, 0, 0.6) 0%, rgba(255, 255, 0, 0) 70%);
    filter: blur(20px);
    z-index: -1;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }

    100% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Utility: Ensure things are actually hidden */
.hidden {
    display: none !important;
}

/* --- Result Container (Center) --- */
.result-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 50;
    pointer-events: none;
    /* Чтобы клики проходили сквозь, когда скрыт */
}

.result-container.visible {
    pointer-events: auto;
}

.result-content {
    text-align: center;
}

/* Скрываем текст Analyzing, когда есть результат */
.loader.hidden {
    display: none;
}

.final-result {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.flag-display {
    width: clamp(400px, 45vw, 600px);
    /* Адаптивный размер флага - очень большой */
    height: auto;
    border-radius: 15px;
    margin-bottom: clamp(10px, 2vh, 20px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    display: block;
    margin-left: auto;
    margin-right: auto;
    border: 4px solid rgba(255, 255, 255, 0.1);
}

.country-name {
    color: #FFF;
    font-size: clamp(28px, 4vw, 48px);
    /* Адаптивный шрифт */
    font-weight: 800;
    text-transform: uppercase;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    margin-bottom: clamp(10px, 2vh, 20px);
}

.close-result-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: clamp(8px, 1.2vh, 10px) clamp(20px, 3vw, 30px);
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: clamp(14px, 1.5vw, 18px);
    transition: all 0.2s;
    backdrop-filter: blur(5px);
}

.close-result-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* Loader style adjustment */
.loader p {
    color: rgba(255, 255, 255, 0.8);
    font-size: clamp(14px, 2vw, 18px);
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Удаляем стили модалки, если они больше не нужны, или оставляем скрытыми */
.modal {
    display: none;
}

.spinner {
    width: clamp(30px, 4vw, 40px);
    height: clamp(30px, 4vw, 40px);
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--btn-yellow);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* --- Large Desktop (1920px+) --- */
@media (min-width: 1920px) {
    .decor-candles-top {
        width: 35%;
        opacity: 0.85;
    }

    .decor-candles-bottom {
        width: 45%;
        opacity: 0.85;
    }

    .logo-container {
        width: 12vw;
        max-width: 350px;
    }

    .illustration-container {
        width: 30vw;
        max-width: 750px;
    }

    .generation-btn {
        width: 28vw;
        max-width: 500px;
    }
}

/* --- Desktop (1440px - 1919px) --- */
@media (min-width: 1440px) and (max-width: 1919px) {
    .decor-candles-top {
        width: 38%;
    }

    .decor-candles-bottom {
        width: 48%;
    }
}

/* --- Tablet Responsive --- */
@media (max-width: 1024px) and (min-width: 769px) {

    /* Свечи адаптивно для планшетов */
    .decor-candles-top {
        position: fixed;
        width: 35%;
        height: auto;
        left: auto;
        right: 0;
        top: 0;
        opacity: 0.6;
        transform: scaleX(1);
    }

    .decor-candles-bottom {
        position: fixed;
        width: 50%;
        height: auto;
        left: 0;
        top: auto;
        bottom: 0;
        opacity: 0.6;
        transform: scaleX(1);
    }

    .illustration-container {
        right: 3vw;
        width: 32vw;
        max-width: 600px;
    }

    .generation-btn {
        width: 50vw;
        max-width: 380px;
    }
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    /* На телефонах перестраиваем в вертикальную колонку */

    body::after {
        opacity: 0.3;
    }

    /* Лого по центру сверху */
    .logo-container {
        position: absolute;
        top: 20px;
        left: 50%;
        transform: translateX(-50%);
        width: 50vw;
        max-width: 200px;
        min-width: 150px;
    }

    .telegram-cta {
        position: fixed;
        top: 1rem;
        right: 1rem;
        width: clamp(360px, 60vw, 490px);
    }

    /* Контейнер приложения в колонку */
    .app-container {
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding: 100px 20px 30px;
    }

    /* Иллюстрация (ноутбук) по центру */
    .illustration-container {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        left: auto;
        margin: 5vh auto 4vh;
        width: 85vw;
        max-width: 450px;
        min-width: 280px;
    }

    /* Кнопка снизу по центру */
    .controls-container {
        position: relative;
        bottom: auto;
        left: auto;
        margin: 0 auto;
        display: flex;
        justify-content: center;
        width: 100%;
    }

    .generation-btn {
        width: 85vw;
        max-width: 400px;
        height: 65px;
        min-width: 280px;
    }

    .btn-content {
        border-radius: 15px;
        font-size: 20px;
    }

    /* Свечи для мобильных - адаптивное позиционирование */
    .decor-candles-top {
        position: fixed;
        width: 60vw;
        max-width: 350px;
        height: auto;
        left: auto;
        right: 0;
        top: 0;
        opacity: 0.4;
        transform: scaleX(1);
        filter: brightness(1.05) contrast(1.1);
    }

    .decor-candles-bottom {
        position: fixed;
        width: 75vw;
        max-width: 450px;
        height: auto;
        left: 0;
        top: auto;
        bottom: 0;
        opacity: 0.4;
        transform: scaleX(1);
        filter: brightness(1.05) contrast(1.1);
    }

    /* Модальные окна на мобильных */
    .result-overlay {
        padding: 20px;
    }

    .result-container {
        width: 90vw;
        max-width: none;
        padding: 25px;
        max-height: 80vh;
    }

    .result-container h2 {
        font-size: 22px;
    }

    .result-container p {
        font-size: 16px;
    }

    .close-result-btn {
        padding: 8px 24px;
        font-size: 14px;
    }
}

/* --- Mobile Landscape --- */
@media (max-width: 768px) and (orientation: landscape) {
    .logo-container {
        top: 10px;
        width: 20vw;
        max-width: 180px;
    }

    .app-container {
        padding: 60px 20px 20px;
    }

    .illustration-container {
        width: 40vw;
        max-width: 400px;
        margin: 2vh auto;
    }

    .generation-btn {
        width: 50vw;
        max-width: 350px;
        height: 55px;
    }

    .decor-candles-top {
        width: 40vw;
        opacity: 0.35;
    }

    .decor-candles-bottom {
        width: 50vw;
        opacity: 0.35;
    }
}

/* --- Small Mobile --- */
@media (max-width: 480px) {
    .logo-container {
        width: 55vw;
        top: 15px;
    }

    .telegram-cta {
        position: fixed;
        top: 0.75rem;
        right: 0.75rem;
        width: clamp(340px, 75vw, 450px);
    }

    .app-container {
        padding: 90px 15px 25px;
    }

    .illustration-container {
        width: 90vw;
        margin: 3vh auto 3vh;
    }

    .generation-btn {
        width: 90vw;
        height: 60px;
    }

    .btn-content {
        font-size: 18px;
    }

    .decor-candles-top {
        width: 70vw;
        right: 0;
        top: 0;
        opacity: 0.3;
    }

    .decor-candles-bottom {
        width: 85vw;
        left: 0;
        bottom: 0;
        opacity: 0.3;
    }

    .result-container {
        padding: 20px;
    }

    .result-container h2 {
        font-size: 20px;
    }

    .result-container p {
        font-size: 14px;
    }
}

/* --- Extra Small Mobile --- */
@media (max-width: 360px) {
    .logo-container {
        width: 60vw;
        top: 10px;
    }

    .telegram-cta {
        top: 0.5rem;
        right: 0.5rem;
        width: clamp(310px, 85vw, 400px);
    }

    .app-container {
        padding: 80px 10px 20px;
    }

    .illustration-container {
        width: 95vw;
        margin: 2vh auto;
    }

    .generation-btn {
        width: 95vw;
        height: 55px;
        min-width: 250px;
    }

    .btn-content {
        font-size: 16px;
    }

    .flag-display {
        width: 300px;
        /* Очень большой для маленьких экранов */
    }

    .country-name {
        font-size: 24px;
    }
}