:root {
    --bg-color: #1a1a2e;
    --primary-color: #16213e;
    --secondary-color: #0f3460;
    --accent-color: #e94560;
    --font-color: #dcdcdc;
    --font-family: 'Poppins', sans-serif;
    --border-radius: 8px;

    --rarity-common: #9e9e9e;
    --rarity-uncommon: #4caf50;
    --rarity-rare: #2196f3;
    --rarity-epic: #9c27b0;
    --rarity-legendary: #ff9800;
    --rarity-mythic: #f44336;
    --rarity-divine: #cddc39;
    --rebirth-color: #4dd0e1;
    --rainbow-color: linear-gradient(90deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8b00ff);
    --transparency-color: linear-gradient(45deg, rgba(255, 255, 255, 0.8), rgba(200, 200, 255, 0.6));
    --purchased-color: #4CAF50; /* Added for purchased upgrades */
    --index-columns: 6;
}

/* NEW: Animated border for Rainbow color */
@keyframes rainbow-border-animation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--font-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 20px;
}

#game-container {
    width: 100%;
    max-width: 800px;
    background-color: var(--primary-color);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background-color: var(--secondary-color);
    padding: 20px;
    text-align: center;
    border-bottom: 2px solid var(--accent-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

header h1 {
    margin-bottom: 10px;
    color: white;
    font-weight: 700;
}

.stats-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: var(--border-radius);
}

.stat h2 {
    font-size: 1.8em;
    font-weight: 600;
}

.stat p {
    font-size: 1.1em;
    font-weight: 300;
}

main {
    padding: 20px;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--secondary-color);
    margin-bottom: 20px;
    position: sticky;
    top: 76px; /* just below the sticky header */
    z-index: 40;
    background-color: var(--primary-color);
}

/* Fixed variant used while scrolling in the Colors tab so the tab buttons remain clickable */
.tabs.fixed {
    position: fixed !important;
    top: 12px; /* a little below the top to match header spacing on small screens */
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 800px;
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
    z-index: 2000;
    background-color: rgba(22,33,62,0.98);
}

.tab-link {
    background: none;
    border: none;
    color: var(--font-color);
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1.1em;
    font-family: var(--font-family);
    transition: background-color 0.3s, color 0.3s;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    border-bottom: 3px solid transparent;
}

.tab-link.active {
    color: white;
    border-bottom: 3px solid var(--accent-color);
}

.tab-link:hover:not(.active) {
    background-color: var(--secondary-color);
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Random Color Button Container */
.random-color-container {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--secondary-color);
}

.random-color-container .upgrade-button {
    width: 200px;
    margin-bottom: 10px;
}

.random-color-container .random-color-description {
    font-size: 0.9em;
    color: var(--font-color);
}

#color-list {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.color-card {
    background-color: var(--secondary-color);
    border-radius: var(--border-radius);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-left: 5px solid;
    transition: transform 0.2s;
}

.color-card:hover {
    transform: translateY(-3px);
}

.color-card[data-rarity="divine"] {
    background-color: #A0522D; /* Darker Orange (Sienna) */
}

.color-card.locked {
    filter: grayscale(80%) brightness(0.7);
}

.color-card.shiny {
    border: 3px solid #FFD700 !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

.color-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.color-name {
    font-size: 1.4em;
    font-weight: 600;
    cursor: pointer;
    /* Color is now set dynamically via JS */
}

.color-rarity {
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    font-weight: bold;
    color: white;
    text-transform: uppercase;
}

/* Add legendary rarity styling */
.color-card[data-rarity="legendary"] .color-rarity {
    background: linear-gradient(45deg, #FFD700, #FFA500, #FFD700);
    animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.color-stats {
    font-size: 0.9em;
}

.upgrade-button {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    font-family: var(--font-family);
    transition: background-color 0.3s;
}

.upgrade-button:hover:not(:disabled) {
    background-color: #ff6680;
}

.upgrade-button:disabled {
    background-color: #555;
    cursor: not-allowed;
}

.upgrade-button:active:not(:disabled) {
    transform: scale(0.97);
}

.color-hex {
    font-family: 'monospace';
    font-size: 0.9em;
    opacity: 0.7;
    margin-top: 5px;
}

.color-components-display {
    background-color: var(--secondary-color);
    padding: 10px;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    font-size: 0.95em;
    color: var(--font-color);
    text-align: center;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    border: 1px solid rgba(255,255,255,0.1);
}

.color-components-display.visible {
    display: block;
    opacity: 1;
}

/* Mixer Tab */
#Mixer {
    text-align: center;
}
#mixer-ui {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.mixer-slots {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}
.mixer-slot {
    width: 120px;
    height: 120px;
    border: 2px dashed var(--secondary-color);
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 0.9em;
    transition: background-color 0.3s, border-color 0.3s;
}
.mixer-slot.drag-over {
    background-color: rgba(233, 69, 96, 0.2);
    border-color: var(--accent-color);
}
.plus-sign {
    font-size: 2em;
    font-weight: bold;
    color: var(--accent-color);
}
#mix-button {
    width: 200px;
    margin-top: 10px;
}
#mixer-message {
    margin-top: 15px;
    min-height: 24px;
    font-size: 1.1em;
    font-weight: 600;
}

