:root {
    --bg-gradient: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    --envelope-color: #ff9a9e;
    --envelope-flap: #ff878d;
    --primary: #ff9a9e;
    --accent: #a18cd1;
    --text: #5e548e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(to top, #fff1eb 0%, #ace0f9 100%);
    font-family: 'Varela Round', sans-serif;
    overflow: hidden;
    user-select: none;
    cursor: pointer; /* Hint that interaction is possible everywhere */
}

/* --- -1. COUNTDOWN SCREEN --- */
#countdown-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    /* Kawaii Gradient + Polka Dots */
    background-color: #ffdde1;
    background-image: 
        radial-gradient(#ffffff 20%, transparent 20%),
        linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    background-size: 20px 20px, 100% 100%;
    background-blend-mode: overlay;
    
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 300;
    color: #5e548e;
    text-align: center;
}

.wait-image {
    width: 220px;
    max-width: 60%;
    height: auto;
    margin-bottom: 1.5rem;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 5px 15px rgba(255, 154, 158, 0.4));
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
    100% { transform: translateY(0px); }
}

.countdown-title {
    font-family: 'Pacifico', cursive;
    font-size: 3rem;
    margin-bottom: 2rem;
    color: #fff;
    text-shadow: 3px 3px 0px #ff9a9e, 6px 6px 0px rgba(0,0,0,0.1);
}

.timer-container {
    display: flex;
    gap: 1rem;
    font-family: 'Varela Round', sans-serif;
    justify-content: center;
    flex-wrap: wrap;
}

.time-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.time-value {
    font-size: 3rem;
    font-weight: bold;
    background: #fff;
    color: #ff9a9e;
    padding: 1rem;
    border-radius: 25px; /* Super rounded */
    min-width: 90px;
    box-shadow: 
        inset 0 -5px 0 rgba(0,0,0,0.1),
        0 10px 20px rgba(255, 154, 158, 0.3);
    border: 4px solid #fff;
    display: flex;
    justify-content: center;
    align-items: center;
}

.time-label {
    margin-top: 0.8rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    background: rgba(255, 154, 158, 0.8);
    padding: 4px 10px;
    border-radius: 15px;
}

/* Mobile Countdown */
@media (max-width: 600px) {
    #countdown-screen {
        padding: 20px;
    }
    .wait-image { width: 160px; margin-bottom: 1rem; }
    .countdown-title { font-size: 2rem; margin-bottom: 1.5rem; }
    .timer-container { gap: 0.8rem; }
    .time-value { 
        font-size: 1.8rem; 
        min-width: 60px; 
        padding: 0.8rem 0.4rem; 
        border-radius: 18px;
        border-width: 3px;
    }
    .time-label { font-size: 0.7rem; margin-top: 0.5rem; padding: 3px 8px; }
}

/* --- 0. LOGIN SCREEN (New) --- */
#login-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(to top, #fff1eb 0%, #ace0f9 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: opacity 0.5s ease;
}

.login-box {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    text-align: center;
    border: 3px solid #fff;
    max-width: 90%;
}

.login-title {
    font-family: 'Pacifico', cursive;
    color: var(--text);
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.code-input {
    padding: 15px 25px;
    border-radius: 50px;
    border: 2px solid #e0e0e0;
    font-family: 'Varela Round', sans-serif;
    font-size: 1.2rem;
    width: 220px;
    text-align: center;
    margin-bottom: 1.5rem;
    outline: none;
    transition: all 0.3s;
    color: var(--text);
    background: rgba(255, 255, 255, 0.9);
}

.code-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(255, 154, 158, 0.2);
}

.error-shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
    border-color: #ff6b6b;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* --- 1. THE ENVELOPE (Intro) --- */
#envelope-container {
    position: absolute;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.8s ease, opacity 0.5s ease;
    cursor: pointer;
    /* Hidden initially until login */
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

#envelope-container.visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.envelope {
    width: 300px;
    height: 200px;
    background: var(--envelope-color);
    position: relative;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* The triangle flap */
.flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-top: 110px solid var(--envelope-flap);
    transform-origin: top;
    transition: transform 0.6s ease-in-out, z-index 0.2s;
    z-index: 102;
}

