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

body {
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    background: #000;
}

#app {
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* Morse Code Quiz Page */
.morse-quiz {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #1a1a1a;
    color: #fff;
}

.morse-quiz h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: #ff6b6b;
}

.morse-quiz .question {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    padding: 0 2rem;
    position: relative;
}

.morse-quiz .hint-icon {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s;
    vertical-align: middle;
}

.morse-quiz .hint-icon:hover {
    opacity: 1;
    transform: scale(1.2) rotate(15deg);
}

.morse-quiz .hint-box {
    background: rgba(255, 215, 0, 0.1);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    max-width: 500px;
    backdrop-filter: blur(10px);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.4s ease;
    transform: translateY(-10px);
}

.morse-quiz .hint-box.visible {
    max-height: 200px;
    opacity: 1;
    transform: translateY(0);
}

.morse-quiz .hint-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 0.5rem;
}

.morse-quiz .hint-content {
    font-size: 0.95rem;
    color: #fff;
    opacity: 0.9;
}

.morse-quiz .device-hint {
    margin-top: 2rem;
    font-size: 0.9rem;
    color: #64b5f6;
    opacity: 0.8;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.morse-quiz input {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    border: 2px solid #ff6b6b;
    background: transparent;
    color: #fff;
    border-radius: 10px;
    margin-bottom: 1rem;
    text-align: center;
    min-width: 300px;
}

.morse-quiz button {
    padding: 1rem 3rem;
    font-size: 1.2rem;
    background: #ff6b6b;
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.morse-quiz button:hover {
    background: #ff5252;
    transform: scale(1.05);
}

.morse-quiz .error {
    color: #ff6b6b;
    margin-top: 1rem;
    font-size: 1rem;
}

/* Countdown Page */
.countdown-page {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #fff;
    color: #000;
}

.countdown-page h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
}

.countdown-display {
    display: flex;
    gap: 2rem;
    font-size: 2rem;
}

.countdown-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.countdown-unit .value {
    font-size: 4rem;
    font-weight: bold;
    min-width: 100px;
    text-align: center;
}

.countdown-unit .label {
    font-size: 1rem;
    text-transform: uppercase;
    margin-top: 0.5rem;
}

/* Main Page */
.main-page {
    width: 100%;
    height: 100%;
    position: relative;
    background: linear-gradient(180deg, #0a1929 0%, #1a237e 100%);
    overflow: hidden;
}

#canvas-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

#canvas-container canvas {
    display: block;
    touch-action: none; /* Prevent default touch actions like double-tap zoom */
}

/* UI Overlay */
.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.ui-overlay > * {
    pointer-events: auto;
}

.instructions {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 1rem 2rem;
    border-radius: 15px;
    color: #ffd700;
    text-align: center;
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
}

.instructions p {
    margin: 0.3rem 0;
}

/* Heart Button */
.heart-button {
    position: absolute;
    top: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #ff1744 0%, #ff6b9d 100%);
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(255, 23, 68, 0.6);
    animation: heartbeat 1.5s infinite;
    /* Ensure visibility on mobile */
    -webkit-tap-highlight-color: transparent;
}

.heart-button:hover {
    transform: scale(1.2);
    box-shadow: 0 6px 30px rgba(255, 23, 68, 0.8);
}

.heart-button:active {
    transform: scale(1.1);
}

/* Music Toggle Button */
.music-toggle {
    position: absolute;
    top: 2rem;
    left: 2rem;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.6);
    -webkit-tap-highlight-color: transparent;
}

.music-toggle:hover {
    transform: scale(1.2);
    box-shadow: 0 6px 30px rgba(255, 215, 0, 0.8);
}

.music-toggle:active {
    transform: scale(1.1);
}

.music-toggle.playing {
    animation: musicPulse 1s ease-in-out infinite;
}

@keyframes musicPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(255, 215, 0, 0.6);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 30px rgba(255, 215, 0, 0.9);
    }
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Message Popup */
.message-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.message-popup.show {
    display: flex;
}

