:root {
    --primary: #FFC0CB; /* Pink */
    --secondary: #FEFCAC; /* YELLOW */
    --bg-gradient: linear-gradient(180deg, var(--secondary) 0%, var(--primary) 100%);
    --envelope-color: #ff6f91;
    --envelope-flap: #ff8fa3;
    --envelope-body: #ff5c82;
    --text-color: #555;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-gradient);
    overflow: hidden;
    touch-action: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Background Gallery Styling --- */
#gallery-bg {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    display: flex; gap: 20px; padding: 0 10px;
    justify-content: center; pointer-events: none; overflow: hidden;
    background: var(--secondary);
    opacity: 0; transition: opacity 3s ease;
}
#gallery-bg.fade-in { opacity: 0.25; }

/* Brighter background (minimized state) */
body.admire-mode #gallery-bg {
    opacity: 1 !important; /* Full visibility for background */
    filter: blur(0px); 
    transition: opacity 1s ease;
}

.gallery-col { flex: 1; display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.col-track { 
    display: flex; flex-direction: column; gap: 20px; 
    animation: scroll-vertical 0s linear infinite; 
}

.gallery-col:nth-child(2) .col-track { transform: translateY(-20%); }

.gallery-img { width: 100%; border-radius: 10px; object-fit: cover; box-shadow: 0 4px 6px rgba(0,0,0,0.1); filter: grayscale(0%); }

@keyframes scroll-vertical { 
    0% { transform: translateY(-50%); } 
    100% { transform: translateY(0%); } 
}

@media (max-width: 768px) { #gallery-bg { gap: 10px; } }

/* --- Login Screen --- */
#login-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: transparent;
    display: flex; justify-content: center; align-items: center;
    z-index: 100; transition: opacity 0.5s ease;
}
.login-container {
    background: rgba(255, 255, 255, 0.95); padding: 3rem; border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); text-align: center;
    animation: pulse-glow 3s infinite ease-in-out;
}
@keyframes pulse-glow {
    0% { box-shadow: 0 0 0 0 rgba(254, 252, 172, 0.6); }
    50% { box-shadow: 0 0 30px 15px rgba(254, 252, 172, 0.2); }
    100% { box-shadow: 0 0 0 0 rgba(254, 252, 172, 0); }
}

input {
    padding: 12px; border: 2px solid var(--primary); border-radius: 8px; margin: 15px 0;
    outline: none; font-size: 1.1rem; text-align: center; letter-spacing: 3px; width: 100%;
    transition: border-color 0.3s;
    animation: pulse-glow 3s infinite ease-in-out;
}

input:focus { border-color: #ff5c82; }
.hint-text { font-size: 0.9rem; color: #888; font-style: italic; margin-bottom: 15px; opacity: 0; transition: opacity 0.3s ease; height: 1.2rem; }
button {
    padding: 10px 30px; background-color: var(--primary); color: white;
    border: none; border-radius: 8px; cursor: pointer; font-size: 1rem;
    transition: transform 0.2s, background 0.3s;
}
button:hover { background-color: #ff9fb0; transform: scale(1.05); }
.shake { animation: shake 0.5s; }
@keyframes shake { 0% { transform: translateX(0); } 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-5px); } 100% { transform: translateX(0); } }

/* --- Main Content --- */
.hidden { display: none !important; }
#main-content {
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    width: 100%; height: 100vh;
    gap: 30px;
}

/* --- Envelope --- */
.envelope-container { 
    cursor: pointer; 
    position: relative; 
    z-index: 2; 
    /* Standard transitions for hover effects, etc. */
    transition: transform 0.3s ease, opacity 1s ease; 
}

/* --- Minimized State (Just Fade Out) --- */
.envelope-container.minimized {
    opacity: 0 !important;
    pointer-events: none !important; /* Click through to background */
}

/* Toggle Button */
#visibility-btn {
    z-index: 6000;
}

.envelope-container:not(.open) { animation: wiggle-hint 4s ease-in-out infinite; }
.envelope-container:not(.open):hover { transform: scale(1.02); animation-play-state: paused; }
@keyframes wiggle-hint {
    0%, 100% { transform: rotate(0deg); }
    5% { transform: rotate(2deg); }
    10% { transform: rotate(-2deg); }
    15% { transform: rotate(2deg); }
    20% { transform: rotate(0deg); }
}

.envelope {
    position: relative; width: 300px; height: 200px;
    background-color: var(--envelope-color);
    border-radius: 0 0 10px 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.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 0.4s; z-index: 4;
}
.body {
    position: absolute; bottom: 0; left: 0; width: 0; height: 0;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-bottom: 120px solid var(--envelope-body);
    z-index: 3; border-radius: 0 0 10px 10px;
}
.open .flap { transform: rotateX(180deg); z-index: 1; }