.pocket {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 150px solid var(--envelope-color);
    border-right: 150px solid var(--envelope-color);
    border-bottom: 100px solid #ffb7b2; /* Slightly darker/lighter for depth */
    border-top: 100px solid transparent;
    border-radius: 0 0 10px 10px;
    z-index: 101;
}

.seal {
    position: absolute;
    top: 35px;
    background: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 103;
    border: 2px solid #eee;
}

.label {
    margin-top: 2rem;
    background: white;
    padding: 10px 20px;
    border-radius: 20px;
    color: var(--text);
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    animation: bounce 2s infinite;
}

/* Open State classes */
.envelope.open .flap {
    transform: rotateX(180deg);
    z-index: 90;
}

.envelope.open .seal {
    opacity: 0;
    transition: opacity 0.2s;
}

/* --- 2. THE CARD (Main Content) --- */
#main-card {
    position: relative;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-radius: 0;
    padding: 2rem 1rem;
    width: 90%;
    max-width: 600px;
    text-align: center;
    box-shadow: none;
    transform: scale(0); /* Start hidden */
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Bouncy pop */
    z-index: 50;
}

#main-card.visible {
    transform: scale(1);
    opacity: 1;
}

h1 {
    font-family: 'Pacifico', cursive;
    color: var(--text);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 3px 3px 6px rgba(255, 255, 255, 0.8), 
                 0 0 20px rgba(161, 140, 209, 0.3);
}

.subtitle {
    color: #a18cd1;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.message-box {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 25px;
    padding: 2.5rem;
    margin: 1.5rem 0;
    min-height: 200px; 
    max-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255, 255, 255, 0.8);
    position: relative;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #ffb7b2 transparent;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

