/* Game Library Manager v5.0 - Enhanced UX Edition */

/* ============================================
   CSS CUSTOM PROPERTIES (Theme Variables)
   ============================================ */
:root {
    /* Dark theme (default) */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-card: #1f2937;
    --bg-card-hover: #2d3748;
    --bg-glass: rgba(31, 41, 55, 0.8);
    --bg-glass-light: rgba(31, 41, 55, 0.6);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-light: rgba(99, 102, 241, 0.15);
    --accent-glow: rgba(99, 102, 241, 0.4);
    --border: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);
    --success: #22c55e;
    --success-light: rgba(34, 197, 94, 0.15);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --error: #ef4444;
    --error-light: rgba(239, 68, 68, 0.15);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.3);

    /* Sizing */
    --header-height: 64px;
    --action-bar-height: 56px;
    --sidebar-width: 240px;
    --card-width-small: 140px;
    --card-width-medium: 180px;
    --card-width-large: 220px;
    --card-width: var(--card-width-medium);
    --border-radius-sm: 8px;
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #e2e8f0;
    --bg-tertiary: #cbd5e1;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-glass: rgba(255, 255, 255, 0.8);
    --bg-glass-light: rgba(255, 255, 255, 0.6);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.1);
    --border-hover: rgba(0, 0, 0, 0.15);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.2);
}

[data-grid="small"] { --card-width: var(--card-width-small); }
[data-grid="medium"] { --card-width: var(--card-width-medium); }
[data-grid="large"] { --card-width: var(--card-width-large); }

/* ============================================
   BASE STYLES & RESET
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom selection color */
::selection {
    background: var(--accent);
    color: white;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
    border: 2px solid var(--bg-primary);
    transition: background var(--transition);
}

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

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-primary);
}

/* ============================================
   HEADER
   ============================================ */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    transition: transform var(--transition), box-shadow var(--transition);
}

.header.scrolled {
    box-shadow: var(--shadow-lg);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* GitHub Link with hover glow */
.github-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-primary);
    text-decoration: none;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.github-link::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    opacity: 0;
    transition: opacity var(--transition);
}

.github-link:hover {
    border-color: var(--accent);
    transform: scale(1.1) rotate(5deg);
    box-shadow: var(--shadow-glow);
}

.github-link:hover::before {
    opacity: 1;
}

.github-link svg {
    position: relative;
    z-index: 1;
    transition: transform var(--transition);
}

.github-link:hover svg {
    color: white;
    transform: scale(1.1);
}

/* Title with animated gradient */
.header-left h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent) 0%, #a855f7 50%, var(--accent) 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 8s ease infinite;
    letter-spacing: -0.5px;
}

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

.version {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Search container with glow effect */
.header-center {
    flex: 1;
    max-width: 480px;
    margin: 0 24px;
}

.search-container {
    position: relative;
    width: 100%;
}

.search-container input {
    width: 100%;
    padding: 12px 50px 12px 20px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 50px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all var(--transition);
}

.search-container input::placeholder {
    color: var(--text-muted);
}

.search-container input:hover {
    border-color: var(--border-hover);
}

.search-container input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light), var(--shadow-glow);
    background: var(--bg-card);
}

.search-icon {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
    transition: color var(--transition);
}

.search-container input:focus + .search-icon {
    color: var(--accent);
}

/* Keyboard hint badge */
.search-container::after {
    content: 'Ctrl+K';
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0.7;
    pointer-events: none;
    transition: opacity var(--transition);
}

.search-container:focus-within::after {
    opacity: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Stats with animated numbers feel */
.stats {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
}

.stats span:not(.separator) {
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.separator {
    color: var(--border);
    margin: 0 4px;
}

/* Header buttons with ripple effect */
.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.header-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: var(--accent-light);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.header-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.header-btn:active::before {
    width: 200px;
    height: 200px;
}

#sortIndicator {
    font-size: 0.75rem;
    color: var(--accent);
    background: var(--accent-light);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ============================================
   ACTION BAR
   ============================================ */
.action-bar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    height: var(--action-bar-height);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 99;
}

.action-bar-left,
.action-bar-center,
.action-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.path-input-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.path-input-label span {
    white-space: nowrap;
}

.path-input-label input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    padding: 8px 14px;
    color: var(--text-primary);
    width: 160px;
    font-size: 0.85rem;
    font-family: 'SF Mono', 'Consolas', monospace;
    transition: all var(--transition);
}