.mixer-drag-tip {
    margin-top: 10px;
    font-size: 0.9em;
    color: #a9a9a9;
    background-color: rgba(0,0,0,0.15);
    padding: 8px;
    border-radius: var(--border-radius);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

#mixer-sort-container {
    margin-top: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

#mixer-sort {
    padding: 5px;
    border-radius: var(--border-radius);
    background-color: var(--secondary-color);
    color: var(--font-color);
    border: 1px solid var(--accent-color);
    font-family: var(--font-family);
    cursor: pointer;
}

#draggable-colors-list {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--secondary-color);
}
#draggable-colors-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}
.draggable-color {
    padding: 10px 15px;
    border-radius: var(--border-radius);
    cursor: grab;
    font-weight: 600;
    border: 2px solid;
    user-select: none;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.draggable-color:active {
    cursor: grabbing;
}

.draggable-color.selected-for-mix {
    box-shadow: 0 0 10px 3px var(--accent-color);
    border-color: var(--accent-color);
    transform: scale(1.05);
}

/* Rebirth Tab */
.rebirth-container {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    background-color: var(--secondary-color);
    border-radius: var(--border-radius);
}

#rebirth-button {
    width: 250px;
    height: 50px;
    font-size: 1.2em;
}

#rebirth-requirement {
    margin-top: 15px;
    font-size: 1.1em;
}

#RebirthColors h2 {
    text-align: center;
    margin-bottom: 10px;
}

.rebirth-stats {
    text-align: center;
    font-size: 1.2em;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}
#rebirth-points-total {
    font-weight: bold;
    color: var(--rebirth-color);
}

#rebirth-upgrades-list {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.rebirth-upgrade-card {
    background-color: var(--secondary-color);
    border-radius: var(--border-radius);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-left: 5px solid var(--rebirth-color);
}

.rebirth-upgrade-card h3 {
    font-size: 1.3em;
    color: var(--rebirth-color);
}
.rebirth-upgrade-card p {
    font-size: 0.95em;
    flex-grow: 1;
}
.rebirth-upgrade-card .upgrade-button {
    background-color: var(--rebirth-color);
}

.rebirth-upgrade-card .upgrade-button:hover:not(:disabled) {
    background-color: #80deea;
}
.rebirth-upgrade-card .upgrade-button.purchased {
     background-color: #555;
     cursor: not-allowed;
}

.rebirth-upgrade-card .upgrade-button:disabled {
     background-color: #555;
     cursor: not-allowed;
}

/* Style for aut-purchased rainbow upgrades */
.rebirth-upgrade-card .upgrade-button.auto-purchased {
    background-color: var(--purchased-color) !important;
    border-color: var(--purchased-color) !important;
    color: white;
    cursor: default;
}

/* Rainbow Tab */
#Rainbow .rebirth-container {
    border: 2px solid;
    border-image: var(--rainbow-color) 1;
    background-color: rgba(0,0,0,0.2);
}

#Rainbow #rainbow-button {
    background-image: var(--rainbow-color);
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

#Rainbow #rainbow-button:hover:not(:disabled) {
    opacity: 0.8;
    background-image: var(--rainbow-color); /* Retain gradient on hover */
}

#rainbow-points-total {
    font-weight: bold;
    background: var(--rainbow-color);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

