:root {
    --bg-dark: #0a0a0a;
    --bg-red: #2b0a0a;
    --note-red: #d32f2f;     /* Màu đỏ tươi cho giấy note nhỏ */
    --card-red: #c62828;     /* Màu đỏ đậm hơn cho thẻ bài lớn */
    --text-gold: #ffecb3;
    --text-white: #f0f0f0;
    --shadow: rgba(0,0,0,0.5);
}

body {
    background: radial-gradient(circle at center, var(--bg-red) 0%, var(--bg-dark) 100%);
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    font-family: 'Montserrat', sans-serif;
    color: white;
}

/* --- 1. FIREFLIES ANIMATION --- */
.firefly {
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: #fff;
    border-radius: 50%;
    opacity: 0.5;
    box-shadow: 0 0 10px #fff, 0 0 20px #ff0055;
    animation: fly 15s infinite linear;
    z-index: -1;
}
.firefly:nth-child(1) { top: 10%; left: 10%; animation-duration: 12s; }
.firefly:nth-child(2) { top: 80%; left: 20%; animation-duration: 18s; animation-delay: 2s; }
.firefly:nth-child(3) { top: 40%; left: 80%; animation-duration: 10s; width: 6px; height: 6px;}
.firefly:nth-child(4) { top: 90%; left: 90%; animation-duration: 15s; }
.firefly:nth-child(5) { top: 20%; left: 60%; animation-duration: 20s; animation-delay: 1s; }
.firefly:nth-child(6) { top: 50%; left: 50%; animation-duration: 25s; }

@keyframes fly {
    0% { transform: translateY(0) translateX(0); opacity: 0; }
    50% { opacity: 0.8; }
    100% { transform: translateY(-100vh) translateX(50px); opacity: 0; }
}

/* --- 2. HEADER (STYLE BẠN THÍCH) --- */
header {
    text-align: center;
    margin-bottom: 40px;
    z-index: 10;
    animation: fadeIn 2s ease-in-out;
}

h1 {
    font-family: 'Great Vibes', cursive;
    font-size: 4rem;
    margin: 0;
    color: var(--text-gold);
    text-shadow: 0 0 10px rgba(255, 236, 179, 0.3);
    letter-spacing: 2px;
}

p.subtitle {
    font-family: 'Montserrat', sans-serif;
    font-weight: 300;
    font-size: 1rem;
    letter-spacing: 4px;
    margin-top: 10px;
    text-transform: uppercase;
    opacity: 0.8;
}

/* --- 3. HEART CONTAINER --- */
/* --- 3. HEART CONTAINER (ĐÃ CHỈNH SỬA HIỆU ỨNG CHỒNG LÊN NHAU) --- */
.heart-container {
    position: relative;
    display: grid;
    /* Tăng kích thước ô lưới lên một chút để chứa note to hơn */
    grid-template-columns: repeat(7, 55px);
    grid-template-rows: repeat(6, 55px);
    /* QUAN TRỌNG: Đưa gap về 0 hoặc số âm để các ô sát vào nhau */
    gap: 0px; 
    transform: rotate(-5deg);
    z-index: 5;
    /* Thêm margin âm để kéo tổng thể lại gần nhau hơn nữa */
    margin: -10px;
}

.note {
    /* Tăng kích thước note để dễ chồng lên nhau (cũ là 50px) */
    width: 60px;
    height: 60px;
    background-color: var(--note-red);
    
    /* Bóng đổ gắt hơn và gần hơn để tạo cảm giác nằm sát nhau */
    box-shadow: 2px 3px 5px rgba(0,0,0,0.5);
    
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 11px;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    
    /* Trạng thái ban đầu khi chưa hiện */
    transform: scale(0) translateY(50px) rotate(0deg);
    
    border-radius: 2px;
    font-family: 'Dancing Script', cursive;
    
    /* Quan trọng để dùng các thuộc tính đẩy vị trí (top, left...) */
    position: relative;
}

/* --- TẠO SỰ LỘN XỘN NGẪU NHIÊN (MAGIC HACK) --- */
/* Đẩy các tờ note số lẻ lệch sang trái và xoay nhẹ */
.note:nth-child(odd) {
    left: -5px;
    top: 2px;
    transform: rotate(-3deg);
    z-index: 1; /* Nằm dưới */
}

/* Đẩy các tờ note số chẵn lệch sang phải và xoay hướng khác */
.note:nth-child(even) {
    left: 5px;
    top: -3px;
    transform: rotate(2deg);
    z-index: 2; /* Nằm đè lên số lẻ */
}

/* Đẩy thêm các tờ ở vị trí chia hết cho 3 để tăng độ ngẫu nhiên */
.note:nth-child(3n) {
    left: -2px;
    top: 6px;
    transform: rotate(4deg);
    z-index: 3; /* Nằm đè lên trên cùng */
}
/* -------------------------------------------------- */

