:root {
    --bg-color-1: #ffd1ff;
    --bg-color-2: #fad0c4;
    --envelope-color: #fce3e3;
    --envelope-pocket: #f8c9c9;
    --envelope-flap: #f3a9a9;
    --letter-bg: #fffcfc;
    --text-color: #555;
    --primary-color: #ff6b81;
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, var(--bg-color-1) 0%, var(--bg-color-2) 100%);
    overflow: hidden;
}

/* Glassmorphism Login */
#login-container {
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px 0 rgba(255, 107, 129, 0.15);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 40px;
    width: 320px;
    text-align: center;
    transition: opacity 0.5s ease, transform 0.5s ease;
    z-index: 10;
}

#login-container h2 {
    margin-top: 0;
    font-family: 'Dancing Script', cursive;
    font-size: 3rem;
    color: var(--primary-color);
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
    margin-bottom: 25px;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #444;
    font-weight: 600;
    font-size: 0.95rem;
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    outline: none;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    box-sizing: border-box;
    transition: all 0.3s ease;
    color: #333;
}

.input-group input:focus {
    background: rgba(255, 255, 255, 1);
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(255, 107, 129, 0.2);
}

.input-group input[readonly] {
    color: #666;
    background: rgba(255, 255, 255, 0.5);
}

.error-msg {
    color: #e74c3c;
    font-size: 0.9rem;
    margin-top: 8px;
    display: none;
    font-weight: 500;
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

button {
    background: linear-gradient(45deg, #ff6b81, #ff4757);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    box-shadow: 0 4px 15px rgba(255, 107, 129, 0.4);
    margin-top: 10px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 129, 0.6);
}

.hidden {
    display: none !important;
}

/* Envelope & Letter */
#letter-container {
    perspective: 1000px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.envelope-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.envelope {
    position: relative;
    width: 360px;
    height: 240px;
    background-color: var(--envelope-color);
    border-radius: 8px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: center;
    transition: transform 0.5s ease;
}

/* Front Pocket */
.pocket {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: var(--envelope-pocket);
    clip-path: polygon(0 100%, 0 0, 50% 55%, 100% 0, 100% 100%);
    z-index: 3;
    border-radius: 0 0 8px 8px;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.02);
}

/* Flap */
.flap {
    position: absolute;
    top: 0;
    width: 100%;
    height: 60%;
    background-color: var(--envelope-flap);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    transform-origin: top;
    transition: transform 0.6s 0.2s ease, z-index 0s 0.5s;
    z-index: 4;
}

/* The letter inside */
.letter {
    position: absolute;
    bottom: 0;
    width: 90%;
    height: 95%;
    background: var(--letter-bg);
    z-index: 2;
    transition: transform 0.8s 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275), height 0.8s 0.6s ease;
    border-radius: 8px;
    padding: 30px;
    box-sizing: border-box;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.letter-content {
    opacity: 0;
    transition: opacity 0.5s 1.2s ease;
    text-align: center;
}

.letter-content h3 {
    font-family: 'Dancing Script', cursive;
    color: var(--primary-color);
    font-size: 2.2rem;
    margin-top: 0;
    margin-bottom: 20px;
}

.letter-content p {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-color);
    margin-bottom: 15px;
}

.letter-content .signature {
    font-family: 'Dancing Script', cursive;
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-top: 30px;
    margin-bottom: 0;
}

.open-btn {
    position: absolute;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    min-width: 160px;
    z-index: 5;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.open-btn:hover {
    transform: translateX(-50%) translateY(-2px);
}

/* Open state classes */
.envelope.open .flap {
    transform: rotateX(180deg);
    z-index: 1; /* drops behind letter */
}

.envelope.open .letter {
    transform: translateY(-130px) scale(1.1);
    height: 130%; /* taller letter when popped out */
    z-index: 5; /* comes in front of pocket */
    box-shadow: 0 15px 40px rgba(0,0,0,0.1);
}

.envelope.open .letter-content {
    opacity: 1;
}

.envelope-wrapper.open .open-btn {
    opacity: 0;
    pointer-events: none;
}
