:root {
    --primary-color: #ff00de; /* Neon Pink */
    --secondary-color: #00d2ff; /* Neon Blue */
    --bg-gradient: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: 1px solid rgba(255, 255, 255, 0.2);
    --text-color: #fff;
}

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

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    width: 100%;
    max-width: 480px; /* Mobile first */
    padding: 20px;
    position: relative;
    z-index: 2;
}

/* Page Transitions */
.page {
    display: none; /* Hide all pages by default */
    transition: opacity 0.5s ease, transform 0.5s ease;
    animation: fadeIn 0.8s ease-out;
    position: relative; /* Ensure pseudo-elements are positioned relative to page */
}

.page.active {
    display: block; /* Show active page */
}

.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Glassmorphism Cards */
.glass-effect, .glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--glass-border);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    text-align: center;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to bottom right,
        rgba(255, 255, 255, 0.3),
        rgba(255, 255, 255, 0) 40%,
        rgba(255, 255, 255, 0)
    );
    transform: rotate(30deg);
    pointer-events: none;
}

/* Typography */
h1, h2 {
    margin-bottom: 20px;
    font-weight: 300;
    text-shadow: 0 0 10px var(--primary-color);
}

p {
    margin-bottom: 25px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
}

.subtitle {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-top: -15px;
    margin-bottom: 25px;
}

.icon {
    font-size: 3rem;
    margin-bottom: 15px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); text-shadow: 0 0 0 rgba(255, 0, 222, 0.7); }
    50% { transform: scale(1.1); text-shadow: 0 0 20px rgba(255, 0, 222, 0.7); }
    100% { transform: scale(1); text-shadow: 0 0 0 rgba(255, 0, 222, 0.7); }
}

/* Buttons */
.btn-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

.btn.primary {
    background: linear-gradient(45deg, var(--primary-color), #ff5e62);
    color: white;
    box-shadow: 0 0 15px var(--primary-color);
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--primary-color);
}

.btn.secondary {
    background: transparent;
    border: 2px solid var(--secondary-color);
    color: var(--secondary-color);
    box-shadow: 0 0 5px var(--secondary-color), inset 0 0 5px rgba(0, 210, 255, 0.2);
}

.btn.secondary:hover {
    background: var(--secondary-color);
    color: #0f0c29;
    box-shadow: 0 0 20px var(--secondary-color);
}

/* Inputs */
.input-group input {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.input-group input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.3);
}

/* Music Control */
.music-control {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
}

#music-btn {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: spin 4s linear infinite;
    animation-play-state: paused;
}

#music-btn.playing {
    animation-play-state: running;
    box-shadow: 0 0 15px var(--primary-color);
}

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

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

.float-item {
    position: absolute;
    bottom: -10%;
    animation: floatUpAnim 15s linear infinite;
    opacity: 0.6;
    font-size: 20px;
    text-shadow: 0 0 10px currentColor;
}

@keyframes floatUpAnim {
    0% { transform: translateY(0) rotate(0deg); opacity: 0; }
    10% { opacity: 0.8; }
    90% { opacity: 0.8; }
    100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}

/* Signature & Final Page */
.signature-area {
    margin: 20px 0;
    border: 1px dashed var(--secondary-color);
    border-radius: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
}

canvas {
    width: 100%;
    height: 150px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    cursor: crosshair;
}

.btn-small {
    font-size: 0.8rem;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 5px;
    margin-top: 5px;
    cursor: pointer;
}

#final-photo-container img {
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 210, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 15px;
}

.date-stamp {
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--secondary-color);
    text-shadow: 0 0 5px var(--secondary-color);
    font-family: 'Courier New', Courier, monospace;
}

.qr-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

#qrcode {
    display: flex;
    justify-content: center;
    margin: 0 auto 10px auto;
    padding: 10px;
    background: white;
    border-radius: 10px;
    width: fit-content;
}

/* Single Photo Display */
.photo-single {
    margin: 20px 0;
    padding: 10px 10px 40px 10px;
    background: #fff;
    transform: rotate(-2deg);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transition: transform 0.3s ease;
    border-radius: 4px;
}

.photo-single:hover {
    transform: rotate(0deg) scale(1.02);
    box-shadow: 0 0 20px var(--primary-color);
    z-index: 10;
}

