* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.hero {
    height: 100vh;
    background: 
        /* Звёзды разной яркости */
        radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.7), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 40% 70%, rgba(255,255,255,0.5), rgba(0,0,0,0)),
        radial-gradient(1px 1px at 60% 20%, rgba(255,255,255,0.6), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 80% 40%, rgba(255,255,255,0.4), rgba(0,0,0,0)),
        /* Тёмный космический фон */
        linear-gradient(
            135deg,
            #000000 0%,
            #0a0a12 25%,
            #111 50%,
            #0a0a12 75%,
            #000000 100%
        );
    background-size: 
        200px 200px,
        250px 250px,
        170px 170px,
        220px 220px,
        100% 100%;
    background-repeat: repeat, repeat, repeat, repeat, no-repeat;
    background-attachment: fixed; /* Фон остаётся на месте при прокрутке */
    position: relative;
    overflow-y: auto; /* Если контента много, появляется вертикальный скролл */
    animation: shimmer 60s linear infinite;
    transition: opacity 0.8s ease;
}

.hero.fade {
    opacity: 0;
}

.poet-image {
    position: absolute;
    bottom: 30%;
    left: 60%;
    width: auto;
    height: 45vh;
    filter: drop-shadow(0 0 20px rgba(255,255,255,0.1));
    
    /* Добавляем задержку появления после последнего пункта меню */
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 3.1s;
    
    /* Сделать кликабельной */
    cursor: pointer;
}

.poet-image:hover {
    /* Эффект при наведении */
    filter: drop-shadow(0 0 25px rgba(255,255,255,0.7));
    cursor: pointer;
}

/* Меню писем */
.books-menu {
    position: fixed;
    width: 100%;
    height: 100vh;
    pointer-events: none;
}

.books-menu ul {
    list-style: none;
    height: 100%;
    position: relative;
}

.books-menu li {
    position: absolute;
    transform-origin: center;
    opacity: 0;
    animation: fadeIn 0.8s ease forwards;
}

/* Позиционирование писем в виде ступенек:
   top = 3% + 2*(n-1)%
   left = n%
   Повороты повторяются по циклу каждые 10 элементов:
      1: -8deg, 2: 12deg, 3: -5deg, 4: 15deg, 5: -10deg,
      6: 8deg, 7: -12deg, 8: 10deg, 9: -7deg, 10: 9deg
*/

.books-menu li:nth-child(1)  { top: 3%;   left: 1%;   transform: rotate(-8deg); }
.books-menu li:nth-child(2)  { top: 5%;   left: 2%;   transform: rotate(12deg); }
.books-menu li:nth-child(3)  { top: 7%;   left: 3%;   transform: rotate(-5deg); }
.books-menu li:nth-child(4)  { top: 9%;   left: 4%;   transform: rotate(15deg); }
.books-menu li:nth-child(5)  { top: 11%;  left: 5%;   transform: rotate(-10deg); }
.books-menu li:nth-child(6)  { top: 13%;  left: 6%;   transform: rotate(8deg); }
.books-menu li:nth-child(7)  { top: 15%;  left: 7%;   transform: rotate(-12deg); }
.books-menu li:nth-child(8)  { top: 17%;  left: 8%;   transform: rotate(10deg); }
.books-menu li:nth-child(9)  { top: 19%;  left: 9%;   transform: rotate(-7deg); }
.books-menu li:nth-child(10) { top: 21%;  left: 10%;  transform: rotate(9deg); }

.books-menu li:nth-child(11) { top: 23%;  left: 11%;  transform: rotate(-8deg); }
.books-menu li:nth-child(12) { top: 25%;  left: 12%;  transform: rotate(12deg); }
.books-menu li:nth-child(13) { top: 27%;  left: 13%;  transform: rotate(-5deg); }
.books-menu li:nth-child(14) { top: 29%;  left: 14%;  transform: rotate(15deg); }
.books-menu li:nth-child(15) { top: 31%;  left: 15%;  transform: rotate(-10deg); }
.books-menu li:nth-child(16) { top: 33%;  left: 16%;  transform: rotate(8deg); }
.books-menu li:nth-child(17) { top: 35%;  left: 17%;  transform: rotate(-12deg); }
.books-menu li:nth-child(18) { top: 37%;  left: 18%;  transform: rotate(10deg); }
.books-menu li:nth-child(19) { top: 39%;  left: 19%;  transform: rotate(-7deg); }
.books-menu li:nth-child(20) { top: 41%;  left: 20%;  transform: rotate(9deg); }

