/* ============================================
   HTML VAULT // REHAULED UI
   Theme: Midnight + Glassmorphism + Neon
   ============================================ */

:root {
    /* Core surfaces - Deep Space / Obsidian Theme */
    --bg-primary: #020408;
    --bg-secondary: #060914;
    --bg-tertiary: #0b1021;
    --bg-panel: #040710;
    --bg-panel-muted: #060a17;
    --bg-card: rgba(8, 12, 26, 0.7);
    --bg-card-hover: rgba(14, 20, 38, 0.85);
    --bg-elevated: #0d1326;

    /* Glass & overlay - Refined */
    --bg-glass: rgba(4, 7, 16, 0.7);
    --bg-glass-strong: rgba(2, 4, 10, 0.9);
    --bg-glass-hover: rgba(10, 15, 35, 0.8);
    --overlay-dark: rgba(0, 0, 0, 0.85);
    --overlay-blur: 20px;

    /* Accents - Neon / Cyber Polished */
    --accent-primary: #7c3aed;
    /* Electric Violet */
    --accent-primary-glow: rgba(124, 58, 237, 0.5);
    --accent-secondary: #06b6d4;
    /* Cyan */
    --accent-purple: #d946ef;
    /* Magenta */
    --accent-pink: #f43f5e;
    /* Rose */
    --accent-success: #10b981;
    /* Emerald */
    --accent-success-soft: rgba(16, 185, 129, 0.15);
    --accent-warning: #f59e0b;
    /* Amber */
    --accent-warning-soft: rgba(245, 158, 11, 0.15);
    --accent-warning-hover: #fbbf24;
    --accent-error: #ef4444;
    /* Red */
    --accent-error-soft: rgba(239, 68, 68, 0.15);
    --accent-tertiary: #3b82f6;
    /* Blue */

    /* Gradients */
    --grad-primary: linear-gradient(135deg, #7c3aed, #06b6d4);
    --grad-secondary: linear-gradient(135deg, #d946ef, #f43f5e);
    --grad-glow: linear-gradient(120deg, rgba(124, 58, 237, 0.4), rgba(6, 182, 212, 0.4));
    --grad-dark: linear-gradient(180deg, rgba(2, 4, 8, 0.98), rgba(4, 7, 16, 0.95));
    --grad-panel: linear-gradient(145deg, rgba(6, 10, 22, 0.9), rgba(4, 7, 16, 0.95));

    /* Typography */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-subtle: #475569;
    --text-invert: #020204;

    /* Surfaces & borders */
    --surface-low: rgba(255, 255, 255, 0.03);
    --surface-mid: rgba(255, 255, 255, 0.05);
    --surface-high: rgba(255, 255, 255, 0.08);
    --surface-border: rgba(148, 163, 184, 0.1);
    --border-color: rgba(124, 58, 237, 0.15);
    --border-subtle: rgba(148, 163, 184, 0.1);
    --border-medium: rgba(148, 163, 184, 0.2);
    --border-hover: rgba(124, 58, 237, 0.4);
    --border-highlight: rgba(6, 182, 212, 0.4);
    --border-accent: rgba(124, 58, 237, 0.6);

    /* Effects */
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.7);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    --shadow-neon: 0 0 15px rgba(124, 58, 237, 0.3), 0 0 30px rgba(6, 182, 212, 0.2);
    --shadow-glow: 0 0 40px rgba(124, 58, 237, 0.25);

    --glow-border: linear-gradient(135deg, rgba(124, 58, 237, 0.6), rgba(6, 182, 212, 0.6));

    /* Radii */
    --radius-sm: 0.375rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.75rem;
    --radius-full: 9999px;

    /* Blur */
    --blur-sm: 8px;
    --blur-md: 16px;
    --blur-lg: 24px;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.5rem;

    /* Motion */
    --transition-fast: 0.15s ease-out;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Fonts */
    --font-heading: 'Orbitron', sans-serif;
    --font-subheading: 'Rajdhani', sans-serif;
    --font-body: 'Space Grotesk', sans-serif;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* GPU-accelerated scrolling */
html {
    scroll-behavior: smooth;
    /* PERF: Enable font smoothing for better text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* PERF: Reduce motion for accessibility and performance */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    /* Disable expensive backdrop-filter */
    .card,
    .main-content,
    .mobile-nav-menu,
    .modal-content,
    .upload-modal-content,
    .auth-modal {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
}

/* PERF: Content visibility for off-screen content (huge perf boost) */
.card {
    content-visibility: auto;
    contain-intrinsic-size: 0 400px;
}

/* PERF: Contain layout for better rendering performance */
.grid {
    contain: layout style;
}

.card-preview {
    contain: strict;
}

/* PERF: Force GPU layer for animated elements */
.card,
.btn-header,
.btn-primary,
.modal,
.mobile-nav-menu {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* PERF: Optimize images */
img {
    content-visibility: auto;
}

/* PERF: Passive touch scrolling */
.grid,
.main-content,
body {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 18% 20%, rgba(124, 58, 237, 0.08), transparent 45%),
        radial-gradient(circle at 82% 15%, rgba(6, 182, 212, 0.08), transparent 45%),
        radial-gradient(circle at 32% 78%, rgba(217, 70, 239, 0.05), transparent 55%),
        radial-gradient(circle at 78% 78%, rgba(59, 130, 246, 0.05), transparent 55%),
        var(--grad-dark);
    background-attachment: fixed;
    position: relative;
    padding-bottom: 4rem;
}

body::before,
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
}

body::before {
    background: radial-gradient(circle at 40% 0%, rgba(124, 58, 237, 0.12), transparent 55%);
    filter: blur(80px);
}

body::after {
    background: radial-gradient(circle at 80% 25%, rgba(6, 182, 212, 0.08), transparent 50%);
    filter: blur(80px);
    opacity: 0.7;
}

body.app-fullscreen {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 10px var(--accent-primary-glow);
    }

    50% {
        box-shadow: 0 0 20px var(--accent-primary-glow);
    }
}

/* Layout */
.page-shell,
.container {
    max-width: 1380px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header */
.header {
    position: sticky;
    top: 1.5rem;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--grad-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(var(--overlay-blur));
    -webkit-backdrop-filter: blur(var(--overlay-blur));
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.header.scrolled {
    box-shadow: var(--shadow-lg);
    background: rgba(1, 3, 10, 0.95);
    border-color: var(--border-hover);
}

.logo-block {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
    padding-right: 1rem;
}

.logo-title {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--grad-primary);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-subtitle {
    display: none;
}

@media (min-width: 768px) {
    .logo-subtitle {
        display: block;
        font-family: var(--font-subheading);
        font-size: 0.9rem;
        color: var(--text-secondary);
        margin-top: 0.2rem;
    }

    .logo-block {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-header {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-full);
    background: var(--surface-low);
    color: var(--text-secondary);
    text-decoration: none;
    font-family: var(--font-subheading);
    font-weight: 600;
    transition: var(--transition);
    border: 1px solid var(--border-color);
    letter-spacing: 0.03em;
}

.btn-header:hover {
    background: var(--surface-mid);
    color: var(--text-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
    transform: translateY(-1px);
}

.btn-header.active,
.btn-header:active {
    color: var(--text-primary);
    border-color: var(--accent-primary);
    background: rgba(96, 165, 250, 0.2);
    box-shadow: var(--shadow-neon);
}

.btn-header .btn-icon {
    font-size: 1.15rem;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    /* Hidden on desktop and tablet - only shown on phones via media query */
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
    z-index: 101;
}

/* Explicitly hide burger menu on tablets and desktops */
@media (min-width: 768px) {
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .mobile-nav-menu,
    .mobile-nav-overlay {
        display: none !important;
    }
}

/* Mobile Nav Menu */
.mobile-nav-menu {
    display: none;
    /* Hidden by default */
    position: fixed;
    top: 0;
    right: 0;
    width: 80%;
    max-width: 300px;
    height: 100vh;
    background: var(--bg-panel);
    z-index: 100;
    padding: 5rem 1.5rem 2rem;
    flex-direction: column;
    gap: 1rem;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.5);
    border-left: 1px solid var(--border-medium);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-nav-menu.active {
    transform: translateX(0);
}

.mobile-nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-nav-overlay.active {
    opacity: 1;
}

.mobile-nav-menu .btn-header {
    width: 100%;
    justify-content: flex-start;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 2rem;
    background: var(--bg-panel-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(var(--blur-md));
    -webkit-backdrop-filter: blur(var(--blur-md));
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    animation: fadeIn 0.5s ease-out;
}

/* Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur-sm));
    -webkit-backdrop-filter: blur(var(--blur-sm));
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    /* PERF: Only animate transform and opacity (GPU-accelerated) */
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    /* PERF: Promote to own layer */
    will-change: transform;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: var(--glow-border);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
}

.card:hover {
    transform: translateY(-8px) scale(1.01);
    /* PERF: Removed box-shadow animation (causes repaint) - use static shadow */
}

.card:hover::before {
    opacity: 1;
}

.card-preview {
    aspect-ratio: 16/10;
    background: var(--grad-panel);
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-preview iframe,
.card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.preview-iframe-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: calc(var(--radius-lg) - 0.75rem);
    border: 1px solid var(--border-subtle);
    background: #01030a;
    opacity: 0;
    transition: opacity var(--transition);
    box-shadow: inset 0 0 35px rgba(2, 6, 23, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-iframe {
    border: none;
    background: transparent;
    position: absolute;
    top: 50%;
    left: 50%;
}

.preview-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 0.5rem;
}

.preview-icon {
    font-size: 2rem;
    opacity: 0.5;
}

.card-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
    line-height: 1.35;
}

.card-category {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-family: var(--font-subheading);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Category Colors */
.card-category.games {
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.card-category.art {
    color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.1);
}

.card-category.tools {
    color: var(--accent-secondary);
    background: rgba(6, 182, 212, 0.1);
}

.card-description {
    padding: 0 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 1rem;
}

.card-meta {
    padding: 0 1rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
    gap: 0.75rem;
}

.card-submitter {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.submitter-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.submitter-link {
    color: var(--accent-success);
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-fast);
}

.submitter-link:hover {
    color: #6ee7b7;
    text-decoration: underline;
}

.card-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.card-actions .btn-icon {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.9rem;
}

.card-footer {
    padding: 0 1rem 1.15rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.card-views {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.rating-stars {
    color: var(--text-muted);
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.rating-stars.is-rated {
    color: var(--accent-warning);
}

.rating .star {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 1rem;
    padding: 0.1rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.rating span.star {
    cursor: default;
    pointer-events: none;
}

.rating .star.filled,
.rating .star:hover,
.rating .star:focus-visible {
    color: var(--accent-warning);
}

.rating .star:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.25);
    border-radius: 50%;
}

/* Prompt Cards */
.prompt-card {
    background: linear-gradient(145deg, rgba(7, 13, 28, 0.92), rgba(3, 7, 16, 0.85));
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.prompt-card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-neon);
    transform: translateY(-4px);
    background: linear-gradient(145deg, rgba(10, 20, 44, 0.95), rgba(4, 10, 24, 0.92));
}

.prompt-text {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0;
    line-height: 1.5;
    max-height: 100px;
    overflow: hidden;
    position: relative;
}

.prompt-text::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, var(--bg-glass));
}

.prompt-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: auto;
}

/* Buttons */
button {
    font-family: var(--font-subheading);
}

.btn-primary {
    background: rgba(124, 58, 237, 0.15);
    color: var(--text-primary);
    border: 1px solid #3b82f6;
    padding: 0.8rem 1.75rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.3);
    letter-spacing: 0.04em;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.5);
}

.btn-primary:hover::before {
    opacity: 1;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.btn-secondary:hover {
    background: var(--surface-high);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-icon {
    background: var(--surface-low);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
    cursor: pointer;
}

.btn-icon:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.25);
    background: rgba(59, 130, 246, 0.1);
    transform: rotate(5deg);
}

button:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-icon:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

/* Sorting Controls */
.sorting {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem;
    background: rgba(7, 12, 25, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius-full);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    height: 38px;
}

.sort-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.45rem 1.2rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sort-btn:hover {
    color: var(--text-primary);
}

.sort-btn.active {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid #3b82f6;
    color: var(--text-primary);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

/* Tabs & Filters */
.tabs-container {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

.filters-row>div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filters-row label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.filters-row select {
    background: var(--bg-panel-muted);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    min-width: 140px;
    height: 38px;
}

.filters-row select:hover {
    border-color: var(--border-hover);
}

.filters-row select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.explorer-tabs {
    display: inline-flex;
    padding: 0.35rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.6rem 1.4rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.03em;
    transition: var(--transition);
}

.tab-btn.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: var(--text-primary);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.filters-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--bg-card);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.filters-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex: 1;
    align-items: center;
}

.category-btn {
    background: var(--surface-low);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    position: relative;
    font-weight: 500;
    height: 38px;
}

.category-btn::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    opacity: 0;
    background: var(--glow-border);
    filter: blur(8px);
    transition: var(--transition);
    z-index: -1;
}

.category-btn:hover,
.category-btn.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: var(--text-primary);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
}