#rainbow-upgrades-list {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

#rainbow-upgrades-list .rebirth-upgrade-card {
    border-left: 5px solid;
    border-image: var(--rainbow-color) 1;
}

#rainbow-upgrades-list .rebirth-upgrade-card h3 {
    background: var(--rainbow-color);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

#rainbow-upgrades-list .upgrade-button {
    background-color: transparent;
    border: 2px solid;
    border-image: var(--rainbow-color) 1;
    transition: background-color 0.3s, color 0.3s;
}

#rainbow-upgrades-list .upgrade-button:hover:not(:disabled) {
    background-image: var(--rainbow-color);
    color: white;
    border-image: none;
}

/* Transparency Tab */
#Transparency .rebirth-container {
    border: 2px solid;
    border-image: var(--transparency-color) 1;
    background-color: rgba(255,255,255,0.05);
}

#Transparency #transparency-button {
    background-image: var(--transparency-color);
    color: #1a1a2e;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.3);
}

#Transparency #transparency-button:hover:not(:disabled) {
    opacity: 0.8;
    background-image: var(--transparency-color); /* Retain gradient on hover */
}

#transparency-points-total {
    font-weight: bold;
    background: var(--transparency-color);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

#transparency-upgrades-list {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

#transparency-upgrades-list .rebirth-upgrade-card {
    border-left: 5px solid;
    border-image: var(--transparency-color) 1;
}

#transparency-upgrades-list .rebirth-upgrade-card h3 {
    background: var(--transparency-color);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

#transparency-upgrades-list .upgrade-button {
    background-color: transparent;
    border: 2px solid;
    border-image: var(--transparency-color) 1;
    transition: background-color 0.3s, color 0.3s;
}

#transparency-upgrades-list .upgrade-button:hover:not(:disabled) {
    background-image: var(--transparency-color);
    color: #1a1a2e;
    border-image: none;
}

/* Notification */
#notification-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    background-color: var(--secondary-color);
    color: white;
    padding: 15px 20px;
    border-radius: var(--border-radius);
    border-left: 5px solid var(--accent-color);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.5s forwards, fadeOut 0.5s 2.5s forwards;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

footer {
    background-color: var(--secondary-color);
    padding: 15px;
    display: flex;
    justify-content: center;
    gap: 15px;
    border-top: 1px solid var(--primary-color);
}

footer button {
    background-color: var(--secondary-color);
    border: 1px solid var(--accent-color);
    color: var(--font-color);
    padding: 8px 15px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}

footer button:hover {
    background-color: var(--accent-color);
    color: white;
}

/* Modals (General) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Ensure 'Similar to…' modal can appear above the Index modal */
#similar-color-modal {
    z-index: 2100;
}

.modal-content {
    background-color: var(--primary-color);
    border-radius: var(--border-radius);
    padding: 25px;
    max-width: 90%;
    width: 100%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    border-top: 3px solid var(--accent-color);
    max-height: 90vh; /* Add max-height */
    overflow-y: auto; /* Add overflow for scrolling */
}

.modal-close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--font-color);
    font-size: 1.8em;
    cursor: pointer;
    line-height: 1;
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 20px;
}

/* Settings Modal Specifics */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--secondary-color);
}

.setting-item label {
    font-size: 1.1em;
}

/* Favorite color display in Settings */
.favorite-color-display {
    align-items: center;
}

.favorite-color-display-value {
    display: flex;
    align-items: center;
    gap: 10px;
}

.favorite-color-swatch-settings {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.4);
    background-color: transparent;
}

#reset-level-button {
    background-color: var(--secondary-color);
    border: 1px solid var(--accent-color);
}
#reset-level-button:hover:not(:disabled) {
    background-color: var(--accent-color);
}

/* NEW: Volume slider styling */
.setting-item input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 50%;
    height: 8px;
    background: var(--secondary-color);
    outline: none;
    opacity: 0.7;
    -webkit-transition: .2s;
    transition: opacity .2s;
    border-radius: 5px;
}

.setting-item input[type="range"]:hover {
    opacity: 1;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    cursor: pointer;
    border-radius: 50%;
}

.setting-item input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

/* Simple checkbox styling */
.setting-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 50px;
    height: 25px;
    background-color: var(--secondary-color);
    border-radius: 25px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s;
}