.books-menu li:nth-child(21) { top: 43%;  left: 21%;  transform: rotate(-8deg); }
.books-menu li:nth-child(22) { top: 45%;  left: 22%;  transform: rotate(12deg); }
.books-menu li:nth-child(23) { top: 47%;  left: 23%;  transform: rotate(-5deg); }
.books-menu li:nth-child(24) { top: 49%;  left: 24%;  transform: rotate(15deg); }
.books-menu li:nth-child(25) { top: 51%;  left: 25%;  transform: rotate(-10deg); }
.books-menu li:nth-child(26) { top: 53%;  left: 26%;  transform: rotate(8deg); }
.books-menu li:nth-child(27) { top: 55%;  left: 27%;  transform: rotate(-12deg); }
.books-menu li:nth-child(28) { top: 57%;  left: 28%;  transform: rotate(10deg); }
.books-menu li:nth-child(29) { top: 59%;  left: 29%;  transform: rotate(-7deg); }
.books-menu li:nth-child(30) { top: 61%;  left: 30%;  transform: rotate(9deg); }

.books-menu li:nth-child(31) { top: 63%;  left: 31%;  transform: rotate(-8deg); }
.books-menu li:nth-child(32) { top: 65%;  left: 32%;  transform: rotate(12deg); }
.books-menu li:nth-child(33) { top: 67%;  left: 33%;  transform: rotate(-5deg); }
.books-menu li:nth-child(34) { top: 69%;  left: 34%;  transform: rotate(15deg); }
.books-menu li:nth-child(35) { top: 71%;  left: 35%;  transform: rotate(-10deg); }
.books-menu li:nth-child(36) { top: 73%;  left: 36%;  transform: rotate(8deg); }
.books-menu li:nth-child(37) { top: 75%;  left: 37%;  transform: rotate(-12deg); }
.books-menu li:nth-child(38) { top: 77%;  left: 38%;  transform: rotate(10deg); }
.books-menu li:nth-child(39) { top: 79%;  left: 39%;  transform: rotate(-7deg); }
.books-menu li:nth-child(40) { top: 81%;  left: 40%;  transform: rotate(9deg); }

.books-menu li:nth-child(41) { top: 83%;  left: 41%;  transform: rotate(-8deg); }
.books-menu li:nth-child(42) { top: 85%;  left: 42%;  transform: rotate(12deg); }
.books-menu li:nth-child(43) { top: 87%;  left: 43%;  transform: rotate(-5deg); }
.books-menu li:nth-child(44) { top: 89%;  left: 44%;  transform: rotate(15deg); }
.books-menu li:nth-child(45) { top: 91%;  left: 45%;  transform: rotate(-10deg); }
.books-menu li:nth-child(46) { top: 93%;  left: 46%;  transform: rotate(8deg); }
.books-menu li:nth-child(47) { top: 95%;  left: 47%;  transform: rotate(-12deg); }

/* Анимация появления */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Задержки анимации для каждого письма */
.books-menu li:nth-child(1)  { animation-delay: 0.1s; }
.books-menu li:nth-child(2)  { animation-delay: 0.2s; }
.books-menu li:nth-child(3)  { animation-delay: 0.3s; }
.books-menu li:nth-child(4)  { animation-delay: 0.4s; }
.books-menu li:nth-child(5)  { animation-delay: 0.5s; }
.books-menu li:nth-child(6)  { animation-delay: 0.6s; }
.books-menu li:nth-child(7)  { animation-delay: 0.7s; }
.books-menu li:nth-child(8)  { animation-delay: 0.8s; }
.books-menu li:nth-child(9)  { animation-delay: 0.9s; }
.books-menu li:nth-child(10) { animation-delay: 1.0s; }
.books-menu li:nth-child(11) { animation-delay: 1.1s; }
.books-menu li:nth-child(12) { animation-delay: 1.2s; }
.books-menu li:nth-child(13) { animation-delay: 1.3s; }
.books-menu li:nth-child(14) { animation-delay: 1.4s; }
.books-menu li:nth-child(15) { animation-delay: 1.5s; }
.books-menu li:nth-child(16) { animation-delay: 1.6s; }
.books-menu li:nth-child(17) { animation-delay: 1.7s; }
.books-menu li:nth-child(18) { animation-delay: 1.8s; }
.books-menu li:nth-child(19) { animation-delay: 1.9s; }
.books-menu li:nth-child(20) { animation-delay: 2.0s; }
.books-menu li:nth-child(21) { animation-delay: 2.1s; }
.books-menu li:nth-child(22) { animation-delay: 2.2s; }
.books-menu li:nth-child(23) { animation-delay: 2.3s; }
.books-menu li:nth-child(24) { animation-delay: 2.4s; }
.books-menu li:nth-child(25) { animation-delay: 2.5s; }
.books-menu li:nth-child(26) { animation-delay: 2.6s; }
.books-menu li:nth-child(27) { animation-delay: 2.7s; }
.books-menu li:nth-child(28) { animation-delay: 2.8s; }
.books-menu li:nth-child(29) { animation-delay: 2.9s; }
.books-menu li:nth-child(30) { animation-delay: 3.0s; }
.books-menu li:nth-child(31) { animation-delay: 3.1s; }
.books-menu li:nth-child(32) { animation-delay: 3.2s; }
.books-menu li:nth-child(33) { animation-delay: 3.3s; }
.books-menu li:nth-child(34) { animation-delay: 3.4s; }
.books-menu li:nth-child(35) { animation-delay: 3.5s; }
.books-menu li:nth-child(36) { animation-delay: 3.6s; }
.books-menu li:nth-child(37) { animation-delay: 3.7s; }
.books-menu li:nth-child(38) { animation-delay: 3.8s; }
.books-menu li:nth-child(39) { animation-delay: 3.9s; }
.books-menu li:nth-child(40) { animation-delay: 4.0s; }
.books-menu li:nth-child(41) { animation-delay: 4.1s; }
.books-menu li:nth-child(42) { animation-delay: 4.2s; }
.books-menu li:nth-child(43) { animation-delay: 4.3s; }
.books-menu li:nth-child(44) { animation-delay: 4.4s; }
.books-menu li:nth-child(45) { animation-delay: 4.5s; }
.books-menu li:nth-child(46) { animation-delay: 4.6s; }
.books-menu li:nth-child(47) { animation-delay: 4.7s; }