.path-input-label input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Action bar buttons */
.action-bar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.action-bar-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity var(--transition);
}

.action-bar-btn:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-bar-btn:hover:not(:disabled)::after {
    opacity: 1;
}

.action-bar-btn:active:not(:disabled) {
    transform: translateY(0);
}

.action-bar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-bar-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Primary button with gradient */
.action-bar-btn.primary {
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    border: none;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.action-bar-btn.primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-hover), #8b5cf6);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.action-bar-btn.primary:disabled {
    background: var(--bg-tertiary);
    box-shadow: none;
}

/* Danger button */
.action-bar-btn.danger {
    background: linear-gradient(135deg, var(--error), #dc2626);
    border: none;
    color: white;
}

.action-bar-btn.danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* Sync button with special animation */
.sync-btn {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6) !important;
    border: none !important;
    color: white !important;
}

.sync-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #2563eb, #7c3aed) !important;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.sync-btn.syncing {
    animation: syncPulse 1.5s ease-in-out infinite;
    background: linear-gradient(135deg, #22c55e, #3b82f6) !important;
}

@keyframes syncPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }
    50% {
        opacity: 0.9;
        transform: scale(0.98);
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }
}

/* Move To Container */
.move-to-container {
    position: relative;
    display: inline-block;
}

.move-to-menu {
    max-height: 400px;
    overflow-y: auto;
    min-width: 220px;
}

.move-to-option {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition);
    font-size: 0.9rem;
}

.move-to-option:hover {
    background: var(--accent-light);
    color: var(--accent);
    padding-left: 20px;
}

.move-to-option:active {
    background: var(--accent);
    color: white;
}

/* Run/Kill Dropdown Container */
.run-dropdown-container,
.kill-dropdown-container {
    position: relative;
    display: inline-flex;
    align-items: stretch;
}

.run-dropdown-container .action-bar-btn:first-child,
.kill-dropdown-container .action-bar-btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 1px solid rgba(255,255,255,0.2);
}

.format-toggle {
    padding: 8px 10px !important;
    min-width: auto !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    margin-left: -1px;
}

.format-menu {
    min-width: 240px;
}

.format-option {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition);
    font-size: 0.9rem;
}

.format-option:hover {
    background: var(--accent-light);
    color: var(--accent);
    padding-left: 20px;
}

.format-option:active {
    background: var(--accent);
    color: white;
}

/* Modal run dropdown */
.modal-run-dropdown {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.modal-run-dropdown .action-btn {
    flex: 1;
    min-width: 140px;
}

/* ============================================
   MAIN CONTAINER & LAYOUT
   ============================================ */
.main-container {
    display: flex;
    margin-top: calc(var(--header-height) + var(--action-bar-height));
    min-height: calc(100vh - var(--header-height) - var(--action-bar-height));
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: calc(var(--header-height) + var(--action-bar-height));
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 50;
    transition: transform var(--transition-slow), width var(--transition);
}

.tabs-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.tabs-header h3 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.tab-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 4px 10px;
    border-radius: 20px;
}

.tab-count-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    margin-left: 6px;
    min-width: 20px;
    text-align: center;
}

.tabs-nav {
    padding: 12px;
}

.tab-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
    text-align: left;
    margin-bottom: 4px;
    position: relative;
    overflow: hidden;
}

.tab-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    transform: scaleY(0);
    transition: transform var(--transition);
}

.tab-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding-left: 20px;
}

.tab-btn:hover::before {
    transform: scaleY(0.5);
}

.tab-btn.active {
    background: linear-gradient(90deg, var(--accent-light), transparent);
    color: var(--accent);
    font-weight: 600;
}

.tab-btn.active::before {
    transform: scaleY(1);
}

.tab-btn .count {
    font-size: 0.75rem;
    background: var(--bg-primary);
    padding: 3px 10px;
    border-radius: 20px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all var(--transition);
}

.tab-btn:hover .count,
.tab-btn.active .count {
    background: var(--accent);
    color: white;
}

/* Hidden tab styling */
.tab-btn.hidden-tab {
    opacity: 0.6;
    border-left: 3px solid var(--warning);
}

.tab-btn.admin-only-tab {
    border-left: 3px solid var(--error);
}

.tab-visibility-toggle,
.admin-only-indicator {
    margin-left: 8px;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.7;
    transition: all var(--transition);
}