.setting-item input[type="checkbox"]::before {
    content: '';
    width: 21px;
    height: 21px;
    background-color: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.setting-item input[type="checkbox"]:checked {
    background-color: var(--accent-color);
}

.setting-item input[type="checkbox"]:checked::before {
    transform: translateX(25px);
}

.setting-description {
    font-size: 0.9em;
    color: #a9a9a9;
    margin-top: 10px;
    text-align: center;
    padding-bottom: 10px; /* Add some padding at the bottom */
}

/* Guide Modal Specifics */
#guide-modal .modal-content {
    max-width: 750px; /* Wider for more text */
    width: 95%;
    max-height: 85vh; /* Taller for more content */
}

#guide-view-container {
    position: relative;
}

.guide-intro {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.1em;
    color: var(--font-color);
}

.guide-menu-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.guide-menu-button {
    background-color: var(--secondary-color);
    border: 1px solid var(--accent-color);
    color: var(--font-color);
    padding: 15px 30px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1.2em;
    font-family: var(--font-family);
    transition: background-color 0.3s, color 0.3s;
}

.guide-menu-button:hover {
    background-color: var(--accent-color);
    color: white;
}

.guide-content-section {
    text-align: left;
    color: var(--font-color);
    line-height: 1.7;
}

.guide-content-section h3 {
    text-align: center;
    color: var(--accent-color);
    font-size: 1.8em;
    margin-bottom: 20px;
}

.guide-content-section h4 {
    color: var(--rebirth-color);
    font-size: 1.3em;
    margin-top: 25px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--secondary-color);
    padding-bottom: 5px;
}

.guide-content-section p,
.guide-content-section ul,
.guide-content-section ol {
    margin-bottom: 15px;
}

.guide-content-section ul, .guide-content-section ol {
    padding-left: 25px;
}

.guide-content-section li {
    margin-bottom: 8px;
}

.guide-content-section strong {
    color: #fff;
    font-weight: 600;
}

.guide-back-button {
    position: absolute;
    top: 0;
    left: 0;
    background: none;
    border: none;
    color: var(--font-color);
    font-size: 1.1em;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: var(--border-radius);
    transition: background-color 0.3s;
}

.guide-back-button:hover {
    background-color: var(--secondary-color);
}

/* Offline Earnings Modal Specifics */
#offline-earnings-modal .modal-content h2 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.8em;
    color: var(--font-color);
}

#offline-earnings-modal .modal-content .emoji {
    font-size: 1.2em;
}

.offline-stats {
    margin-top: 20px;
    margin-bottom: 25px;
    text-align: center;
    font-size: 1.1em;
    line-height: 1.6;
    color: var(--font-color);
}

.offline-stats p {
    margin-bottom: 8px;
}

#offline-accept-button {
    display: block;
    width: 80%;
    margin: 0 auto;
    font-size: 1.1em;
    padding: 15px;
}

/* Favorite Color Picker */
.favorite-color-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--border-radius);
    cursor: pointer;
    margin-bottom: 4px;
    transition: background-color 0.2s, transform 0.1s;
}

.favorite-color-option:hover {
    background-color: rgba(255,255,255,0.05);
    transform: translateY(-1px);
}

.favorite-color-option.selected {
    background-color: rgba(233, 69, 96, 0.4);
}

.favorite-color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.3);
}

