/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Bitcount Ink", system-ui;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings:
        "slnt" 0,
        "CRSV" 0.5,
        "ELSH" 0,
        "ELXP" 0,
        "SZP1" 0,
        "SZP2" 0,
        "XPN1" 0,
        "XPN2" 0,
        "YPN1" 0,
        "YPN2" 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #f5576c 75%, #4facfe 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    overflow-x: hidden;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Bitcount Ink Font */
.bitcount-ink {
    font-family: "Bitcount Ink", system-ui;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings:
        "slnt" 0,
        "CRSV" 0.5,
        "ELSH" 0,
        "ELXP" 0,
        "SZP1" 0,
        "SZP2" 0,
        "XPN1" 0,
        "XPN2" 0,
        "YPN1" 0,
        "YPN2" 0;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    25% { background-position: 100% 50%; }
    50% { background-position: 50% 100%; }
    75% { background-position: 0% 100%; }
    100% { background-position: 0% 50%; }
}

.launch-container {
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: min(20px, 3vw);
    padding-top: 80px; /* Space for crown */
    position: relative;
    overflow-y: auto;
    box-sizing: border-box;
    max-width: 1200px;
    margin: 0 auto;
}

/* Sound Control Button */
.sound-control-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-family: "Bitcount Ink", system-ui;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings:
        "slnt" 0,
        "CRSV" 0.5,
        "ELSH" 0,
        "ELXP" 0,
        "SZP1" 0,
        "SZP2" 0,
        "XPN1" 0,
        "XPN2" 0,
        "YPN1" 0,
        "YPN2" 0;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
    user-select: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.sound-control-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.sound-control-btn:active {
    transform: scale(0.95);
}

.sound-control-btn.playing {
    background: rgba(76, 175, 80, 0.9);
    border-color: rgba(76, 175, 80, 0.9);
    color: white;
}

.sound-control-btn.muted {
    background: rgba(244, 67, 54, 0.9);
    border-color: rgba(244, 67, 54, 0.9);
    color: white;
}

/* Postcard Design with Rainbow Border */
.postcard {
    width: 80%;
    max-width: min(600px, 80vw);
    min-width: 450px;
    aspect-ratio: 4/3;
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 20px;
    backdrop-filter: blur(15px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: min(40px, 5vw) min(30px, 4vw);
    position: relative;
    overflow: visible;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

/* Content area with side-by-side layout */
.postcard-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 20px;
    margin-bottom: 20px; /* Reduce gap to button */
}

.postcard-left {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.postcard-right {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.postcard:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow:
        0 0 0 2px #ff0000,
        0 0 0 4px #ff8000,
        0 0 0 6px #ffff00,
        0 0 0 8px #00ff00,
        0 0 0 10px #0080ff,
        0 0 0 12px #4000ff,
        0 0 0 14px #8000ff,
        0 35px 70px rgba(0, 0, 0, 0.2);
    animation: rainbowPulse 2s ease-in-out infinite;
}

@keyframes rainbowPulse {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.1);
    }
}

.postcard-gif {
    width: 100%;
    max-width: 200px;
    height: auto;
    object-fit: contain;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
}

.postcard-gif:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