.tab-visibility-toggle:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* ============================================
   CONTENT AREA
   ============================================ */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: calc(100vh - var(--header-height) - var(--action-bar-height));
    animation: contentFadeIn 0.5s ease;
}

@keyframes contentFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   GAMES GRID
   ============================================ */
.games-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 24px;
}

@media (max-width: 1440px) {
    .games-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================
   GAME CARD - Enhanced
   ============================================ */
.game-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
    border: 2px solid var(--border);
    position: relative;
    transform-style: preserve-3d;
    animation: cardFadeIn 0.4s ease backwards;
}

/* Staggered animation for cards */
.game-card:nth-child(1) { animation-delay: 0.02s; }
.game-card:nth-child(2) { animation-delay: 0.04s; }
.game-card:nth-child(3) { animation-delay: 0.06s; }
.game-card:nth-child(4) { animation-delay: 0.08s; }
.game-card:nth-child(5) { animation-delay: 0.1s; }
.game-card:nth-child(6) { animation-delay: 0.12s; }
.game-card:nth-child(7) { animation-delay: 0.14s; }
.game-card:nth-child(8) { animation-delay: 0.16s; }
.game-card:nth-child(9) { animation-delay: 0.18s; }
.game-card:nth-child(10) { animation-delay: 0.2s; }
.game-card:nth-child(n+11) { animation-delay: 0.22s; }

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Card glow effect on hover */
.game-card::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, var(--accent), #a855f7, var(--accent));
    border-radius: var(--border-radius);
    opacity: 0;
    z-index: -1;
    transition: opacity var(--transition);
}

.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-xl), 0 0 40px var(--accent-glow);
    border-color: var(--accent);
}

.game-card:hover::before {
    opacity: 0.5;
}

/* Selected state */
.game-card.selected {
    border-color: var(--success);
    box-shadow: 0 0 0 3px var(--success-light), var(--shadow-lg);
}

.game-card.selected::before {
    background: linear-gradient(135deg, var(--success), #16a34a);
    opacity: 0.3;
}

.game-card.selected::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    width: 28px;
    height: 28px;
    background: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    animation: checkmarkPop 0.3s var(--transition-bounce);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.5);
}

.game-card.selected .checkmark-icon {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 28px;
    height: 28px;
    z-index: 6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
}

@keyframes checkmarkPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Checkbox styling */
.select-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 24px;
    height: 24px;
    z-index: 10;
    cursor: pointer;
    opacity: 0;
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-glass);
    border: 2px solid var(--border);
    border-radius: 6px;
    transition: all var(--transition);
}

.game-card:hover .select-checkbox {
    opacity: 1;
}

.game-card.selected .select-checkbox {
    opacity: 0;
}

.select-checkbox:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

/* Info button */
.info-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all var(--transition);
    z-index: 10;
    opacity: 0;
    transform: scale(0.8);
}

.game-card:hover .info-btn {
    opacity: 1;
    transform: scale(1);
}

.info-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.15) !important;
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* Install button */
.install-btn {
    position: absolute;
    top: 10px;
    right: 48px;
    width: 32px;
    height: 32px;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all var(--transition);
    z-index: 10;
    opacity: 0;
    transform: scale(0.8);
}

.game-card:hover .install-btn {
    opacity: 1;
    transform: scale(1);
}

.install-btn:hover {
    background: var(--success);
    border-color: var(--success);
    transform: scale(1.15) !important;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.install-btn.is-installed {
    opacity: 1;
    background: var(--success);
    border-color: var(--success);
    transform: scale(1);
}

/* Installed badge */
.installed-badge {
    position: absolute;
    top: 50px;
    left: 10px;
    background: linear-gradient(135deg, var(--success), #16a34a);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
}

.game-card.installed {
    border-color: var(--success);
}

/* New game badge with glow */
.new-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: newBadgePulse 2s ease-in-out infinite;
    box-shadow: 0 2px 12px rgba(245, 158, 11, 0.5);
}

@keyframes newBadgePulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 2px 12px rgba(245, 158, 11, 0.5);
    }
    50% {
        opacity: 0.9;
        box-shadow: 0 2px 20px rgba(245, 158, 11, 0.8);
    }
}

.game-card.new-game {
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

.game-card.new-game:hover {
    box-shadow: var(--shadow-xl), 0 0 30px rgba(245, 158, 11, 0.5);
}

/* Image container with loading skeleton */
.game-card .image-container {
    position: relative;
    width: 100%;
    padding-top: 133.33%; /* 3:4 aspect ratio */
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    overflow: hidden;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
}

/* Skeleton loading animation */
.game-card .image-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.05),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.game-card img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow), filter var(--transition);
}