/* Hiệu ứng cong góc giấy (Giữ nguyên) */
.note::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    border-width: 0 0 12px 12px; /* Cong góc to hơn chút */
    border-style: solid;
    border-color: transparent transparent rgba(0,0,0,0.3) rgba(0,0,0,0.3);
}

/* Hover: Phóng to và luôn nổi lên trên cùng nhất */
.note:hover {
    /* Dùng !important để ghi đè lên các transform ngẫu nhiên ở trên */
    transform: scale(1.3) rotate(5deg) !important;
    z-index: 100 !important;
    background-color: #ff4444;
    box-shadow: 0 15px 30px rgba(0,0,0,0.5); /* Bóng đổ xa hơn khi nhấc lên */
}

/* Khi xuất hiện: Ghi đè transform để hiện ra đúng vị trí lộn xộn */
.note.show:nth-child(odd) { opacity: 1; transform: scale(1) translateY(0) rotate(-3deg); }
.note.show:nth-child(even) { opacity: 1; transform: scale(1) translateY(0) rotate(2deg); }
.note.show:nth-child(3n) { opacity: 1; transform: scale(1) translateY(0) rotate(4deg); }

/* Vị trí lưới (Giữ nguyên không đổi) */
.n1 { grid-column: 2; grid-row: 1; } .n2 { grid-column: 3; grid-row: 1; }
.n3 { grid-column: 5; grid-row: 1; } .n4 { grid-column: 6; grid-row: 1; }
.n5 { grid-column: 1; grid-row: 2; } .n6 { grid-column: 2; grid-row: 2; }
.n7 { grid-column: 3; grid-row: 2; } .n8 { grid-column: 4; grid-row: 2; }
.n9 { grid-column: 5; grid-row: 2; } .n10 { grid-column: 6; grid-row: 2; }
.n11 { grid-column: 7; grid-row: 2; }
.n12 { grid-column: 1; grid-row: 3; } .n13 { grid-column: 2; grid-row: 3; }
.n14 { grid-column: 3; grid-row: 3; } .n15 { grid-column: 4; grid-row: 3; }
.n16 { grid-column: 5; grid-row: 3; } .n17 { grid-column: 6; grid-row: 3; }
.n18 { grid-column: 7; grid-row: 3; }
.n19 { grid-column: 2; grid-row: 4; } .n20 { grid-column: 3; grid-row: 4; }
.n21 { grid-column: 4; grid-row: 4; } .n22 { grid-column: 5; grid-row: 4; }
.n23 { grid-column: 6; grid-row: 4; }
.n24 { grid-column: 3; grid-row: 5; } .n25 { grid-column: 4; grid-row: 5; }
.n26 { grid-column: 5; grid-row: 5; }
.n27 { grid-column: 4; grid-row: 6; }

/* --- 4. RED CARD MODAL (STYLE NÂNG CAO) --- */


/* Lớp nền mờ phía sau */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    
    /* Tăng độ tối lên 92% để làm nổi bật tấm thẻ */
    background: rgba(0, 0, 0, 0.92);
    
    /* Tăng độ blur lên 15px để nền web phía sau mờ ảo hoàn toàn */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px); /* Hỗ trợ Safari */
    
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
    
    /* QUAN TRỌNG: Perspective tạo chiều sâu 3D cho cú lật */
    perspective: 1200px;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

/* Tấm thẻ đỏ (Giấy Note Lớn) */
.red-card {
    /* Màu đỏ nhung sẫm hơn một chút cho sang */
    background-color: #b71c1c; 
    
    /* TEXTURE MỚI: Dùng vân giấy sần (Noise/Paper) thay vì hình khối */
    background-image: url('https://www.transparenttextures.com/patterns/cream-paper.png');
    /* Hòa trộn vân giấy vào màu đỏ */
    background-blend-mode: overlay; 
    
    width: 340px; /* To hơn chút xíu cho dễ đọc */
    min-height: 500px;
    padding: 30px;
    
    /* Bóng đổ sâu hơn để tạo cảm giác giấy đang lơ lửng */
    box-shadow: 0 40px 80px rgba(0,0,0,0.8), 
                inset 0 0 20px rgba(0,0,0,0.4); /* Bóng đổ bên trong viền giấy */
    
    /* Setup cho Animation lật */
    transform: rotateY(-100deg) scale(0.8); /* Nghiêng nhiều hơn chút */
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1); /* Hiệu ứng nảy nhẹ khi lật xong */
    
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    color: #fff;
    
    /* Giữ không gian 3D */
    transform-style: preserve-3d;
    border-radius: 4px; /* Bo góc cực nhẹ cho giống giấy cắt */
}

/* Khi thẻ hiện ra */
.modal-overlay.active .red-card {
    transform: rotateY(0deg) scale(1);
    opacity: 1;
}