.category-btn:hover::after,
.category-btn.active::after {
    opacity: 0.7;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
textarea,
select {
    width: 100%;
    background: var(--bg-panel-muted);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    transition: var(--transition);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), 0 0 15px rgba(59, 130, 246, 0.1);
    background: var(--bg-card-hover);
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 3rem;
}

.pagination-btn {
    background: rgba(124, 58, 237, 0.15);
    border: 2px solid var(--accent-primary);
    color: var(--text-primary);
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.2rem;
    font-weight: 600;
    box-shadow: 0 0 15px var(--accent-primary-glow), inset 0 0 10px rgba(124, 58, 237, 0.1);
    text-shadow: 0 0 8px var(--accent-primary-glow);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--accent-primary-glow), 0 5px 20px rgba(124, 58, 237, 0.4);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.pagination-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 0 20px var(--accent-primary-glow), 0 0 30px rgba(124, 58, 237, 0.3);
}

.pagination-info {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    color: var(--text-primary);
    font-family: var(--font-subheading);
    font-size: 1rem;
    font-weight: 600;
    text-shadow: 0 0 10px var(--accent-primary-glow);
    min-width: 60px;
}



/* Modals */
.modal,
.upload-prompt-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--overlay-dark);
    backdrop-filter: blur(var(--overlay-blur));
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 1rem;
}

.viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    background: #010511;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 0;
}

/* Prompt modal override - keep centered style */
.viewer-modal.prompt-modal {
    align-items: center;
    justify-content: center;
    background: var(--overlay-dark);
    backdrop-filter: blur(var(--overlay-blur));
    padding: 1rem;
}

.modal.active,
.viewer-modal.active,
.upload-prompt-modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content,
.upload-modal-content {
    background: var(--grad-panel);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 500px;
    position: relative;
    box-shadow: var(--shadow-xl), var(--shadow-glow);
    transform: translateY(20px);
    transition: var(--transition-bounce);
    max-height: 90vh;
    overflow-y: auto;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.modal.active .modal-content,
.viewer-modal.active .viewer-wrapper,
.upload-prompt-modal.active .upload-modal-content {
    transform: translateY(0);
}

.modal-header,
.upload-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2,
.upload-modal-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin: 0;
}

.modal-close,
.upload-modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover,
.upload-modal-close:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

/* Auth Modal */
.auth-modal {
    background: var(--bg-glass-strong);
    backdrop-filter: blur(var(--overlay-blur));
    -webkit-backdrop-filter: blur(var(--overlay-blur));
    border: 1px solid var(--border-color);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8), var(--shadow-neon);
}

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.35rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius-full);
}

.auth-tab {
    flex: 1;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
}

.auth-tab:hover {
    color: var(--text-primary);
}

.auth-tab.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: var(--text-primary);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.auth-form {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.auth-form+.auth-form {
    margin-top: 1.5rem;
}

.auth-submit-btn {
    width: 100%;
    justify-content: center;
}

.auth-form .form-hint {
    color: var(--text-muted);
}

.btn-loading {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
}

.terms-checkbox-wrapper {
    padding: 0.75rem 0.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-panel-muted);
    border: 1px solid var(--border-subtle);
}

.terms-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.terms-checkbox {
    position: absolute;
    opacity: 0;
}

.terms-checkbox-custom {
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 0.35rem;
    border: 1px solid rgba(148, 163, 184, 0.5);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.terms-checkbox:checked+.terms-checkbox-custom {
    background: rgba(124, 58, 237, 0.3);
    border-color: #3b82f6;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.terms-checkbox-text a {
    color: var(--accent-primary);
    text-decoration: none;
}

.terms-checkbox-text a:hover {
    text-decoration: underline;
}

/* Viewer Modal - Auto Mode Style */
.viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #010511;
    transform: translateY(20px);
    transition: var(--transition);
}

.viewer-modal.active .viewer-container {
    transform: translateY(0);
}

.viewer-modal #viewerFrame {
    width: 100%;
    flex: 1;
    border: none;
    background: #010511;
}

/* Viewer Bottom Bar - Auto Mode Style */
.viewer-bar {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(5, 9, 18, 0.9);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-full);
    padding: 0.5rem 1.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    gap: 1.5rem;
    backdrop-filter: blur(18px);
    min-width: 300px;
    max-width: calc(100vw - 3rem);
}

.viewer-bar-left,
.viewer-bar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.viewer-bar-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.viewer-bar-title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
    margin: 0;
}

.viewer-bar-rating {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.viewer-bar-rating .rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.viewer-bar-rating .rating-stars {
    display: flex;
    gap: 0.1rem;
}

.viewer-bar-rating .star {
    background: transparent;
    border: none;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.25);
    cursor: pointer;
    transition: var(--transition);
    padding: 0 0.1rem;
    line-height: 1;
}

.viewer-bar-rating .star:hover,
.viewer-bar-rating .star.filled {
    color: #fbbf24;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.viewer-bar-rating .rating-value {
    font-family: var(--font-subheading);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.viewer-bar-rating .rating-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.viewer-bar-btn {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.viewer-bar-btn:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.viewer-exit-btn {
    width: auto;
    padding: 0 1rem;
    font-family: var(--font-subheading);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.viewer-exit-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Fullscreen state */
.viewer-container.viewer-wrapper--fullscreen .viewer-bar {
    display: none;
}

.viewer-container.viewer-wrapper--fullscreen #viewerFrame {
    border-radius: 0;
}

/* Mobile responsive */
@media (max-width: 767px) {
    .viewer-bar {
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        border-radius: 0;
        border-top: 1px solid rgba(148, 163, 184, 0.2);
        border-left: none;
        border-right: none;
        border-bottom: none;
        padding: 0.625rem 0.75rem;
        padding-bottom: calc(0.625rem + env(safe-area-inset-bottom, 0px));
        gap: 0.5rem;
    }
    
    .viewer-bar-title {
        font-size: 0.75rem;
        max-width: 150px;
    }
    
    .viewer-bar-btn {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    .viewer-exit-btn {
        padding: 0 0.75rem;
        font-size: 0.8rem;
    }
}

/* Legacy support - keep old selectors working */
.viewer-wrapper {
    width: 100%;
    height: 100%;
}

#exitFullscreenBtn {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.92);
    color: var(--text-primary);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-full);
    padding: 0.45rem 1.35rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    box-shadow: var(--shadow-lg);
    z-index: 1200;
}

/* Footer */
.site-footer {
    margin-top: 4rem;
    padding: 3rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(var(--blur-sm));
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
    position: relative;
}

.footer-link:hover {
    color: var(--accent-primary);
}

.footer-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--accent-primary);
    transition: var(--transition);
}

