:root {
    --bg-color: #e8f5e9; /* Light Green */
    --text-color: #212121;
    --primary-color: #4CAF50; /* Green */
    --primary-hover: #43A047;
    --secondary-color: #81C784;
    --container-bg: #ffffff;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --border-radius: 16px;
    --font-main: 'Montserrat', sans-serif;
    --font-heading: 'Playfair Display', serif;
    --background-image: linear-gradient(135deg, #e8f5e9 0%, #d8e8d8 100%);

    /* Rarity Colors */
    --rarity-Common: #9E9E9E;
    --rarity-Uncommon: #66BB6A;
    --rarity-Rare: #42A5F5;
    --rarity-Epic: #AB47BC;
    --rarity-Legendary: #FFEE58;
    --rarity-Mythic: #FF7043;
}

/* --- THEMES --- */
body.theme-day {
    --bg-color: #e8f5e9;
    --text-color: #212121;
    --primary-color: #4CAF50;
    --primary-hover: #43A047;
    --secondary-color: #81C784;
    --container-bg: rgba(255, 255, 255, 0.9);
    --background-image: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}
body.theme-night {
    --bg-color: #2c3e50;
    --text-color: #ecf0f1;
    --primary-color: #3498db;
    --primary-hover: #2980b9;
    --secondary-color: #5dade2;
    --container-bg: rgba(44, 62, 80, 0.85);
    --background-image: linear-gradient(to top, #09203f 0%, #537895 100%);
}
body.theme-night header h1, body.theme-night .tab-link.active, body.theme-night #collection-tab h2, body.theme-night #crafting-tab h2 {
    color: var(--primary-color);
}
body.theme-night header p, body.theme-night .tab-link, body.theme-night #tree-description, body.theme-night .recipe-info p {
    color: #bdc3c7;
}
body.theme-night .recipe-card, body.theme-night #result-container {
    background-color: #34495e;
    border-color: #7f8c8d;
}
body.theme-night .recipe-info h3 {
    color: #ecf0f1;
}

body.theme-forest {
    --bg-color: #3e5246;
    --text-color: #f0f2ef;
    --primary-color: #8fbc8f;
    --primary-hover: #7aa97a;
    --secondary-color: #a7c9a7;
    --container-bg: rgba(43, 62, 51, 0.85);
    --background-image: linear-gradient(to top, #1e3c27 0%, #2a5238 100%);
}
body.theme-forest header h1, body.theme-forest .tab-link.active, body.theme-forest #collection-tab h2, body.theme-forest #crafting-tab h2 {
    color: var(--primary-color);
}
body.theme-forest header p, body.theme-forest .tab-link, body.theme-forest #tree-description, body.theme-forest .recipe-info p {
    color: #c8d1c9;
}
body.theme-forest .recipe-card, body.theme-forest #result-container {
    background-color: #324739;
    border-color: #5a7864;
}
body.theme-forest .recipe-info h3 {
    color: #f0f2ef;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    background-image: var(--background-image);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    transition: background-color 0.5s ease, color 0.5s ease;
}

#app {
    width: 100%;
    max-width: 900px;
    text-align: center;
    background: var(--container-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: background-color 0.5s ease;
}

#luck-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(255, 215, 0, 0.85); /* Gold */
    color: #333;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 1001;
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255,255,255,0.5);
    animation: fadeIn 0.5s;
}

header {
    position: relative;
}

header h1 {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    transition: color 0.5s ease;
}

header p {
    font-size: 1.1rem;
    color: #555;
    margin-top: 0;
    transition: color 0.5s ease;
}

#theme-switcher {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0,0,0,0.05);
    padding: 5px 10px;
    border-radius: 20px;
}

.theme-btn {
    border: none;
    background: #ccc;
    color: #333;
    padding: 5px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

body.theme-day .theme-btn[data-theme="day"],
body.theme-night .theme-btn[data-theme="night"],
body.theme-forest .theme-btn[data-theme="forest"] {
    background: var(--primary-color);
    color: white;
}

main {
    margin: 0;
}

#rollButton {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.3rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

#rollButton:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

#rollButton:disabled {
    background-color: #999;
    cursor: not-allowed;
}

#potion-inventory-container {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(128,128,128,0.2);
}

#potion-inventory-container h3 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    margin-bottom: 1rem;
    transition: color 0.5s ease;
}

#potion-inventory {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.potion-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(0,0,0,0.03);
    padding: 0.8rem;
    border-radius: var(--border-radius);
    min-width: 120px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.potion-item img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.potion-info {
    text-align: center;
}

.potion-info span {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}

.potion-info .count {
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 0.5rem;
}

body.theme-night .potion-info .count,
body.theme-forest .potion-info .count {
    color: #bdc3c7;
}

.use-potion-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.use-potion-btn:hover {
    background-color: var(--primary-color);
}

#active-buffs {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.buff-active {
    background-color: var(--secondary-color);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#result-container {
    background-color: #fafafa;
    border-radius: var(--border-radius);
    padding: 2rem;
    margin: 2rem auto 0;
    box-shadow: none;
    border: 2px solid;
    max-width: 600px;
    animation: fadeIn 0.5s ease-out;
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

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

.hidden {
    display: none !important;
}

#tree-rarity {
    font-weight: 700;
    font-size: 1.5rem;
    margin: 0;
    transition: color 0.5s ease;
}

