:root {
    --primary: #f7a8b8;
    --secondary: #e2c0e8;
    --accent: #ff8c94;
    --bg-color: #fff0f5;
    --text-color: #55424c;
    --font-heading: 'Dancing Script', cursive;
    --font-body: 'Quicksand', sans-serif;
    --font-numpad: 'Fredoka', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--bg-color), #ffe4e1);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Particles / Floating elements */
#particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.particle {
    position: absolute;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: floatUp linear infinite;
}

@keyframes floatUp {
    0% { transform: translateY(100vh) scale(0); opacity: 0; }
    20% { opacity: 0.8; }
    80% { opacity: 0.5; }
    100% { transform: translateY(-100px) scale(1); opacity: 0; }
}

#app {
    position: relative;
    width: 100%;
    height: 100vh;
    z-index: 1;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease, visibility 0.8s ease;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

.content-wrapper {
    width: 100%;
    max-width: 800px;
    text-align: center;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(247, 168, 184, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.6);
    margin: auto;
}

.title {
    font-family: var(--font-heading);
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.05);
}

/* Gift Box */
.giftbox {
    position: relative;
    width: 240px;
    height: 360px;
    margin: 20px auto 40px;
    perspective: 1000px;
    transition: filter 0.3s ease;
}

.giftbox:hover {
    filter: drop-shadow(0 0 20px rgba(247, 168, 184, 0.8));
}

.giftbox-body {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 300px;
    background: var(--primary);
    border-radius: 10px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.1), 0 10px 20px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 50px 15px 15px;
}

.giftbox-lid {
    position: absolute;
    top: 50px;
    left: -10px;
    width: 260px;
    height: 50px;
    background: var(--primary);
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1), 0 5px 15px rgba(0,0,0,0.2);
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.6s ease;
    z-index: 2;
    transform-origin: top center;
}

.ribbon-lid {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 100%;
    background: #fff;
}

.ribbon-bow {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 50px;
}

.ribbon-bow::before, .ribbon-bow::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    border: 10px solid #fff;
    border-radius: 50% 50% 0 50%;
    top: 0;
    left: 0;
    transform: rotate(45deg);
    box-sizing: border-box;
}

.ribbon-bow::after {
    left: auto;
    right: 0;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px) rotate(-2deg); }
    50% { transform: translateX(10px) rotate(2deg); }
    75% { transform: translateX(-10px) rotate(-2deg); }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

.open-animation .giftbox-lid {
    transform: translateY(-100px) rotateX(40deg) rotateZ(10deg);
    opacity: 0;
}

@keyframes boxExplode {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); filter: brightness(1.2) drop-shadow(0 0 30px rgba(247, 168, 184, 1)); }
    100% { transform: scale(1); }
}

.box-explode {
    animation: boxExplode 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Numpad Styles */
.numpad-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.numpad-display {
    width: 80%;
    height: 30px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 5px;
    color: var(--text-color);
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
    font-family: var(--font-numpad);
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
}

.num-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 8px;
    padding: 8px 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.1s, background 0.2s;
    font-family: var(--font-numpad);
}

.num-btn:active {
    transform: scale(0.95);
    background: var(--secondary);
}

.btn-clear {
    color: #ff4d4d;
}

.btn-enter {
    color: var(--accent);
}

/* Login Form Text */
.login-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.instruction-text {
    font-size: 1.1rem;
    font-weight: 500;
}

.error-msg {
    color: #ff4d4d;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 20px;
    margin-top: 5px;
}
/* General Buttons */
.btn {
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(247, 168, 184, 0.4);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(247, 168, 184, 0.6);
}

.btn:active {
    transform: translateY(1px);
}

/* Gallery - Screen 2 */
.gallery {
    column-count: 2;
    column-gap: 20px;
    margin-bottom: 30px;
}

.gallery-item {
    break-inside: avoid;
    margin-bottom: 20px;
    background: white;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    
    /* Scroll Animation */
    opacity: 0;
    transform: translateY(40px) scale(0.95);
    transition: opacity 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275), transform 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.gallery-item.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.gallery-item.visible:hover {
    transform: scale(1.02) rotate(-1deg);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    z-index: 10;
    position: relative;
}

.gallery-item img, .gallery-item video {
    width: 100%;
    border-radius: 8px;
    display: block;
}

.caption {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-top: 10px;
    color: var(--accent);
}

/* Chapter Styles */
.story-chapters {
    display: flex;
    flex-direction: column;
    gap: 50px;
    margin-top: 20px;
    margin-bottom: 40px;
}

.chapter {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(255, 255, 255, 0.5);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.03);
}

.chapter-title {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    color: var(--accent);
    text-align: left;
    margin-bottom: 5px;
    border-bottom: 2px dashed rgba(247, 168, 184, 0.5);
    padding-bottom: 10px;
}

.chapter-desc {
    font-size: 1.1rem;
    color: var(--text-color);
    text-align: left;
    margin-bottom: 20px;
    font-style: italic;
    opacity: 0.9;
}

