.modal-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 1000;
    overflow-y: auto;
    padding: 30% 30%;
    box-sizing: border-box;
}

.modal-menu.active {
    display: block;
}

/* Закрытие меню */
.modal-menu .close-menu {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 50px;
    cursor: pointer;
    color: #DFC070;
    z-index: 1001;
}

/* Общие стили для меню */
.modal-menu ul {
    list-style: none;
    padding: 0;
    margin: -5px;
}

.modal-menu li {
    position: relative;
}

/* Главные пункты меню (уровень 0) */
.modal-menu > ul > li {
    margin-bottom: 20px;
}

/* Десктопная версия (3 колонки) */
@media (min-width: 992px) {
    .modal-menu {
        padding: 15% 10%;
    }

    .modal-menu > ul {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 30px;
        max-width: 1200px;
        margin: 0 auto;
        align-items: flex-start;
    }

    /* Стили для разных уровней меню */
    .top-level-item {
        background: linear-gradient(180deg, #DFC070 0%, #D5B460 100%);
        box-shadow: 0px 6px 9px rgba(0, 0, 0, 0.25),
                   inset 0px 5px 11.7px rgba(255, 255, 255, 0.25);
        border-radius: 20px;
        padding: 5px;
        text-align: center;
        min-height: 70px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }

    .top-level-item:hover {
        transform: translateY(-5px);
        background: linear-gradient(180deg, #ffe7a9 0%, #e9c76f 100%);
        box-shadow: 0px 6px 9px rgba(0, 0, 0, 0.25), inset 0px 5px 11.7px rgba(255, 255, 255, 0.25);
    }
    .top-level-item:active {
        background: linear-gradient(180deg, #dfc070 0%, #d5b460 100%);
        box-shadow: inset 0px 5px 4.4px rgba(31, 31, 31, 0.25);
    }

    .first-level-child {
        margin: 25px 0;
    }

    .nested-level-2,
    .nested-level-3 {
        margin: 23px 0;
    }

    /* Стили для ссылок разных уровней */
    .main-menu-link {
        color: #FFFFFF;
        font-size: 20px;
        font-weight: 500;
        text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
        padding: 12px 20px;
        text-decoration: none;
    }

    .submenu-level-1 {
        padding: 10px 15px;
        font-family: 'Montserrat Alternates';
        font-style: normal;
        font-weight: 400;
        font-size: 20px;
        line-height: 29px;
        color: #D6B663;
        text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
        text-decoration: none;
    }

    .submenu-level-2 {
        padding: 8px 15px;
        font-family: 'Montserrat Alternates';
        font-style: normal;
        font-weight: 400;
        font-size: 18px;
        line-height: 29px;
        color: #5B2812;
        text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
        text-decoration: none;
    }

    .submenu-level-3 {
        color: #666;
        font-size: 14px;
        padding: 6px 15px;
        text-decoration: none;
    }

    /* Стрелки для пунктов с подменю */
    .has-children > a {
        position: relative;
        padding-right: 40px !important;
    }

    .has-children .toggle-submenu {
        position: absolute;
        right: 15px;
        top: 15px;
        transform: translateY(-50%);
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10;
    }

    .has-children.top-level-item .toggle-submenu {
        position: absolute;
        right: 15px;
        top: 30px;
        transform: translateY(-50%);
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10;
    }


    .has-children .toggle-submenu:after {
        content: "▼";
        color: #A1A1A1;
        font-size: 14px;
        margin-right: 10%;
        transition: transform 0.3s;
    }

    .has-children .toggle-submenu.active:after {
        transform: rotate(180deg);
    }

    /* Подменю (все уровни) */
    .children {
        display: none;
        padding: 15px;
        margin-top: 10px;
        position: relative;
        z-index: 2;
    }

    .children.active {
        display: block;
    }

    /* Подложка для подменю */
    .children:before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: -10px;
        bottom: 0;
        background: white;
        border-radius: 0 0 20px 20px;
        z-index: -1;
    }

    /* Подменю второго уровня */
    .first-level-child > .children {
        border-radius: 0 0 10px 10px;
        margin-top: 5px;
    }

    .first-level-child > .children:before {
        border-radius: 0 0 10px 10px;
        left: 5px;
        right: -10px;
    }

    /* Подменю третьего уровня */
    .nested-level-2 > .children,
    .nested-level-3 > .children {
        border-radius: 0 0 8px 8px;
        margin-top: 3px;
    }

    .nested-level-2 > .children:before,
    .nested-level-3 > .children:before {
        border-radius: 0 0 8px 8px;
        left: 10px;
        right: -8px;
    }

    /* Гарантия видимости подменю */
    .children {
        max-height: 70vh;
        width: 100%;
    }
}

/* Мобильная версия */
@media (max-width: 991px) {
    .modal-menu {
        padding: 25% 15%;
    }

    .modal-menu > ul {
        max-width: 600px;
        margin: 0 auto;
        list-style: none;
        padding: 0;
        margin-left: -12px;
        margin-right: -12px;
    }

    /* Общие стили для всех уровней */
    .top-level-item,
    .first-level-child,
    .nested-level-2,
    .nested-level-3 {
        background: linear-gradient(180deg, #DFC070 0%, #D5B460 100%);
        border-radius: 15px;
        margin-top: 15px;
        padding: 12px;
    }

    /* Стили для ссылок */
    .main-menu-link,
    .submenu-level-1,
    .submenu-level-2,
    .submenu-level-3 {
        color: white;
        font-size: 16px;
        padding: 10px 15px;
        position: relative;
        text-decoration: none;
    }

    /* Подменю всех уровней */
    .children {
        display: none;
        background: rgba(255,255,255,0.9);
        border-radius: 0 0 15px 15px;
        margin: 8px -12px -12px -12px;
        padding: 5px 15px 10px 25px;
    }

    .children.active {
        display: block;
        margin: 0 -15px -15px;
        background: rgba(255, 255, 255, 1);
    }

    /* Стрелки для пунктов с подменю */
    .has-children > a {
        padding-right: 40px !important;
    }

    .has-children .toggle-submenu {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        width: 24px;
        height: 24px;
        border-radius: 50%;
        display: flex !important;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 2;
    }

    .has-children.top-level-item .toggle-submenu {
        position: absolute;
        right: 15px;
        top: 25px;
        transform: translateY(-50%);
        width: 24px;
        height: 24px;
        border-radius: 50%;
        display: flex !important;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 2;
    }

    .has-children .toggle-submenu:after {
        content: "▼";
        color: #A1A1A1;
        font-size: 14px;
        transition: transform 0.3s;
    }

    .has-children .toggle-submenu.active:after {
        transform: rotate(180deg);
    }

    /* Стили для подменю в мобильной версии */
    .children .top-level-item,
    .children .first-level-child,
    .children .nested-level-2,
    .children .nested-level-3 {
        background: rgba(255,255,255,0.8);
        border-radius: 10px;
    }

    .children .main-menu-link,
    .children .submenu-link {
        color: #333;
    }

    .main-menu-link {
        font-family: 'Montserrat Alternates';
        font-size: 24px;
    }

    .submenu-link.submenu-level-1 {
        font-family: 'Montserrat Alternates';
        font-style: normal;
        font-weight: 400;
        font-size: 20px;
        line-height: 29px;
        color: #D6B663;
        text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
        margin: 20px;
    }

    .submenu-link.submenu-level-2 {
        font-family: 'Montserrat Alternates';
        font-style: normal;
        font-weight: 400;
        font-size: 18px;
        line-height: 29px;
        color: #5B2812;
        margin-left: 30px;
    }

    .submenu-link.submenu-level-3 {
        font-family: 'Montserrat Alternates';
        font-style: normal;
        font-weight: 400;
        font-size: 18px;
        line-height: 29px;
        color: #A1A1A1;
        margin-left: 40px;
    }
}

/* Дополнительные стили для активных пунктов */
.active-menu-item {
    font-weight: 700;
    position: relative;
}

.active-menu-item:after {
    content: "";
    position: absolute;
    bottom: 5px;
    left: 15px;
    right: 15px;
    height: 2px;
    background: currentColor;
}

/* Анимация открытия меню */
@keyframes menuFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-menu.active > ul > li {
    animation: menuFadeIn 0.3s ease forwards;
}

.modal-menu.active > ul > li:nth-child(1) { animation-delay: 0.1s; }
.modal-menu.active > ul > li:nth-child(2) { animation-delay: 0.2s; }
.modal-menu.active > ul > li:nth-child(3) { animation-delay: 0.3s; }