/* Pixelated Text Effect */
.pixel-text {
    font-family: "Bitcount Ink", system-ui;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings:
        "slnt" 0,
        "CRSV" 0.5,
        "ELSH" 0,
        "ELXP" 0,
        "SZP1" 0,
        "SZP2" 0,
        "XPN1" 0,
        "XPN2" 0,
        "YPN1" 0,
        "YPN2" 0;
    font-size: clamp(36px, 8vw, 80px);
    color: #000;
    text-align: center;
    line-height: 1.2;
    margin-bottom: clamp(10px, 2vw, 20px);
    position: relative;
    z-index: 2;
    cursor: default;
    user-select: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.pixel-char {
    display: inline-block;
    transition: color 0.2s ease;
    padding: 1px;
}

.pixel-char:hover {
    color: #e91e63 !important;
    text-shadow: 0 0 5px rgba(233, 30, 99, 0.5);
}

/* 3D Crown Container - positioned on main container border */
.crown-container {
    width: clamp(100px, 15vw, 160px);
    height: clamp(70px, 10vw, 100px);
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    pointer-events: none;
}

#crownCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.celebrate-btn {
    background: linear-gradient(45deg, #e74c3c, #f39c12, #e67e22);
    background-size: 200% 200%;
    color: white;
    border: none;
    padding: 15px 40px;
    font-family: "Bitcount Ink", system-ui;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings:
        "slnt" 0,
        "CRSV" 0.5,
        "ELSH" 0,
        "ELXP" 0,
        "SZP1" 0,
        "SZP2" 0,
        "XPN1" 0,
        "XPN2" 0,
        "YPN1" 0,
        "YPN2" 0;
    font-size: 1.2em;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(231, 76, 60, 0.3);
    animation: buttonGlow 3s ease-in-out infinite;
    width: 100%;
    max-width: 280px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

@keyframes buttonGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.celebrate-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(231, 76, 60, 0.4);
}

.celebrate-btn:active {
    transform: translateY(-1px) scale(1.02);
}

/* Floating Decorations */
.floating-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.decoration {
    position: absolute;
    font-family: "Bitcount Ink", system-ui;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings:
        "slnt" 0,
        "CRSV" 0.5,
        "ELSH" 0,
        "ELXP" 0,
        "SZP1" 0,
        "SZP2" 0,
        "XPN1" 0,
        "XPN2" 0,
        "YPN1" 0,
        "YPN2" 0;
    font-size: 2em;
    opacity: 0.6;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.balloon-1 {
    top: 10%;
    left: 10%;
    animation: float1 6s ease-in-out infinite;
}

.balloon-2 {
    top: 20%;
    right: 15%;
    animation: float2 8s ease-in-out infinite;
}

.star-1 {
    top: 60%;
    left: 5%;
    animation: twinkle 4s ease-in-out infinite;
}

.star-2 {
    top: 70%;
    right: 10%;
    animation: twinkle 3s ease-in-out infinite 1s;
}

.cake-1 {
    top: 40%;
    left: 85%;
    animation: float1 7s ease-in-out infinite 2s;
}

.gift-1 {
    bottom: 20%;
    left: 15%;
    animation: bounce 5s ease-in-out infinite;
}

@keyframes float1 {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
}

@keyframes float2 {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-30px) rotate(-180deg); }
}

@keyframes twinkle {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Large Screen Optimization */
@media (min-width: 800px) {
    .postcard {
        width: 700px;
        max-width: 700px;
        padding: 45px 35px;
    }

    .pixel-text {
        font-size: 48px;
    }

    .postcard-gif {
        max-width: 280px;
    }

    .celebrate-btn {
        font-size: 1.1em;
        padding: 16px 45px;
        max-width: 320px;
    }
}

/* Enhanced Responsive Design */
@media (max-height: 600px) {
    .launch-container {
        justify-content: flex-start;
        padding-top: min(10px, 2vh);
        padding-bottom: min(10px, 2vh);
    }

    .postcard {
        width: 85%;
        height: auto;
        min-height: 80vh;
        max-height: 95vh;
        padding: min(20px, 3vh) min(15px, 3vw);
    }
}

@media (max-width: 768px) {
    .launch-container {
        padding: min(15px, 2vw);
    }

    .postcard {
        width: 90%;
        padding: min(25px, 4vw) min(20px, 3vw);
    }
}

@media (max-width: 480px) {
    .launch-container {
        padding: 15px;
        justify-content: center;
        padding-top: 100px; /* More space for crown */
        padding-bottom: 20px;
    }

    .postcard {
        width: 95%;
        min-width: 280px;
        padding: 25px 20px;
        aspect-ratio: auto; /* Remove fixed aspect ratio */
        min-height: auto;
    }

    .postcard-content {
        flex-direction: column;
        gap: 20px;
        margin-bottom: 25px; /* Reduce gap to button */
    }

    .pixel-text {
        font-size: clamp(32px, 7vw, 48px);
        margin-bottom: 0;
    }

    .postcard-gif {
        max-width: 200px; /* Larger GIF */
        width: 80%;
    }

    .crown-container {
        width: clamp(80px, 20vw, 120px);
        height: clamp(60px, 15vw, 90px);
        top: 15px;
    }
}

@media (max-width: 320px) {
    .postcard {
        width: 98%;
        min-width: 240px;
        padding: 15px 10px;
    }

    .celebrate-btn {
        min-width: 180px;
        font-size: clamp(0.9em, 3vw, 1.1em);
    }
}

/* Handle very small heights */
@media (max-height: 500px) {
    .launch-container {
        min-height: auto;
        height: auto;
        padding: 5px;
    }

    .postcard {
        min-height: 95vh;
        max-height: none;
        overflow-y: auto;
    }
}