/* Ẩn tất cả các thẻ liên kết chứa văn bản quảng cáo của Somee */
a[href*="somee.com"] {
    display: none !important;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #ffe5ec, #ffc2d1);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Quicksand', sans-serif;
    overflow: hidden;
    position: relative;
    padding: 15px;
}

/* --- NỀN TRÁI TIM BAY --- */
.bg-hearts {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    top: 0; left: 0;
    z-index: 1;
    pointer-events: none;
}
.heart-particle {
    position: absolute;
    bottom: -10%;
    color: rgba(255, 75, 110, 0.25);
    animation: floatUp 8s linear infinite;
}
@keyframes floatUp {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}

/* --- KHỐI CHỨA PHONG BÌ & LÁ THƯ --- */
.envelope-wrapper {
    position: relative;
    width: 100%;
    max-width: 420px;
    height: 280px;
    background-color: #f08080; 
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    z-index: 2;
    cursor: pointer;
    transition: transform 0.5s ease, margin-top 0.5s ease, opacity 0.8s ease;
}

.envelope-wrapper::before {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 5;
    border-left: 210px solid #f49797;
    border-right: 210px solid #f49797;
    border-bottom: 140px solid #f49797;
    border-top: 140px solid transparent;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

/* Hỗ trợ responsive cho đường chéo phong bì */
@media (max-width: 480px) {
    .envelope-wrapper::before {
        border-left-width: 45vw;
        border-right-width: 45vw;
        border-bottom-width: 30vw;
        border-top-width: 30vw;
    }
}

.flap {
    position: absolute;
    top: 0; left: 0;
    width: 0; height: 0;
    border-left: 210px solid transparent;
    border-right: 210px solid transparent;
    border-top: 140px solid #e06d6d;
    transform-origin: top;
    transition: transform 0.4s ease 0.2s, z-index 0.2s ease 0.4s;
    z-index: 6;
}

@media (max-width: 480px) {
    .flap {
        border-left-width: 45vw;
        border-right-width: 45vw;
        border-top-width: 30vw;
    }
}

.heart-seal {
    position: absolute;
    top: 120px; left: 50%;
    transform: translateX(-50%) scale(1);
    font-size: 38px;
    z-index: 7;
    transition: transform 0.3s ease, opacity 0.3s ease;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.15); }
}

/* --- KHUNG LÁ THƯ --- */
.letter-container {
    position: absolute;
    bottom: 0; left: 5%;
    width: 90%; height: 250px;
    background: #fffdf6;
    padding: 20px 15px;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    z-index: 3;
    transition: all 0.6s ease 0.5s;
    overflow-y: auto; 
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.letter-container::-webkit-scrollbar {
    width: 4px;
}
.letter-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 10px;
}

/* CĂN CHỈNH ĐƯỜNG KẺ TẬP HỌC SINH */
.paper-lines {
    background-image: linear-gradient(transparent 96%, #b4d3e6 96%);
    background-size: 100% 36px; /* Khoảng cách cố định giữa các dòng kẻ */
    position: relative;
    min-height: 100%;
    padding-top: 24px; /* Đẩy tiêu đề và chữ dòng đầu xuống vị trí hợp lý */
}

.letter-title {
    font-family: 'Dancing Script', cursive;
    font-size: 30px;
    color: #d90429;
    margin-bottom: 12px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s ease 1.2s;
}

/* CĂN CHỈNH CHỮ NẰM TRÊN DÒNG KẺ */
.letter-content {
    font-family: 'Dancing Script', cursive;
    font-size: 20px;
    line-height: 36px; /* BẮT BUỘC bằng với background-size của .paper-lines để không lệch dòng */
    color: #2b2b2b;
    padding-left: 5px;
    padding-right: 5px;
    word-wrap: break-word;
    display: inline-block;
    width: 100%;
    transform: translateY(-3px); /* Nhấc nhẹ toàn bộ chữ lên sát mặt dòng kẻ */
}

/* --- HIỆU ỨNG MỞ PHONG BÌ --- */
.envelope-wrapper.open { 
    margin-top: 120px; 
}
.envelope-wrapper.open .flap { 
    transform: rotateX(180deg); 
    z-index: 1; 
}
.envelope-wrapper.open .heart-seal { 
    opacity: 0; 
    pointer-events: none; 
}

.envelope-wrapper.open .letter-container {
    bottom: 60px; 
    height: 380px; 
    width: 106%;  
    left: -3%;
    z-index: 10;   
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    transform: rotate(-0.5deg);
}
.envelope-wrapper.open .letter-title { opacity: 1; }

.envelope-wrapper.fade-out {
    opacity: 0;
    transform: scale(0.7) translateY(200px);
    pointer-events: none;
    transition: all 1s ease;
}

/* --- TRANG MÀN HÌNH BÁNH KEM --- */
.cake-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: -1;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 1.2s ease, transform 1.2s ease, z-index 0s linear 1.2s;
    padding: 20px;
}

.cake-screen.show {
    z-index: 20;
    opacity: 1;
    transform: scale(1);
    transition: opacity 1.2s ease, transform 1.2s ease;
}

.cake-title {
    font-family: 'Dancing Script', cursive;
    font-size: 32px;
    color: #d90429;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 0 10px;
}

