:root {
    --bg-color: #FFF0F5; /* Lavender Blush - softer pinkish bg */
    --primary-color: #FF69B4; /* Hot Pink */
    --accent-color: #FF1493; /* Deep Pink */
    --text-color: #880E4F; /* Dark Pink/Burgundy */
    --white: #ffffff;
    --shadow: 0 10px 30px rgba(255, 105, 180, 0.2);
}

/* Add some cute floating elements */
.floating-hearts {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.heart-icon {
    position: absolute;
    font-size: 20px;
    color: var(--primary-color);
    opacity: 0.6;
    animation: floatUp 6s infinite linear;
}

@keyframes floatUp {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 390px; /* iPhone 15 width */
    max-height: 844px; /* iPhone 15 height */
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

section {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

/* Landing Section */
.content {
    text-align: center;
}

.title {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--text-color);
}

.subtitle {
    font-size: 1.1rem;
    color: #8D6E63;
    margin-bottom: 40px;
}

/* Button Styling */
.btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    background-color: var(--accent-color);
    color: var(--white);
    border: none;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(255, 138, 128, 0.4);
    cursor: pointer;
    transition: transform 0.3s ease, background-color 0.3s ease, opacity 0.8s ease;
}

.btn:active {
    transform: scale(0.95);
}

.btn.hidden {
    opacity: 0;
    transform: translateY(20px);
}

.btn.visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* Modal Styling */
.modal-card {
    background: var(--white);
    padding: 30px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 320px;
    text-align: center;
}

.modal-card h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#password-input {
    padding: 12px;
    border: 2px solid #EEE;
    border-radius: 10px;
    outline: none;
    font-size: 1rem;
    transition: border-color 0.3s;
}

#password-input:focus {
    border-color: var(--primary-color);
}

.error-msg {
    color: #E57373;
    font-size: 0.9rem;
    min-height: 20px;
}

/* Envelope Styling */
.envelope-wrapper {
    height: 380px;
    width: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.envelope {
    position: relative;
    width: 280px;
    height: 180px;
    background: #fdfdfd;
    box-shadow: var(--shadow);
    cursor: pointer;
    transform-style: preserve-3d;
}

.envelope:before {
    content: "";
    position: absolute;
    z-index: 2;
    border-top: 100px solid transparent;
    border-right: 140px solid #f9f9f9;
    border-bottom: 80px solid #f9f9f9;
    border-left: 140px solid #f9f9f9;
    top: 0;
}

.flap {
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    border-left: 140px solid transparent;
    border-right: 140px solid transparent;
    border-top: 100px solid #f2f2f2;
    transform-origin: top;
    transition: transform 0.6s 0.4s ease;
    z-index: 3;
}

.pocket {
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    border-left: 140px solid transparent;
    border-right: 140px solid transparent;
    border-bottom: 180px solid #fff;
    z-index: 2;
}

.letter {
    position: absolute;
    bottom: 0;
    width: 260px;
    height: 160px;
    background: #fff;
    left: 10px;
    transition: transform 0.6s ease, height 0.6s ease;
    z-index: 1;
    padding: 20px;
    box-shadow: 0 0 10px rgba(0,0,0,0.05);
    overflow-y: auto; /* Enable scrolling */
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

/* Custom scrollbar for Chrome, Safari and Opera */
.letter::-webkit-scrollbar {
    width: 4px;
}

.letter::-webkit-scrollbar-track {
    background: transparent;
}

.letter::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.letter-content {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #333;
}

.handwritten {
    font-family: 'Brush Script MT', cursive;
    font-size: 1.2rem;
    margin-bottom: 5px;
    color: var(--text-color);
}

.message-text {
    margin-bottom: 10px;
    white-space: pre-line;
    line-height: 1.6;
}

/* Envelope Open State */
.envelope.open .flap {
    transform: rotateX(180deg);
    z-index: 0;
}

.envelope.open .letter {
    transform: translateY(-120px);
    height: 320px;
    z-index: 2;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

/* Animations */
.fade-in {
    animation: fadeIn 1.2s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    50% { transform: translateX(10px); }
    75% { transform: translateX(-10px); }
}

/* Footer - Fixed at the very bottom */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.6;
    z-index: 1000;
    background: rgba(255, 240, 245, 0.8);
    padding: 10px 0;
}

/* Scrollable Container for sections that grow */
#envelope-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Start from top to allow scrolling */
    padding-top: 150px; /* Room for letter to slide UP */
    padding-bottom: 100px;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Hide for Firefox */
    -ms-overflow-style: none;  /* Hide for Internet Explorer and Edge */
}

/* Hide scrollbar for Chrome, Safari and Opera */
#envelope-section::-webkit-scrollbar {
    display: none;
}

.envelope-wrapper {
    margin-bottom: 50px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

/* Extra Content Styling */
.extra-content {
    width: 100%;
    margin-top: 40px;
    padding-bottom: 50px;
    text-align: center;
    transition: opacity 1s ease 1s;
}

.gallery-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-color);
}

.polaroid-grid {
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: center;
    margin-bottom: 40px;
}

.polaroid {
    background: white;
    padding: 15px 15px 30px 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transform: rotate(-2deg);
    width: 250px;
}

.polaroid:nth-child(even) {
    transform: rotate(3deg);
}

.photo-placeholder {
    width: 220px;
    height: 220px;
    background: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #999;
    font-size: 0.8rem;
    border: 1px dashed #ccc;
    overflow: hidden; /* Prevent any overflow */
}

.photo-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensures image fills the square nicely */
    display: block;
}

.gif-container {
    margin: 20px auto;
    width: 80%;
    max-width: 250px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.birthday-gif {
    width: 100%;
    display: block;
}

.caption {
    font-family: 'Brush Script MT', cursive;
    font-size: 1.2rem;
    margin-top: 15px;
    color: #444;
}

.special-note {
    background: #FFF9C4;
    padding: 20px;
    width: 90%;
    margin: 0 auto;
    border-radius: 5px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.05);
    text-align: left;
    transform: rotate(1deg);
}

.special-note h4 {
    margin-bottom: 10px;
    color: var(--text-color);
}

.special-note ul {
    list-style: none;
}

.special-note li {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.recipient-name {
    color: var(--accent-color);
    text-shadow: 1px 1px 0px rgba(255,255,255,0.5);
}

@media (max-height: 600px) {
    .title { font-size: 1.8rem; }
    .envelope-wrapper { transform: scale(0.8); }
}

/* Music Toggle - Centered above the greeting */
.music-toggle {
    position: relative;
    display: inline-flex;
    margin-bottom: 30px;
    background: var(--white);
    padding: 10px 20px;
    border-radius: 30px;
    justify-content: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(255, 105, 180, 0.3);
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid var(--primary-color);
}

/* Persistent ripple to show it can be tapped */
.music-toggle::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 30px;
    border: 2px solid var(--primary-color);
    animation: ripple 2s infinite;
    z-index: -1;
}

@keyframes ripple {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.4); opacity: 0; }
}

.music-toggle span {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.music-toggle .icon {
    font-size: 1.2rem;
    animation: wiggle 2s infinite;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-20deg); }
    75% { transform: rotate(20deg); }
}

.music-toggle:active {
    transform: scale(0.9);
}

.music-toggle.playing {
    background: var(--primary-color);
    border-color: var(--white);
}

.music-toggle.playing span, 
.music-toggle.playing .icon {
    color: var(--white);
}

.music-toggle.playing::after {
    border-color: var(--white);
    animation: ripple 1s infinite;
}