/* Стили для ссылок */
.books-menu a {
    pointer-events: auto;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.9rem;
    letter-spacing: 2px;
    padding: 0.5rem 1rem;
    position: relative;
    transition: all 0.5s ease;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

.books-menu a:hover {
    color: white;
    transform: scale(1.05);
    letter-spacing: 3px;
    text-shadow: 
        0 0 10px rgba(255, 255, 255, 0.6),
        0 0 20px rgba(255, 255, 255, 0.4),
        0 0 30px rgba(255, 255, 255, 0.2);
}

/* Анимация фона */
@keyframes shimmer {
    0% {
        background-position: 
            0 0,
            0 0,
            0 0,
            0 0,
            0 0;
    }
    100% {
        background-position: 
            200px 200px,
            250px 250px,
            170px 170px,
            220px 220px,
            0 0;
    }
}

/* Кнопка возврата на главную */
.back-home {
    position: fixed;
    top: 2rem;
    right: 2rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 1.2rem;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    transition: all 0.3s ease;
}

.back-home-books {
    right: 15rem;
}

.back-home:hover {
    color: white;
    border-color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Модальное окно для стихотворения */
.poem-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: 
        /* Звёзды разной яркости */
        radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.7), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 40% 70%, rgba(255,255,255,0.5), rgba(0,0,0,0)),
        radial-gradient(1px 1px at 60% 20%, rgba(255,255,255,0.6), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 80% 40%, rgba(255,255,255,0.4), rgba(0,0,0,0)),
        /* Тёмный космический фон */
        linear-gradient(
            135deg,
            #000000 0%,
            #0a0a12 25%,
            #111 50%,
            #0a0a12 75%,
            #000000 100%
        );
    background-size: 
        200px 200px,
        250px 250px,
        170px 170px,
        220px 220px,
        100% 100%;
    background-repeat: repeat, repeat, repeat, repeat, no-repeat;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.poem-modal.active {
    display: flex;
    animation: fadeIn 0.5s ease-out forwards, shimmer 60s linear infinite;
}

.poem-content {
    width: 90%; /* или 100% в зависимости от дизайна */
    max-height: 90vh; /* ограничение по высоте окна, чтобы на телефоне помещалось всё */
    overflow-y: auto; /* включаем вертикальную прокрутку */
    -webkit-overflow-scrolling: touch; /* плавная прокрутка в iOS */
    padding: 20px; /* можно настроить отступы по необходимости */
    box-sizing: border-box;
    color: #fff;
    text-align: left;
    position: relative;
    margin: 0 auto;
    padding-right: 10px;
    scrollbar-width: thin; /* для Firefox */
    scrollbar-color: rgba(0, 0, 0, 0.3) rgba(0, 0, 0, 0.1);
}

/* Кастомизация скроллбара для браузеров на базе WebKit (Chrome, Safari, Edge) */
.poem-content::-webkit-scrollbar {
    width: 8px;
}