.photo-single img {
    width: 100%;
    display: block;
    border: 1px solid #ddd;
}

/* Final Page Background Logic */
#page-4 {
    overflow: hidden; /* Contain fireworks */
}

#fireworks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; /* Behind content but above background */
    pointer-events: none;
}

#result-content {
    position: relative;
    z-index: 10; /* Above fireworks */
    background: rgba(15, 12, 41, 0.85); /* Darker for better contrast */
    box-shadow: 0 0 30px var(--primary-color), inset 0 0 20px rgba(0, 210, 255, 0.2);
    border: 1px solid rgba(255, 0, 222, 0.3);
    padding: 15px !important; /* Reduced padding for mobile */
    max-height: 90vh; /* Prevent overflow */
    overflow-y: auto; /* Allow scrolling if absolutely necessary, but try to fit */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#result-content h2 {
    margin-bottom: 5px;
    font-size: 1.2rem;
}

#result-content .success-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

#result-content .final-quote {
    font-size: 0.95rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px var(--secondary-color);
    margin: 10px 0;
    line-height: 1.4;
}

#result-content .signature-area {
    margin: 5px 0;
    padding: 5px;
    min-height: auto;
}

#final-signature img {
    max-height: 50px;
    width: auto;
    display: block;
    margin: 0 auto;
}

#result-content canvas {
    height: 80px; /* Smaller signature area */
}

#result-content .date-stamp {
    margin-top: 5px;
    font-size: 0.8rem;
}

#result-content .qr-section {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#result-content #qrcode {
    padding: 5px;
    margin: 0 auto 5px auto;
}

#result-content .hint {
    margin-bottom: 5px;
    font-size: 0.7rem;
}

#result-content .btn-group {
    gap: 10px;
}

#page-4.has-bg::before {
    content: '';
    position: fixed; /* Fixed to cover screen */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.6; /* Slightly more visible */
    z-index: -1;
    filter: blur(3px);
}

#page-4.has-bg .glass-effect {
    background: rgba(15, 12, 41, 0.8); /* Darker overlay for readability against photo */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Full Screen Photo Mode Override */
.full-screen-mode {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    position: fixed !important;
    top: 0;
    left: 0;
    z-index: 100;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.full-screen-mode .photo-single {
    width: 90%;
    max-width: 600px;
    height: auto;
    max-height: 80vh;
    transform: none !important; /* Remove rotation for full view */
    background: #fff;
    padding: 10px 10px 50px 10px; /* Polaroid bottom spacing */
    margin: 0;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    animation: zoomInPhoto 0.5s ease-out;
}

@keyframes zoomInPhoto {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.full-screen-mode .photo-single img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* or contain, depending on photo aspect ratio vs container */
    flex-grow: 1;
}

.full-screen-mode .btn-group {
    position: absolute;
    bottom: 40px;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 101;
}

.full-screen-mode .btn {
    background: rgba(255, 0, 222, 0.9);
    backdrop-filter: blur(5px);
    padding: 12px 30px;
    font-size: 1.1rem;
    box-shadow: 0 0 20px var(--primary-color);
    border-radius: 30px;
    color: white;
    border: 1px solid rgba(255,255,255,0.5);
}

/* --- RECONSTRUCTED & NEW STYLES --- */

/* Layer 2: Cyberpunk Mode */
body.cyberpunk-mode {
    background: #000;
    /* Animated cyberpunk gradient */
    background: linear-gradient(45deg, #0f0c29, #302b63, #24243e);
}

.cyberpunk-box {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #00d2ff;
    box-shadow: 0 0 20px rgba(0, 210, 255, 0.5), inset 0 0 20px rgba(255, 0, 222, 0.2);
    z-index: 10;
    backdrop-filter: blur(5px);
}

#layer2-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.layer-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
}

.cyberpunk-btn {
    background: transparent;
    border: 2px solid #00d2ff;
    color: #00d2ff;
    text-shadow: 0 0 5px #00d2ff;
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
}

.cyberpunk-btn:hover {
    background: #00d2ff;
    color: #000;
    box-shadow: 0 0 20px #00d2ff;
}

/* Layer 2 Background Slides */
.layer2-bg-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    z-index: -1;
}

.layer2-bg-slide.active {
    opacity: 1;
}

