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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Arial', sans-serif;
    background: url('back.png') center/cover no-repeat fixed;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 20px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.15);
    pointer-events: none;
    z-index: 0;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    /* Используем высоту body, чтобы центрирование корректно работало в мобильных браузерах */
    height: 100%;
    width: 100%;
    position: relative;
    z-index: 1;
}

.envelope {
    position: relative;
    width: 450px;
    height: 300px;
    max-width: 90vw;
    max-height: 60vh;
    cursor: pointer;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}

.envelope:hover:not(.opened) {
    transform: scale(1.05);
}

.envelope-front {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #64B5F6 0%, #42A5F5 100%);
    border-radius: 12px;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 12px 40px rgba(66, 165, 245, 0.5);
    backface-visibility: hidden;
}

.envelope-front::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: rgba(255, 255, 255, 0.2);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    border-radius: 12px 12px 0 0;
    z-index: 3;
}

@media (max-width: 768px) {
    .envelope {
        width: 100%;
        height: auto;
        aspect-ratio: 3 / 2;
    }
}

.envelope.opened {
    transform: rotateY(180deg);
}

.envelope-back {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #90CAF9 0%, #BBDEFB 100%);
    border-radius: 12px;
    z-index: 1;
    box-shadow: 0 12px 40px rgba(66, 165, 245, 0.5);
    transform: rotateY(180deg);
    backface-visibility: hidden;
}

.heart {
    font-size: 80px;
    z-index: 4;
    position: relative;
    animation: heartbeat 1.5s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

@media (max-width: 768px) {
    .heart {
        font-size: 60px;
    }
}

@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.letter {
    position: absolute;
    width: calc(100% - 30px);
    height: calc(100% - 20px);
    background: transparent;
    border-radius: 12px;
    z-index: 3;
    top: 10px;
    left: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: rotateY(180deg);
    backface-visibility: hidden;
}

.letter-content {
    text-align: center;
    padding: 24px;
    width: 100%;
}

.letter-content h2 {
    color: #1E88E5;
    font-size: 22px;
    margin: 0 0 24px 0;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.8);
}

@media (max-width: 768px) {
    .letter-content {
        padding: 16px;
    }
    
    .letter-content h2 {
        font-size: 18px;
        margin-bottom: 20px;
    }
}

.buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 28px;
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.3px;
    min-width: 120px;
}

.btn-yes {
    background: linear-gradient(135deg, #c2185b 0%, #e91e63 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(194, 24, 91, 0.4);
}

.btn-yes:hover {
    background: linear-gradient(135deg, #ad1457 0%, #c2185b 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(194, 24, 91, 0.5);
}

.btn-no {
    background: #ffffff;
    color: #666;
    border: 2px solid #e0e0e0;
    transition: all 0.1s ease;
    position: relative;
}

.btn-no:hover {
    background: #f5f5f5;
    border-color: #bdbdbd;
}

@media (max-width: 768px) {
    .buttons {
        gap: 10px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
        min-width: 100px;
    }
}

/* Попап */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    padding: 20px;
}

.popup-overlay.show {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.popup-content {
    position: relative;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Карточки */
.cards-container {
    position: relative;
    width: 320px;
    height: 380px;
    max-width: 85vw;
    max-height: 50vh;
    perspective: 1000px;
}

.card {
    position: absolute;
    width: 100%;
    height: 100%;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card-content {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #ffffff;
    border-radius: 20px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.card-number {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #c2185b;
    font-size: 14px;
    font-weight: 600;
    opacity: 0.6;
}

.card-text {
    color: #333333;
    font-size: 26px;
    line-height: 1.6;
    text-align: center;
}

@media (max-width: 768px) {
    .cards-container {
        width: 90vw;
        height: 50vh;
        max-height: 450px;
    }
    
    .card-content {
        padding: 24px 20px;
    }
    
    .card-text {
        font-size: 24px;
        line-height: 1.5;
    }
}

.popup-paper {
    background: #ffffff;
    padding: 48px;
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
    max-width: 640px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.popup-paper::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.popup-paper h3 {
    color: #c2185b;
    font-size: 26px;
    margin: 0 0 32px 0;
    text-align: center;
    font-weight: 600;
    letter-spacing: 1px;
}

@media (max-width: 768px) {
    .popup-paper {
        padding: 32px 24px;
        border-radius: 16px;
    }
    
    .popup-paper h3 {
        font-size: 22px;
        margin-bottom: 24px;
    }
    
    .paper-content {
        font-size: 15px;
    }
}

.paper-content {
    color: #333333;
    font-size: 16px;
    line-height: 1.7;
}

.paper-content p {
    margin: 0 0 18px 0;
}

.paper-content p:last-child {
    margin-bottom: 0;
}

.jumping-cat {
    width: 200px;
    height: auto;
    margin: 0 auto 24px;
    display: block;
    animation: bounceCat 0.6s ease infinite;
}

@keyframes bounceCat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1001;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ff6b9d;
    position: absolute;
    animation: confettiFall linear forwards;
}

.confetti:nth-child(2n) {
    background: #42A5F5;
    width: 8px;
    height: 8px;
}

.confetti:nth-child(3n) {
    background: #ffd700;
    width: 12px;
    height: 12px;
}

.confetti:nth-child(4n) {
    background: #ff1493;
    width: 9px;
    height: 9px;
}

.confetti:nth-child(5n) {
    background: #00ff00;
    width: 7px;
    height: 7px;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(150vh) rotate(720deg);
        opacity: 0;
    }
}

@media (max-width: 768px) {
    .jumping-cat {
        width: 150px;
        margin-bottom: 20px;
    }
}
