/* Общие стили */
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #06080b;
    font-family: 'EB Garamond', serif;
    color: #e0d5c1;
}

/* Эффект звезд/искр */
#stars {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    background: radial-gradient(circle at 50% 50%, rgba(20,25,35,0.4) 0%, rgba(6,8,11,1) 100%);
    z-index: 1;
}

/* Экраны */
.screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease-in-out;
    z-index: 2;
}
.screen.active {
    opacity: 1;
    pointer-events: auto;
}

/* Первый экран */
.welcome-content {
    text-align: center;
    padding: 20px;
}
.magic-title {
    font-family: 'Cinzel', serif;
    font-size: 3.5rem;
    color: #c5a880;
    margin-bottom: 10px;
    letter-spacing: 4px;
    text-shadow: 0 0 20px rgba(197, 168, 128, 0.4);
    animation: pulseTitle 3s infinite ease-in-out;
}
.magic-subtitle {
    font-size: 1.5rem;
    color: #8c9bb0;
    margin-bottom: 40px;
    font-style: italic;
}
.magic-btn {
    font-family: 'Cinzel', serif;
    background: transparent;
    border: 1px solid #c5a880;
    color: #c5a880;
    padding: 15px 40px;
    font-size: 1.2rem;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.4s ease;
    box-shadow: 0 0 15px rgba(197, 168, 128, 0.1);
}
.magic-btn:hover {
    background: #c5a880;
    color: #06080b;
    box-shadow: 0 0 25px rgba(197, 168, 128, 0.5);
    transform: translateY(-2px);
}

/* Кнопка звука */
.mute-btn {
    position: fixed;
    top: 20px; right: 20px;
    background: rgba(20, 24, 32, 0.6);
    border: 1px solid #c5a880;
    color: #c5a880;
    font-size: 1.5rem;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s;
}
.mute-btn:hover { background: rgba(197, 168, 128, 0.2); }

/* Конверт и анимация */
.envelope-wrapper {
    position: relative;
    width: 450px;
    height: 300px;
}
.envelope {
    position: relative;
    width: 100%;
    height: 100%;
    background: #2b1f1d;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    border-radius: 4px;
    transition: transform 0.5s ease;
}
.envelope .flap {
    position: absolute;
    top: 0; left: 0; width: 0; height: 0;
    border-left: 225px solid transparent;
    border-right: 225px solid transparent;
    border-top: 160px solid #362825;
    transform-origin: top;
    transition: transform 0.6s ease 0.4s;
    z-index: 5;
}
.envelope .pocket {
    position: absolute;
    bottom: 0; left: 0; width: 0; height: 0;
    border-left: 225px solid #231917;
    border-right: 225px solid #231917;
    border-bottom: 150px solid #201715;
    z-index: 4;
}
.wax-seal {
    position: absolute;
    top: 130px; left: 200px;
    width: 50px; height: 50px;
    background: #8b0000;
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5), inset 0 0 10px rgba(0,0,0,0.4);
    z-index: 6;
    cursor: pointer;
    transition: transform 0.5s, opacity 0.4s ease 0.2s;
}
.wax-seal::after {
    content: 'H';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Cinzel', serif;
    color: #4a0000;
    font-weight: bold;
    font-size: 1.4rem;
}

/* Открытое состояние конверта */
.envelope.open .flap {
    transform: rotateX(180deg);
    z-index: 3;
}
.envelope.open .wax-seal {
    transform: scale(0);
    opacity: 0;
}

/* Пергамент и его анимация */
.letter {
    position: absolute;
    top: 10px; left: 15px;
    width: 420px; height: 280px;
    z-index: 3;
    transition: transform 0.8s ease 1s, height 0.8s ease 1.8s;
}
.envelope.open .letter {
    transform: translateY(-200px);
    height: 550px;
    z-index: 7;
}
.parchment {
    width: 100%; height: 100%;
    background: #f4edd4;
    background-image: radial-gradient(rgba(0,0,0,0.03) 1px, transparent 0);
    background-size: 24px 24px;
    box-sizing: border-box;
    padding: 40px;
    color: #2b1f1d;
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
    overflow-y: auto;
    border: 2px solid #dfd3b3;
    outline: 10px solid #f4edd4;
}

/* Текст письма */
.hogwarts-crest {
    width: 70px; height: 70px;
    margin: 0 auto 20px auto;
    background: url('https://img.icons8.com/ios-filled/100/731111/castle.png') no-repeat center/contain;
    opacity: 0.8;
}
.letter-text {
    font-size: 1.15rem;
    line-height: 1.6;
    text-align: justify;
    opacity: 0;
    transition: opacity 1s ease 2.5s;
}
.letter-text p { margin: 12px 0; }
.letter-text .heading {
    font-family: 'Cinzel', serif;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
    color: #731111;
}
.meta-info {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px dashed rgba(43,31,29,0.3);
    font-size: 1rem;
    color: #55413c;
}

@keyframes pulseTitle {
    0%, 100% { opacity: 0.9; text-shadow: 0 0 20px rgba(197,168,128,0.4); }
    50% { opacity: 1; text-shadow: 0 0 35px rgba(197,168,128,0.7); }
}

/* Мобильная адаптивность */
@media(max-width: 500px) {
    .magic-title { font-size: 2.2rem; }
    .envelope-wrapper { width: 320px; height: 220px; }
    .envelope .flap { border-left-width: 160px; border-right-width: 160px; border-top-width: 120px; }
    .envelope .pocket { border-left-width: 160px; border-right-width: 160px; border-bottom-width: 110px; }
    .wax-seal { top: 90px; left: 135px; }
    .letter { width: 290px; height: 200px; left: 15px; }
    .envelope.open .letter { transform: translateY(-160px); height: 420px; }
    .parchment { padding: 20px; }
}