.game-card img.loaded {
    animation: imageReveal 0.5s ease;
}

@keyframes imageReveal {
    from {
        opacity: 0;
        transform: scale(1.1);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.game-card:hover img {
    transform: scale(1.08);
}

/* Card info section */
.game-card .card-info {
    padding: 14px;
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
}

.game-card .title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color var(--transition);
}

.game-card:hover .title {
    color: var(--accent);
}

.game-card .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-size: 0.75rem;
}

.category-badge {
    background: var(--accent-light);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: capitalize;
}

.time-badge,
.size-badge {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

/* ============================================
   LOADING INDICATOR
   ============================================ */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 20px;
}

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

.loading p {
    font-size: 1rem;
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* No results */
.no-results {
    text-align: center;
    padding: 80px 40px;
    color: var(--text-secondary);
}

.no-results::before {
    content: '🔍';
    display: block;
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-results p {
    font-size: 1.1rem;
}

/* ============================================
   MODAL - Enhanced with animations
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: modalFadeIn 0.3s ease;
}

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

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    max-width: 850px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.4s var(--transition-bounce);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    z-index: 10;
}

.modal-close:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
    transform: rotate(90deg);
}

.modal-body {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    padding: 30px;
}

.modal-image {
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-lg);
}

.modal-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform var(--transition);
}

.modal-image:hover img {
    transform: scale(1.05);
}

.modal-info h2 {
    font-size: 1.75rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: 700;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.meta-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.meta-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.docker-section {
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 24px;
    border: 1px solid var(--border);
}

.docker-section h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.command-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 14px 18px;
    margin-bottom: 20px;
}

.command-box code {
    flex: 1;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.75rem;
    color: var(--success);
    word-break: break-all;
    line-height: 1.5;
}

.copy-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 1rem;
}

.copy-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.1);
}

.action-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all var(--transition);
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.action-btn.primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), #8b5cf6);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px var(--accent-glow);
}

.action-btn.secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.action-btn.secondary:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.terminal-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.terminal-info p {
    margin-bottom: 8px;
}

#detectedOS {
    color: var(--accent);
    font-weight: 600;
}

.terminal-hint {
    opacity: 0.8;
}

/* ============================================
   SETTINGS MODAL
   ============================================ */
.settings-modal {
    max-width: 520px;
}

.settings-modal h2 {
    padding: 24px 30px;
    border-bottom: 1px solid var(--border);
    font-size: 1.5rem;
}

.settings-body {
    padding: 30px;
}

.setting-group {
    margin-bottom: 32px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group h3 {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item span {
    color: var(--text-primary);
    font-weight: 500;
}

.setting-item input[type="text"],
.setting-item select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    width: 180px;
    font-size: 0.9rem;
    transition: all var(--transition);
}

.setting-item input[type="text"]:focus,
.setting-item select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Custom checkbox */
.setting-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 48px;
    height: 26px;
    background: var(--bg-tertiary);
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: all var(--transition);
    border: 2px solid var(--border);
}

.setting-item input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    background: var(--text-muted);
    transition: all var(--transition);
}

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

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

.setting-actions {
    display: flex;
    gap: 12px;
}

.setting-btn {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    font-weight: 500;
}

.setting-btn:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

/* ============================================
   DROPDOWN MENU
   ============================================ */
.dropdown-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 8px;
    min-width: 200px;
    box-shadow: var(--shadow-xl);
    z-index: 150;
    animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sort-option {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition);
    font-size: 0.9rem;
}

.sort-option:hover {
    background: var(--accent-light);
    color: var(--accent);
    padding-left: 20px;
}

.sort-option.active {
    background: var(--accent);
    color: white;
}

/* ============================================
   TOAST NOTIFICATIONS - Enhanced
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 16px 24px;
    box-shadow: var(--shadow-xl);
    animation: toastSlideIn 0.4s var(--transition-bounce);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 450px;
    pointer-events: auto;
    backdrop-filter: blur(10px);
}

.toast.success {
    border-left: 4px solid var(--success);
    background: linear-gradient(90deg, var(--success-light), var(--bg-secondary));
}
.toast.error {
    border-left: 4px solid var(--error);
    background: linear-gradient(90deg, var(--error-light), var(--bg-secondary));
}
.toast.info {
    border-left: 4px solid var(--accent);
    background: linear-gradient(90deg, var(--accent-light), var(--bg-secondary));
}
.toast.warning {
    border-left: 4px solid var(--warning);
    background: linear-gradient(90deg, var(--warning-light), var(--bg-secondary));
}

.toast span:first-child {
    font-size: 1.3rem;
}

.toast span:last-child {
    flex: 1;
    font-weight: 500;
}

/* Toast progress bar */
.toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    animation: toastProgress 3s linear forwards;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.toast.success::after { background: var(--success); }
.toast.error::after { background: var(--error); }
.toast.warning::after { background: var(--warning); }

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

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0; }
}

