:root {
    /* --mobile-palette-height removed as palette is no longer fixed */
}

body {
    font-family: 'Lato', sans-serif;
    margin: 0;
    background: linear-gradient(135deg, #fde6f3 0%, #e6f7ff 100%);
    color: #4a4a4a;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 10px;
    box-sizing: border-box;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    font-size: 16px;
}

.container {
    background-color: rgba(255, 255, 255, 0.92); /* Slightly more opaque */
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.07); /* Softer shadow */
    padding: 15px 10px;
    width: 100%;
    max-width: 1200px;
    border: 1px solid rgba(255,182,193, 0.4); /* Softer border */
    animation: fadeInPage 0.5s ease-out forwards;
    box-sizing: border-box;
}

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

header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #f7c0cb;
    position: relative; /* For mute button positioning */
}
.header-top-row {
    display: flex;
    justify-content: center; /* Center H1 */
    align-items: center;
    position: relative; /* Ensure H1 stays centered even with absolute positioned button */
    margin-bottom: 5px;
}

header h1 {
    font-family: 'Sacramento', cursive;
    color: #d87093;
    font-size: 2.1rem;
    margin: 0; /* Adjusted margin */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    word-break: break-word;
    flex-grow: 1; /* Allow h1 to take space */
    text-align: center;
}

header p {
    color: #6b4f5c;
    font-size: 0.85rem;
    margin-top: 5px;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

.player-stats {
    margin-top: 10px;
    font-size: 1rem;
    color: #c7657f;
    font-weight: bold;
}

#player-points.updated, #total-pps.updated {
    animation: valueUpdateFlash 0.5s ease-out;
}
@keyframes valueUpdateFlash {
    0%, 100% { color: inherit; transform: scale(1); }
    50% { color: #e73370; transform: scale(1.08); }
}

.petal-icon {
    font-size: 1.2em;
    vertical-align: middle;
}

.game-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.shop-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.75); /* Slightly more opaque */
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04); /* Softer shadow */
    order: -1;
    margin-bottom: 15px;
}

.shop-tabs {
    display: flex;
    border-bottom: 1px solid #e0c8d1;
    flex-wrap: wrap;
}

.tab-button {
    flex: 1 1 auto; /* Allow wrapping and equal distribution */
    padding: 10px 5px;
    font-size: 0.8rem;
    font-weight: bold;
    font-family: 'Playfair Display', serif;
    background-color: transparent;
    border: none;
    cursor: pointer;
    color: #a7778b;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    border-bottom: 3px solid transparent;
    min-width: 80px; /* Minimum width before wrapping for 4 tabs */
    text-align: center;
    white-space: nowrap;
}
.tab-button:first-child { border-top-left-radius: 15px; }
.tab-button:last-child { border-top-right-radius: 15px; }

.tab-button.active {
    color: #d87093;
    border-bottom-color: #d87093;
    background-color: rgba(255, 240, 245, 0.6);
}
.tab-button:hover:not(.active) {
    color: #c7657f;
    background-color: rgba(240, 240, 240, 0.4);
}

.tab-content-wrapper {
    /* no specific styles needed */
}

.tab-panel {
    display: none;
    padding: 15px;
    animation: fadeInPanel 0.3s ease-out;
}
.tab-panel.active {
    display: block;
}

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

#plant-palette, #upgrade-shop, #achievements-panel, #statistics-panel {
    background-color: transparent;
    border: none;
    box-shadow: none;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #f7c0cb rgba(255, 255, 255, 0.5);
}
#plant-palette::-webkit-scrollbar,
#upgrade-shop::-webkit-scrollbar,
#achievements-panel::-webkit-scrollbar,
#statistics-panel::-webkit-scrollbar {
    width: 8px;
}
#plant-palette::-webkit-scrollbar-thumb,
#upgrade-shop::-webkit-scrollbar-thumb,
#achievements-panel::-webkit-scrollbar-thumb,
#statistics-panel::-webkit-scrollbar-thumb {
    background-color: #f7c0cb;
    border-radius: 10px;
}
#plant-palette::-webkit-scrollbar-track,
#upgrade-shop::-webkit-scrollbar-track,
#achievements-panel::-webkit-scrollbar-track,
#statistics-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.5);
}


