:root {
    --bg-color: #1a1a2e;
    --primary-color: #e0e0fc;
    --secondary-color: #16213e;
    --accent-color: #0f3460;
    --highlight-color: #53bf9d;
    --money-color: #f4d35e;
    --highscore-color: #ff8c00; /* Dark Orange for High Score */
    /* Rarity Colors */
    --common-color: #cccccc;
    --uncommon-color: #86efac;
    --rare-color: #4dabf7;
    --epic-color: #a78bfa;
    --celestial-color: #cc5de8;
    --transcendent-color: #ffcc00;
    --astral-color: #f43f5e; /* Rose-red */
    --quantum-color: #16a34a; /* Emerald green */
    --divine-color: #a5b4fc; /* Light Indigo */
    --god-orb-color: #ffd700; /* Gold */
    --god-orb-gradient-light: #ffffff;
    --god-orb-gradient-dark: #ffd700;
    /* Bonus Bar Colors */
    --bonus-bar-bg: rgba(15, 52, 96, 0.7); /* Slightly transparent accent */
    --bonus-bar-fill-bg: linear-gradient(90deg, #53bf9d, #76dbc1);
    --bonus-bar-border: rgba(83, 191, 157, 0.7); /* Highlight color, less opaque */
    --bonus-bar-active-border: var(--transcendent-color);
    --bonus-bar-active-fill-bg: linear-gradient(90deg, #ffcc00, #ffae00, #ffcc00); /* Brighter gold */
    --bonus-bar-active-text: #331a00; /* Darker text for contrast */
    --bonus-bar-glow: rgba(255, 204, 0, 0.6); /* Transcendent glow */
    /* Mega Bonus Bar Colors */
    --mega-bonus-bar-bg: rgba(15, 52, 96, 0.7); /* Same bg as normal, semi-transparent */
    --bonus-bar-active-fill-bg: linear-gradient(90deg, #ffcc00, #ffae00, #ffcc00); /* Brighter gold */
    --mega-bonus-bar-active-border: var(--divine-color); /* Use Divine color for active border */
    --mega-bonus-bar-active-fill-bg: linear-gradient(135deg, var(--astral-color), var(--quantum-color), var(--celestial-color), var(--epic-color)); /* Rainbow-ish */
    --mega-bonus-bar-active-text: #ffffff; /* White text */
    --mega-bonus-glow: rgba(165, 180, 252, 0.7); /* Divine glow */
    /* Quantum Frenzy Styles */
    --quantum-frenzy-color: var(--quantum-color); /* Emerald Green */
    --quantum-frenzy-button-bg: var(--quantum-color);
    --quantum-frenzy-button-hover-bg: #15803d; /* Darker green */
    --quantum-frenzy-active-glow: rgba(22, 163, 74, 0.8); /* Quantum color glow */
    --orb-size: clamp(150px, 40vmin, 300px); /* Responsive orb size */
    --inventory-grid-gap: 10px;
    --inventory-item-bg: #1f2a4a; /* Slightly lighter than accent */
    --inventory-item-hover-bg: #2a395a;
    --inventory-item-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    --inventory-item-border-radius: 6px;
    --button-sell-all-type-bg: #5a67d8; /* Indigo-like color */
    --button-sell-all-type-hover-bg: #434190;
    --button-combine-bg: #b8860b; /* DarkGoldenrod */
    --button-combine-hover-bg: #daa520; /* Goldenrod */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    /* REMOVE overflow: hidden; to allow scrolling */
    font-family: 'Orbitron', sans-serif;
    background-color: var(--bg-color);
    color: var(--primary-color);
    -webkit-tap-highlight-color: transparent; /* Disable blue tap highlight on mobile */
}

#mute-button {
    position: fixed;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.4); /* Semi-transparent background */
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 200; /* Above other elements */
    padding: 0; /* Remove default padding */
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

#mute-button:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: #fff;
}

#mute-button svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

#mute-button.muted .icon-volume-on {
    display: none;
}

#mute-button.muted .icon-volume-off {
    display: block;
}