.favorite-color-label {
    flex: 1;
    font-size: 0.95em;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    #game-container {
        max-width: 100%;
        margin: 0;
    }

    header {
        padding: 15px;
    }

    header h1 {
        font-size: 1.5em;
        margin-bottom: 8px;
    }

    .stats-container {
        flex-direction: column;
        gap: 10px;
        padding: 8px;
    }

    .stat h2 {
        font-size: 1.4em;
    }

    .stat p {
        font-size: 1em;
    }

    main {
        padding: 15px;
    }

    .tabs {
        flex-wrap: wrap;
        gap: 5px;
    }

    .tab-link {
        padding: 8px 12px;
        font-size: 0.9em;
        flex: 1;
        min-width: 80px;
        text-align: center;
    }

    /* Random Color Button Container */
    .random-color-container .upgrade-button {
        width: 100%;
        max-width: 250px;
    }

    #color-list {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .color-card {
        padding: 12px;
    }

    .color-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .color-name {
        font-size: 1.2em;
    }

    .upgrade-button {
        padding: 12px;
        font-size: 1em;
        min-height: 44px; /* Touch-friendly minimum */
    }

    /* Mixer Tab Mobile */
    .mixer-slots {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .mixer-slot {
        width: 100%;
        max-width: 200px;
        height: 80px;
        font-size: 0.9em;
        min-height: 44px; /* Touch-friendly */
    }

    .plus-sign {
        font-size: 1.5em;
        transform: rotate(90deg);
    }

    #mix-button {
        width: 100%;
        max-width: 250px;
        min-height: 44px;
    }

    #draggable-colors-container {
        gap: 8px;
    }

    .draggable-color {
        padding: 12px 15px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    /* Rebirth Tab Mobile */
    .rebirth-container {
        padding: 15px;
    }

    #rebirth-button {
        width: 100%;
        max-width: 300px;
        min-height: 44px;
    }

    #rebirth-upgrades-list {
        grid-template-columns: 1fr;
    }

    .rebirth-upgrade-card {
        padding: 12px;
    }

    .rebirth-upgrade-card h3 {
        font-size: 1.1em;
    }

    .rebirth-upgrade-card p {
        font-size: 0.9em;
    }

    /* Footer Mobile */
    footer {
        padding: 12px;
        flex-direction: column;
        gap: 10px;
    }

    footer button {
        padding: 12px 15px;
        min-height: 44px;
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }

    /* Notifications Mobile */
    #notification-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .notification {
        padding: 12px 15px;
        font-size: 0.9em;
    }

    /* Color Components Display Mobile */
    .color-components-display {
        padding: 8px;
        font-size: 0.85em;
    }

    /* Modals Mobile */
    .modal-content {
        padding: 20px;
    }
    .modal-content h2 {
        font-size: 1.5em;
        margin-bottom: 15px;
    }
    .setting-item label {
        font-size: 1em;
    }
    .setting-description {
        font-size: 0.8em;
    }
    #offline-earnings-modal .modal-content h2 {
        font-size: 1.5em;
    }
    .offline-stats {
        font-size: 1em;
    }
    #offline-accept-button {
        font-size: 1em;
        padding: 12px;
    }
}

/* NEW */
.mobile-mixer-sort-container {
    margin-bottom: 15px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.mobile-mixer-sort-container label {
    font-size: 0.95em;
    color: var(--font-color);
}

.mobile-mixer-sort-container select {
    padding: 5px;
    border-radius: var(--border-radius);
    background-color: var(--secondary-color);
    color: var(--font-color);
    border: 1px solid var(--accent-color);
    font-family: var(--font-family);
    cursor: pointer;
    font-size: 0.9em;
}

/* Touch-specific styles */
@media (hover: none) and (pointer: coarse) {
    .color-card:hover {
        transform: none;
    }
    
    .tab-link:hover:not(.active) {
        background-color: transparent;
    }
    
    .upgrade-button:hover:not(:disabled) {
        background-color: var(--accent-color);
    }
    
    .rebirth-upgrade-card .upgrade-button:hover:not(:disabled) {
        background-color: var(--rebirth-color);
    }
    
    footer button:hover {
        background-color: var(--secondary-color);
        color: var(--font-color);
    }
    
    .mobile-color-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
        margin-bottom: 20px;
    }

    .mobile-picker-cancel {
        margin-top: 10px;
    }

    .draggable-color {
       cursor: pointer;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.3em;
    }
    
    .stats-container {
        padding: 6px;
    }
    
    .stat h2 {
        font-size: 1.2em;
    }
    
    main {
        padding: 10px;
    }
    
    .tab-link {
        padding: 6px 8px;
        font-size: 0.8em;
    }
    
    .color-card {
        padding: 10px;
    }
    
    .color-name {
        font-size: 1.1em;
    }
    
    .mixer-slot {
        height: 70px;
        font-size: 0.8em;
    }
}

/* Mobile Color Picker Modal */
.mobile-color-picker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mobile-color-picker-content {
    background-color: var(--primary-color);
    border-radius: var(--border-radius);
    padding: 20px;
    max-width: 90%;
    max-height: 80%;
    overflow-y: auto;
    width: 100%;
    max-width: 400px;
}