/* Diamond Layer */
.diamond-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 10;
}

.diamond-img {
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 50px rgba(0, 210, 255, 0.5));
    animation: diamond-pulse 3s ease-in-out infinite;
    border-radius: 10px;
}

.diamond-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60vh;
    height: 60vh;
    background: radial-gradient(circle, rgba(0, 210, 255, 0.2) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

.diamond-text {
    margin-top: 30px;
    text-align: center;
    color: #fff;
    z-index: 20;
}

.diamond-text h1 {
    font-size: 3rem;
    text-shadow: 0 0 20px rgba(0, 210, 255, 0.8), 0 0 40px rgba(0, 210, 255, 0.5);
    margin-bottom: 10px;
    font-family: 'Cinzel', serif;
}

.diamond-text p {
    font-size: 1.5rem;
    color: #e0e0e0;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    margin-bottom: 30px;
}

@keyframes diamond-pulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 50px rgba(0, 210, 255, 0.5)); }
    50% { transform: scale(1.02); filter: drop-shadow(0 0 80px rgba(0, 210, 255, 0.8)); }
}

/* Layer 3: Future Mode (Sunny & Bright) */
body.future-mode {
    background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
    color: #333;
}

.future-box {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    color: #333;
}

.explore-future-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d2ff, #ff00de);
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: 0 0 20px rgba(0, 210, 255, 0.6);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    margin-top: 20px;
    animation: pulse-btn 2s infinite;
}

.explore-future-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(255, 0, 222, 0.8);
}

.explore-future-btn span {
    line-height: 1.2;
}

@keyframes pulse-btn {
    0% { box-shadow: 0 0 0 0 rgba(0, 210, 255, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(0, 210, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 210, 255, 0); }
}

.future-text h3 {
    color: #2c3e50;
    font-weight: 600;
}

.future-text p {
    color: #555;
    font-weight: 500;
}

.future-btn {
    background: linear-gradient(45deg, #a1c4fd, #c2e9fb);
    color: #2c3e50;
    box-shadow: 0 5px 15px rgba(161, 196, 253, 0.4);
    font-weight: bold;
}

.future-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(161, 196, 253, 0.6);
}

.layer3-bg-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    z-index: -1;
}

.layer3-bg-slide.active {
    opacity: 1;
}

/* Final Departure Overlay */
#departure-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 2s ease;
}

#departure-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.warp-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 2px;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.warp-star {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 40px; /* Long streaks */
    background: linear-gradient(to bottom, rgba(255,255,255,0), #fff);
    transform-origin: 0 0;
    opacity: 0;
}

.departure-text {
    position: relative;
    z-index: 100;
    text-align: center;
    color: #fff;
    font-family: "Songti SC", "SimSun", serif; /* Elegant serif font */
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.departure-text p {
    margin: 10px 0;
    opacity: 0;
    transform: translateY(20px);
    transition: all 1s ease;
}

.departure-text .line1 { font-size: 1.8rem; letter-spacing: 2px; }
.departure-text .line2 { font-size: 1.5rem; letter-spacing: 1px; color: #ddd; }
.departure-text .line3 { font-size: 2.2rem; font-weight: bold; letter-spacing: 4px; margin-top: 30px; }
.departure-text .line4 { font-size: 2rem; letter-spacing: 3px; }

.departure-text .divider {
    width: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.5);
    margin: 20px auto;
    transition: width 1.5s ease;
}

/* Animation Classes */
#departure-overlay.active .departure-text .line1 { animation: text-reveal 1.5s ease forwards 1s; }
#departure-overlay.active .departure-text .line2 { animation: text-reveal 1.5s ease forwards 2.5s; }
#departure-overlay.active .departure-text .divider { width: 100px; transition-delay: 3.5s; }
#departure-overlay.active .departure-text .line3 { animation: text-reveal 1.5s ease forwards 4s; }
#departure-overlay.active .departure-text .line4 { animation: text-reveal 1.5s ease forwards 5.5s; }

@keyframes text-reveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes warp-speed {
    0% {
        transform: rotate(var(--angle)) translateZ(0) translateY(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    100% {
        transform: rotate(var(--angle)) translateZ(800px) translateY(var(--distance));
        opacity: 0;
    }
}