#mute-button:not(.muted) .icon-volume-on {
    display: block;
}

#mute-button:not(.muted) .icon-volume-off {
    display: none;
}

#game-container {
    display: flex;
    flex-direction: column;
    min-height: 100%; /* CHANGE height to min-height to allow content expansion */
    width: 100%;
    max-width: 800px; /* Limit max width on larger screens */
    margin: 0 auto;
    padding: 10px;
}

#stats-area {
    padding: 15px 20px; /* Slightly more padding */
    background-color: var(--secondary-color);
    border-radius: 10px; /* More rounded corners */
    margin-bottom: 15px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.35); /* Slightly stronger shadow */
    transition: background-color 0.3s ease;
    display: flex; /* Use flexbox */
    flex-direction: column; /* Stack children vertically */
    align-items: center; /* Center items horizontally */
    gap: 12px; /* Increased space between items */
    position: relative; /* Needed for absolute positioning of feedback target area */
}

#money-container {
    font-size: 1.6em; /* Slightly larger */
    font-weight: bold;
    transition: transform 0.3s ease; /* For smoother animations */
    width: 100%; /* Take full width for text alignment */
    text-align: center;
    align-items: center;
}

#money-display {
    color: var(--money-color);
    margin-left: 8px;
    display: inline-block; /* Needed for transform to work reliably */
    transition: color 0.2s ease, transform 0.3s ease; /* Smooth color/transform transitions */
    text-shadow: 0 0 5px rgba(244, 211, 94, 0.5); /* Subtle gold glow */
}

#bonus-bar-container,
#mega-bonus-bar-container { /* Apply common styles to both */
    width: 100%;
    max-width: 450px; /* Slightly wider */
    display: flex;
    flex-direction: column;
    align-items: center;
}

#quantum-frenzy-container {
    width: 100%;
    max-width: 280px; /* Reduced max-width further */
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 8px; /* Slightly less space below mega bonus */
    border: 1px solid rgba(22, 163, 74, 0.5); /* Thinner, slightly transparent border */
    border-radius: 6px; /* Slightly smaller radius */
    padding: 4px 8px; /* Reduced padding further */
    background-color: rgba(22, 163, 74, 0.08); /* Even lighter transparent bg */
    transition: box-shadow 0.4s ease, background-color 0.4s ease;
    gap: 4px; /* Reduced gap */
}

#quantum-frenzy-container.quantum-frenzy-active {
    background-color: rgba(22, 163, 74, 0.15); /* Slightly darker green */
    box-shadow: 0 0 10px rgba(22, 163, 74, 0.6); /* Less intense glow */
    border-color: rgba(22, 163, 74, 0.8);
}

.mega-bonus-header {
    display: flex;
    justify-content: space-between; /* Space label and button */
    align-items: center;
    width: 100%;
    margin-bottom: 5px; /* Keep space below header */
}

.quantum-frenzy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 4px; /* Reduced space below header */
}

.bonus-label,
.mega-bonus-label { /* Apply common styles to both labels */
    font-size: 0.9em; /* Slightly larger label */
    color: var(--primary-color);
    opacity: 0.9;
    text-transform: uppercase; /* Uppercase for emphasis */
    letter-spacing: 0.5px;
}

.quantum-frenzy-label {
    font-size: 0.75em; /* Reduced label size */
    color: var(--quantum-frenzy-color);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#watch-ad-button {
    padding: 4px 8px; /* Smaller padding */
    font-size: 0.75em; /* Smaller text */
    background-color: var(--quantum-color); /* Emerald Green */
    border-color: var(--quantum-color);
    color: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

#watch-quantum-ad-button {
    width: 100%; /* Full width button */
    padding: 4px 8px; /* Reduced padding */
    font-size: 0.75em; /* Reduced font size */
    background-color: var(--quantum-frenzy-button-bg);
    border-color: var(--quantum-frenzy-button-bg);
    color: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center; /* Center content */
    gap: 4px; /* Reduced gap */
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
    margin-bottom: 2px; /* Reduced space below button */
}