/* NEW: Hide scrollbar for Webkit browsers */
.mobile-color-picker-content::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome, Safari, Edge */
}

/* NEW: Hide scrollbar for Firefox */
.mobile-color-picker-content {
    scrollbar-width: none; /* Firefox */
}

.mobile-color-picker-content h3 {
    text-align: center;
    margin-bottom: 15px;
    color: var(--font-color);
}

.mobile-color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.mobile-color-option {
    padding: 12px;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    min-height: 44px;
    transition: transform 0.2s, border-color 0.2s;
}

.mobile-color-option:hover:not(:disabled) {
    transform: scale(1.05);
    border-color: var(--accent-color);
}

.mobile-color-option:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mobile-picker-cancel {
    width: 100%;
    padding: 12px;
    background-color: var(--secondary-color);
    color: var(--font-color);
    border: 1px solid var(--accent-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 1em;
    min-height: 44px;
}

.mobile-picker-cancel:hover {
    background-color: var(--accent-color);
    color: white;
}

#scroll-to-top-btn {
    bottom: 150px;
}

.scroll-button {
    position: fixed;
    bottom: 90px; /* Above footer buttons */
    right: 30px;
    background-color: var(--accent-color);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: background-color 0.3s, transform 0.2s, opacity 0.3s;
    z-index: 1001;
}

.scroll-button:hover {
    background-color: #ff6680;
    transform: translateY(-2px);
}

.scroll-button img {
    width: 24px;
    height: 24px;
}

/* Tutorial panel */
.tutorial-panel {
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(15, 52, 96, 0.97);
    border-radius: var(--border-radius);
    padding: 18px 20px;
    max-width: 90%;
    width: 420px;
    z-index: 1500;
    border: 2px solid var(--accent-color);
    font-size: 1em;
    text-align: center;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.7);
}

/* Highlighted actions during tutorial */
.tutorial-action-highlight {
    box-shadow: 0 0 14px 3px rgba(233, 69, 96, 0.9) !important;
    border-color: var(--accent-color) !important;
    position: relative;
    z-index: 1501;
}

/* Highlighted Mixer tab during tutorial */
.tab-link.tutorial-highlight {
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.8);
    border-bottom-color: var(--accent-color);
}

@media (max-width: 768px) {
    .scroll-button {
        bottom: 70px; /* Adjust for smaller footer height */
        right: 15px;
        width: 40px;
        height: 40px;
    }
    #scroll-to-top-btn {
        bottom: 120px;
    }
    .scroll-button img {
        width: 20px;
        height: 20px;
    }
}

/* Level System UI */
#level-system-container {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--secondary-color);
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1002;
    width: 220px;
    border: 1px solid var(--accent-color);
    transition: opacity 0.3s, transform 0.3s;
}

#level-system-container h3 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.xp-bar-container {
    width: 100%;
    height: 20px;
    background-color: var(--primary-color);
    border-radius: 10px;
    margin-bottom: 5px;
    overflow: hidden;
    border: 1px solid #0f3460;
}

.xp-bar-fill {
    height: 100%;
    background-color: var(--accent-color);
    width: 0%;
    border-radius: 10px;
    transition: width 0.5s ease-in-out;
}

#xp-text {
    text-align: center;
    font-size: 0.9em;
    margin-bottom: 10px;
}

#rarity-chances-display {
    font-size: 0.85em;
    line-height: 1.5;
}

#rarity-chances-display h4 {
    margin-bottom: 5px;
    text-align: center;
    color: var(--accent-color);
}

#rarity-chances-display p {
    display: flex;
    justify-content: space-between;
}

@media (max-width: 768px) {
    #level-system-container {
        display: none !important; /* Hide on mobile for now to prevent layout issues */
    }
}

/* Tooltip */
#tooltip {
    position: absolute;
    background-color: rgba(26, 26, 46, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    font-size: 0.9em;
    font-family: var(--font-family);
    z-index: 3000;
    pointer-events: none; /* Important so it doesn't block mouse events on elements below it */
    border: 1px solid var(--accent-color);
    white-space: nowrap;
    transition: opacity 0.2s;
}

/* NEW: Rainbow text class */
.rainbow-text {
    background: var(--rainbow-color);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: bold;
}