/* --- Letter System --- */
.letter {
    position: absolute; top: 10px; left: 15px;
    width: 270px; height: 180px; 
    perspective: 1000px; z-index: 1;
    /* Transition for normal operations */
    transition: transform 0.8s ease, z-index 0s linear, width 0.8s ease, height 0.8s ease;
}

.letter-inner {
    position: relative; width: 100%; height: 100%;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.letter-front, .letter-back {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    background-color: var(--secondary);
    border-radius: 5px;
    padding: 20px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    
    transform: translateZ(0); 
}

.letter h1, .letter p {
    transform: translateZ(0); 
    backface-visibility: visible; 
}

.letter-front {
    z-index: 2;
    transform: rotateY(0deg);
}

.letter-front h1, .letter-front p, .letter-front .signature {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.letter.full-size .letter-front h1, 
.letter.full-size .letter-front p, 
.letter.full-size .letter-front .signature {
    opacity: 1;
    transition-delay: 0.2s; 
}

.letter-back {
    transform: rotateY(180deg);
    z-index: 1;
    border: 2px solid white;
}

.letter p {
    font-size: 1rem; color: var(--text-color);
    white-space: pre-wrap; line-height: 1.5;
    margin: 10px 0;
}
.letter h1 { font-size: 1.5rem; color: var(--envelope-body); margin-bottom: 5px; }

.open .letter {
    transform: translateY(-100px);
    z-index: 10; cursor: grab;
}

.letter.flipped .letter-inner {
    transform: rotateY(180deg);
}

.letter.full-size {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    
    height: 60vh;
    max-height: 600px;
    width: 90vw;
    max-width: 400px;
    margin: 0;
    
    z-index: 4000 !important; 

    /* Opening Transition (With Delay) */
    transition: transform 0.8s ease 1s, z-index 0s linear 1s, width 0.8s ease 1s, height 0.8s ease 1s;
}

.letter.full-size .letter-front {
    position: absolute;
    height: 100%;
    overflow-y: auto;
    justify-content: flex-start;
    padding-top: 30px;
}

.letter.full-size .letter-back h1 {
    white-space: nowrap; 
    font-size: min(2.5rem, 7vw); 
    margin-bottom: 20px;
}
.letter.full-size .letter-back p { font-size: 1.5rem; }
.letter.full-size .letter-back .heart-decoration { font-size: 5rem; margin-top: 30px; }

.letter-front::-webkit-scrollbar { width: 5px; }
.letter-front::-webkit-scrollbar-thumb { background: #ff8fa3; border-radius: 10px; }
.letter-front::-webkit-scrollbar-track { background: transparent; }

.letter.full-size .letter-back { height: 100%; }

/* --- Response Buttons (Yes / No) --- */
.response-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex; gap: 20px;
    opacity: 0; 
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 2500; 
}

.response-container.visible {
    opacity: 1;
    pointer-events: auto;
}

.response-btn {
    padding: 15px 30px;
    border-radius: 50px;
    border: none;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.2s, background 0.3s, opacity 1s ease;
}

.response-btn.yes { background-color: white; color: var(--envelope-body); }
.response-btn.yes:hover { background-color: var(--secondary); transform: scale(1.1); }
.response-btn.no { background-color: #ffcccb; color: white; }

/* --- Gift Button --- */
.gift-btn {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translate(-50%, 20px);
    display: flex; align-items: center; justify-content: center; gap: 8px;
    white-space: nowrap;
    text-decoration: none;
    background-color: white; color: var(--envelope-body);
    padding: 15px 30px; border-radius: 50px;
    font-weight: bold;
    font-size: clamp(0.9rem, 4vw, 1.1rem);
    width: auto; max-width: 90vw;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    opacity: 0; pointer-events: none;
    z-index: 1000; 
}

.gift-btn.visible { 
    opacity: 1; pointer-events: auto; transform: translate(-50%, 0); 
}

.gift-btn:hover { 
    background-color: var(--secondary); transform: translate(-50%, -5px);
}

/* Icons */
.flip-hint { 
    position: relative; bottom: auto; right: auto;
    margin-top: auto; align-self: flex-end; 
    padding-top: 20px; padding-right: 10px;
    font-size: 1.5rem; color: #aaa; animation: wiggle 2s infinite; 
    flex-shrink: 0; 
}

.heart-decoration { font-size: 3rem; color: #ff5c82; margin-top: 10px; animation: heartbeat 1.5s infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(0deg); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
@keyframes heartbeat { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }

/* --- Visibility Toggle Button --- */
.icon-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 6000;
    transition: transform 0.2s, background 0.3s, opacity 0.5s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    
    opacity: 0;
    pointer-events: none;
}

.icon-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.icon-btn:hover {
    transform: scale(1.1);
    background-color: var(--secondary);
}

body.admire-mode .response-container,
body.admire-mode .gift-btn,
body.admire-mode #no-btn {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.5s ease;
}