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

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #e0e0e0;
    min-height: 100vh;
    height: 100vh; /* Thuộc tính fallback */
    font-family: sans-serif;
    overflow: hidden; /* Cần thiết để thiết kế tràn không sinh ra thanh cuộn */
}

@supports (height: 100dvh) {
    body {
        min-height: 100dvh;
        height: 100dvh;
    }
}

.screen {
    width: 390px;
    height: 696px;
    position: relative;
    background-color: #fff;
    overflow: hidden;
    /* Việc bo góc, tính toán thu phóng Scale sẽ được xử lý linh hoạt 100% bằng JavaScript để độ chính xác cao nhất */
}

img, div {
    position: absolute;
}

.bg {
    left: 0;
    top: 0;
    width: 390px;
    height: 696px;
    object-fit: cover;
}

.logo {
    left: 73px;
    top: 53px;
    width: 110px;
    height: 110px;
}

.title {
    left: 168px;
    top: 77px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 10px;
    line-height: 1.4;
    letter-spacing: -0.02em;
    color: #6A350E;
    text-align: left;
    white-space: nowrap;
}

.line1 {
    left: 169px;
    top: 125px;
    width: 60px;
    height: 1px;
    background-color: #6A350E;
}

.touch-text {
    left: 195px;
    top: 450px;
    transform: translateX(-50%) rotate(-2deg);
    font-family: 'Dancing Script', cursive;
    font-weight: 600;
    font-size: 16px;
    line-height: 1.4;
    letter-spacing: -0.02em;
    color: #6A350E;
    opacity: 0.6;
    text-align: center;
    white-space: nowrap;
}

.from {
    left: 135px;
    top: 510px;
    transform: translateX(-50%) rotate(-2deg);
    font-family: 'Dancing Script', cursive;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.4;
    letter-spacing: -0.02em;
    color: #6A350E;
    text-align: left;
    white-space: nowrap;
}

.name {
    left: 195px;
    top: 535px;
    transform: translateX(-50%) rotate(-2deg);
    font-family: 'Dancing Script', cursive;
    font-weight: 400;
    font-size: 20px;
    line-height: 1.4;
    letter-spacing: -0.02em;
    color: #6A350E;
    text-align: center;
    white-space: nowrap;
}

.line2 {
    left: 195px;
    top: 565px;
    width: 160.69px;
    height: 1px;
    background-color: #6A350E;
    transform: translateX(-50%) rotate(-2deg) scaleY(0.2);
}

.object {
    left: 275px; 
    top: 535px;
    width: 26px;
    height: 30px;
}

.card-closed {
    left: 53.5px;
    top: 215px;
    width: 283px;
    height: 211px;
    transform: rotate(-2deg);
    border-radius: 10px;
    box-shadow: -5px 5px 4px 0 rgba(0, 0, 0, 0.25);
    transition: opacity 0.5s ease-in-out, transform 0.5s ease;
    opacity: 1;
    z-index: 2;
}

.card-opened {
    left: 55px; 
    top: 138px; /* Dịch xuống 24px */
    width: 280px;
    height: 322px;
    transform: rotate(-1deg);
    border-radius: 10px;
    transition: opacity 0.5s ease-in-out, transform 0.5s ease;
    opacity: 0;
    visibility: hidden;
    z-index: 1;
}

.screen.is-open .card-closed {
    opacity: 0;
    visibility: hidden;
    transform: rotate(0deg) scale(0.95);
}

.screen.is-open .card-opened {
    opacity: 1;
    visibility: visible;
    z-index: 2;
}

.touch-text, .object {
    transition: opacity 0.5s ease;
}

.screen.is-open .touch-text {
    opacity: 0;
    pointer-events: none;
}

/* === 1. LEAVES FALLING ANIMATION === */
.leaves-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 99;
}
.leaf {
    position: absolute;
    top: -100px;
}
@keyframes fallSway1 {
    0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
    10%  { opacity: 0.8; }
    25%  { transform: translate(-80px, 200px) rotate(45deg); }
    50%  { transform: translate(-120px, 400px) rotate(-30deg); }
    75%  { transform: translate(-220px, 600px) rotate(60deg); }
    90%  { opacity: 0.8; }
    100% { transform: translate(-300px, 850px) rotate(-45deg); opacity: 0; }
}
@keyframes fallSway2 {
    0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
    10%  { opacity: 0.8; }
    25%  { transform: translate(-100px, 200px) rotate(-45deg); }
    50%  { transform: translate(-180px, 400px) rotate(30deg); }
    75%  { transform: translate(-200px, 600px) rotate(-60deg); }
    90%  { opacity: 0.8; }
    100% { transform: translate(-350px, 850px) rotate(45deg); opacity: 0; }
}

.leaf-1 { left: 350px; animation: fallSway1 12s linear infinite 0s; width: 30px; }
.leaf-2 { left: 450px; animation: fallSway2 14s linear infinite 2s; width: 25px; }
.leaf-3 { left: 250px; animation: fallSway1 11s linear infinite 4s; width: 20px; }
.leaf-4 { left: 300px; animation: fallSway2 15s linear infinite 6s; width: 35px; }
.leaf-5 { left: 400px; animation: fallSway1 13s linear infinite 8s; width: 28px; }
.leaf-6 { left: 200px; animation: fallSway2 16s linear infinite 10s; width: 32px; }

/* === 2. INITIAL FADE IN EFFECTS === */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInCardTop { from { opacity: 0; top: 235px; } to { opacity: 1; top: 215px; } }
@keyframes slideUpText { from { opacity: 0; transform: translateX(-50%) translateY(15px) rotate(-2deg); } to { opacity: 1; transform: translateX(-50%) translateY(0) rotate(-2deg); } }
@keyframes drawLine { 0% { width: 0; opacity: 0; } 1% { opacity: 1; border-color: transparent;} 100% { width: 160.69px; opacity: 1; } }

.bg { animation: fadeIn 1.2s ease-out forwards; }
.logo, .title, .line1 { animation: fadeIn 1s ease-out 0.4s backwards; }
.card-closed { animation: fadeInCardTop 1s ease-out 0.8s backwards; }
.from, .name { animation: slideUpText 1s ease-out 1s backwards; }
.line2 { animation: drawLine 1s ease-out 1.2s backwards; }

/* === 3. INTERACTIVE CTA === */
@keyframes pulseText { 0%, 100% { opacity: 0.6; } 50% { opacity: 0.9; } }
@keyframes floatObject { 0%, 100% { top: 535px; } 50% { top: 541px; } }

/* Re-assign touch-text and object to avoid overriding transforms */
.touch-text { animation: fadeIn 1s ease-out 1.2s backwards, pulseText 2s ease-in-out 2.2s infinite; }
.object { animation: fadeIn 1s ease-out 1.2s backwards, floatObject 2s ease-in-out 2.2s infinite; }

/* Hide animation when card opens */
@keyframes fadeOutFast { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }
.screen.is-open .touch-text { animation: fadeOutFast 0.5s ease-out forwards !important; pointer-events: none; }