#plant-palette h2, #upgrade-shop h2, #achievements-panel h2, #statistics-panel h2 {
    font-family: 'Playfair Display', serif;
    margin-top: 0;
    text-align: center;
    font-size: 1.4rem;
    padding-bottom: 8px;
    margin-bottom: 12px;
}
#plant-palette h2 { color: #c7657f; border-bottom: 1px solid #f3a7b9; }
#upgrade-shop h2 { color: #7b68ee; border-bottom: 1px solid #c9c0f0; }
#achievements-panel h2 { color: #6a5acd; border-bottom: 1px solid #d8bfd8; }
#statistics-panel h2 { color: #3cb371; border-bottom: 1px solid #98fb98; }


#plant-palette .plant-selector,
.upgrade-selector,
.achievement-item {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #eee; /* Lighter base border */
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03); /* Very subtle shadow */
    width: 100%;
    box-sizing: border-box;
}
#plant-palette .plant-selector:hover:not(.selected):not(.cannot-afford):not(.already-placed),
.upgrade-selector:hover:not(.cannot-afford):not(.maxed-out),
.achievement-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    border-color: #f7a8b8;
}

#plant-palette .plant-selector.selected {
    border-color: #d87093;
    background-color: #fce4ec;
    transform: none;
}
#plant-palette .plant-selector:active:not(.cannot-afford):not(.already-placed),
.upgrade-selector:active:not(.cannot-afford):not(.maxed-out) {
    transform: scale(0.98);
}
#plant-palette .plant-selector.cannot-afford,
.upgrade-selector.cannot-afford {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f5f5f5;
}
#plant-palette .plant-selector.already-placed {
    opacity: 0.5;
    cursor: default;
    background-color: #e9e9e9;
    border-color: #d0d0d0;
}
.upgrade-selector.maxed-out {
    opacity: 0.7;
    cursor: default;
    background-color: #e8e8e8;
}


#plant-palette .plant-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-bottom: 0;
    flex-grow: 1;
}
#plant-palette .plant-icon {
    font-size: 1.8rem;
    margin-right: 10px;
    margin-bottom: 0;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#plant-palette .plant-name {
    font-weight: bold;
    color: #5c3c4c;
    font-size: 1rem;
    text-align: left;
}
#plant-palette .plant-details {
    font-size: 0.8rem;
    color: #a7778b;
    margin-top: 0;
    text-align: right;
    white-space: nowrap;
}
#plant-palette .plant-details span {
    margin: 0 3px;
}
.plant-selector.is-special .plant-name {
    color: #DAA520;
}
.plant-selector.is-special {
    border-left: 4px solid #FFD700;
}


.upgrade-icon {
    font-size: 1.8em;
    margin-right: 12px;
    width: 35px;
    text-align: center;
}
.upgrade-name-desc { flex-grow: 1; }
.upgrade-name {
    font-weight: bold;
    color: #483D8B;
    font-size: 1em;
    display: block;
    margin-bottom: 3px;
}
.upgrade-description {
    font-size: 0.8em;
    color: #6a5acd;
    margin: 0 0 5px 0;
}
.upgrade-cost {
    font-size: 0.9em;
    color: #7b68ee;
    font-weight: bold;
    white-space: nowrap;
}

