/* ═══════════════════════════════════════════
   Enchanted Celestial Garden — Variables
   ═══════════════════════════════════════════ */
:root {
    --void: #050511;
    --midnight: #0c1222;
    --midnight-mid: #101830;
    --amber: #e8a87c;
    --amber-bright: #f2c4a0;
    --amber-glow: rgba(232, 168, 124, 0.45);
    --amber-deep: #c48a60;
    --rose-gold: #d4a0a0;
    --rose-gold-soft: #e8c4c4;
    --celestial: #f0b4c8;
    --cream: #faf0e6;
    --cream-muted: #d8cfc4;
    --wine: #4a1942;
    --wine-soft: rgba(74, 25, 66, 0.3);
    --sage: #7ec8a0;
    --sage-glow: rgba(126, 200, 160, 0.3);
    --ember: #e06050;
    --ember-soft: rgba(224, 96, 80, 0.15);
    --glass: rgba(12, 18, 34, 0.55);
    --glass-border: rgba(232, 168, 124, 0.12);
    --glass-border-hover: rgba(232, 168, 124, 0.35);

    --font-script: 'Pinyon Script', cursive;
    --font-heading: 'Playfair Display', 'Georgia', serif;
    --font-body: 'Outfit', 'Segoe UI', sans-serif;

    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-silk: cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ═══════════ Reset ═══════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { height: 100%; }

body {
    background: var(--void);
    color: var(--cream);
    font-family: var(--font-body);
    font-weight: 300;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ═══════════ Aurora Background ═══════════ */
.aurora-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.aurora-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.35;
    will-change: transform;
}

.aurora-blob-1 {
    width: 60vw; height: 60vw;
    max-width: 800px; max-height: 800px;
    background: radial-gradient(circle, rgba(232, 168, 124, 0.3) 0%, rgba(74, 25, 66, 0.15) 50%, transparent 70%);
    top: -20%; left: -15%;
    animation: auroraFloat1 25s ease-in-out infinite;
}

.aurora-blob-2 {
    width: 50vw; height: 50vw;
    max-width: 700px; max-height: 700px;
    background: radial-gradient(circle, rgba(240, 180, 200, 0.2) 0%, rgba(212, 160, 160, 0.1) 40%, transparent 70%);
    bottom: -25%; right: -10%;
    animation: auroraFloat2 30s ease-in-out infinite;
}

.aurora-blob-3 {
    width: 40vw; height: 40vw;
    max-width: 600px; max-height: 600px;
    background: radial-gradient(circle, rgba(74, 25, 66, 0.25) 0%, rgba(12, 18, 34, 0.15) 50%, transparent 70%);
    top: 40%; left: 50%;
    transform: translate(-50%, -50%);
    animation: auroraFloat3 20s ease-in-out infinite;
}

@keyframes auroraFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(8vw, 5vh) scale(1.1); }
    66% { transform: translate(-3vw, 8vh) scale(0.95); }
}
@keyframes auroraFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-6vw, -4vh) scale(1.05); }
    66% { transform: translate(4vw, -7vh) scale(1.12); }
}
@keyframes auroraFloat3 {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-45%, -55%) scale(1.15); }
}

/* ═══════════ Grain Overlay ═══════════ */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    z-index: 0;
    pointer-events: none;
    opacity: 0.5;
    mix-blend-mode: overlay;
}

/* ═══════════ Particle Canvas ═══════════ */
#particles-canvas {
    position: fixed;
    inset: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ═══════════ CSS Fireflies ═══════════ */
.firefly-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.firefly {
    position: absolute;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow:
        0 0 6px 2px var(--amber-glow),
        0 0 20px 6px rgba(232, 168, 124, 0.15);
    opacity: 0;
    animation: fireflyDrift 12s ease-in-out infinite, fireflyGlow 4s ease-in-out infinite;
}

