.skins-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.skins-overlay.fade-in {
    opacity: 1;
}

.skins-modal {
    width: 90%;
    max-width: 1100px;
    height: 85vh;
    background-color: #111;
    border: 1px solid #333;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Header */
.skins-header {
    height: 60px;
    background-color: #1a1a1a;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    flex-shrink: 0;
}

.skins-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 24px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.skins-close-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

.skins-close-btn:hover {
    color: #fff;
}

.skins-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.skins-sidebar {
    width: 200px;
    background-color: rgba(0, 0, 0, 0.3);
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    padding: 15px;
    gap: 8px;
    overflow-y: auto;
}

.category-btn {
    background: transparent;
    border: none;
    color: #888;
    text-align: left;
    padding: 10px 15px;
    cursor: pointer;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 16px;
    border-radius: 4px;
    transition: all 0.2s;
    text-transform: uppercase;
}

.category-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.category-btn.active {
    color: #4fecff;
    background: rgba(79, 236, 255, 0.1);
    box-shadow: inset 3px 0 0 #4fecff;
}

/* Content / Grid */
.skins-content {
    flex: 1;
    /* Grid/Flex nesting fix */
    min-width: 0;
    width: 100%;

    padding: 20px;
    overflow-y: auto;
    display: grid;
    /* More fluid grid */
    /* More fluid grid */
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    grid-auto-rows: max-content;
    /* Ensure rows have height */
    gap: 15px;
    align-content: start;
}

/* Custom Scrollbar */
.skins-content::-webkit-scrollbar {
    width: 6px;
}

.skins-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.skins-content::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.skins-content::-webkit-scrollbar-thumb:hover {
    background: #4fecff;
}

.skin-item {
    aspect-ratio: 1;
    min-height: 140px;
    width: 100%;
    background-color: rgba(79, 236, 255, 0.1);
    border: 2px solid #333;
    border-radius: 8px;
    cursor: pointer;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.skin-item:hover {
    transform: translateY(-4px);
    border-color: #4fecff;
    box-shadow: 0 8px 15px rgba(79, 236, 255, 0.25);
    z-index: 2;
}

.skin-selection-popup {
    position: absolute;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    z-index: 2001;
    width: 240px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.skin-selection-popup.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.skin-preview-large {
    width: 100%;
    aspect-ratio: 1;
    background-size: cover;
    background-position: center;
    border-radius: 4px;
    margin-bottom: 10px;
    border: 1px solid #333;
}

.popup-btn {
    background: #333;
    border: none;
    color: #eee;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.popup-btn:hover {
    background: #444;
    color: #fff;
}

.popup-btn.primary {
    background: linear-gradient(135deg, #00b9e8, #007bff);
    color: white;
}

.popup-btn.primary:hover {
    filter: brightness(1.1);
}

.popup-btn.secondary {
    background: linear-gradient(135deg, #e8005d, #ff007b);
    color: white;
}

.popup-btn.secondary:hover {
    filter: brightness(1.1);
}

.popup-btn.cancel {
    background: transparent;
    border: 1px solid #444;
}

.popup-btn.cancel:hover {
    background: #222;
    border-color: #666;
}

@media (max-width: 768px) {
    .skins-modal {
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
        border: none;
    }

    .skins-body {
        flex-direction: column;
    }

    .skins-sidebar {
        width: 100%;
        height: 60px;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: none;
        border-bottom: 1px solid #333;
        padding: 10px;
        white-space: nowrap;
    }

    .category-btn {
        flex: 0 0 auto;
        padding: 5px 15px;
        font-size: 14px;
    }

    .category-btn.active {
        box-shadow: inset 0 -3px 0 #4fecff;
        background: transparent;
    }

    .skins-content {
        padding: 15px;
        gap: 10px;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* Height-based responsiveness to prevent "folding" on short screens */
@media (max-height: 700px) {
    .skins-content {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 10px;
        padding: 10px;
    }

    .skins-header {
        height: 50px;
    }

    .skins-title {
        font-size: 20px;
    }
}