/* --- Base Variables --- */

:root {
    --bg-wall: #1a261a;
    --bg-highlight: rgba(255,255,255,0.05);
    --glass-bg: rgba(30, 45, 30, 0.7);
    --glass-border: rgba(100, 255, 150, 0.2);
    --text-primary: #f0f5f0; 
    --text-secondary: #a0b5a0;
    
    /* Palette */
    --p-leaf-dark: #1B5E20; 
    --p-leaf-mid: #2E7D32; 
    --p-leaf-light: #4CAF50; 
    --p-leaf-lime: #AEEA00;
    --p-pot-terra: #FF5722; 
    --p-pot-clay: #D84315; 
    --p-pot-sand: #FFB74D;
    --p-flower: #FFD600; 
    --p-rose: #E91E63; 
    --p-cactus: #004D40;
    
    /* Fruits & UI */
    --f-grape: #9C27B0; 
    --f-tomato: #D50000;
    --fire: #FF3D00; 
    --coin: #FFD700;
}

body, html { 
    overflow-x: hidden; /* Cuts off anything sticking out the side */
    width: 100%;
    margin: 0; 
    padding: 0; 
    height: 100%; 
    width: 100%; 
    background-color: var(--bg-wall); 
    font-family: 'Montserrat', sans-serif; 
    overflow: hidden; 
    color: var(--text-primary); 
    transition: background-color 0.5s ease; 
    min-height: 100vh;
    /* Add padding equal to the ad bar height + extra space */
    padding-bottom: 120px !important; 
    box-sizing: border-box;
}

/* --- Header & Navigation --- */
header { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    padding: 15px 30px; 
    box-sizing: border-box; 
    z-index: 1000; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: rgba(20, 30, 20, 0.6); 
    backdrop-filter: blur(10px); 
    border-bottom: 1px solid var(--glass-border); 
}

.logo { 
    font-weight: 900; 
    font-size: 1.2rem; 
    letter-spacing: 1px; 
    color: #fff; 
    text-transform: uppercase; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    cursor: pointer; 
    transition: opacity 0.2s; 
}
.logo:hover { opacity: 0.8; }

.header-controls { display: flex; align-items: center; gap: 15px; }

.coin-display { 
    background: rgba(0,0,0,0.4); 
    padding: 5px 12px; 
    border-radius: 20px; 
    font-weight: 700; 
    display: flex; 
    align-items: center; 
    gap: 5px; 
    color: var(--coin); 
    border: 1px solid var(--coin); 
    font-size: 0.9rem; 
}
.coin-anim { animation: popCoin 0.3s ease-in-out; }
/* Add these new styles for the Account Button */
.account-btn {
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 5px;
}

.account-btn.logged-in {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
}

/* SPECIAL PREMIUM TITLE STYLE */
.account-btn.premium {
    background: linear-gradient(45deg, #FFD700, #FFA000); /* Gold */
    color: #000;
    border: none;
    font-weight: 900;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
    100% { filter: brightness(1); }
}

/* Ensure Home is always centered */
#home {
    display: flex; /* Override the default display:none logic for Home if needed, though JS handles class toggle */
}
/* Premium Button */
.premium-btn-header {
    background: linear-gradient(135deg, #FFD700, #FFA000);
    color: #000; 
    border: none; 
    padding: 8px 16px; 
    border-radius: 20px;
    font-weight: 800; 
    font-size: 0.8rem; 
    cursor: pointer; 
    text-transform: uppercase;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4); 
    transition: transform 0.2s;
}
.premium-btn-header:hover { transform: scale(1.05); }

.nav-group { display: flex; gap: 8px; }