.firefly:nth-child(1)  { left: 8%;  top: 15%; animation-delay: 0s, 0.2s; animation-duration: 14s, 3.5s; }
.firefly:nth-child(2)  { left: 22%; top: 70%; animation-delay: 1.5s, 0.8s; animation-duration: 11s, 4.2s; }
.firefly:nth-child(3)  { left: 45%; top: 30%; animation-delay: 3s, 1.5s; animation-duration: 16s, 3.8s; }
.firefly:nth-child(4)  { left: 68%; top: 80%; animation-delay: 0.5s, 0.3s; animation-duration: 13s, 4.6s; }
.firefly:nth-child(5)  { left: 85%; top: 20%; animation-delay: 2s, 1s; animation-duration: 12s, 3.2s; }
.firefly:nth-child(6)  { left: 15%; top: 50%; animation-delay: 4s, 2s; animation-duration: 15s, 4s; }
.firefly:nth-child(7)  { left: 55%; top: 60%; animation-delay: 1s, 0.6s; animation-duration: 10s, 5s; }
.firefly:nth-child(8)  { left: 78%; top: 45%; animation-delay: 3.5s, 1.8s; animation-duration: 14s, 3.6s; }
.firefly:nth-child(9)  { left: 35%; top: 85%; animation-delay: 2.5s, 1.2s; animation-duration: 11s, 4.4s; }
.firefly:nth-child(10) { left: 92%; top: 65%; animation-delay: 0.8s, 0.4s; animation-duration: 13s, 3.9s; }
.firefly:nth-child(11) { left: 5%;  top: 35%; animation-delay: 5s, 2.5s; animation-duration: 16s, 4.8s; }
.firefly:nth-child(12) { left: 60%; top: 10%; animation-delay: 1.8s, 0.9s; animation-duration: 12s, 3.4s; }
.firefly:nth-child(13) { left: 40%; top: 55%; animation-delay: 4.5s, 2.2s; animation-duration: 15s, 5.2s; }
.firefly:nth-child(14) { left: 75%; top: 90%; animation-delay: 0.3s, 0.1s; animation-duration: 11s, 4.1s; }
.firefly:nth-child(15) { left: 28%; top: 25%; animation-delay: 3.2s, 1.6s; animation-duration: 14s, 3.7s; }

@keyframes fireflyDrift {
    0%   { transform: translate(0, 0); }
    20%  { transform: translate(30px, -40px); }
    40%  { transform: translate(-20px, -60px); }
    60%  { transform: translate(40px, -30px); }
    80%  { transform: translate(-10px, -70px); }
    100% { transform: translate(0, 0); }
}

@keyframes fireflyGlow {
    0%, 100% { opacity: 0; }
    15% { opacity: 0.9; }
    50% { opacity: 0.4; }
    85% { opacity: 0.8; }
}

/* ═══════════ Screen System ═══════════ */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.2s var(--ease-silk);
    padding: 2rem;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

/* Staggered entrance for screen children */
.screen.active > * {
    animation: screenReveal 1s var(--ease-out-expo) both;
}
.screen.active > *:nth-child(1) { animation-delay: 0.15s; }
.screen.active > *:nth-child(2) { animation-delay: 0.3s; }
.screen.active > *:nth-child(3) { animation-delay: 0.45s; }
.screen.active > *:nth-child(4) { animation-delay: 0.6s; }
.screen.active > *:nth-child(5) { animation-delay: 0.75s; }
.screen.active > *:nth-child(6) { animation-delay: 0.9s; }

@keyframes screenReveal {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ═══════════ Clue Flash Overlay ═══════════ */
.clue-flash {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(12, 18, 34, 0.97), rgba(5, 5, 17, 0.99));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.8s var(--ease-silk);
    backdrop-filter: blur(12px);
}
.clue-flash.hidden { opacity: 0; pointer-events: none; display: flex !important; }

.clue-label {
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--celestial);
    margin-bottom: 2rem;
    letter-spacing: 6px;
    text-transform: uppercase;
    opacity: 0.8;
}

/* Scratch card container */
.scratch-card {
    position: relative;
    width: 340px;
    height: 160px;
    border-radius: 20px;
    overflow: hidden;
    border: 2px solid rgba(232, 168, 124, 0.3);
    box-shadow:
        0 0 40px rgba(232, 168, 124, 0.1),
        inset 0 0 30px rgba(232, 168, 124, 0.05);
    background: rgba(12, 18, 34, 0.8);
}

#scratch-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
    border-radius: 18px;
    z-index: 2;
    transition: opacity 0.6s ease;
}
#scratch-canvas.revealed {
    opacity: 0;
    pointer-events: none;
}

.clue-word {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 3.5rem;
    color: var(--amber-bright);
    text-shadow:
        0 0 40px var(--amber-glow),
        0 0 100px rgba(232, 168, 124, 0.2);
    z-index: 1;
    margin: 0;
}

.clue-word.revealed {
    animation: clue-breathe 2.5s ease-in-out infinite;
}