#watch-ad-button svg {
    margin-right: 2px; /* Space between icon and text */
}

#watch-quantum-ad-button svg {
    margin-right: 3px;
}

#watch-ad-button:hover:not(:disabled) {
    background-color: #15803d; /* Darker green */
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#watch-quantum-ad-button:hover:not(:disabled) {
    background-color: var(--quantum-frenzy-button-hover-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#watch-quantum-ad-button:disabled {
    background-color: #115e59; /* Darker teal when disabled */
    border-color: #115e59;
    opacity: 0.6;
}

#bonus-bar,
#mega-bonus-bar { /* Apply common styles to both bars */
    width: 100%;
    height: 22px; /* Slightly taller */
    border-radius: 11px; /* Match height/2 */
    overflow: hidden;
    position: relative; /* For text overlay */
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5); /* Deeper inset shadow */
    transition: border-color 0.4s ease, box-shadow 0.4s ease; /* Slower transition */
    border: 2px solid transparent; /* Start with transparent border */
}

/* Specific Backgrounds and Borders */
#bonus-bar {
    background-color: var(--bonus-bar-bg);
    border-color: var(--bonus-bar-border);
}
#mega-bonus-bar {
    background-color: var(--mega-bonus-bar-bg);
    border-color: var(--mega-bonus-bar-border);
}

#bonus-bar-fill,
#mega-bonus-bar-fill { /* Common fill styles */
    height: 100%;
    width: 0%; /* Start empty */
    border-radius: 9px 0 0 9px; /* Inner radius for fill */
    transition: width 0.4s cubic-bezier(0.65, 0, 0.35, 1), background 0.4s ease, border-radius 0.1s linear; /* Smooth width, bg; snap border-radius */
    box-shadow: inset 0 -1px 2px rgba(0,0,0,0.2);
    position: absolute; /* Position fill relative to parent bar */
    top: 0;
    left: 0;
}

/* Specific Fill Backgrounds */
#bonus-bar-fill {
    background: var(--bonus-bar-fill-bg);
}
#mega-bonus-bar-fill {
    background: var(--mega-bonus-bar-fill-bg);
}

#bonus-bar-text,
#mega-bonus-bar-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.85em; /* Slightly larger text */
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7); /* Stronger text shadow */
    white-space: nowrap;
    transition: color 0.4s ease, text-shadow 0.4s ease;
    z-index: 1; /* Ensure text is above fill */
    pointer-events: none; /* Allow clicks through text */
}

#quantum-ad-counter {
    font-size: 0.7em; /* Reduced counter size */
    color: var(--primary-color);
    opacity: 0.85; /* Slightly more transparent */
}

#quantum-frenzy-timer {
    font-size: 0.75em; /* Reduced timer size */
    font-weight: bold;
    color: var(--quantum-frenzy-color);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5); /* Slightly less shadow */
    height: 1.1em; /* Adjust height to fit smaller font */
    line-height: 1.1em;
    text-align: center;
    margin-top: 2px; /* Reduced space above timer */
}

/* --- Active Bonus State --- */
#bonus-bar-container.bonus-active #bonus-bar {
    border-color: var(--bonus-bar-active-border);
    box-shadow: 0 0 12px var(--bonus-bar-glow), inset 0 1px 3px rgba(0,0,0,0.4); /* Enhanced glow */
}

#bonus-bar-container.bonus-active #bonus-bar-fill {
    background: var(--bonus-bar-active-fill-bg);
    background-size: 300% 100%; /* Larger size for smoother animation */
    animation: activeBonusPulseGold 2s ease-in-out infinite;
    border-radius: 9px; /* Full inner radius when full/active */
}

#bonus-bar-container.bonus-active #bonus-bar-text {
    color: var(--bonus-bar-active-text);
    text-shadow: none; /* Remove shadow for better contrast on bright bg */
    animation: bonusTextPulse 1s infinite alternate;
}