.footer-link:hover::after {
    width: 100%;
}

.footer-copyright {
    color: var(--text-muted);
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Profile Page Styles - Enhanced */
.profile-header {
    background: var(--bg-panel-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    overflow: hidden;
    margin-bottom: 2rem;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.profile-banner {
    height: 200px;
    background:
        radial-gradient(circle at 20% 50%, rgba(124, 58, 237, 0.2), transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(6, 182, 212, 0.2), transparent 50%),
        var(--grad-dark);
    position: relative;
    border-bottom: 1px solid var(--border-subtle);
}

.profile-banner::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: linear-gradient(to bottom, black, transparent);
    -webkit-mask-image: linear-gradient(to bottom, black, transparent);
    opacity: 0.3;
}

.profile-content {
    padding: 0 2.5rem 2.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: -60px;
}

.profile-avatar {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 4px solid var(--bg-panel-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    position: relative;
    z-index: 2;
    box-shadow: var(--shadow-xl);
    background: linear-gradient(145deg, #0f172a, #020617);
}

.profile-info {
    text-align: center;
    margin-top: 1rem;
    margin-bottom: 2rem;
    max-width: 600px;
}

.profile-name {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(124, 58, 237, 0.15);
}

.profile-username {
    color: var(--accent-primary);
    font-family: var(--font-subheading);
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    letter-spacing: 0.05em;
}

.profile-verified {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.2);
    border-radius: var(--radius-full);
    color: var(--accent-secondary);
    font-family: var(--font-subheading);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.profile-bio-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 2rem;
    margin-top: 1.5rem;
    position: relative;
}

.profile-bio-section::before {
    content: '';
    display: none;
}

.profile-bio {
    color: var(--text-secondary);
    font-style: normal;
    line-height: 1.7;
    font-size: 0.95rem;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    width: 100%;
    max-width: 900px;
    margin-bottom: 2rem;
}

.stat-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    text-align: center;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.stat-item:hover {
    transform: translateY(-3px);
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-md);
}

.stat-number {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-heading);
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.profile-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Auto Mode UI */
.auto-mode-container {
    position: relative;
    min-height: 100vh;
    padding: 2.25rem 1.75rem 3.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    isolation: isolate;
}

.auto-mode-container::before {
    content: '';
    position: absolute;
    inset: 1.25rem;
    border-radius: 2.5rem;
    background:
        radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.16), transparent 55%),
        radial-gradient(circle at 80% 5%, rgba(236, 72, 153, 0.12), transparent 60%),
        radial-gradient(circle at 60% 80%, rgba(6, 182, 212, 0.1), transparent 70%);
    filter: blur(80px);
    opacity: 0.8;
    pointer-events: none;
    z-index: 0;
}

.auto-mode-container>* {
    position: relative;
    z-index: 1;
}

#autoFrame {
    width: 100%;
    height: calc(100vh - 220px);
    min-height: 440px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 1.25rem;
    background: #010511;
    box-shadow: 0 25px 50px rgba(2, 6, 23, 0.65);
    backdrop-filter: blur(6px);
    transition: var(--transition);
}

.auto-top-bar {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(5, 9, 18, 0.9);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-full);
    padding: 0.5rem 1.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    gap: 1.5rem;
    backdrop-filter: blur(18px);
    width: min(95%, 800px);
}

.auto-center-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
}

.auto-nav-controls,
.auto-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auto-title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.auto-back-btn,
.auto-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: var(--text-secondary);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-width: 46px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.auto-back-btn:hover,
.auto-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 10px 20px rgba(14, 165, 233, 0.25);
}

.auto-fullscreen-btn {
    min-width: 46px;
    padding: 0.35rem 0.65rem;
    font-size: 1.1rem;
}

.auto-fullscreen-btn .auto-fullscreen-icon.exit {
    display: none;
}

.auto-mode-container.is-fullscreen .auto-fullscreen-btn .auto-fullscreen-icon.enter,
.auto-mode-container:fullscreen .auto-fullscreen-btn .auto-fullscreen-icon.enter {
    display: none;
}

.auto-mode-container.is-fullscreen .auto-fullscreen-btn .auto-fullscreen-icon.exit,
.auto-mode-container:fullscreen .auto-fullscreen-btn .auto-fullscreen-icon.exit {
    display: inline;
}

.auto-back-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* .auto-bottom-bar removed - merged into top bar */

.auto-stars {
    display: flex;
    gap: 0.25rem;
}

.auto-star {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.25);
    cursor: pointer;
    transition: var(--transition);
    padding: 0 0.1rem;
    line-height: 1;
}

.auto-star:hover,
.auto-star.active,
.auto-star.selected {
    color: var(--accent-warning);
    transform: translateY(-2px);
}

.auto-restore-btn {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    background: rgba(6, 95, 70, 0.85);
    border: 1px solid rgba(16, 185, 129, 0.6);
    color: #edfff7;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: none;
}

.auto-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(2, 6, 23, 0.92);
    border-radius: inherit;
    backdrop-filter: blur(12px);
    z-index: 10;
}

.auto-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: 0.85rem 1.2rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(10px);
    transition: var(--transition);
}

.auto-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.auto-mode-container.is-fullscreen,
.auto-mode-container:fullscreen {
    padding: 1.5rem 1.5rem 2.25rem;
    gap: 1.5rem;
}

.auto-mode-container.is-fullscreen #autoFrame,
.auto-mode-container:fullscreen #autoFrame {
    height: calc(100vh - 180px);
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
}

.auto-mode-container.is-fullscreen .auto-top-bar,
.auto-mode-container:fullscreen .auto-top-bar {
    top: 1rem;
    background: rgba(3, 7, 18, 0.88);
    border-color: rgba(59, 130, 246, 0.35);
    box-shadow: var(--shadow-lg);
}

.auto-mode-container.is-fullscreen .auto-bottom-bar,
.auto-mode-container:fullscreen .auto-bottom-bar {
    width: min(520px, calc(100% - 3rem));
    bottom: 1.25rem;
}