.nav-btn { 
    background: transparent; 
    border: 1px solid transparent; 
    cursor: pointer; 
    color: var(--text-secondary); 
    font-weight: 700; 
    font-size: 0.8rem; 
    text-transform: uppercase; 
    padding: 8px 16px; 
    border-radius: 20px; 
    transition: all 0.3s ease; 
}
.nav-btn:hover { color: #fff; background: var(--bg-highlight); }
.nav-btn.active { 
    background-color: var(--p-leaf-mid); 
    color: #fff; 
    box-shadow: 0 4px 15px rgba(46, 125, 50, 0.4); 
}

/* --- Layout --- */
.scene-container { 
    position: relative; 
    width: 100%; 
    height: 100%; 
    background: radial-gradient(circle at center top, var(--bg-highlight) 0%, var(--bg-wall) 70%); 
}

.bg-particles-wrapper { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    z-index: 0; 
    pointer-events: none; 
}

.leaf-particle { 
    position: absolute; 
    opacity: 0.2; 
    fill: var(--p-leaf-light); 
    mix-blend-mode: overlay; 
}

.page-section { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    display: none; 
    flex-direction: column; 
    opacity: 0; 
    padding-top: 70px; 
    padding-bottom: 90px; 
    box-sizing: border-box; 
    transition: opacity 0.4s ease; 
}
.page-section.active { display: flex; opacity: 1; }

.content-wrapper { 
    width: 100%; 
    height: 100%; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    padding: 30px 20px; 
    box-sizing: border-box; 
}

/* --- Garden Grid --- */
.garden-toolbar { 
    display: flex; 
    gap: 15px; 
    margin-bottom: 30px; 
    background: var(--glass-bg); 
    padding: 10px 20px; 
    border-radius: 50px; 
    border: 1px solid var(--glass-border); 
    backdrop-filter: blur(10px); 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
    z-index: 20; 
    position: sticky; 
    top: 0; 
}

.tool-btn { 
    background: rgba(255,255,255,0.1); 
    border: 2px solid transparent; 
    color: #fff; 
    font-size: 1.4rem; 
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    cursor: pointer; 
    transition: all 0.2s; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
}
.tool-btn:hover { background: var(--p-leaf-mid); transform: translateY(-3px); }
.tool-btn.delete-mode-active { background: var(--p-pot-terra); animation: pulseRed 1.5s infinite; }

.garden-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); 
    gap: 40px; 
    width: 100%; 
    max-width: 1200px; 
    padding-bottom: 50px; 
}

.potted-plant-card { 
    position: relative; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    cursor: pointer; 
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); 
}
.potted-plant-card:hover { transform: translateY(-10px); }

.plant-visual-container { 
    width: 100%; 
    height: 200px; 
    position: relative; 
    display: flex; 
    justify-content: center; 
    align-items: flex-end; 
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.5)); 
}

.interactive-plant-svg { width: 85%; height: auto; overflow: visible; }

.plant-info { 
    background: var(--glass-bg); 
    backdrop-filter: blur(10px); 
    padding: 15px 20px; 
    border-radius: 15px; 
    border: 1px solid var(--glass-border); 
    text-align: center; 
    width: 90%; 
    margin-top: -20px; 
    z-index: 5; 
    box-shadow: 0 5px 20px rgba(0,0,0,0.2); 
    position: relative;
}

.growth-badge { 
    position: absolute; 
    top: -10px; 
    left: 50%; 
    transform: translateX(-50%); 
    background: var(--p-leaf-dark); 
    color: var(--p-leaf-lime); 
    font-size: 0.65rem; 
    text-transform: uppercase; 
    font-weight: 800; 
    padding: 4px 10px; 
    border-radius: 20px; 
    border: 1px solid var(--p-leaf-lime); 
}

.progress-bar-container { 
    width: 100%; 
    height: 6px; 
    background: rgba(0,0,0,0.3); 
    border-radius: 3px; 
    margin-top: 8px; 
    overflow: hidden; 
}
.progress-bar-fill { height: 100%; background: var(--p-leaf-lime); transition: width 0.3s; }

.watering-can-anim { 
    position: absolute; 
    top: -40px; 
    left: 50%; 
    transform: translateX(-50%); 
    font-size: 4rem; 
    opacity: 0; 
    pointer-events: none; 
    z-index: 20; 
}
.potted-plant-card.is-watering .watering-can-anim { animation: waterPlant 1.5s ease-in-out forwards; }
.potted-plant-card.is-watering .interactive-plant-svg { animation: plantShake 0.5s ease-in-out infinite; }

/* --- Habits --- */
.habits-container { 
    display: flex; 
    flex-direction: column; 
    gap: 30px; 
    width: 100%; 
    max-width: 900px; 
    padding-bottom: 50px; 
}

.habit-row { 
    position: relative; 
    height: 160px; 
    background: rgba(255,255,255,0.03); 
    border-radius: 20px; 
    border: 1px solid var(--glass-border); 
    display: flex; 
    align-items: center; 
    padding: 0 20px; 
    transition: background 0.2s; 
}
.habit-row:hover { background: rgba(255,255,255,0.06); }