/* Custom scrollbar for webkit */
.message-box::-webkit-scrollbar { width: 6px; }
.message-box::-webkit-scrollbar-thumb { background-color: #ffb7b2; border-radius: 10px; }

.message-text {
    color: #444;
    font-size: 1.2rem;
    line-height: 1.7;
    animation: fadeIn 0.8s ease;
    text-align: left;
    width: 100%;
    font-weight: 400;
}

/* Buttons */
.btn {
    background: linear-gradient(45deg, #ff9a9e 0%, #fad0c4 100%);
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    color: white;
    font-weight: bold;
    font-family: 'Varela Round', sans-serif;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(255, 154, 158, 0.4);
    transition: transform 0.2s;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.btn:hover { transform: scale(1.05) rotate(-2deg); }
.btn:active { transform: scale(0.95); }

/* Floating Stamps */
.stamp {
    position: absolute;
    pointer-events: none;
    animation: stampPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 2rem;
    z-index: 10;
}

.hint-text {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    color: rgba(94, 84, 142, 0.5);
    font-size: 0.9rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s;
}

/* Page indicator dots */
.dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
}
.dot {
    width: 8px;
    height: 8px;
    background: #e0e0e0;
    border-radius: 50%;
    transition: background 0.3s;
}
.dot.active {
    background: var(--primary);
}

/* Photo content container - Notebook Style */
#photo-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin: 1rem 0;
    
    /* Notebook Paper Look */
    background-color: #fff;
    background-image: 
        linear-gradient(90deg, transparent 39px, #ff878d 39px, #ff878d 41px, transparent 41px),
        linear-gradient(#e1e1e1 .1em, transparent .1em);
    background-size: 100% 1.5em;
    padding: 2rem 1rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border-radius: 5px;
    position: relative;
    min-height: 300px;
}

/* Holes on the left */
#photo-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10px;
    height: 100%;
    width: 20px;
    background: radial-gradient(circle, #f0f0f0 20%, transparent 25%);
    background-size: 20px 30px;
    background-position: 0 10px;
}

/* Childhood Photo Styling */
.childhood-photo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 0;
    width: 100%;
    z-index: 1;
}

/* Photo Card - now just the photo wrapper */
.photo-card {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-radius: 0;
    padding: 8px;
    box-shadow: 2px 4px 8px rgba(0,0,0,0.2);
    border: 5px solid #fff; /* White border */
    margin-bottom: 1rem;
    animation: photoCardFadeIn 1s ease;
    max-width: 100%;
    transform: rotate(-3deg); /* Tilted photo */
    width: auto;
}

.childhood-photo {
    width: 100%;
    max-width: 220px; /* Smaller size */
    height: auto;
    display: block;
}

/* Photo Message - Caption container */
.photo-message {
    background: transparent; /* Remove card background */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-radius: 0;
    padding: 0.5rem;
    box-shadow: none;
    border: none;
    
    font-family: 'Courier New', Courier, monospace; /* Typewriter font */
    font-size: 1.2rem;
    color: #333;
    font-weight: 600;
    font-style: normal;
    text-align: center;
    line-height: 1.6;
    animation: messageFadeIn 1s ease 0.3s backwards;
    max-width: 90%;
    transform: rotate(1deg);
}

@keyframes photoCardFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.photo-caption {
    font-size: 1.1rem;
    color: #555;
    font-style: italic;
    text-align: center;
    line-height: 1.6;
    padding: 0 1rem;
    font-family: 'Varela Round', sans-serif;
}

@keyframes photoFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Keyframes */
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes stampPop { 0% { transform: scale(0) rotate(-45deg); opacity: 0; } 100% { transform: scale(1) rotate(0deg); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile Adjustments */
@media (max-width: 600px) {
    /* Login Screen */
    .login-box { 
        padding: 1.5rem; 
        width: 85%;
        max-width: 320px;
    }
    .login-title { font-size: 1.5rem; }
    .code-input { width: 100%; padding: 12px 20px; font-size: 1rem; }

    /* Envelope */
    .envelope { width: 240px; height: 160px; }
    .flap { border-left-width: 120px; border-right-width: 120px; border-top-width: 90px; }
    .pocket { border-left-width: 120px; border-right-width: 120px; border-bottom-width: 80px; }
    
    /* Main Card */
    #main-card { 
        padding: 1rem; 
        width: 92%; 
        max-width: 100%;
    }
    
    h1 { font-size: 1.6rem; margin-bottom: 0.2rem; }
    .subtitle { font-size: 0.85rem; margin-bottom: 1rem; }
    
    /* Message Box */
    .message-box {
        padding: 1.2rem;
        min-height: 150px;
        max-height: 50vh; /* Use viewport height to ensure it fits */
        margin: 1rem 0;
    }
    .message-text { font-size: 0.95rem; line-height: 1.5; }
    
    /* Notebook Photo Section */
    #photo-content {
        padding: 1.5rem 0.5rem;
        background-size: 100% 1.5rem; /* Match line-height */
        background-image: 
            linear-gradient(90deg, transparent 29px, #ff878d 29px, #ff878d 31px, transparent 31px),
            linear-gradient(#e1e1e1 .1em, transparent .1em);
        min-height: auto;
    }
    #photo-content::before {
        left: 5px;
        width: 15px;
        background-size: 15px 1.5rem; /* Match line-height */
    }
    
    .childhood-photo {
        max-width: 150px; /* Smaller photo for mobile */
    }
    
    .photo-message {
        font-size: 1rem;
        line-height: 1.5rem; /* Match background lines */
        padding: 0 0.5rem;
        max-width: 95%;
        background: transparent !important; /* Ensure lines show through */
        margin-top: 0.2rem; /* Fine tune alignment */
    }
    
    /* Buttons */
    .btn {
        padding: 10px 24px;
        font-size: 0.95rem;
        margin-top: 5px;
    }
    
    /* Dots */
    .dot { width: 6px; height: 6px; }
}

/* Message Form Styling */
.message-form-container {
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
}

.form-title {
    font-family: 'Pacifico', cursive;
    color: var(--text);
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 1.5rem;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.8);
}

.message-form {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 25px;
    padding: 2rem;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-input,
.form-textarea {
    padding: 15px 20px;
    border-radius: 15px;
    border: 2px solid #e0e0e0;
    font-family: 'Varela Round', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
    color: #555;
    background: rgba(255, 255, 255, 0.9);
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(255, 154, 158, 0.2);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-btn {
    margin-top: 0.5rem;
}

.form-status {
    text-align: center;
    margin-top: 1rem;
    padding: 12px;
    border-radius: 15px;
    font-weight: 600;
    animation: fadeIn 0.5s ease;
}

.form-status.success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 2px solid #10b981;
}

.form-status.error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 2px solid #ef4444;
}