/* INDEX MODAL */
#index-modal .index-modal-content {
    max-width: 900px;
    width: 95%;
    display: flex;
    flex-direction: column;
}

#index-toolbar {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.index-toolbar-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

#index-sort-select {
    flex: 1;
    padding: 6px 8px;
    border-radius: var(--border-radius);
    background-color: var(--secondary-color);
    color: var(--font-color);
    border: 1px solid var(--accent-color);
    font-family: var(--font-family);
    font-size: 0.9em;
}

#index-reset-button,
#index-back-to-grid {
    flex-shrink: 0;
    padding: 8px 12px;
    min-height: 36px;
}

#index-search-input {
    flex: 1;
    padding: 8px 10px;
    border-radius: var(--border-radius);
    border: 1px solid var(--secondary-color);
    background-color: var(--primary-color);
    color: var(--font-color);
    font-family: var(--font-family);
    font-size: 0.9em;
}

#index-grid {
    display: grid;
    grid-template-columns: repeat(var(--index-columns), minmax(0, 1fr));
    gap: 10px;
}

.index-square {
    position: relative;
    width: 100%;
    padding-top: 100%; /* perfect square */
    border-radius: 6px;
    overflow: hidden;
    background-color: #000;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    display: block;
}

.index-square-inner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.index-square-label {
    width: 100%;
    padding: 3px 4px;
    background: rgba(0,0,0,0.55);
    font-size: 0.7em;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.index-square-label.locked {
    color: #777;
}

.index-square-label.unlocked {
    color: #fff;
}

.index-show-more {
    margin-top: 12px;
    width: 100%;
}

/* Detail view */
#index-detail-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.index-detail-card {
    background-color: var(--secondary-color);
    border-radius: 10px;
    padding: 18px 20px;
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
    box-shadow: 0 6px 18px rgba(0,0,0,0.6);
    text-align: center;
    border: 1px solid rgba(255,255,255,0.12);
}

.index-detail-card .index-detail-back {
    align-self: flex-start;
    margin-bottom: 10px;
}

#index-detail-color-name {
    font-size: 1.7em;
    font-weight: 700;
    margin-bottom: 6px;
}

.index-detail-status-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.index-detail-status {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-unlocked {
    background-color: rgba(76, 175, 80, 0.2);
    border: 1px solid #4caf50;
    color: #c8e6c9;
}

.status-locked {
    background-color: rgba(244, 67, 54, 0.2);
    border: 1px solid #f44336;
    color: #ffcdd2;
}

#index-detail-swatch {
    width: 140px;
    height: 140px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.6);
    border: 2px solid rgba(255,255,255,0.6);
    margin: 0 auto 14px auto;
}

#index-detail-stats {
    width: 100%;
    font-size: 0.95em;
    line-height: 1.6;
    text-align: center;
}

#index-detail-stats dt {
    font-weight: 600;
    margin-top: 6px;
}

#index-detail-stats dd {
    margin-left: 0;
    margin-bottom: 4px;
    opacity: 0.9;
}

/* Rarity badge in detail */
.index-detail-badge {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid rgba(255,255,255,0.3);
}

.index-detail-badge.rarity-common {
    background-color: rgba(158,158,158,0.2);
    border-color: var(--rarity-common);
}

.index-detail-badge.rarity-uncommon {
    background-color: rgba(76,175,80,0.2);
    border-color: var(--rarity-uncommon);
}

.index-detail-badge.rarity-rare {
    background-color: rgba(33,150,243,0.2);
    border-color: var(--rarity-rare);
}

.index-detail-badge.rarity-epic {
    background-color: rgba(156,39,176,0.2);
    border-color: var(--rarity-epic);
}

.index-detail-badge.rarity-legendary {
    background-color: rgba(255,152,0,0.2);
    border-color: var(--rarity-legendary);
}

.index-detail-badge.rarity-mythic {
    background-color: rgba(244,67,54,0.2);
    border-color: var(--rarity-mythic);
}

.index-detail-badge.rarity-divine {
    background-color: rgba(205,220,57,0.2);
    border-color: var(--rarity-divine);
}

/* Prevent index squares from colliding on small screens */
@media (max-width: 768px) {
    #index-grid {
        gap: 8px;
    }

    .index-detail-card {
        max-width: 95%;
        padding: 16px;
    }
}