/* --- CÁC PHẦN NỘI DUNG BÊN TRONG (Giữ nguyên hoặc chỉnh nhẹ) --- */

.content-media {
    width: 100%;
    height: 260px;
    object-fit: cover;
    /* Viền ảnh kiểu Polaroid mỏng hơn */
    border: 5px solid #fff; 
    margin-bottom: 25px;
    /* Bóng đổ của tấm ảnh lên mặt giấy */
    box-shadow: 0 5px 15px rgba(0,0,0,0.4); 
    transform: translateZ(20px); /* Đẩy tấm ảnh nổi lên khỏi mặt giấy */
}

.meta-tag {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 4px;
    opacity: 0.7;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 5px;
    width: 100%;
    text-align: center;
    color: #ffcdd2; /* Màu hồng phấn nhạt */
}

/* --- SỬA FONT CHỮ TRONG THẺ --- */

.content-title {
    /* Đổi sang font bay bướm */
    font-family: 'Great Vibes', cursive; 
    
    /* Tăng kích thước lên vì font này nét khá thanh mảnh */
    font-size: 3rem; 
    margin-bottom: 5px;
    text-transform: none; /* Bỏ viết hoa toàn bộ để giữ nét uốn lượn đẹp hơn */
    text-align: center;
    font-weight: 400;
    color: #ffecb3; /* Màu vàng nhạt cho nổi bật trên nền đỏ */
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    line-height: 1.2;
}

.content-text {
    /* Đổi sang font nét trẻ con/nguệch ngoạc */
    font-family: 'Mali', cursive; 
    
    font-size: 1.3rem; /* Chữ to rõ ràng */
    text-align: center;
    line-height: 1.6;
    margin-top: 15px;
    color: rgba(255,255,255,0.95);
    font-weight: 400; /* Độ đậm vừa phải giống bút chì/bút sáp */
}

/* Nút đóng đẹp hơn */
.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    font-size: 2rem;
    transition: 0.3s;
    line-height: 1;
}
.close-btn:hover { 
    color: white; 
    transform: rotate(90deg); /* Xoay khi hover */
}

.full-mode {
    object-fit: contain !important; /* Quan trọng: Giữ nguyên tỉ lệ, không cắt ảnh */
    height: auto !important;        /* Chiều cao tự động theo độ dài ảnh */
    max-height: 60vh !important;    /* Giới hạn chiều cao tối đa để không chọc thủng màn hình */
    width: 100% !important;
    
    /* Đồng bộ Style với ảnh thường (.content-media) */
    background-color: #fff;         /* Nền trắng phòng khi ảnh trong suốt */
    border: 5px solid #fff !important; /* Viền trắng dày */
    box-shadow: 0 5px 15px rgba(0,0,0,0.4) !important; /* Bóng đổ nổi khối */
}

/* --- STORY MODE NAVIGATION --- */
/* --- INSTAGRAM STORY STYLE --- */

/* Khung chứa Story */
.story-wrapper {
    position: relative;
    width: 100%;
    height: 380px; /* Chiều cao cố định cho vùng ảnh story */
    background: #000; /* Nền đen để tôn ảnh */
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border: 3px solid #fff; /* Viền trắng giống Polaroid */
}

/* Thanh Progress Bar ở trên cùng */
.story-progress {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    z-index: 20;
}

.progress-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.3); /* Màu xám mờ */
    flex: 1; /* Tự chia đều chiều rộng */
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    width: 0%;
    background: #fff; /* Màu trắng sáng khi đã xem */
    transition: width 0.1s linear;
}

.progress-bar.active .fill { width: 100%; }
.progress-bar.passed .fill { width: 100%; }

/* Ảnh hiển thị */
.story-image {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Đảm bảo ảnh full khung không bị méo */
    transition: opacity 0.2s ease; /* Hiệu ứng mờ nhẹ khi chuyển */
}

/* Vùng chạm vô hình (Click Zones) */
.click-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 10;
    cursor: pointer;
    /* background: rgba(255,0,0,0.2); Bật dòng này nếu muốn debug vùng bấm */
}

.zone-left { left: 0; width: 35%; }  /* 35% bên trái để quay lại */
.zone-right { right: 0; width: 65%; } /* 65% bên phải để đi tiếp */

/* --- NÚT ĐIỀU HƯỚNG (NAVIGATION ARROWS) --- */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    padding: 20px;
    z-index: 1100; /* Cao hơn modal overlay */
    transition: all 0.3s ease;
    user-select: none;
}

.nav-arrow:hover {
    color: #fff;
    transform: translateY(-50%) scale(1.2);
    text-shadow: 0 0 10px rgba(255,255,255,0.8);
}

.prev-note { left: 20px; }
.next-note { right: 20px; }

/* Ẩn nút trên mobile để đỡ che ảnh (tùy chọn) */
@media (max-width: 768px) {
    .nav-arrow { display: none; }
}