.auto-mode-container.is-fullscreen .auto-restore-btn,
.auto-mode-container:fullscreen .auto-restore-btn {
    bottom: 1.25rem;
    right: 1.25rem;
}

/* Battle Mode UI */
.battle-mode-container {
    position: relative;
    min-height: 100vh;
    padding: 2.5rem 1.75rem 4.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    isolation: isolate;
}

.battle-mode-container::before {
    content: '';
    position: absolute;
    inset: 1.25rem;
    border-radius: 2.75rem;
    background:
        radial-gradient(circle at 15% 20%, rgba(248, 113, 113, 0.22), transparent 60%),
        radial-gradient(circle at 80% 5%, rgba(251, 113, 133, 0.15), transparent 55%),
        radial-gradient(circle at 60% 85%, rgba(59, 7, 100, 0.25), transparent 70%);
    filter: blur(90px);
    opacity: 0.85;
    pointer-events: none;
    z-index: 0;
}

.battle-mode-container>* {
    position: relative;
    z-index: 1;
}

.battle-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(27, 6, 6, 0.9), rgba(5, 2, 8, 0.9));
    border: 1px solid rgba(248, 113, 113, 0.35);
    border-radius: var(--radius-lg);
    padding: 0.9rem 1.25rem;
    box-shadow: 0 25px 60px rgba(120, 16, 32, 0.45);
}

.battle-nav-controls,
.battle-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.battle-title {
    font-family: var(--font-heading);
    letter-spacing: 0.25em;
    color: #fecdd3;
    text-transform: uppercase;
}

.battle-back-btn,
.battle-btn {
    background: rgba(120, 20, 40, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #fecaca;
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.battle-back-btn:hover,
.battle-btn:hover {
    background: rgba(248, 113, 113, 0.2);
    color: var(--text-primary);
    box-shadow: 0 15px 35px rgba(248, 113, 113, 0.35);
}

.battle-split-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

.battle-frame-wrapper {
    background: rgba(8, 10, 20, 0.9);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.battle-frame-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(248, 113, 113, 0.15);
}

.battle-item-title {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.battle-frame-controls {
    display: flex;
    gap: 0.35rem;
}

.battle-frame-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(248, 113, 113, 0.25);
    color: #fecdd3;
    padding: 0.35rem 0.8rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.battle-frame-btn:hover {
    background: rgba(248, 113, 113, 0.2);
}

.battle-iframe-container {
    width: 100%;
    height: clamp(320px, 45vh, 520px);
    position: relative;
    overflow: hidden;
    background: #020617;
}

.battle-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: #020617;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
}

.battle-frame-wrapper.battle-fullscreen {
    grid-column: 1 / -1;
    min-height: clamp(360px, calc(100vh - 280px), 1200px);
    border-radius: calc(var(--radius-lg) + 0.5rem);
    box-shadow: var(--shadow-xl);
}

.battle-frame-wrapper.battle-fullscreen .battle-iframe-container {
    height: clamp(420px, calc(100vh - 340px), 900px);
}

.battle-bottom-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: rgba(5, 8, 16, 0.95);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
}

.battle-rating {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1rem;
    min-width: 260px;
}

.battle-rating-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.battle-stars {
    display: flex;
    gap: 0.35rem;
}

.battle-star {
    background: transparent;
    border: none;
    font-size: 1.6rem;
    color: rgba(252, 231, 243, 0.25);
    cursor: pointer;
    transition: var(--transition);
}

.battle-star:hover,
.battle-star.active,
.battle-star.selected {
    color: #fb7185;
    transform: translateY(-3px);
}

.battle-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fecaca;
    font-weight: 700;
    letter-spacing: 0.5em;
}

.battle-submit-btn {
    background: linear-gradient(135deg, #fb7185, #ef4444);
    border: none;
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 18px 40px rgba(239, 68, 68, 0.35);
    transition: var(--transition);
}

.battle-submit-btn:hover {
    transform: translateY(-2px);
}

.battle-fullscreen-minimize {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    background: rgba(248, 113, 113, 0.2);
    border: 1px solid rgba(248, 113, 113, 0.5);
    color: var(--text-primary);
    padding: 0.35rem 1rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    display: none;
    z-index: 20;
}

.battle-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(12, 2, 16, 0.95);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-lg);
    z-index: 10;
}

.battle-toast {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(6, 4, 10, 0.95);
    border: 1px solid rgba(248, 113, 113, 0.3);
    padding: 0.9rem 1.2rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    color: #fecdd3;
    opacity: 0;
    transform: translateY(-10px);
    transition: var(--transition);
}

.battle-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.battle-mode-container.has-fullscreen {
    padding-bottom: 7rem;
}

.battle-mode-container.has-fullscreen .battle-top-bar {
    position: sticky;
    top: 1rem;
    z-index: 25;
}

.battle-mode-container.has-fullscreen .battle-bottom-section {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: min(1100px, calc(100% - 3rem));
    box-shadow: var(--shadow-xl);
    background: rgba(5, 8, 16, 0.95);
    border-color: rgba(248, 113, 113, 0.45);
    z-index: 40;
}

.battle-mode-container.has-fullscreen .battle-rating {
    background: rgba(255, 255, 255, 0.04);
}

.battle-mode-container:fullscreen {
    padding: 1.75rem 1.5rem 3.5rem;
}

/* Loading Spinner */
.loading-spinner-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    z-index: 2000;
    transition: opacity 0.3s;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
}

.spinner-visual {
    position: relative;
    width: 62px;
    height: 62px;
}

.spinner-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid rgba(148, 163, 184, 0.2);
    border-top-color: var(--accent-primary);
    animation: spin 1s linear infinite;
}

.spinner-ring:nth-child(2) {
    inset: 6px;
    border-color: rgba(148, 163, 184, 0.15);
    border-top-color: var(--accent-secondary);
    animation-duration: 1.5s;
}

.spinner-ring:nth-child(3) {
    inset: 12px;
    border-color: rgba(148, 163, 184, 0.1);
    border-top-color: var(--accent-purple);
    animation-duration: 1.9s;
}