/* ============================================
   SCROLL TO TOP BUTTON
   ============================================ */
.scroll-top-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg), 0 0 20px var(--accent-glow);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all var(--transition);
}

.scroll-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: var(--shadow-xl), 0 0 30px var(--accent-glow);
}

/* ============================================
   MOBILE SIDEBAR TOGGLE
   ============================================ */
.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 50px;
    height: 50px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 90;
    transition: all var(--transition);
}

.sidebar-toggle:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 49;
    opacity: 0;
    transition: opacity var(--transition);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================
   KEYBOARD SHORTCUTS HINT
   ============================================ */
.keyboard-hints {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 10px 20px;
    display: flex;
    gap: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
    z-index: 80;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

.keyboard-hints.visible {
    opacity: 1;
    visibility: visible;
}

.keyboard-hints kbd {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: inherit;
    font-weight: 600;
    margin-right: 6px;
}

/* ============================================
   ADMIN STYLES
   ============================================ */
.admin-login {
    display: flex;
    align-items: center;
    position: relative;
}

.admin-login input {
    width: 130px;
    padding: 10px 14px;
    border: 2px solid var(--warning);
    border-radius: var(--border-radius-sm);
    background: var(--warning-light);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all var(--transition);
}

.admin-login input::placeholder {
    color: var(--warning);
    opacity: 1;
}

.admin-login input:focus {
    outline: none;
    border-color: var(--error);
    background: var(--error-light);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}

.admin-logged {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-badge {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    padding: 6px 14px;
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    font-weight: 700;
    animation: adminGlow 2s ease-in-out infinite;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes adminGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.5); }
    50% { box-shadow: 0 0 25px rgba(245, 158, 11, 0.8); }
}

.logout-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition);
}

.logout-btn:hover {
    background: var(--error);
    border-color: var(--error);
    transform: scale(1.1);
}

/* Hide admin-only features when not admin */
body:not(.is-admin) .admin-only {
    display: none !important;
}

body:not(.is-admin) .move-to-container {
    display: none !important;
}

body:not(.is-admin) .tab-btn.hidden-tab {
    display: none !important;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1200px) {
    .sidebar {
        width: 200px;
    }
    .content {
        margin-left: 200px;
    }
}

@media (max-width: 1024px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
    }

    .keyboard-hints {
        display: none;
    }

    .games-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 60px;
        --action-bar-height: auto;
    }

    .header {
        padding: 0 16px;
    }

    .header-left h1 {
        font-size: 1.2rem;
    }

    .version {
        display: none;
    }

    .header-center {
        display: none;
    }

    .header-right {
        gap: 8px;
    }

    .stats {
        display: none;
    }

    .header-btn span:not(#sortIndicator) {
        display: none;
    }

    .admin-login input {
        width: 100px;
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .action-bar {
        flex-wrap: wrap;
        padding: 12px 16px;
        gap: 10px;
    }

    .action-bar-left,
    .action-bar-center,
    .action-bar-right {
        flex: 1 1 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .action-bar-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .path-input-label {
        flex: 1 1 100%;
        justify-content: center;
    }

    .path-input-label input {
        flex: 1;
        max-width: 200px;
    }

    .main-container {
        margin-top: calc(var(--header-height) + 120px);
    }

    .sidebar {
        top: calc(var(--header-height) + 120px);
    }

    .content {
        padding: 16px;
    }

    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .modal-body {
        grid-template-columns: 1fr;
        padding: 20px;
    }

    .modal-image {
        max-width: 220px;
        margin: 0 auto;
    }

    .action-buttons {
        flex-direction: column;
    }

    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 80px;
    }

    .toast {
        min-width: unset;
        width: 100%;
    }

    .scroll-top-btn {
        bottom: 80px;
        right: 16px;
        width: 44px;
        height: 44px;
    }

    .sidebar-toggle {
        bottom: 80px;
        left: 16px;
        width: 44px;
        height: 44px;
    }
}