/* --- Active Mega Bonus State --- */
#mega-bonus-bar-container.mega-bonus-active #mega-bonus-bar { /* Select container */
    border-color: var(--mega-bonus-bar-active-border);
    box-shadow: 0 0 15px var(--mega-bonus-glow), inset 0 1px 3px rgba(0,0,0,0.4); /* More intense glow */
}

#mega-bonus-bar-container.mega-bonus-active #mega-bonus-bar-fill { /* Select container */
    background: var(--mega-bonus-bar-active-fill-bg);
    background-size: 400% 400%; /* Even larger for diagonal rainbow effect */
    animation: activeBonusPulseRainbow 4s linear infinite; /* Slower, linear rainbow cycle */
    border-radius: 9px; /* Full inner radius when full/active */
}

#mega-bonus-bar-container.mega-bonus-active #mega-bonus-bar-text { /* Select container */
    color: var(--mega-bonus-bar-active-text);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8); /* Keep shadow on white text */
    animation: bonusTextPulse 1s infinite alternate;
}

/* Keyframes for Active Bonus Pulses */
@keyframes activeBonusPulseGold {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes activeBonusPulseRainbow {
	0% { background-position: 0% 0%; }
	50% { background-position: 100% 100%; }
	100% { background-position: 0% 0%; }
}

@keyframes bonusTextPulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

#orb-area {
    flex-grow: 1; /* Takes up available space */
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative; /* For positioning click feedback */
    min-height: 200px; /* Ensure minimum height */
    margin-bottom: 15px;
}

#main-orb {
    width: var(--orb-size);
    height: var(--orb-size);
    cursor: pointer;
    transition: transform 0.1s ease-out;
    filter: drop-shadow(0 0 15px rgba(200, 200, 255, 0.5));
}

#main-orb circle {
     transition: fill 0.2s ease; /* Smooth color transition for rarity */
}

#main-orb:active {
    transform: scale(0.95);
}

/* Click Feedback Container (overlay) */
#click-feedback-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Don't interfere with clicks */
    overflow: hidden; /* Clip feedback that goes outside */
    z-index: 100; /* Ensure feedback is above ALL other elements */
}

/* Base style for all feedback elements */
.feedback-element {
    position: absolute;
    font-weight: bold;
    white-space: nowrap;
    transform: translateX(-50%); /* Center horizontally */
    will-change: transform, opacity, filter; /* Optimize animation */
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.7)); /* Base drop shadow */
}

/* Styles for standard orb clicks */
.feedback-click {
    font-size: clamp(1.8em, 5vw, 2.5em); /* Responsive & Larger Font Size */
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.3),
                 -1px -1px 1px rgba(0, 0, 0, 0.4),
                 0 0 10px rgba(255, 255, 255, 0.3); /* Enhanced text shadow for pop */
    animation: floatUpClickMindNumbing 1.2s cubic-bezier(0.17, 0.84, 0.44, 1.3) forwards; /* Longer, bouncier animation */
    /* Inherit color from JS */
}

/* Animation for orb clicks - Mind Numbing Version! */
@keyframes floatUpClickMindNumbing {
    0% {
        transform: translate(-50%, 0) scale(0.7) rotate(-5deg);
        opacity: 0.8;
    }
    20% {
        transform: translate(-50%, -40px) scale(1.3) rotate(5deg); /* Overshoot scale & move up quickly */
        opacity: 1;
    }
    80% {
        transform: translate(-50%, -110px) scale(1.1) rotate(-2deg); /* Further up, slightly smaller */
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -130px) scale(0.9); /* Final drift up and fade */
        opacity: 0;
    }
}

/* Styles for selling items */
.feedback-sell {
    font-size: 1.4em;
    color: var(--money-color); /* Use money color directly */
    text-shadow: 1px 1px 4px rgba(0,0,0,0.8), 0 0 8px var(--money-color); /* Add stronger gold glow */
    animation: floatToMoney 1.3s cubic-bezier(0.2, 0.5, 0.3, 1.1) forwards; /* Custom bezier for overshoot feel */
}