.chapter-divider {
    width: 100%;
    height: 30px;
    background-image: url('data:image/svg+xml;utf8,<svg width="100" height="30" xmlns="http://www.w3.org/2000/svg"><path d="M0,15 Q25,0 50,15 T100,15" fill="none" stroke="%23f7a8b8" stroke-width="2"/></svg>');
    background-repeat: repeat-x;
    opacity: 0.6;
    margin: -10px 0;
}

@media (max-width: 600px) {
    .gallery {
        column-count: 1;
    }
    
    .title {
        font-size: 2rem;
    }

    .chapter-title {
        font-size: 1.8rem;
    }

    .content-wrapper {
        padding: 20px;
    }

    .giftbox-lid {
        width: 260px;
        left: -10px;
    }

    .cake-container {
        transform: scale(0.8);
    }

    .glass-card {
        padding: 30px 20px;
        width: 95%;
    }

    .letter h3 {
        font-size: 1.8rem;
    }
}

/* Desktop & Large Screen Responsiveness */
@media (min-width: 768px) {
    .content-wrapper {
        max-width: 900px;
    }
    
    .chapter {
        padding: 40px;
    }
}

@media (min-width: 1200px) {
    .content-wrapper {
        max-width: 1200px;
    }
    
    .gallery {
        column-count: 3;
        column-gap: 20px;
    }
}

/* Screen 3 - Cake & Letter */
#screen3 {
    transition: background-color 1s ease;
}

.dark-mode {
    background-color: #1a1a2e !important;
}

.cake-wrapper {
    transition: opacity 1s, background-color 1s, box-shadow 1s, border-color 1s;
    z-index: 2;
}

.dark-mode .cake-wrapper {
    background: rgba(26, 26, 46, 0.6);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.dark-mode .title, .dark-mode .instruction {
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.cake-container {
    position: relative;
    height: 250px;
    width: 200px;
    margin: 40px auto;
}

.cake {
    position: absolute;
    bottom: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.layer {
    width: 100%;
    background: #ffb6b9;
    border-radius: 10px;
    position: relative;
    box-shadow: inset 0 -10px 0 rgba(0,0,0,0.1);
}

.layer-bottom { height: 60px; width: 180px; }
.layer-middle { height: 50px; width: 150px; }
.layer-top { height: 40px; width: 120px; }

.icing {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 15px;
    background: #fff;
    border-radius: 10px 10px 0 0;
}

.icing::after {
    content: '';
    position: absolute;
    top: 15px;
    left: 10px;
    width: 15px;
    height: 20px;
    background: #fff;
    border-radius: 0 0 10px 10px;
    box-shadow: 30px 5px 0 #fff, 60px -5px 0 #fff, 90px 8px 0 #fff;
}

.candle {
    width: 10px;
    height: 40px;
    background: repeating-linear-gradient(45deg, #fff, #fff 5px, var(--accent) 5px, var(--accent) 10px);
    position: relative;
    border-radius: 5px;
    margin-bottom: -5px;
    z-index: 10;
}

.flame {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    width: 15px;
    height: 25px;
    background: #fdd835;
    border-radius: 50% 50% 20% 20%;
    box-shadow: 0 0 20px #ffeb3b, 0 0 40px #ff9800;
    animation: flicker 0.1s infinite alternate;
    transition: opacity 0.5s, transform 0.5s;
}

@keyframes flicker {
    0% { transform: translateX(-50%) scale(1); opacity: 0.9; }
    100% { transform: translateX(-50%) scale(1.1); opacity: 1; box-shadow: 0 0 25px #ffeb3b, 0 0 50px #ff9800; }
}

.flame.blown-out {
    opacity: 0;
    transform: translateX(-50%) scale(0);
    animation: none;
}

.plate {
    width: 220px;
    height: 10px;
    background: #dcdde1;
    border-radius: 50px;
    margin-top: -5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.instruction {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--text-color);
}

.mic-status {
    font-size: 0.8rem;
    color: #888;
    margin-top: 10px;
    font-style: italic;
}

.dark-mode .mic-status {
    color: #ccc;
}

/* Letter */
.letter-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(100vh);
    width: 90%;
    max-width: 500px;
    z-index: 100;
    opacity: 0;
    transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 1s;
    pointer-events: none;
}

.letter-container.show {
    transform: translate(-50%, -50%) translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.glass-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 40px 30px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    font-family: var(--font-body);
    font-size: 1.1rem;
    line-height: 1.6;
    text-align: center;
    position: relative;
    color: var(--text-color);
}

.letter-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.avatar-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
    box-shadow: 0 5px 15px rgba(247, 168, 184, 0.4);
    margin-bottom: 15px;
}

.letter h3 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    color: var(--accent);
    line-height: 1.2;
    margin: 0;
}

.letter h3 .date {
    font-size: 1.2rem;
    font-family: var(--font-body);
    color: var(--text-color);
    opacity: 0.8;
}

.letter-body {
    margin-bottom: 25px;
}

.letter p {
    margin-bottom: 12px;
}

/* CTA Buttons */
.cta-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    margin-top: 30px;
}

.btn-cta {
    width: 100%;
    max-width: 250px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
    box-shadow: none;
}

.btn-secondary:hover {
    background: rgba(247, 168, 184, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(247, 168, 184, 0.2);
}