@media (max-width: 480px) {
    .header-left h1 {
        font-size: 1rem;
    }

    .header-btn {
        padding: 8px 10px;
    }

    .game-card .card-info {
        padding: 10px;
    }

    .game-card .title {
        font-size: 0.85rem;
    }

    .game-card .meta {
        font-size: 0.7rem;
    }

    .games-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   MOBILE 375px — Responsive Layout Fix
   Ensures 1-column layout, tap-friendly targets,
   readable text, full-width search, no h-scroll
   ============================================ */
@media (max-width: 375px) {
    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Force 1-column game grid */
    .games-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    /* Tap-friendly header buttons (min 44px height) */
    .header-btn {
        padding: 12px 10px;
        min-height: 44px;
        min-width: 44px;
        font-size: 0.8rem;
    }

    /* Tap-friendly action bar buttons */
    .action-bar-btn {
        padding: 12px 10px;
        min-height: 44px;
        font-size: 0.8rem;
    }

    /* Ensure action bar wraps properly */
    .action-bar {
        flex-direction: column;
        padding: 10px 12px;
        gap: 8px;
    }

    .action-bar-left,
    .action-bar-center,
    .action-bar-right {
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Full-width search bar */
    .search-container {
        width: 100%;
        max-width: 100%;
    }

    .search-container input {
        width: 100%;
        font-size: 0.875rem; /* 14px readable minimum */
        padding: 12px 44px 12px 16px;
        box-sizing: border-box;
    }

    /* Readable text (min 14px = 0.875rem) */
    .game-card .title {
        font-size: 0.875rem;
    }

    .game-card .meta {
        font-size: 0.75rem;
    }

    .game-card .card-info {
        padding: 10px 12px;
    }

    /* Header layout on narrow viewport */
    .header {
        padding: 0 10px;
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .header-left h1 {
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .header-right {
        gap: 4px;
        flex-shrink: 0;
    }

    /* Remove min-width from dropdowns to prevent h-scroll */
    .move-to-menu,
    .format-menu {
        min-width: 160px;
        max-width: calc(100vw - 32px);
    }

    .modal-run-dropdown .action-btn {
        min-width: 0;
        flex: 1 1 100%;
    }

    /* Path input full width */
    .path-input-label input {
        max-width: 100%;
        width: 100%;
    }

    /* Modal adjustments */
    .modal-content {
        margin: 8px;
        max-width: calc(100vw - 16px);
    }

    .modal-body {
        padding: 12px;
    }

    /* Sidebar toggle tap target */
    .sidebar-toggle,
    .scroll-top-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    /* Nav/tab controls spacing */
    .tabs-header {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        min-height: 44px;
        padding: 10px 12px;
        white-space: nowrap;
        font-size: 0.8rem;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .header,
    .action-bar,
    .sidebar,
    .modal,
    .toast-container,
    .scroll-top-btn,
    .sidebar-toggle {
        display: none !important;
    }

    .content {
        margin: 0;
        padding: 0;
    }

    .game-card {
        break-inside: avoid;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* Page-based pagination controls */
.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 0;
    width: 100%;
}

.page-btn {
    background: linear-gradient(135deg, var(--accent, #6366f1) 0%, var(--accent-hover, #818cf8) 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.page-btn:hover:not(:disabled) {
    opacity: 0.85;
    transform: translateY(-1px);
}

.page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.page-indicator {
    font-size: 0.9rem;
    color: var(--text-secondary, #94a3b8);
    font-weight: 600;
    min-width: 120px;
    text-align: center;
}

/* ============================================
   STAR / FAVOURITE BUTTON
   ============================================ */
.star-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.2s;
    z-index: 10;
    line-height: 1;
    padding: 2px;
}

.star-btn.active,
.star-btn:hover {
    color: #fbbf24;
}

/* ============================================
   DOWNLOAD PROGRESS BAR
   ============================================ */
.download-progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1e1e2e;
    padding: 12px 20px;
    z-index: 1000;
    border-top: 2px solid #6366f1;
    animation: slideUpIn 0.3s ease;
}

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

.dp-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 900px;
    margin: 0 auto;
}

#dpText {
    color: #f8fafc;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    min-width: 280px;
}

.dp-bar {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}

.dp-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6366f1, #818cf8);
    border-radius: 4px;
    transition: width 0.4s ease;
}