.spinner-text,
.loading-text {
    font-size: 0.95rem;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Utilities */
/* ============================================
   RESPONSIVE DESIGN - TABLET & MOBILE
   ============================================ */

/* Tablet Styles (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {

    .page-shell,
    .container {
        padding: 2rem 1.25rem 3rem;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1.25rem;
    }

    .header {
        padding: 0.875rem 1.5rem;
    }

    .btn-header {
        padding: 0.45rem 1rem;
        font-size: 0.9rem;
    }

    .card-title {
        font-size: 1.05rem;
    }
}

/* Mobile Styles (phones only - tablets get desktop layout) */
@media (max-width: 767px) {
    body {
        padding-bottom: 2rem;
    }

    .page-shell,
    .container {
        padding: 1rem 0.875rem 2.5rem;
        gap: 1.5rem;
    }

    /* Hide Battle Mode and Battle Leaderboard on mobile phones */
    .btn-battle-mode,
    .btn-battle-leaderboard {
        display: none !important;
    }

    /* Header Mobile Optimization */
    .header {
        flex-direction: row;
        /* Keep horizontal for mobile */
        align-items: center;
        justify-content: space-between;
        top: 0.5rem;
        padding: 0.875rem 1rem;
        margin: 0 0.5rem;
    }

    .logo-title {
        font-size: 1.25rem;
    }

    .logo-icon svg {
        width: 28px;
        height: 28px;
    }

    .header-actions {
        display: none;
        /* Hide desktop nav on phones */
    }

    .mobile-menu-toggle {
        display: block;
        /* Show burger menu on phones */
    }

    /* Mobile Menu */
    .mobile-nav-menu {
        display: flex;
    }

    .mobile-nav-overlay {
        /* Keep display: none by default, JS will show it when menu opens */
        display: none;
    }

    /* Main Content */
    .main-content {
        padding: 1.25rem;
        gap: 1.5rem;
        margin: 0 0.5rem;
    }

    /* Filters Toolbar */
    .filters-toolbar {
        padding: 0.875rem;
        gap: 0.875rem;
    }

    .filters-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.625rem;
    }

    .filters-row>div {
        width: 100%;
    }

    .filters-row select,
    .filters-row input {
        width: 100%;
        padding: 0.625rem;
        font-size: 0.9rem;
    }

    .categories {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .category-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.85rem;
        flex-grow: 1;
    }

    /* Grid Layout */
    .grid {
        grid-template-columns: 1fr;
        /* Single column on mobile */
        gap: 1.25rem;
    }

    /* Cards Mobile Optimization */
    .card {
        border-radius: var(--radius-md);
    }

    .card:hover {
        transform: translateY(-4px) scale(1);
    }

    .card-header {
        padding: 0.875rem;
    }

    .card-title {
        font-size: 1.05rem;
    }

    .card-description {
        padding: 0 0.875rem;
        font-size: 0.875rem;
        margin-bottom: 0.875rem;
    }

    .card-footer {
        padding: 0.875rem;
        gap: 0.75rem;
    }

    .card-actions {
        gap: 0.5rem;
    }

    .card-actions .btn-icon {
        width: 2.2rem;
        height: 2.2rem;
    }

    /* Stats */
    .card-stats {
        gap: 0.75rem;
        font-size: 0.8rem;
    }

    .profile-stats {
        gap: 1.25rem;
    }

    /* Auto Mode Mobile */
    #autoFrame {
        height: calc(100vh - 160px);
        height: calc(var(--vh, 1vh) * 100 - 160px);
        min-height: 300px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .auto-mode-container {
        padding: 0;
        gap: 0;
    }

    .auto-mode-container::before {
        display: none;
    }

    .auto-top-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        padding: 0.625rem 0.75rem;
        padding-bottom: calc(0.625rem + env(safe-area-inset-bottom, 0px));
        border-radius: 0;
        border-top: 1px solid rgba(148, 163, 184, 0.2);
        border-bottom: none;
        border-left: none;
        border-right: none;
        background: rgba(3, 7, 18, 0.95);
    }

    .auto-nav-controls {
        gap: 0.375rem;
        order: 1;
    }

    .auto-center-group {
        flex: 1;
        order: 2;
        gap: 0.25rem;
        min-width: 0;
    }

    .auto-title {
        font-size: 0.8rem;
        padding: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .auto-controls {
        gap: 0.375rem;
        flex-wrap: nowrap;
        order: 3;
    }

    .auto-btn {
        padding: 0.5rem;
        font-size: 0.85rem;
        min-width: 40px;
        min-height: 40px;
    }

    .auto-back-btn {
        padding: 0.5rem 0.625rem;
        font-size: 0.8rem;
        min-height: 40px;
    }

    .auto-history-btn {
        padding: 0.5rem;
    }

    .auto-bottom-bar {
        padding: 0.75rem;
        border-radius: 0;
    }

    .auto-stars {
        gap: 0.25rem;
    }

    .auto-star {
        font-size: 1.5rem;
        min-width: 36px;
        min-height: 36px;
        padding: 0.25rem;
    }

    .auto-restore-btn {
        bottom: auto;
        top: 0.5rem;
        right: 0.5rem;
        padding: 0.5rem 0.875rem;
        font-size: 0.8rem;
    }

    /* Hide some less essential buttons on very small screens */
    .auto-fullscreen-btn {
        display: none;
    }

    /* Battle Mode Mobile */
    .battle-mode-container {
        padding: 0;
        gap: 0;
    }

    .battle-top-bar {
        flex-wrap: wrap;
        gap: 0.625rem;
        padding: 0.75rem;
        border-radius: 0;
    }

    .battle-title {
        flex: 1 1 100%;
        order: 3;
        text-align: center;
        font-size: 1.1rem;
        padding: 0.5rem 0 0;
    }

    .battle-nav-controls {
        gap: 0.5rem;
    }

    .battle-back-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.85rem;
        min-height: 44px;
    }

    .battle-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.85rem;
        min-height: 44px;
    }

    .battle-split-container {
        flex-direction: column;
        height: auto;
        min-height: 70vh;
    }

    .battle-frame-wrapper {
        width: 100%;
        height: 50vh;
        min-height: 350px;
    }

    .battle-frame-header {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .battle-item-title {
        font-size: 0.9rem;
    }

    .battle-frame-btn {
        padding: 0.45rem 0.75rem;
        font-size: 0.8rem;
        min-height: 40px;
    }

    .battle-bottom-section {
        flex-direction: column;
        padding: 1rem;
        gap: 1.25rem;
        border-radius: 0;
    }

    .battle-rating-container {
        width: 100%;
    }

    .battle-rating {
        width: 100%;
        gap: 0.75rem;
    }

    .battle-rating-label {
        font-size: 0.875rem;
    }

    .battle-stars {
        gap: 0.5rem;
    }

    .battle-star {
        font-size: 1.75rem;
        min-width: 44px;
        min-height: 44px;
    }

    .battle-divider {
        width: 100%;
        height: 2px;
        margin: 0;
    }

    .battle-divider-text {
        transform: translateY(-50%);
    }

    .battle-submit-btn {
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
        min-height: 50px;
    }

    .battle-mode-container.has-fullscreen .battle-bottom-section {
        width: calc(100% - 1rem);
        padding: 0.875rem;
    }

    /* Leaderboard Mobile */
    .leaderboard-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-value {
        font-size: 2rem;
    }

    .leaderboard-table {
        font-size: 0.85rem;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 0.75rem 0.875rem;
    }

    .leaderboard-table th {
        font-size: 0.75rem;
    }

    /* Toast Notifications */
    #globalToast,
    .prompt-toast,
    .profile-toast,
    .auto-toast,
    .battle-toast {
        bottom: 1rem;
        padding: 0.875rem 1.5rem;
        font-size: 0.9rem;
        max-width: calc(100vw - 2rem);
    }

    /* Buttons General */
    .btn-primary,
    .btn-secondary {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
        min-height: 48px;
    }
}