.habit-info { 
    width: 30%; 
    z-index: 2; 
    position: relative; 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    height: 100%;
}
.habit-title { font-weight: 800; font-size: 1.2rem; color: #fff; margin: 0 0 10px 0; }

.habit-stats { 
    display: flex; 
    flex-direction: column; 
    gap: 5px; 
    font-size: 0.75rem; 
    color: #ccc; 
    background: rgba(0,0,0,0.3); 
    padding: 8px; 
    border-radius: 8px; 
    width: fit-content;
}

.stat-item { display: flex; align-items: center; gap: 6px; }
.stat-val { font-weight: 800; color: #fff; }
.fire-active { color: var(--fire); animation: pulseRed 2s infinite; text-shadow: 0 0 5px var(--fire); }

.vine-container { flex-grow: 1; height: 100%; position: relative; }
.vine-svg { width: 100%; height: 100%; overflow: visible; }

.fruit-group { cursor: pointer; } 
.fruit-circle { transition: fill 0.2s, opacity 0.2s; stroke: rgba(0,0,0,0.3); stroke-width: 1px; }
.fruit-collected { opacity: 1; filter: drop-shadow(0 0 5px currentColor); }
.fruit-uncollected { opacity: 0.2; filter: grayscale(1); }
.fruit-group:hover .fruit-circle { stroke: #fff; stroke-width: 2px; }
.day-label { font-size: 10px; fill: var(--text-secondary); text-anchor: middle; font-weight: 600; opacity: 0.7;}


/* --- Modals --- */
dialog { 
    background: var(--bg-wall); 
    color: var(--text-primary); 
    border: 2px solid var(--p-leaf-mid); 
    border-radius: 20px; 
    padding: 30px; 
    width: 90%; 
    max-width: 500px; 
    box-shadow: 0 25px 50px rgba(0,0,0,0.8); 
}
dialog::backdrop { background: rgba(0,0,0,0.9); backdrop-filter: blur(8px); }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 700; color: var(--p-leaf-lime); }
.form-group input, textarea, select { 
    width: 100%; 
    padding: 12px; 
    background: rgba(255,255,255,0.05); 
    border: 1px solid var(--glass-border); 
    border-radius: 8px; 
    color: #fff; 
    font-family: inherit; 
    box-sizing: border-box; 
}

.checklist-container { 
    margin-top: 10px; 
    max-height: 150px; 
    overflow-y: auto; 
    background: rgba(0,0,0,0.2); 
    padding: 10px; 
    border-radius: 8px; 
}
.checklist-item { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    margin-bottom: 8px; 
    padding: 5px; 
    background: rgba(255,255,255,0.05); 
    border-radius: 5px; 
}
.checklist-item input[type="checkbox"] { 
    width: auto; 
    cursor: pointer; 
    accent-color: var(--p-leaf-lime); 
    width: 20px; 
    height: 20px;
}
.checklist-item span { flex-grow: 1; font-size: 0.9rem; }
.checklist-item.done span { text-decoration: line-through; color: var(--text-secondary); }

.checklist-add-row { display: flex; gap: 10px; margin-top: 10px; }
.btn-small { background: var(--p-leaf-mid); border: none; color: white; border-radius: 5px; cursor: pointer; padding: 0 15px; }

.shop-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.shop-item { 
    background: rgba(0,0,0,0.3); 
    border: 1px solid var(--glass-border); 
    padding: 10px; 
    border-radius: 10px; 
    text-align: center; 
    cursor: pointer; 
    opacity: 0.5; 
    position: relative;
}
.shop-item.unlocked { opacity: 1; border-color: var(--p-leaf-lime); }
.shop-item.selected { background: rgba(174, 234, 0, 0.2); border: 2px solid var(--p-leaf-lime); }
.shop-item:hover { transform: translateY(-2px); }

.shop-price { 
    position: absolute; 
    top: -5px; 
    right: -5px; 
    background: var(--coin); 
    color: #000; 
    font-size: 0.7rem; 
    padding: 2px 6px; 
    border-radius: 10px; 
    font-weight: bold; 
}
.owned-badge { 
    display: none; 
    position: absolute; 
    top: -5px; 
    right: -5px; 
    background: var(--p-leaf-mid); 
    color: #fff; 
    font-size: 0.7rem; 
    padding: 2px 6px; 
    border-radius: 10px; 
}
.shop-item.unlocked .shop-price { display: none; }
.shop-item.unlocked .owned-badge { display: block; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; }
.btn-primary { background: var(--p-leaf-mid); color: #fff; border: none; padding: 12px 24px; border-radius: 30px; font-weight: 700; cursor: pointer; }
.btn-secondary { background: transparent; color: var(--text-secondary); border: 2px solid var(--glass-border); padding: 12px 24px; border-radius: 30px; cursor: pointer; }

/* Auth & Premium Overlays */
.auth-container { text-align: center; }
.auth-toggle { color: var(--p-leaf-lime); cursor: pointer; text-decoration: underline; margin-top: 10px; display: inline-block;}

.premium-upgrade-btn { 
    background: linear-gradient(135deg, #FFD700, #FFA000); 
    color: #000; 
    border: none; 
    padding: 15px 30px; 
    border-radius: 30px; 
    font-weight: 900; 
    font-size: 1.1rem; 
    cursor: pointer; 
    width: 100%; 
    margin-top: 20px; 
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.3); 
    transition: transform 0.2s;
}
.premium-upgrade-btn:hover { transform: scale(1.02); }
/* --- Mobile Adjustments --- */
/* --- Force "Fit to Frame" on Mobile --- */
/* --- Mobile Fixes (All Pages) --- */
/* --- Mobile Fixes (Sticky Header + Horizontal Scroll) --- */
@media (max-width: 768px) {

    /* 1. STICKY HEADER WITH HORIZONTAL SCROLL */
    header {
        position: fixed; /* Pins it to the glass */
        top: 0;
        left: 0;
        width: 100%;
        z-index: 1000; /* Ensures it sits on top of everything */
        background-color: #111a11; /* Must match your background so content doesn't show through */
        
        /* Horizontal Scroll Magic */
        display: flex;
        align-items: center;
        justify-content: flex-start; /* Aligns items to the left */
        overflow-x: auto; /* Allows swiping left/right */
        white-space: nowrap; /* FORCES buttons to stay on one line */
        flex-wrap: nowrap !important; /* 禁止 wrapping */
        padding: 15px 20px;
        gap: 20px;
        
        /* Smooth scrolling for iOS */
        -webkit-overflow-scrolling: touch;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05); /* Optional: subtle border */
    }

    /* Hide the scrollbar on the header (Cleaner look) */
    header::-webkit-scrollbar {
        display: none;
    }

    /* 2. BODY ADJUSTMENTS */
    /* We add padding to the top so the first line of text isn't hidden behind the header */
    body {
        padding-top: 80px !important; 
        overflow-y: auto; /* Normal vertical scrolling for the page */
    }

    /* 3. ENSURE NAV LINKS STAY IN A ROW */
    header nav {
        display: flex;
        gap: 15px;
        flex-shrink: 0; /* Prevents links from getting squashed */
    }

    /* 4. TEXT SCALING FOR PAGE CONTENT */
    /* This ensures your Home/Habits/Projects content fits comfortably below */
    .page-section {
        min-height: calc(100vh - 80px); /* Full height minus header */
        padding: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* Keep text readable */
    h1 { font-size: 2.5rem !important; text-align: center; }
    p { text-align: center; }
}
/* Animations */
@keyframes pulseRed { 0% { text-shadow: 0 0 5px var(--fire); transform: scale(1); } 50% { text-shadow: 0 0 15px var(--fire); transform: scale(1.2); } 100% { text-shadow: 0 0 5px var(--fire); transform: scale(1); } }
@keyframes waterPlant { 0% { opacity: 1; transform: translateX(-50%) rotate(0deg); } 50% { transform: translateX(-50%) rotate(-30deg); } 100% { opacity: 0; transform: translateX(-50%) rotate(0deg); } }
@keyframes plantShake { 0% { transform: rotate(0deg); } 25% { transform: rotate(5deg); } 75% { transform: rotate(-5deg); } 100% { transform: rotate(0deg); } }
@keyframes popCoin { 0% { transform: scale(1); } 50% { transform: scale(1.4); } 100% { transform: scale(1); } }