.poem-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.poem-content::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.poem-title {
    font-size: 2rem;
    margin-bottom: 3rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: left;
    letter-spacing: 3px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 1s ease;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.poem-modal.active .poem-title {
    opacity: 1;
    transform: translateY(0);
}

.poem-text {
    font-size: 1.4rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 1);
    text-shadow: 
        0 0 15px rgba(255, 255, 255, 0.3),
        0 0 30px rgba(255, 255, 255, 0.2);
    text-align: left;
    margin-left: 40px;
}

.poem-text p {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.8s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Добавляем задержки для каждой строки */
.poem-text p:nth-child(1) { animation-delay: 0.1s; }
.poem-text p:nth-child(2) { animation-delay: 0.2s; }
.poem-text p:nth-child(3) { animation-delay: 0.3s; }
.poem-text p:nth-child(4) { animation-delay: 0.4s; }
.poem-text p:nth-child(5) { animation-delay: 0.5s; }
.poem-text p:nth-child(6) { animation-delay: 0.6s; }
.poem-text p:nth-child(7) { animation-delay: 0.7s; }
.poem-text p:nth-child(8) { animation-delay: 0.8s; }
.poem-text p:nth-child(9) { animation-delay: 0.9s; }
.poem-text p:nth-child(10) { animation-delay: 1.0s; }
.poem-text p:nth-child(11) { animation-delay: 1.1s; }
.poem-text p:nth-child(12) { animation-delay: 1.2s; }
.poem-text p:nth-child(13) { animation-delay: 1.3s; }
.poem-text p:nth-child(14) { animation-delay: 1.4s; }
.poem-text p:nth-child(15) { animation-delay: 1.5s; }
.poem-text p:nth-child(16) { animation-delay: 1.6s; }
.poem-text p:nth-child(17) { animation-delay: 1.7s; }
.poem-text p:nth-child(18) { animation-delay: 1.8s; }
.poem-text p:nth-child(19) { animation-delay: 1.9s; }
.poem-text p:nth-child(20) { animation-delay: 2.0s; }
.poem-text p:nth-child(21) { animation-delay: 2.1s; }
.poem-text p:nth-child(22) { animation-delay: 2.2s; }
.poem-text p:nth-child(23) { animation-delay: 2.3s; }
.poem-text p:nth-child(24) { animation-delay: 2.4s; }
.poem-text p:nth-child(25) { animation-delay: 2.5s; }

.close-poem {
    position: fixed;
    top: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.5s ease;
    background: transparent;
    font-size: 1.5rem;
}

.close-poem:hover {
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
    transform: rotate(90deg);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Эффект размытия для фона при открытом модальном окне */
.books-menu.blur {
    filter: blur(5px);
    transition: filter 0.5s ease;
}

/* Навигация в модальном окне */
.poem-navigation {
    display: flex;
    justify-content: center;
    gap: 4rem;
    margin-bottom: 2rem;
    padding: 0 2rem;
}

.nav-prev, .nav-next {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 2rem;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem;
}

.nav-prev:hover, .nav-next:hover {
    color: white;
    text-shadow: 
        0 0 10px rgba(255, 255, 255, 0.6),
        0 0 20px rgba(255, 255, 255, 0.4);
    transform: scale(1.2);
}

/* Стили для квантового оверлея, аналогичные тем, что используются на главной */
#flashOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 2000;
    transition: opacity 0.3s ease-in-out;
}

#flashOverlay.active {
    opacity: 1;
}

/* Респонсивные корректировки для узких экранов (например, iPhone 12 Pro) */
@media screen and (max-width: 420px) {
    /* Переделываем меню, чтобы пункты шли по потоку и не накладывались */
    .books-menu {
        position: relative;
        width: 100%;
        height: auto;
        pointer-events: auto;
        padding: 1rem;
    }
    .books-menu ul {
        list-style: none;
        margin: 0;
        padding: 0;
        /* Естественное вертикальное размещение элементов */
    }
    .books-menu li {
        position: static;   /* Отменяем абсолютное позиционирование */
        transform: none;    /* Убираем повороты/смещения */
        margin: 0.5rem 0;
        text-align: center;
        font-size: 1rem;    /* Можно регулировать размер шрифта */
    }
    .books-menu a {
        text-decoration: none;
        color: rgba(255,255,255,0.7);
    }
    
    /* Корректируем изображение двери так, чтобы оно отображалось после меню */
    .poet-image {
        position: relative;
        display: block;
        margin: 2rem auto;
        left: 0;
        bottom: auto;
        transform: none;
        height: 30vh;
        animation-delay: 1s; /* Перенастраиваем задержку, если потребуется */
        cursor: pointer;
    }
    .poet-image:hover {
        filter: drop-shadow(0 0 25px rgba(255,255,255,0.7)); /* Эффект при наведении сохраняется */
    }
} 