.achievement-item {
    border-left: 4px solid #d1c4e9;
}
.achievement-item.unlocked {
    border-left-color: #8fbc8f;
}
.achievement-name {
    font-weight: bold;
    color: #4a235a;
    font-size: 1em;
    margin-bottom: 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.achievement-description {
    font-size: 0.85em;
    color: #6a5acd;
    margin-bottom: 5px;
}
.achievement-status {
    font-size: 0.8em;
    font-style: italic;
    color: #a7778b;
}
.achievement-item.unlocked .achievement-status {
    color: #2e8b57;
    font-weight: bold;
}
.achievement-reward-icon {
    font-size: 1.5em;
    opacity: 0.5;
}
.achievement-item.unlocked .achievement-reward-icon {
    opacity: 1;
}

#statistics-panel .stats-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.stat-item {
    background-color: #f9f9f9; /* Slightly off-white */
    padding: 10px 15px; /* More padding */
    border-radius: 8px; /* More rounded */
    font-size: 0.9em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid #a2d5ab; /* Softer green accent */
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.stat-label {
    color: #555;
    font-weight: bold;
    margin-right: 10px;
}
.stat-value {
    color: #3cb371;
    font-weight: bold;
    text-align: right;
}
.plant-counts-section {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px dashed #bdecb6;
}
.plant-counts-section h3 {
    font-family: 'Playfair Display', serif;
    color: #3cb371;
    font-size: 1.2rem;
    margin-bottom: 8px;
    text-align: left;
}
#stat-plant-counts-list {
    list-style-type: none;
    padding-left: 0;
    font-size: 0.85em;
    color: #4a4a4a;
}
#stat-plant-counts-list li {
    padding: 5px 2px; /* Slightly more padding */
    border-bottom: 1px dotted #e0e0e0; /* Dotted divider */
}
#stat-plant-counts-list li:last-child {
    border-bottom: none;
}


#garden-bed {
    flex-grow: 1;
    width: 100%;
    box-sizing: border-box;
    height: clamp(300px, 50vh, 400px);
    background-color: #d2b48c;
    /* Subtle texture for garden bed */
    background-image: repeating-linear-gradient(
        45deg,
        rgba(0,0,0,0.02),
        rgba(0,0,0,0.02) 10px,
        transparent 10px,
        transparent 20px
    );
    border: 5px solid #b08d57;
    border-radius: 15px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.12); /* Slightly deeper inset shadow */
}

.planted-item {
    position: absolute; cursor: grab; user-select: none; -webkit-user-select: none;
    touch-action: none; font-size: 2.5em;
    transition: transform 0.1s ease-out, opacity 0.2s, filter 0.2s;
    display: flex; align-items: center; justify-content: center; text-align: center;
    filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.2)); will-change: transform, opacity, filter;
}
.planted-item.appearing { animation: plantAppear 0.3s ease-out forwards; }
@keyframes plantAppear {
    from { transform: scale(0.5) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}
.planted-item.dragging {
    cursor: grabbing; opacity: 0.7; transform: scale(1.15);
    z-index: 1000; filter: drop-shadow(4px 4px 8px rgba(0,0,0,0.3));
}

.planted-item.over-bin {
    opacity: 0.3 !important;
    transform: scale(0.6) !important;
    filter: grayscale(80%) brightness(0.7) !important;
}

.planted-item.is-buffed-by-gnome {
    filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.2)) drop-shadow(0 0 6px #98FB98); /* PaleGreen glow */
}
.planted-item.is-buffed-by-rainbow {
    animation: rainbowBuffEffect 3s infinite linear;
}
@keyframes rainbowBuffEffect { /* Base drop shadow included in animation for consistency */
    0%   { filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.2)) hue-rotate(0deg) saturate(1.8) brightness(1.05); }
    50%  { filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.2)) hue-rotate(180deg) saturate(1.8) brightness(1.05); }
    100% { filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.2)) hue-rotate(360deg) saturate(1.8) brightness(1.05); }
}
.planted-item.is-buffed-by-phoenix {
     filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.2)) drop-shadow(0 0 10px #FFA500) drop-shadow(0 0 3px #FF4500); /* Orange with inner red glow */
}


footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed #f7c0cb;
    color: #a7778b;
    position: relative;
}

.delete-bin {
    display: none;
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 80, 80, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: white;
    padding: 12px 20px;
    border-radius: 20px;
    border: 2px dashed rgba(255,255,255,0.7);
    z-index: 1001;
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    box-shadow: 0 0 15px rgba(255,0,0,0.2);
    transition: all 0.2s ease-out;
    pointer-events: none;
}

body.dragging-plant .delete-bin {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    animation: fadeInBin 0.3s ease-out;
}

@keyframes fadeInBin {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}


.delete-bin .bin-icon {
    font-size: 1.5rem;
    margin-right: 8px;
}