/* Small Mobile Styles (max-width: 480px) */
@media (max-width: 480px) {

    .page-shell,
    .container {
        padding: 0.75rem 0.5rem 2rem;
    }

    .header {
        margin: 0 0.25rem;
        padding: 0.75rem 0.875rem;
        gap: 0.75rem;
    }

    .logo-title {
        font-size: 1.15rem;
    }

    .main-content {
        padding: 1rem;
        margin: 0 0.25rem;
    }

    .mobile-nav-menu {
        width: 85%;
    }

    /* Auto Mode Small Mobile */
    #autoFrame {
        height: calc(100vh - 140px);
        height: calc(var(--vh, 1vh) * 100 - 140px);
        min-height: 280px;
    }

    .auto-top-bar {
        padding: 0.5rem;
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
        gap: 0.375rem;
    }

    .auto-title {
        font-size: 0.75rem;
    }

    .auto-btn {
        padding: 0.375rem;
        min-width: 36px;
        min-height: 36px;
    }

    .auto-back-btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
        min-height: 36px;
    }

    .auto-star {
        font-size: 1.25rem;
        min-width: 32px;
        min-height: 32px;
    }

    /* Hide download button on very small screens to save space */
    #downloadAutoBtn {
        display: none !important;
    }

    /* Battle Mode Small Mobile */
    .battle-frame-wrapper {
        height: 45vh;
        min-height: 300px;
    }

    .battle-item-title {
        font-size: 0.8rem;
    }

    .battle-frame-btn {
        padding: 0.4rem 0.65rem;
        font-size: 0.75rem;
        min-height: 36px;
    }

    .battle-star {
        font-size: 1.5rem;
        min-width: 40px;
        min-height: 40px;
    }

    .card-title {
        font-size: 1rem;
    }
}

/* Landscape Mobile Optimization */
@media (max-height: 600px) and (orientation: landscape) {
    .auto-mode-container #autoFrame {
        height: calc(100vh - 100px);
        height: calc(var(--vh, 1vh) * 100 - 100px);
    }

    .battle-frame-wrapper {
        height: 60vh;
    }

    .auto-top-bar {
        padding: 0.375rem 0.5rem;
        padding-bottom: calc(0.375rem + env(safe-area-inset-bottom, 0px));
        gap: 0.5rem;
    }

    .battle-top-bar {
        padding: 0.5rem 0.75rem;
    }

    .auto-center-group {
        flex-direction: row;
        gap: 0.75rem;
    }

    .auto-title {
        font-size: 0.8rem;
    }

    .auto-stars {
        gap: 0.125rem;
    }

    .auto-star {
        font-size: 1.25rem;
        min-width: 32px;
        min-height: 32px;
    }

    .auto-bottom-bar,
    .battle-bottom-section {
        padding: 0.75rem;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {

    /* Increase touch targets */
    .btn-header,
    .auto-btn,
    .battle-btn,
    .battle-frame-btn,
    .category-btn,
    .btn-card,
    .tab-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* Disable hover effects on touch devices */
    .card:hover {
        transform: translateY(0);
    }

    /* Make star ratings more touch-friendly */
    .auto-star,
    .battle-star {
        padding: 0.5rem;
    }
}

/* ============================================
   MOBILE-SPECIFIC ENHANCEMENTS
   ============================================ */

/* Touch active states */
.is-mobile-device .touch-active {
    opacity: 0.7;
    transform: scale(0.96);
    transition: all 0.1s ease;
}

.is-mobile-device .card.touch-active {
    transform: scale(0.98);
}

/* Improved tap targets for mobile */
.is-mobile-device button,
.is-mobile-device a,
.is-mobile-device .category-btn,
.is-mobile-device .btn-card {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Custom viewport height for mobile browsers */
.auto-mode-container,
.battle-mode-container {
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
}

.auto-mode-container #autoFrame {
    height: calc(var(--vh, 1vh) * 100 - 150px);
}

/* Prevent text selection on interactive elements on mobile */
.is-mobile-device .btn-header,
.is-mobile-device .auto-btn,
.is-mobile-device .battle-btn,
.is-mobile-device .category-btn,
.is-mobile-device .card-actions button {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Optimize scrolling on mobile */
.is-mobile-device {
    -webkit-overflow-scrolling: touch;
}

.is-mobile-device .main-content,
.is-mobile-device .auto-mode-container,
.is-mobile-device .battle-mode-container {
    overflow-x: hidden;
}

/* Better form inputs on mobile */
@media (max-width: 767px) {

    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px;
        /* Prevents zoom on iOS */
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }
}

/* Swipe indicator hints (subtle) */
.is-mobile-device .auto-mode-container::after {
    content: '← Swipe →';
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.3;
    pointer-events: none;
    animation: fadeOut 3s ease-out 2s forwards;
}

.is-mobile-device .battle-bottom-section::after {
    content: '← Swipe to skip';
    position: absolute;
    bottom: 0.5rem;
    right: 1rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.3;
    pointer-events: none;
    animation: fadeOut 3s ease-out 2s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* Improve loading states on mobile */
.is-mobile-device .loading-spinner {
    transform: scale(0.85);
}

/* Better modal/overlay behavior on mobile */
@media (max-width: 767px) {
    .viewer-overlay {
        padding: 0;
    }

    .viewer-panel {
        border-radius: 0;
        max-height: 100vh;
        max-height: calc(var(--vh, 1vh) * 100);
    }
}

/* Improve grid performance on mobile */
.is-mobile-device .grid {
    will-change: transform;
}

.is-mobile-device .card {
    will-change: transform;
}

/* Safe area padding for notched devices */
@supports (padding: max(0px)) {
    .header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .auto-top-bar,
    .battle-top-bar {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }

    .auto-bottom-bar,
    .battle-bottom-section {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}



/* Leaderboard Specific Styles - Enhanced */
.leaderboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: linear-gradient(145deg, rgba(12, 18, 38, 0.6), rgba(6, 10, 24, 0.8));
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    transition: var(--transition-bounce);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle at 100% 0%, rgba(124, 58, 237, 0.15), transparent 70%);
    opacity: 0.6;
    pointer-events: none;
    border-top-right-radius: var(--radius-lg);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-primary);
    box-shadow: 0 15px 30px -10px rgba(124, 58, 237, 0.2);
    background: linear-gradient(145deg, rgba(18, 24, 50, 0.7), rgba(10, 14, 32, 0.9));
}

