﻿/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #fce4ec 0%, #f8bbd0 30%, #e1bee7 70%, #d1c4e9 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}
#app {
    width: 100%;
    max-width: 420px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
}
.page {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    animation: fadeIn 0.6s ease;
}
.page.active { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}
@keyframes floatUp {
    0% { transform: translateY(0) scale(0); opacity: 0; }
    50% { transform: translateY(-50px) scale(1); opacity: 1; }
    100% { transform: translateY(-120px) scale(0.5); opacity: 0; }
}
@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.3); }
    30% { transform: scale(1); }
}

/* ===== Buttons ===== */
.btn {
    padding: 14px 36px;
    border: none;
    border-radius: 50px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}
.btn-primary {
    background: linear-gradient(135deg, #e91e63, #ad1457);
    color: white;
    box-shadow: 0 4px 15px rgba(233, 30, 99, 0.3);
}
.btn-primary:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(233, 30, 99, 0.4); }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-secondary {
    background: rgba(255,255,255,0.9); color: #666; border: 1px solid #ddd;
}
.btn-secondary:hover { background: #fff; }
.pulse-btn { animation: pulse 2s ease-in-out infinite; }

/* ===== Splash Page ===== */
.splash-inner {
    background: rgba(255,255,255,0.93);
    border-radius: 24px;
    padding: 48px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    width: 100%;
}
.splash-icon { font-size: 56px; animation: float 3s ease-in-out infinite; }
.splash-title { font-size: 26px; font-weight: 800; color: #333; text-align: center; }
.splash-subtitle { font-size: 15px; color: #e91e63; font-weight: 600; }
.splash-divider { width: 60px; height: 3px; background: linear-gradient(90deg, #e91e63, #ad1457); border-radius: 2px; margin: 4px 0; }
.splash-desc { font-size: 14px; color: #888; text-align: center; line-height: 1.6; }
.splash-hint { font-size: 12px; color: #bbb; margin-top: 8px; }

/* ===== Quiz Page ===== */
.quiz-header {
    width: 100%; display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.quiz-progress-bar {
    flex: 1; height: 6px; background: rgba(255,255,255,0.5); border-radius: 3px; overflow: hidden;
}
.quiz-progress-fill {
    height: 100%; background: linear-gradient(90deg, #e91e63, #ad1457); border-radius: 3px;
    transition: width 0.5s ease; width: 0%;
}
.quiz-progress-text { font-size: 13px; color: #888; font-weight: 600; }
.quiz-content {
    width: 100%;
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: 32px 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    min-height: 320px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.quiz-question-number { font-size: 13px; color: #e91e63; font-weight: 700; }
.quiz-question-text { font-size: 18px; font-weight: 700; color: #333; line-height: 1.5; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
    padding: 14px 18px;
    border: 2px solid #eee;
    border-radius: 14px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    color: #444;
    text-align: left;
}
.quiz-option:hover { border-color: #e91e63; background: #fce4ec; }
.quiz-option.selected { border-color: #e91e63; background: #fce4ec; color: #e91e63; font-weight: 600; }
.quiz-footer { width: 100%; display: flex; justify-content: center; }

/* ===== Reveal Page ===== */
.reveal-inner {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}
.loading-spinner {
    width: 60px; height: 60px;
    border: 4px solid rgba(233,30,99,0.15);
    border-top-color: #e91e63;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 15px; color: #888; }

.surprise-box {
    background: rgba(255,255,255,0.95);
    border-radius: 24px;
    padding: 40px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    width: 100%;
    animation: scaleIn 0.6s ease;
}
.surprise-icon { font-size: 64px; animation: heartBeat 1.5s ease-in-out infinite; }
.surprise-title { font-size: 28px; font-weight: 800; color: #e91e63; }
.surprise-desc { font-size: 16px; color: #666; }
.surprise-reveal {
    background: linear-gradient(135deg, #fce4ec, #f3e5f5);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
}
.reveal-line { font-size: 16px; color: #555; }
.highlight-line { font-size: 22px; color: #e91e63; font-weight: 800; }
.surprise-from { font-size: 14px; color: #999; margin-top: 4px; }

/* ===== Memories Cover ===== */
.memories-cover {
    width: 100%;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cover-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transition: transform 0.5s ease;
}
.memories-cover:hover .cover-bg {
    transform: scale(1.05);
}
.cover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(233,30,99,0.4) 100%);
}
.cover-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 40px 28px;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.cover-icon { font-size: 64px; animation: float 3s ease-in-out infinite; }
.cover-title { font-size: 28px; font-weight: 800; text-shadow: 0 2px 10px rgba(0,0,0,0.3); }
.cover-subtitle { font-size: 15px; opacity: 0.9; }
.cover-content .btn-primary {
    background: rgba(255,255,255,0.9);
    color: #e91e63;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

/* ===== Story Pages ===== */
.story-container {
    width: 100%;
}
.story-scroll {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 8px 0;
}
.story-section {
    animation: slideUp 0.6s ease both;
    animation-delay: calc(var(--card-i) * 0.2s);
}
.story-badge {
    display: inline-block;
    padding: 4px 16px;
    background: linear-gradient(135deg, #e91e63, #ad1457);
    color: white;
    font-size: 12px;
    font-weight: 700;
    border-radius: 50px;
    margin-bottom: 10px;
    letter-spacing: 2px;
}
.story-card {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: 28px 24px;
    box-shadow: 0 4px 25px rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
}
.story-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #e91e63, #9c27b0);
    border-radius: 0 2px 2px 0;
}
.story-icon-wrap {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fce4ec, #f3e5f5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 12px;
}
.story-title { font-size: 18px; font-weight: 700; color: #333; margin-bottom: 8px; }
.story-divider { width: 40px; height: 3px; background: linear-gradient(90deg, #e91e63, #9c27b0); border-radius: 2px; margin-bottom: 12px; }
.story-text { font-size: 15px; color: #555; line-height: 1.8; margin-bottom: 12px; }
.story-quote {
    font-size: 13px;
    color: #e91e63;
    font-style: italic;
    padding: 10px 14px;
    background: #fce4ec;
    border-radius: 10px;
    text-align: center;
}
.story-footer {
    text-align: center;
    padding: 20px 0 40px;
}

/* ===== 3D Card ===== */
.card-wrapper {
    width: 100%;
    perspective: 1000px;
    margin-bottom: 16px;
}
.card-3d {
    width: 100%;
    min-height: 420px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.card-3d.flipped {
    transform: rotateY(180deg);
}
.card-front, .card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 420px;
    border-radius: 20px;
    overflow: hidden;
    backface-visibility: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12);
}
.card-back {
    transform: rotateY(180deg);
    background: white;
}
.card-front-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.2;
}
.card-front-content {
    position: relative;
    z-index: 1;
    height: 100%;
    min-height: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 32px 24px;
    background: linear-gradient(135deg, rgba(233,30,99,0.03), rgba(156,39,176,0.03));
}
.card-badge {
    padding: 8px 24px;
    background: linear-gradient(135deg, #e91e63, #ad1457);
    color: white;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
}
.card-names {
    display: flex;
    align-items: center;
    gap: 12px;
}
.card-name {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #e91e63, #9c27b0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.card-amp { font-size: 18px; color: #e91e63; font-weight: 800; }
.card-days { font-size: 15px; color: #888; }
.card-hearts {
    display: flex;
    gap: 8px;
    font-size: 20px;
}
.card-hearts span {
    animation: float 3s ease-in-out infinite;
}
.card-hearts span:nth-child(2) { animation-delay: 0.5s; }
.card-hearts span:nth-child(3) { animation-delay: 1s; }

.card-back-content {
    padding: 36px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 420px;
    gap: 20px;
    background: linear-gradient(135deg, #fce4ec, #f3e5f5);
}
.card-back-label {
    font-size: 14px;
    color: #e91e63;
    font-weight: 700;
    letter-spacing: 1px;
}
.card-back-msg {
    font-size: 17px;
    color: #444;
    line-height: 2;
    text-align: center;
    padding: 0 12px;
}
.card-back-footer {
    font-size: 14px;
    color: #e91e63;
    font-weight: 600;
    margin-top: 8px;
}

.btn-flip {
    width: 100%;
    padding: 12px;
    border: 2px solid #e91e63;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    background: white;
    color: #e91e63;
    transition: all 0.3s ease;
    margin-top: 12px;
}
.btn-flip:hover {
    background: #e91e63;
    color: white;
}

.card-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}
.card-actions .btn {
    flex: 1;
    text-align: center;
    font-size: 14px;
    padding: 12px 16px;
}

/* ===== Particles ===== */
#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}
.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    opacity: 0.5;
    animation: floatParticle 15s infinite linear;
}
@keyframes floatParticle {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { transform: translateY(-10vh) rotate(720deg); opacity: 0; }
}

/* ===== Save Overlay ===== */
.save-flash {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: rgba(233,30,99,0.95);
    color: white;
    padding: 24px 40px;
    border-radius: 16px;
    font-size: 18px;
    font-weight: 700;
    z-index: 1000;
    animation: savePop 0.5s ease forwards;
}
@keyframes savePop {
    0% { transform: translate(-50%, -50%) scale(0); }
    60% { transform: translate(-50%, -50%) scale(1.1); }
   100% { transform: translate(-50%, -50%) scale(1); }
}
/* =========================================================
   Story Section - Scroll Effects & Progress
   ========================================================= */
.story-section {
    opacity: 0;
    transform: translateY(60px) scale(0.95);
    transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.8s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.6s ease;
    position: relative;
}
.story-section.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.story-section.visible .story-card {
    box-shadow: 0 8px 40px rgba(233,30,99,0.15);
}
.story-section.visible .story-icon-wrap {
    animation: iconPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes iconPop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}
.story-progress {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 20;
    margin-bottom: 8px;
}
.story-progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(233,30,99,0.2);
    border: 2px solid transparent;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
}
.story-progress-dot.active {
    background: #e91e63;
    border-color: rgba(233,30,99,0.3);
    box-shadow: 0 0 16px rgba(233,30,99,0.5);
    transform: scale(1.4);
}
.story-progress-dot.done {
    background: #e91e63;
    opacity: 0.6;
}
.story-text {
    min-height: 5em;
}
.typewriter-cursor::after {
    content: '|';
    animation: twBlink 0.7s step-end infinite;
    color: #e91e63;
    font-weight: 700;
    margin-left: 2px;
}
@keyframes twBlink {
    50% { opacity: 0; }
}
.story-particle {
    position: fixed;
    pointer-events: none;
    z-index: 5;
    animation: floatParticleUp 4s ease-out forwards;
}
@keyframes floatParticleUp {
    0%   { opacity: 0; transform: translateY(0) translateX(0) scale(0) rotate(0deg); }
    15%  { opacity: 1; transform: translateY(-20px) translateX(15px) scale(1) rotate(15deg); }
    100% { opacity: 0; transform: translateY(-200px) translateX(-30px) scale(0.4) rotate(60deg); }
}
.story-glow {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 600px;
    height: 600px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 1.5s ease;
    border-radius: 50%;
}
.story-glow.active {
    opacity: 1;
}
/* =========================================================
   Card Page - Tilt, Hearts & Sparkles
   ========================================================= */
.card-wrapper {
    transition: transform 0.15s ease-out;
}
.card-float-hearts {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}
.card-float-heart {
    position: absolute;
    font-size: 18px;
    animation: heartFloatUp 5s ease-out forwards;
    opacity: 0;
    will-change: transform, opacity;
}
@keyframes heartFloatUp {
    0%   { transform: translateY(0) translateX(0) scale(0); opacity: 0; }
    15%  { opacity: 0.9; transform: translateY(-10px) translateX(8px) scale(1); }
    100% { opacity: 0; transform: translateY(-250px) translateX(-20px) scale(0.3); }
}
.card-sparkle {
    position: fixed;
    pointer-events: none;
    z-index: 100;
    animation: sparkleBurst 0.8s ease-out forwards;
}
@keyframes sparkleBurst {
    0%   { opacity: 1; transform: translate(0,0) scale(1); }
    100% { opacity: 0; transform: translate(var(--sx), var(--sy)) scale(0); }
}
.card-wrapper.has-glow::after {
    content: '';
    position: absolute;
    inset: -20px;
    background: radial-gradient(ellipse at 50% 50%, rgba(233,30,99,0.12), transparent 70%);
    border-radius: 40px;
    z-index: -1;
    animation: cardGlowPulse 3s ease-in-out infinite;
}
@keyframes cardGlowPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}
.card-back-content {
    position: relative;
    background: linear-gradient(135deg, #fff5f7 0%, #fce4ec 40%, #f3e5f5 100%);
}
.card-back-content::before {
    content: '✧';
    position: absolute;
    top: 16px;
    left: 16px;
    font-size: 14px;
    color: rgba(233,30,99,0.2);
}
.card-back-content::after {
    content: '✧';
    position: absolute;
    bottom: 16px;
    right: 16px;
    font-size: 14px;
    color: rgba(233,30,99,0.2);
}
.card-back-msg {
    position: relative;
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(4px);
    border-radius: 12px;
    padding: 20px 24px;
    border: 1px solid rgba(233,30,99,0.1);
    box-shadow: 0 2px 12px rgba(233,30,99,0.06);
}
.card-back-footer {
    position: relative;
    padding: 10px 24px;
    background: linear-gradient(135deg, rgba(233,30,99,0.08), rgba(156,39,176,0.08));
    border-radius: 50px;
    font-size: 14px;
}
#page-memories.chapter-0 { background: linear-gradient(180deg, #fce4ec 0%, #f8bbd0 50%, #e1bee7 100%); }
#page-memories.chapter-1 { background: linear-gradient(180deg, #f3e5f5 0%, #e1bee7 50%, #d1c4e9 100%); }
#page-memories.chapter-2 { background: linear-gradient(180deg, #e8eaf6 0%, #c5cae9 50%, #b3e5fc 100%); }
#page-memories.chapter-3 { background: linear-gradient(180deg, #fff8e1 0%, #ffe0b2 50%, #ffccbc 100%); }
#page-memories {
    transition: background 1.2s ease;
}
.story-scroll {
    position: relative;
    z-index: 2;
}
.memories-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(233,30,99,0.2), transparent 60%);
    z-index: 1;
}
.cover-content {
    z-index: 3;
}