/* Styles for combining items */
.feedback-combine {
    font-size: 1.5em; /* Larger size for combine */
    color: var(--god-orb-color); /* Gold color */
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.8), 1px 1px 3px rgba(0,0,0,0.7);
    animation: combineFeedbackPulse 1.8s ease-out forwards; /* Special animation */
}

/* Keyframes for combine feedback */
@keyframes combineFeedbackPulse {
    0% {
        transform: translate(-50%, 0) scale(0.9);
        opacity: 0.8;
    }
    30% {
        transform: translate(-50%, -30px) scale(1.4); /* Large pulse */
        opacity: 1;
        filter: drop-shadow(0 0 15px var(--god-orb-color));
    }
    100% {
        transform: translate(-50%, -80px) scale(1); /* Settle and fade */
        opacity: 0;
        filter: drop-shadow(0 0 5px var(--god-orb-color));
    }
}

/* Keyframes for sell feedback (Moves towards money display) */
@keyframes floatToMoney {
    0% {
        transform: translate(-50%, 0) scale(0.7);
        opacity: 0.8;
    }
    60% {
        /* Move towards top-center */
        transform: translate(calc(-50% + 0px), -180px) scale(1.2); /* Adjust X offset if money is not centered */
        opacity: 1;
    }
    100% {
        transform: translate(calc(-50% + 0px), -220px) scale(0.5);
        opacity: 0;
    }
}

@keyframes floatUpClick {
    0% {
        transform: translate(-50%, 0) scale(0.8);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -80px) scale(1.3);
        opacity: 0;
    }
}

@keyframes moneyPulse {
    0% {
        transform: scale(1);
        text-shadow: 0 0 5px rgba(244, 211, 94, 0.5);
    }
    50% {
        transform: scale(1.15);
        text-shadow: 0 0 10px rgba(244, 211, 94, 0.9); /* Brighter Glow effect */
        color: #fff5c2; /* Brighter yellow */
    }
    100% {
        transform: scale(1);
        text-shadow: 0 0 5px rgba(244, 211, 94, 0.5);
    }
}

.money-increase-animation {
    animation: moneyPulse 0.4s ease-out;
}

#inventory-area {
    background: linear-gradient(180deg, var(--secondary-color) 0%, #11182d 100%); /* Darker gradient bg */
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4); /* Deeper shadow */
    overflow-y: auto;
    max-height: 40vh; /* Limit height - content inside scrolls if needed */
    min-height: 150px; /* Ensure minimum height */
    border-top: 2px solid var(--highlight-color); /* Add a top border highlight */
    position: relative; /* Needed for potential internal absolute positioning */
    z-index: 5; /* Below stats area, below feedback container */
    flex-shrink: 0; /* Prevent inventory from shrinking too much */
}

#inventory-area h2 {
    text-align: center;
    margin-bottom: 15px; /* Increased spacing */
    color: var(--highlight-color);
    text-shadow: 0 0 5px rgba(83, 191, 157, 0.5); /* Subtle glow */
}

#inventory-controls {
    display: flex;
    justify-content: center; /* Center buttons */
    margin-bottom: 15px; /* Increased spacing */
    gap: 10px;
    flex-wrap: wrap;
}

#save-management-area {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px; /* Space above save buttons */
    margin-bottom: 5px; /* Less space below */
    flex-wrap: wrap;
}

#player-info-area {
    text-align: center;
    font-size: 0.8em;
    opacity: 0.7;
    margin-top: 5px; /* Less space above */
    margin-bottom: 10px; /* More space below */
}

#player-info-area .label {
    font-weight: bold;
    margin-right: 5px;
}

#privacy-policy-area {
    text-align: center;
    margin-top: 15px; /* Add more space above privacy link */
    padding-top: 10px; /* Add padding above */
    border-top: 1px solid rgba(224, 224, 252, 0.2); /* Faint separator line */
}

#privacy-policy-link {
    color: var(--primary-color);
    opacity: 0.8; /* Make it slightly less transparent */
    text-decoration: none;
    font-size: 0.9em; /* Slightly larger font size */
    font-weight: bold; /* Make it bold */
    transition: opacity 0.2s ease, color 0.2s ease, text-shadow 0.2s ease; /* Add text-shadow transition */
    padding: 3px 5px; /* Add small padding */
    border-radius: 3px; /* Slightly rounded corners */
}

