* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.screen {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.5s ease-in-out;
}

.hidden {
    display: none !important;
    opacity: 0;
}

.scrollable {
    overflow-y: auto;
}

/* Background Variations */
.dynamic-bg-dark {
    background-color: #9c1c26;
    color: white;
}

.dynamic-bg-light {
    background-color: #f7d6d8;
    color: #4a0e17;
}

/* --- SCREEN 1: PASSCODE --- */
.passcode-container {
    display: flex;
    gap: 40px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    padding: 20px;
}

.polaroid {
    background: white;
    padding: 15px 15px 30px 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    transform: rotate(-3deg);
    text-align: center;
}

.polaroid img {
    width: 220px;
    height: 220px;
    object-fit: cover;
}

.polaroid-text {
    color: #333;
    font-weight: bold;
    margin-top: 15px;
    font-size: 18px;
}

.keypad-box {
    text-align: center;
}

#passcode-display {
    background: rgba(0,0,0,0.2);
    font-size: 24px;
    padding: 10px;
    letter-spacing: 5px;
    border-radius: 5px;
    margin: 15px 0;
    min-width: 200px;
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 70px);
    gap: 10px;
    justify-content: center;
}

.keypad button {
    height: 70px;
    border-radius: 50%;
    border: 2px solid white;
    background: transparent;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: 0.2s;
}

.keypad button:active {
    background: white;
    color: #9c1c26;
}

/* --- SCREEN 2: LOADING --- */
.loading-container {
    text-align: center;
}

.progress-bar {
    width: 250px;
    height: 15px;
    background: #e0b6b9;
    border-radius: 10px;
    overflow: hidden;
    margin: 20px auto;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: #9c1c26;
    animation: fillProgress 3s forwards;
}

.cake-emoji {
    font-size: 30px;
    display: inline-block;
    animation: bounce 1s infinite alternate;
}

@keyframes fillProgress {
    to { width: 100%; }
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

/* --- SCREEN 3: ENVELOPE --- */
.envelope-wrapper {
    cursor: pointer;
}

.envelope {
    position: relative;
    width: 280px;
    height: 180px;
    background: #d95363;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.flap {
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    border-left: 140px solid transparent;
    border-right: 140px solid transparent;
    border-top: 100px solid #bd3a4a;
    transform-origin: top;
    transition: transform 0.4s ease;
    z-index: 3;
}

.pocket {
    position: absolute;
    bottom: 0;
    width: 0;
    height: 0;
    border-left: 140px solid #e36473;
    border-right: 140px solid #e36473;
    border-bottom: 90px solid #d44657;
    border-top: 90px solid transparent;
    border-radius: 10px;
    z-index: 2;
}

.letter {
    position: absolute;
    bottom: 10px;
    left: 20px;
    width: 240px;
    height: 140px;
    background: white;
    padding: 20px;
    text-align: center;
    transition: transform 0.5s ease;
    z-index: 1;
}

/* --- SCREEN 4: GALLERY & LETTER --- */
.gallery-container {
    max-width: 900px;
    padding: 40px 20px;
    margin: auto;
    text-align: center;
}

.main-title {
    margin-bottom: 20px;
}

.gallery-layout {
    display: flex;
    gap: 30px;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.text-letter {
    flex: 1;
    min-width: 280px;
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: left;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.text-letter p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.next-btn {
    background: #9c1c26;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    margin-top: 10px;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.photo-grid img {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: 10px;
    border: 4px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* --- SCREEN 5: CAKE & FIREWORKS --- */
#fireworksCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.cake-container {
    text-align: center;
    z-index: 2;
}

.cake {
    width: 200px;
    height: 120px;
    background: #f4b2b7;
    position: relative;
    margin: 60px auto;
    border-radius: 10px;
    cursor: pointer;
}

.cake-base {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 40px;
    background: #e28f95;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
}

.frosting {
    position: absolute;
    top: 0;
    width: 100%;
    height: 25px;
    background: white;
    border-radius: 10px 10px 0 0;
}

.candles {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 25px;
}

.candle-stick {
    width: 8px;
    height: 30px;
    background: linear-gradient(to bottom, #ffc107, #ff5722);
    position: relative;
}

.candle-stick::before {
    content: '';
    position: absolute;
    top: -12px;
    left: -1px;
    width: 10px;
    height: 14px;
    background: #ffeb3b;
    border-radius: 50% 50% 20% 20%;
    box-shadow: 0 0 10px #ffeb3b;
    animation: flicker 0.5s infinite alternate;
}

.candles.blown .candle-stick::before {
    display: none;
}

@keyframes flicker {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}