.message-content {
    background: linear-gradient(135deg, #fef9f3 0%, #fdf5eb 50%, #fff8f0 100%);
    padding: 3rem 3.5rem;
    border-radius: 15px;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    text-align: left;
    position: relative;
    animation: popupAppear 0.5s ease-out;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    border: 2px solid #d4af37;
}

/* Letter texture background */
.message-content.letter-style {
    background:
        linear-gradient(135deg, rgba(212, 175, 55, 0.05) 0%, rgba(255, 215, 0, 0.08) 100%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 1.2rem,
            rgba(200, 180, 150, 0.1) 1.2rem,
            rgba(200, 180, 150, 0.1) 1.3rem
        ),
        #fef9f3;
}

@keyframes popupAppear {
    from {
        transform: scale(0.5) rotate(-2deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Letter Header */
.letter-header {
    margin-bottom: 2rem;
    border-bottom: 2px solid #d4af37;
    padding-bottom: 1rem;
}

.letter-header .dear {
    color: #8b4513;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.letter-header .greeting {
    color: #c41e3a;
    font-size: 2rem;
    margin: 0;
    font-weight: bold;
    text-align: center;
}

/* Letter Body */
.letter-body {
    color: #2c2416;
    font-size: 1.05rem;
    line-height: 1.9;
}

.letter-body p {
    margin: 0.7rem 0;
    color: #2c2416;
}

.letter-body .space-top {
    margin-top: 1.5rem;
}

/* Highlights */
.highlight {
    background: linear-gradient(120deg, #ffd700 0%, #ffed4e 100%);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: bold;
    color: #8b0000;
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.3);
}

.highlight-wish {
    background: linear-gradient(120deg, #ff6b9d 0%, #ffc1e3 100%);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: bold;
    color: #8b0000;
    box-shadow: 0 2px 4px rgba(255, 107, 157, 0.3);
}

.place {
    color: #1e90ff;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(30, 144, 255, 0.3);
}

.travel-list {
    font-style: italic;
    padding-left: 1rem;
}

.meaning {
    font-weight: 600;
    color: #c41e3a;
    font-style: italic;
    text-align: center;
    margin: 1rem 0 !important;
}

.promise {
    font-style: italic;
    color: #555;
}

.answer {
    color: #c41e3a;
    font-size: 1.15rem;
    text-align: center;
    margin: 1rem 0 !important;
}

.gratitude {
    color: #8b4513;
    font-size: 1.15rem;
    text-align: center;
    margin: 1.5rem 0 !important;
}

.wish {
    font-weight: 600;
    color: #2c2416;
}

.merry-christmas {
    color: #c41e3a;
    font-size: 1.2rem;
    text-align: center;
    margin: 1.5rem 0 1rem 0 !important;
}

.promise-future {
    font-weight: 600;
    color: #8b4513;
    text-align: center;
    font-style: italic;
}

/* Letter Footer */
.letter-footer {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(212, 175, 55, 0.3);
    text-align: right;
}

.signature {
    color: #8b4513;
    font-size: 1.2rem;
    font-weight: 600;
    font-style: italic;
}

.message-content .close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 35px;
    height: 35px;
    border: none;
    background: rgba(139, 69, 19, 0.1);
    border-radius: 50%;
    font-size: 1.8rem;
    cursor: pointer;
    color: #8b4513;
    transition: all 0.3s;
}

.message-content .close-btn:hover {
    background: rgba(139, 69, 19, 0.2);
    transform: rotate(90deg);
}

/* Snowfall */
.snowflake {
    position: fixed;
    top: -10px;
    color: #fff;
    font-size: 1em;
    z-index: 9999;
    pointer-events: none;
    animation: fall linear infinite;
}

@keyframes fall {
    to {
        transform: translateY(100vh);
    }
}

/* Custom Cursor - Gingerbread Man */
.custom-cursor {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    width: 40px;
    height: 40px;
    font-size: 40px;
    transform: translate(-50%, -50%);
    transition: transform 0.1s ease;
}

body.cursor-active {
    cursor: none;
}

/* CHAOS Mode */
.chaos-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 500;
}

.chaos-mode.active {
    display: flex;
}

.chaos-mode img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    animation: chaosAppear 0.5s ease-out;
}

@keyframes chaosAppear {
    from {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.chaos-mode .close-chaos {
    position: absolute;
    top: 2rem;
    right: 2rem;
    font-size: 3rem;
    color: #fff;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 501;
    transition: all 0.3s;
}

.chaos-mode .close-chaos:hover {
    transform: scale(1.2);
    color: #ff6b6b;
}

.chaos-mode .prev-photo,
.chaos-mode .next-photo {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 4rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    cursor: pointer;
    z-index: 501;
    width: 60px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.chaos-mode .prev-photo {
    left: 2rem;
    border-radius: 0 10px 10px 0;
}

.chaos-mode .next-photo {
    right: 2rem;
    border-radius: 10px 0 0 10px;
}

.chaos-mode .prev-photo:hover,
.chaos-mode .next-photo:hover {
    background: rgba(255, 215, 0, 0.8);
    color: #000;
    transform: translateY(-50%) scale(1.1);
}

.chaos-mode .prev-photo:active,
.chaos-mode .next-photo:active {
    transform: translateY(-50%) scale(0.95);
}

.chaos-mode .photo-counter {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #ffd700;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    backdrop-filter: blur(10px);
    z-index: 501;
}

/* Responsive */
@media (max-width: 768px) {
    .morse-quiz h1 {
        font-size: 2rem;
    }

    .morse-quiz .question {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    .morse-quiz .hint-box {
        padding: 0.8rem 1rem;
        margin-bottom: 1.5rem;
    }

    .morse-quiz .hint-title {
        font-size: 1rem;
    }

    .morse-quiz .hint-content {
        font-size: 0.85rem;
    }

    .morse-quiz .device-hint {
        font-size: 0.8rem;
    }

    .countdown-page h1 {
        font-size: 2rem;
    }

    .countdown-unit .value {
        font-size: 2.5rem;
        min-width: 60px;
    }

    .countdown-display {
        gap: 1rem;
        font-size: 1.2rem;
    }

    .message-content {
        padding: 2rem;
        margin: 1rem;
    }

    .message-content h2 {
        font-size: 1.8rem;
    }

    .message-content p {
        font-size: 1rem;
    }

    /* Mobile heart button - larger and repositioned to avoid system navbar */
    .heart-button {
        top: auto;
        bottom: 6rem;
        right: 1.5rem;
        width: 70px;
        height: 70px;
        font-size: 2.5rem;
    }

    /* Mobile music button */
    .music-toggle {
        top: auto;
        bottom: 6rem;
        left: 1.5rem;
        width: 70px;
        height: 70px;
        font-size: 2.5rem;
    }

    /* Mobile instructions - smaller and repositioned */
    .instructions {
        bottom: 1rem;
        font-size: 0.75rem;
        padding: 0.75rem 1.5rem;
    }

    .instructions p {
        margin: 0.2rem 0;
    }

    /* Mobile touch improvements */
    body.cursor-active {
        cursor: auto;
    }

    .custom-cursor {
        display: none;
    }

    /* Optimize 3D canvas for mobile */
    #canvas-container canvas {
        touch-action: pan-y pinch-zoom;
    }

    /* Mobile photo navigation */
    .chaos-mode .prev-photo,
    .chaos-mode .next-photo {
        width: 50px;
        height: 70px;
        font-size: 3rem;
    }

    .chaos-mode .prev-photo {
        left: 0.5rem;
    }

    .chaos-mode .next-photo {
        right: 0.5rem;
    }

    .chaos-mode .photo-counter {
        bottom: 1rem;
        font-size: 1rem;
        padding: 0.4rem 1rem;
    }

    .chaos-mode .close-chaos {
        top: 1rem;
        right: 1rem;
        font-size: 2.5rem;
    }
}
