* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1a1a1a;
    --bg-hover: #252525;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --border: #2a2a2a;
    --success: #4caf50;
    --error: #f44336;
    --card-bg: #161616;
    --card-hover: #1e1e1e;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo img {
    height: 28px;
    width: auto;
}

.page-title {
    font-size: 14px;
    color: var(--text-secondary);
    padding-left: 16px;
    border-left: 1px solid var(--border);
}

.skin-count {
    font-size: 13px;
    color: var(--text-muted);
}

.credits-inline {
    font-size: 0.75rem;
    color: #666;
    margin-left: 12px;
}

.credits-inline a {
    color: #888;
    text-decoration: none;
    transition: color 0.2s;
}

.credits-inline a:hover {
    color: var(--accent);
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 400px;
}

.search-box input {
    width: 100%;
    padding: 10px 36px 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    display: none;
}

.clear-btn.visible {
    display: block;
}

.filters select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    min-width: 160px;
}

.filters select:focus {
    outline: none;
    border-color: var(--accent);
}

.view-options {
    display: flex;
    gap: 4px;
}

.view-btn {
    padding: 8px 10px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.view-btn:last-child {
    border-radius: 0 6px 6px 0;
}

.view-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Main Content */
.main-content {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

#filterInfo {
    color: var(--accent);
}

/* Skin Grid */
.skin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.skin-grid.list-view {
    grid-template-columns: 1fr;
    gap: 8px;
}

/* Skin Card */
.skin-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.skin-card:hover {
    background: var(--card-hover);
    border-color: var(--accent);
    transform: translateY(-3px);
}

.skin-thumb {
    aspect-ratio: 1/1;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 12px;
    position: relative;
    overflow: hidden;
}

.skin-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s;
    image-rendering: pixelated;
}

.skin-card:hover .skin-thumb img {
    transform: scale(1.08);
}

.skin-thumb .placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.skin-thumb .placeholder svg {
    width: 48px;
    height: 48px;
    opacity: 0.3;
}

.skin-info {
    padding: 12px;
}

.skin-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.skin-credits {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.skin-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* List View Cards */
.skin-grid.list-view .skin-card {
    display: flex;
    align-items: stretch;
}

.skin-grid.list-view .skin-thumb {
    width: 80px;
    height: 80px;
    aspect-ratio: auto;
    flex-shrink: 0;
}

.skin-grid.list-view .skin-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    padding: 8px 16px;
}

/* Loading */
.loading {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 60px;
    color: var(--text-secondary);
}

.loading.visible {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 80px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state.visible {
    display: flex;
}

.empty-state svg {
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 14px;
}

/* Load More */
.load-more {
    text-align: center;
    padding: 30px;
    display: none;
}

.load-more.visible {
    display: block;
}

#loadMoreBtn {
    padding: 12px 32px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

#loadMoreBtn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.visible {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 22px;
    z-index: 10;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--error);
    color: white;
}

.modal-body {
    display: flex;
    gap: 24px;
    padding: 24px;
    overflow: auto;
}

/* Modal Preview */
.modal-preview {
    width: 256px;
    height: 256px;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.modal-preview .placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.modal-preview .placeholder svg {
    width: 64px;
    height: 64px;
    opacity: 0.3;
}

/* Modal Info */
.modal-info {
    flex: 1;
    min-width: 0;
}

.modal-info h2 {
    font-size: 22px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.modal-info .skin-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.info-item {
    background: var(--bg-tertiary);
    padding: 10px;
    border-radius: 6px;
}

.info-item label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 3px;
}

.info-item span {
    font-size: 13px;
    color: var(--text-primary);
}

.info-item a {
    color: var(--accent);
    text-decoration: none;
}

.info-item a:hover {
    text-decoration: underline;
}

.info-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.info-tag {
    padding: 3px 10px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-viewer {
    background: #14b8a6;
    color: white;
}

.btn-viewer:hover {
    background: #2dd4bf;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.lightbox.visible {
    display: flex;
}

.lightbox-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    image-rendering: pixelated;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 24px;
    padding: 12px 16px;
    border-radius: 6px;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Modal preview clickable */
.modal-preview {
    cursor: pointer;
}

.modal-preview:hover img {
    opacity: 0.85;
}

/* Responsive */
@media (max-width: 900px) {
    .modal-body {
        flex-direction: column;
        align-items: center;
    }

    .modal-preview {
        width: 200px;
        height: 200px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 10px 16px;
    }

    .page-title {
        display: none;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px;
        gap: 12px;
    }

    .search-box {
        max-width: none;
    }

    .view-options {
        display: none;
    }

    .main-content {
        padding: 16px;
    }

    .skin-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    .modal {
        padding: 0;
    }

    .modal-content {
        border-radius: 16px 16px 0 0;
        max-height: 95vh;
        margin-top: auto;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-actions {
        padding: 12px 16px;
    }

    .modal-actions .btn {
        flex: 1;
        justify-content: center;
        min-width: 45%;
    }
}

@media (max-width: 480px) {
    .skin-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .skin-info {
        padding: 8px;
    }

    .skin-name {
        font-size: 13px;
    }

    .modal-preview {
        width: 160px;
        height: 160px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