.delete-bin.active-dropzone {
    background-color: rgba(255, 50, 50, 0.9);
    border-color: #fff;
    border-style: solid;
    transform: translateX(-50%) scale(1.08);
    box-shadow: 0 0 20px rgba(255,0,0,0.4);
}


#clear-garden-btn {
    background-color: #ff6961; color: white; border: none;
    padding: 10px 20px; border-radius: 20px; cursor: pointer;
    font-size: 0.9rem; font-weight: bold;
    transition: background-color 0.3s, transform 0.2s;
    margin-bottom: 10px; box-shadow: 0 2px 5px rgba(216, 112, 147, 0.3);
}
#clear-garden-btn:hover:not(:active) { background-color: #e0524a; transform: translateY(-2px); }
#clear-garden-btn:active { background-color: #c44841; transform: translateY(1px) scale(0.98); }

/* --- Medium Screens (Mobile L / Tablet Portrait) --- */
@media (min-width: 481px) {
    .container { padding: 20px 15px; }
    header h1 { font-size: 2.5rem; }
    #mute-button { left: 10px; width: 40px; height: 40px; font-size: 1.3rem;}
    header p { font-size: 0.95rem; }
    .tab-button { font-size: 0.85rem; padding: 12px 8px; }

    #plant-palette h2, #upgrade-shop h2, #achievements-panel h2, #statistics-panel h2 { font-size: 1.6rem; }
    #plant-palette, #upgrade-shop, #achievements-panel, #statistics-panel { max-height: 350px; }

    #plant-palette .plant-icon { font-size: 2rem; }
    #plant-palette .plant-name { font-size: 1.05rem; }
    #plant-palette .plant-details { font-size: 0.85rem; }

    .upgrade-name { font-size: 1.05em; }
    .upgrade-description { font-size: 0.85em; }
    .upgrade-cost { font-size: 0.95em; }

    .achievement-name { font-size: 1.05em; }
    .achievement-description { font-size: 0.9em; }

    #garden-bed { height: clamp(350px, 55vh, 450px); }

    .delete-bin { font-size: 1.1rem; padding: 15px 25px; }
    .delete-bin .bin-icon { font-size: 1.8rem; }
}


/* --- Large Screens (Tablet Landscape / Desktop) --- */
@media (min-width: 769px) {
    body { padding: 20px; }
    .container { padding: 30px 40px; }
    header { margin-bottom: 30px; padding-bottom: 20px; }
    header h1 { font-size: 3.8rem; }
    #mute-button { left: 20px; }
    header p { font-size: 1.05rem; max-width: 700px; }
    .player-stats { margin-top: 15px; font-size: 1.15rem; }

    .game-area {
        flex-direction: row;
        gap: 30px;
        align-items: flex-start;
    }

    .shop-container {
        flex: 0 0 300px;
        order: 0;
        margin-bottom: 0;
        background-color: rgba(255, 255, 255, 0.8);
    }
    .tab-button { font-size: 0.9rem; padding: 12px 10px; }

    #plant-palette, #upgrade-shop, #achievements-panel, #statistics-panel {
        padding: 20px;
         max-height: 450px;
    }

    #plant-palette h2, #upgrade-shop h2, #achievements-panel h2, #statistics-panel h2 { font-size: 1.8rem; }
    #plant-palette .plant-selector { padding: 12px; }
    #plant-palette .plant-icon { font-size: 2rem; margin-right: 10px; }
    #plant-palette .plant-name { font-size: 1.1rem; }
    #plant-palette .plant-details { font-size: 0.9rem; }

    #garden-bed {
        flex-grow: 1;
        height: 600px;
    }

    footer { margin-top: 30px; padding-top: 20px; }
    #clear-garden-btn { padding: 12px 25px; font-size: 1rem; }
}
@media (min-width: 1000px) {
    .shop-container { flex: 0 0 320px; }
     #plant-palette, #upgrade-shop, #achievements-panel, #statistics-panel {
        max-height: 50vh; /* Changed from 500px to be more responsive */
    }
    #garden-bed {
        height: calc(100vh - 180px); /* Adjust based on actual header/footer height */
        min-height: 550px;
    }
}