/* KHỐI CHỨA BÁNH KEM 3D */
.cake-container {
    position: relative;
    width: 220px; 
    height: 200px;
    display: flex;
    justify-content: center;
}

.cake-plate {
    position: absolute;
    bottom: -5px;
    width: 260px;
    height: 14px;
    background: linear-gradient(to bottom, #e2e8f0, #cbd5e1);
    border-radius: 50%;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.cake-layer {
    position: absolute;
    left: 50%; 
    transform: translateX(-50%);
    border-radius: 20px 20px 15px 15px;
    box-shadow: 
        inset 0 4px 8px rgba(255,255,255,0.7),
        0 6px 12px rgba(0,0,0,0.08);
    background: #fff5f7;
}

.layer-bottom { 
    width: 200px; 
    height: 80px; 
    bottom: 5px; 
    z-index: 2;
}

.layer-top { 
    width: 150px; 
    height: 70px; 
    bottom: 80px; 
    z-index: 4;
}

.cream-drip {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 25px;
    background: #ffb3c6;
    border-radius: 20px 20px 0 0;
}
.cream-drip::after {
    content: '';
    position: absolute;
    width: 100%; height: 15px;
    top: 20px; left: 0;
    background: transparent;
    background-image: radial-gradient(circle at 10px -5px, #ffb3c6 12px, transparent 13px);
    background-size: 20px 20px;
}

.pearls {
    position: absolute;
    width: 100%;
    top: 10px;
    display: flex;
    justify-content: space-around;
    padding: 0 12px;
    z-index: 5;
}
.pearl {
    width: 5px; height: 5px;
    background: radial-gradient(circle at 2px 2px, #fff, #fef08a);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.candle {
    position: absolute;
    width: 8px; 
    height: 55px;
    background: linear-gradient(to right, #fbbf24, #fef08a, #fbbf24);
    bottom: 140px; 
    left: 50%; 
    transform: translateX(-50%);
    border-radius: 4px;
    z-index: 10;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}
.candle::before {
    content: '';
    position: absolute;
    width: 100%; height: 100%;
    background: repeating-linear-gradient(45deg, transparent, transparent 8px, #f43f5e 8px, #f43f5e 12px);
    opacity: 0.7;
    border-radius: 4px;
}

.flame {
    position: absolute;
    width: 16px; height: 24px;
    background: radial-gradient(circle at 50% 80%, #ffedd5, #f97316, #ef4444);
    border-radius: 50% 50% 20% 20%;
    bottom: 195px; left: 50%;
    transform: translateX(-50%);
    animation: flicker 0.5s infinite alternate;
    box-shadow: 0 0 25px #f97316, 0 0 10px #fef08a;
    z-index: 11;
    transform-origin: bottom center;
}

@keyframes flicker {
    0% { transform: translateX(-50%) scale(1) rotate(-1deg); }
    100% { transform: translateX(-50%) scale(1.1) rotate(2deg); }
}

.smoke {
    position: absolute;
    width: 5px; height: 0px;
    background: rgba(255,255,255,0.75);
    bottom: 198px; left: 50%;
    transform: translateX(-50%);
    border-radius: 50%;
    opacity: 0;
    z-index: 11;
}

.cake-container.blown .flame { display: none; }
.cake-container.blown .smoke { animation: smokeUp 2.5s ease-out forwards; }

@keyframes smokeUp {
    0% { opacity: 0.8; height: 12px; filter: blur(1px); }
    40% { width: 14px; height: 40px; transform: translateX(-60%) translateY(-20px); opacity: 0.5; filter: blur(3px); }
    100% { width: 30px; height: 60px; transform: translateX(-30%) translateY(-70px); opacity: 0; filter: blur(5px); }
}

/* NÚT THỔI NẾN */
.blow-btn {
    margin-top: 30px;
    padding: 10px 30px;
    font-family: 'Quicksand', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #ff4b6e, #ff758f);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(255, 75, 110, 0.4);
    transition: all 0.3s ease;
    z-index: 5;
}
.blow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 75, 110, 0.6);
}
.blow-btn.hide {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    margin-top: 0;
    height: 0;
    padding: 0;
}

/* LỜI CHÚC XUẤT HIỆN */
.wishes-text {
    margin-top: 0px;
    font-size: 18px;
    color: #d90429;
    font-weight: bold;
    text-align: center;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transform: translateY(20px);
    transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 0 15px;
    width: 100%;
}

.wishes-text.active { 
    margin-top: 30px;
    opacity: 1; 
    max-height: 120px;
    transform: translateY(0); 
}

/* MÀN HÌNH ĐIỆN THOẠI NHỎ */
@media (max-width: 360px) {
    .envelope-wrapper.open {
        margin-top: 100px;
    }
    .envelope-wrapper.open .letter-container {
        height: 320px;
    }
    .paper-lines {
        background-size: 100% 36px;
        padding-top: 24px; 
    }
    .letter-content {
        font-size: 18px;
        line-height: 36px; /* Giữ nguyên line-height bằng background-size để tránh bị lệch */
        transform: translateY(-4px); /* Tinh chỉnh lại độ cao chữ cho màn hình nhỏ */
    }
    .cake-title {
        font-size: 26px;
    }
    .wishes-text {
        font-size: 16px;
    }
}