.stat-value {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 30%, #a5b4fc);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: var(--font-heading);
    margin-bottom: 0.25rem;
    position: relative;
    z-index: 1;
    line-height: 1;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-label::before {
    content: '';
    display: block;
    width: 20px;
    height: 2px;
    background: var(--accent-primary);
    border-radius: 2px;
}

.leaderboard-container {
    background: var(--bg-panel-muted);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-subtle);
    padding: 0;
    position: relative;
}

.leaderboard-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    /* Collapsed for cleaner lines in container */
}

.leaderboard-table thead th {
    background: rgba(2, 6, 16, 0.95);
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 1.25rem 1.5rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
}

.leaderboard-table tbody tr {
    transition: var(--transition);
    background: transparent;
}

.leaderboard-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.01);
}

.leaderboard-table td {
    padding: 1.25rem 1.5rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

.leaderboard-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

.leaderboard-table tbody tr:hover td {
    color: #fff;
}

/* Rank Styling */
.rank-cell {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-muted);
    width: 80px;
    text-align: center;
}

.rank-badge {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin: 0 auto;
    font-size: 0.9rem;
}

/* Top 3 Ranks */
.rank-1 .rank-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
    font-size: 1.1rem;
}

.rank-2 .rank-badge {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    color: #fff;
    box-shadow: 0 0 15px rgba(148, 163, 184, 0.3);
}

.rank-3 .rank-badge {
    background: linear-gradient(135deg, #b45309, #78350f);
    color: #fff;
    box-shadow: 0 0 15px rgba(180, 83, 9, 0.3);
}

.rank-1 td {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.08), transparent);
}

.rank-2 td {
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.05), transparent);
}

.rank-3 td {
    background: linear-gradient(90deg, rgba(180, 83, 9, 0.05), transparent);
}

.model-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.model-icon {
    width: 32px;
    height: 32px;
    background: var(--surface-mid);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Column Specifics */
.rating-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rating-number {
    font-weight: 700;
    font-family: var(--font-subheading);
    font-size: 1.1rem;
}

.count-cell,
.creations-cell,
.views-cell {
    font-family: var(--font-subheading);
    font-size: 1.05rem;
    color: var(--text-secondary);
}

.leaderboard-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1rem;
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
}

.logo-bracket {
    color: var(--accent-primary);
    opacity: 0.7;
}

.logo-text {
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(124, 58, 237, 0.3);
}

.prompts-shell {
    padding: 2rem;
    background: var(--bg-panel-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.prompts-header {
    margin-bottom: 2rem;
    text-align: center;
}

.prompts-header h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.prompts-header p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.prompts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.btn-back,
.btn-auto {
    background: var(--surface-low);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-back:hover,
.btn-auto:hover {
    background: var(--surface-mid);
    color: var(--text-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(96, 165, 250, 0.2);
    transform: translateY(-1px);
}

/* Utilities & Overlays */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.4;
}

.mobile-disclaimer {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(34, 211, 238, 0.15));
    color: var(--text-primary);
    text-align: center;
    padding: 0.875rem 1rem;
    font-weight: 500;
    font-size: 0.85rem;
    display: none;
    border-bottom: 1px solid rgba(96, 165, 250, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.mobile-disclaimer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.mobile-disclaimer-icon {
    font-size: 1.1rem;
    filter: drop-shadow(0 2px 4px rgba(96, 165, 250, 0.5));
}

/* Hide mobile disclaimer banner on phones */
@media (max-width: 767px) {
    .mobile-disclaimer {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .mobile-disclaimer {
        display: none !important;
    }
}

#maintenanceOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.95);
    z-index: 9999;
    backdrop-filter: blur(10px);
    justify-content: center;
    align-items: center;
}

/* Toast Notifications */
#globalToast,
.prompt-toast,
.profile-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-glass-strong);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 1rem 2rem;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-xl), var(--shadow-neon);
    z-index: 5000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 500;
}

#globalToast.visible,
.prompt-toast.visible,
.profile-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    background: var(--bg-glass);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-color);
    margin: 2rem 0;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-hint {
    font-size: 0.9rem;
    margin-top: 0.5rem;
    color: var(--text-secondary);
}



/* Logo & Icon Polish */
.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    margin-right: 0.5rem;
    transition: var(--transition);
}

.logo-title:hover .logo-icon {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px var(--accent-primary-glow);
    transform: rotate(5deg);
}

/* Battle Mode & Leaderboard specific buttons */
.btn-battle-mode,
.btn-battle-leaderboard {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.45);
}

.btn-battle-mode:hover,
.btn-battle-leaderboard:hover {
    color: var(--text-primary);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(248, 113, 113, 0.35));
    border-color: rgba(248, 113, 113, 0.6);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.45);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Maintenance Overlay */
.maintenance-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-dark);
    z-index: 9999;
    backdrop-filter: blur(var(--overlay-blur));
    -webkit-backdrop-filter: blur(var(--overlay-blur));
    justify-content: center;
    align-items: center;
    display: flex;
}

.maintenance-content {
    text-align: center;
    max-width: 600px;
    padding: 2rem;
}

.maintenance-icon {
    margin-bottom: 2rem;
    animation: pulse 2s ease-in-out infinite;
    color: var(--accent-primary);
}

.maintenance-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--grad-primary);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.maintenance-text {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.maintenance-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-neon);
}

.maintenance-dot {
    width: 12px;
    height: 12px;
    background: var(--accent-warning);
    border-radius: 50%;
    animation: blink 1.5s ease-in-out infinite;
    box-shadow: 0 0 10px var(--accent-warning);
}