.clue-hint {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 300;
    color: var(--amber);
    margin-top: 1.5rem;
    letter-spacing: 2px;
    opacity: 0;
    transition: opacity 0.6s ease;
}
.clue-hint.visible {
    opacity: 0.8;
}

@keyframes clue-breathe {
    0%, 100% { transform: scale(1); opacity: 1; filter: brightness(1); }
    50% { transform: scale(1.03); opacity: 0.85; filter: brightness(1.15); }
}

/* ═══════════ Audio Toggle ═══════════ */
.audio-btn {
    position: fixed;
    top: 24px; right: 24px;
    z-index: 200;
    width: 46px; height: 46px;
    border-radius: 50%;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--amber);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.5s var(--ease-out-expo);
    backdrop-filter: blur(16px);
}
.audio-btn:hover {
    background: rgba(232, 168, 124, 0.12);
    border-color: var(--glass-border-hover);
    box-shadow: 0 0 30px rgba(232, 168, 124, 0.12);
    transform: scale(1.1);
}
.audio-btn.muted { opacity: 0.25; }

/* ═══════════ Common Button ═══════════ */
.btn {
    font-family: var(--font-body);
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 0.88rem;
    padding: 17px 48px;
    border: 1.5px solid rgba(232, 168, 124, 0.4);
    background: rgba(232, 168, 124, 0.06);
    color: var(--amber-bright);
    border-radius: 60px;
    cursor: pointer;
    transition: all 0.5s var(--ease-out-expo);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(6px);
}

/* Shimmer sweep on hover */
.btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(232, 168, 124, 0.18), transparent);
    transition: left 0.7s var(--ease-out-expo);
}
.btn:hover::before { left: 100%; }

.btn:hover {
    background: rgba(232, 168, 124, 0.12);
    border-color: var(--amber);
    box-shadow:
        0 0 35px rgba(232, 168, 124, 0.18),
        0 0 70px rgba(232, 168, 124, 0.06),
        inset 0 0 35px rgba(232, 168, 124, 0.04);
    transform: translateY(-3px);
    color: var(--cream);
}
.btn:active {
    transform: translateY(-1px);
    transition-duration: 0.1s;
}

/* ═══════════ Glass Card ═══════════ */
.glass-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    backdrop-filter: blur(20px);
    box-shadow:
        0 8px 60px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* ═══════════ Hidden Utility ═══════════ */
.hidden { display: none !important; }

/* ═══════════ Mobile ═══════════ */
@media (max-width: 768px) {
    .screen { padding: 1.5rem; }
    .welcome-title { font-size: 4rem !important; }
    .lovegate-question { font-size: 1.8rem !important; }
    .scratch-card { width: 280px; height: 130px; }
    .clue-word { font-size: 2.8rem !important; }
    .map-container { width: 95vw; height: 400px; }
    .node-icon { width: 50px !important; height: 50px !important; font-size: 1.1rem !important; }
    .node-label { font-size: 0.65rem !important; }
    .memory-grid { grid-template-columns: repeat(4, 72px) !important; gap: 8px !important; }
    .memory-card { width: 72px !important; height: 96px !important; }
    .puzzle-board { grid-template-columns: repeat(3, 90px) !important; grid-template-rows: repeat(3, 90px) !important; }
    .puzzle-piece { width: 90px !important; height: 90px !important; }
    .puzzle-slot { width: 90px !important; height: 90px !important; }
    .finale-title { font-size: 3rem !important; }
    .clue-word { font-size: 3.5rem; }
    .quiz-container { padding: 1.5rem !important; }
    .quiz-question { font-size: 1.15rem !important; }
    .aurora-blob { filter: blur(80px); }
}

@media (max-width: 480px) {
    .welcome-title { font-size: 3rem !important; }
    .welcome-subtitle { font-size: 0.75rem !important; letter-spacing: 3px !important; }
    .btn { padding: 14px 32px; font-size: 0.82rem; }
    .memory-grid { grid-template-columns: repeat(4, 64px) !important; }
    .memory-card { width: 64px !important; height: 85px !important; }
    .puzzle-board { grid-template-columns: repeat(3, 80px) !important; grid-template-rows: repeat(3, 80px) !important; }
    .puzzle-piece { width: 80px !important; height: 80px !important; }
    .puzzle-slot { width: 80px !important; height: 80px !important; }
}

/* ═══════════ Scrollbar ═══════════ */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(232, 168, 124, 0.25); border-radius: 2px; }

@keyframes shakeX {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-6px); }
    30%, 70% { transform: translateX(6px); }
}