#privacy-policy-link:hover {
    color: var(--highlight-color);
    opacity: 1;
    text-decoration: underline;
    text-shadow: 0 0 3px var(--highlight-color); /* Add subtle glow on hover */
    background-color: rgba(83, 191, 157, 0.1); /* Very faint background on hover */
}

/* --- Base Button Style --- */
button {
    font-family: 'Orbitron', sans-serif;
    padding: 8px 15px;
    border-radius: 5px;
    border: 1px solid var(--highlight-color);
    background-color: var(--accent-color);
    color: var(--primary-color);
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    text-transform: uppercase; /* Keep consistent text casing */
}

button:hover:not(:disabled) {
    background-color: #1f4e80; /* Slightly lighter accent */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    transform: translateY(-1px);
}

button:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--secondary-color); /* Darker, less saturated background */
    border-color: rgba(83, 191, 157, 0.4); /* Dimmer border */
    box-shadow: none; /* Remove shadow when disabled */
}

/* --- Specific Button Overrides --- */

/* Style for the Combine All button */
#combine-all {
    background-color: var(--button-combine-bg);
    border-color: var(--god-orb-color);
    color: #ffffff; /* White text */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

#combine-all:hover:not(:disabled) {
    background-color: var(--button-combine-hover-bg);
    border-color: var(--god-orb-gradient-light);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), 0 0 5px var(--god-orb-color); /* Add glow on hover */
}

#inventory-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Responsive grid */
    gap: var(--inventory-grid-gap);
}

.inventory-item {
    background-color: var(--inventory-item-bg);
    border-radius: var(--inventory-item-border-radius);
    padding: 12px;
    box-shadow: var(--inventory-item-shadow);
    transition: background-color 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column; /* Stack content vertically */
    gap: 8px; /* Space between header, details, actions */
    border-left: 4px solid transparent; /* Placeholder for rarity color */
}

.inventory-item:hover {
    background-color: var(--inventory-item-hover-bg);
    transform: translateY(-2px); /* Subtle lift */
}

/* Rarity Border Colors */
.inventory-item[data-rarity="common"] { border-left-color: var(--common-color); }
.inventory-item[data-rarity="uncommon"] { border-left-color: var(--uncommon-color); }
.inventory-item[data-rarity="rare"] { border-left-color: var(--rare-color); }
.inventory-item[data-rarity="epic"] { border-left-color: var(--epic-color); }
.inventory-item[data-rarity="celestial"] { border-left-color: var(--celestial-color); }
.inventory-item[data-rarity="transcendent"] { border-left-color: var(--transcendent-color); }
.inventory-item[data-rarity="god"] { border-left-color: var(--god-orb-color); } /* Add God Orb Border */
/* Add missing rarities */
.inventory-item[data-rarity="astral"] { border-left-color: var(--astral-color); }
.inventory-item[data-rarity="quantum"] { border-left-color: var(--quantum-color); }
.inventory-item[data-rarity="divine"] { border-left-color: var(--divine-color); }

.inventory-item .item-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inventory-item .item-orb-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
    flex-shrink: 0; /* Prevent icon from shrinking */
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.3); /* Subtle inset shadow */
}

/* Icon Rarity Colors */
.inventory-item[data-rarity="common"] .item-orb-icon { background-color: var(--common-color); }
.inventory-item[data-rarity="uncommon"] .item-orb-icon { background-color: var(--uncommon-color); }
.inventory-item[data-rarity="rare"] .item-orb-icon { background-color: var(--rare-color); }
.inventory-item[data-rarity="epic"] .item-orb-icon { background-color: var(--epic-color); }
.inventory-item[data-rarity="celestial"] .item-orb-icon { background-color: var(--celestial-color); }
.inventory-item[data-rarity="transcendent"] .item-orb-icon { background-color: var(--transcendent-color); }
.inventory-item[data-rarity="god"] .item-orb-icon { background: linear-gradient(45deg, var(--god-orb-gradient-light), var(--god-orb-gradient-dark)); } /* Add God Orb Icon */
/* Add missing rarity icons */
.inventory-item[data-rarity="astral"] .item-orb-icon { background-color: var(--astral-color); }
.inventory-item[data-rarity="quantum"] .item-orb-icon { background-color: var(--quantum-color); }
.inventory-item[data-rarity="divine"] .item-orb-icon { background-color: var(--divine-color); }