#tree-name {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    margin: 0.5rem 0;
    transition: color 0.5s ease;
}

.image-wrapper {
    width: 100%;
    max-width: 300px;
    height: 300px;
    margin: 1rem auto;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: background-color 0.5s ease;
}

#tree-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    padding: 5px;
    box-sizing: border-box;
    transition: all 0.4s ease;
}

/* --- Mutation Visuals --- */
#tree-image.mutation-glowing {
    filter: drop-shadow(0 0 15px #ffee58) brightness(1.15);
}
#tree-image.mutation-ancient {
    filter: sepia(0.5) contrast(0.9) grayscale(0.2);
}
#tree-image.mutation-mossy {
    filter: drop-shadow(0 0 10px #2E8B57) sepia(0.2) brightness(0.95);
}
#tree-image.mutation-peeled {
    filter: contrast(1.2) brightness(0.9);
}
#tree-image.mutation-sapling {
    transform: scale(0.8);
}

#tree-description {
    font-size: 1.1rem;
    color: #616161;
    max-width: 500px;
    margin: 1rem auto 0;
    transition: color 0.5s ease;
}

/* Tabs */
#tabs {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
    border-bottom: 1px solid #e0e0e0;
    transition: border-color 0.5s ease;
}

.tab-link {
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    border: none;
    background: none;
    color: #757575;
    position: relative;
    transition: color 0.3s ease;
}

.tab-link::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary-color);
    transform: scaleX(0);
    transition: transform 0.3s ease, background-color 0.5s ease;
}

.tab-link.active {
    color: var(--primary-color);
}

.tab-link.active::after {
    transform: scaleX(1);
}

.tab-content {
    display: none;
    animation: fadeIn 0.5s;
}

.tab-content.active {
    display: block;
}

/* Collection */
#collection-tab h2, #crafting-tab h2 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    transition: color 0.5s ease;
}

#collection-container {
    background-color: var(--container-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-top: 2rem;
    box-shadow: var(--shadow);
}

#collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    margin-top: 1rem;
}

.collection-item {
    width: 100px;
    height: 100px;
    background-color: #f5f5f5;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.collection-item .count {
    position: absolute;
    bottom: 2px;
    right: 5px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

.collection-item.discovered {
    background-color: #fff;
    border: 2px solid #e0e0e0;
}

.collection-item.discovered:hover {
    transform: scale(1.1);
    z-index: 10;
}

.collection-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.collection-item .tooltip {
    visibility: hidden;
    width: 120px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;
    position: absolute;
    z-index: 1;
    bottom: 110%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
}

.collection-item:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

/* Crafting */
#crafting-recipes {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2rem;
}

.recipe-card {
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

.recipe-card.potion-recipe {
    border-left: 5px solid var(--rarity-Epic);
}

.recipe-result-image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-right: 1rem;
}

.recipe-info {
    flex-grow: 1;
}

.recipe-info h3 {
    margin: 0 0 0.5rem 0;
    font-family: var(--font-heading);
    color: #333;
    transition: color 0.5s ease;
}

.recipe-info p {
    margin: 0 0 1rem 0;
    color: #666;
    font-size: 0.9rem;
    transition: color 0.5s ease;
}

.recipe-ingredients {
    display: flex;
    gap: 0.5rem;
}

.ingredient {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.8rem;
    color: #777;
}

.ingredient img {
    width: 40px;
    height: 40px;
    background: #e9ecef;
    border-radius: 50%;
    padding: 5px;
    margin-bottom: 4px;
}

.craft-button {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.craft-button:hover:not(:disabled) {
    background-color: var(--primary-color);
    transform: translateY(-2px);
}

.craft-button:disabled {
    background-color: #BDBDBD;
    cursor: not-allowed;
}

/* Cutscene */
#cutscene-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 2rem;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#cutscene-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

#cutscene-content {
    position: relative;
    text-align: center;
}

#cutscene-text {
    animation: pulse 1.5s infinite;
}

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

.particles {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    box-shadow: 
        /* Common - White */
        -23vw 1vh #fff, 38vw -31vh #fff, 2vw 27vh #fff, -18vw -20vh #fff,
        /* Add more particles */
        -3vw 10vh #fff, 40vw 30vh #fff, -40vw -10vh #fff;
    animation: zoom 1.5s forwards;
}

.cutscene-Rare .particles {
    box-shadow: 
        -23vw 1vh var(--rarity-Rare), 38vw -31vh var(--rarity-Rare), 2vw 27vh var(--rarity-Rare), -18vw -20vh var(--rarity-Rare),
        -3vw 10vh #fff, 40vw 30vh var(--rarity-Rare), -40vw -10vh #fff;
}

.cutscene-Legendary .particles,
.cutscene-Mythic .particles,
.cutscene-Epic .particles {
    animation: zoom 1.5s forwards, rotate 1.5s linear forwards;
    box-shadow: 
        -23vw 1vh var(--rarity-Legendary), 38vw -31vh var(--rarity-Epic), 2vw 27vh var(--rarity-Rare), -18vw -20vh var(--rarity-Mythic),
        -3vw 10vh var(--rarity-Uncommon), 40vw 30vh var(--rarity-Legendary), -40vw -10vh #fff;
}

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