.inventory-item .name {
    font-weight: bold;
    font-size: 1.1em;
    color: var(--primary-color);
    flex-grow: 1; /* Allow name to take available space */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inventory-item .item-details {
    font-size: 0.9em;
    opacity: 0.9;
    display: flex;
    justify-content: space-between; /* Space out count and value */
    gap: 10px;
}

.inventory-item .value {
    color: var(--money-color);
    font-weight: bold;
}

.inventory-item .item-actions {
    margin-top: 8px; /* Add some space above buttons */
    display: flex;
    flex-direction: column; /* Stack buttons vertically */
    gap: 6px; /* Space between buttons */
}

/* Use the base button styles */
.inventory-item .sell-button,
.inventory-item .sell-all-type-button {
    width: 100%; /* Make buttons fill the space */
    padding: 6px 10px; /* Slightly smaller padding for item buttons */
    font-size: 0.8em;
}

/* Optional: Different color for sell-all-type */
.inventory-item .sell-all-type-button {
    background-color: var(--button-sell-all-type-bg); /* Custom bg if desired */
    border-color: var(--button-sell-all-type-bg);
}

.inventory-item .sell-all-type-button:hover:not(:disabled) {
     background-color: var(--button-sell-all-type-hover-bg); /* Custom hover bg */
}

/* Animation for newly added inventory items */
@keyframes newItemFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.new-item-animation {
    animation: newItemFadeIn 0.5s ease-out forwards;
}

/* Animation for combining orbs */
@keyframes combineEffect {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0px rgba(255, 215, 0, 0.5);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
        opacity: 0.8;
    }
    100% {
        transform: scale(0);
        box-shadow: 0 0 30px rgba(255, 215, 0, 1);
        opacity: 0;
    }
}

.combine-animation-target {
    /* Temporary class to mark items being combined */
    animation: combineEffect 0.6s ease-in forwards;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    #stats-area {
        flex-direction: column; /* Stack money and bonus bar */
        align-items: center; /* Center items */
        gap: 10px;
    }

    #money-container {
        font-size: 1.3em;
        text-align: center; /* Center text */
    }
    #bonus-bar-container,
    #mega-bonus-bar-container { /* Apply to both */
        max-width: 90%; /* Allow bar to be wider */
    }

    #orb-area {
        min-height: 180px; /* Slightly smaller min height */
    }

    #inventory-area {
        max-height: 35vh; /* Adjust height slightly */
        padding: 10px;
    }

     #inventory-list {
        grid-template-columns: 1fr; /* Single column on small screens */
        gap: 8px;
    }

    .inventory-item {
        padding: 10px;
    }

    .inventory-item .item-actions {
       flex-direction: row; /* Buttons side-by-side on small screens */
       justify-content: space-between; /* Space them out */
    }
    .inventory-item .sell-button,
    .inventory-item .sell-all-type-button {
       width: auto; /* Allow buttons to size naturally */
       flex-basis: 48%; /* Roughly half width each */
    }

    #quantum-frenzy-container {
        max-width: 90%; /* Override desktop max-width */
        padding: 4px 8px; /* Keep smaller padding */
    }
    #watch-quantum-ad-button {
        font-size: 0.75em; /* Keep smaller font */
    }
    .quantum-frenzy-label {
        font-size: 0.75em; /* Keep smaller font */
    }
    #quantum-ad-counter {
        font-size: 0.7em; /* Keep smaller font */
    }
    #quantum-frenzy-timer {
        font-size: 0.75em; /* Keep smaller font */
    }
}