@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

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

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: #1a1a3e;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --success: #22c55e;
    --gold: #fbbf24;
    --silver: #94a3b8;
    --bronze: #f97316;
}

body {
    background-color: var(--bg-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    color: var(--text-primary);
}

nav {
    position: fixed;
    top: 0;
    left: 0;
    backdrop-filter: blur(20px) saturate(180%);
    background: rgba(10, 10, 26, 0.85);
    color: #fff;
    display: flex;
    height: 70px;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link {
    color: #fff;
    text-decoration: none;
    padding: 10px 20px;
    background: var(--accent);
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.nav-link:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.nav-link.secondary {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.nav-link.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

.nav-link i {
    font-size: 16px;
}

nav img {
    height: 45px;
    width: 45px;
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

nav img:hover {
    transform: scale(1.05);
}

nav h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mobile-menu-btn {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 10px;
    transition: background 0.3s ease;
}

.mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.mobile-nav {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    background: rgba(10, 10, 26, 0.98);
    backdrop-filter: blur(20px);
    padding: 15px 20px;
    gap: 5px;
    z-index: 99;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.mobile-nav a {
    color: #fff;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    padding: 14px 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.3s ease;
}

.mobile-nav a:hover {
    background: rgba(255, 255, 255, 0.05);
}

.mobile-nav a i {
    color: var(--accent);
    width: 20px;
}

.mobile-nav.active {
    display: flex;
}

.recently-played-section {
    margin-top: 70px;
    padding: 30px 40px;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.recently-played-section h2 {
    color: #fff;
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.recently-played-section h2 i {
    color: var(--accent);
}

.recently-played-games {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
    scroll-behavior: smooth;
}

.recently-played-games::-webkit-scrollbar {
    height: 6px;
}

.recently-played-games::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.recently-played-games::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.recently-played-games .game-card {
    min-width: 130px;
    max-width: 130px;
    flex-shrink: 0;
}

.recently-played-games .game-card img {
    width: 130px;
    height: 130px;
    object-fit: cover;
}

.recently-played-games .game-info {
    padding: 10px;
}

.recently-played-games .game-title {
    font-size: 12px;
}

.top-played-section {
    padding: 50px 40px;
    padding-top: 100px;
    margin-top: 70px;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-primary) 100%);
}

.recently-played-section + .top-played-section {
    margin-top: 0;
}

.section-header {
    text-align: center;
    margin-bottom: 35px;
}

.section-header h1 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.section-header h1 i {
    color: #f97316;
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 16px;
}

.top-played-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.game-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-card);
    text-decoration: none;
    display: block;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px var(--accent-glow);
    border-color: var(--accent);
}

.game-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    transition: all 0.4s ease;
}

.game-card:hover img {
    filter: brightness(0.6);
    transform: scale(1.05);
}

.rank-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.rank-badge.rank-gold {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #000;
}

.rank-badge.rank-silver {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    color: #000;
}

.rank-badge.rank-bronze {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fff;
}

.game-card .play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 70px;
    height: 70px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 25px var(--accent-glow);
}

.game-card:hover .play-button {
    transform: translate(-50%, -50%) scale(1);
}

.game-card .play-button i {
    color: #fff;
    font-size: 26px;
    margin-left: 4px;
}

.game-info {
    padding: 16px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.6), transparent);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

.game-title {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.play-count {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.play-count i {
    color: var(--accent);
}

.game-description {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 4px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-tags {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.game-tag {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
    font-size: 10px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.content {
    padding: 0 40px 50px;
    background: var(--bg-primary);
}

.section-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(99, 102, 241, 0.3), transparent);
    margin: 40px 0;
}

.search-container {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.search {
    display: flex;
    align-items: center;
    max-width: 500px;
    width: 100%;
    background: var(--bg-card);
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.search-icon {
    padding: 0 20px;
    color: var(--text-secondary);
    font-size: 16px;
}

.search input {
    flex: 1;
    padding: 16px 20px 16px 0;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    outline: none;
}

.search input::placeholder {
    color: var(--text-secondary);
    font-weight: 400;
}

.no-results {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.no-results i {
    font-size: 70px;
    margin-bottom: 20px;
    display: block;
    opacity: 0.3;
}

.no-results p {
    font-size: 18px;
    font-weight: 500;
}

.all-games-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.all-games-title i {
    color: var(--accent);
}

#games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

#games-grid .game-card img {
    height: 180px;
}

#games-grid .game-info {
    padding: 14px;
}

#games-grid .game-title {
    font-size: 14px;
}

#games-grid .game-description {
    font-size: 11px;
}

footer {
    background: var(--bg-secondary);
    padding: 30px 40px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

footer p {
    color: var(--text-secondary);
    font-size: 14px;
}

@media (max-width: 768px) {
    nav {
        height: 60px;
        padding: 0 20px;
    }

    nav h1 {
        font-size: 18px;
    }

    nav img {
        height: 38px;
        width: 38px;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-links {
        display: none;
    }

    .mobile-nav {
        top: 60px;
    }

    .top-played-section {
        padding: 30px 20px;
        margin-top: 60px;
    }

    .recently-played-section {
        margin-top: 60px;
        padding: 25px 20px;
    }

    .section-header h1 {
        font-size: 26px;
    }

    .top-played-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .game-card img {
        height: 160px;
    }

    .game-card .play-button {
        width: 55px;
        height: 55px;
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }

    .game-card .play-button i {
        font-size: 20px;
    }

    .game-info {
        padding: 12px;
    }

    .game-title {
        font-size: 13px;
    }

    .game-description,
    .play-count {
        font-size: 11px;
    }

    .content {
        padding: 0 20px 30px;
    }

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

    #games-grid .game-card img {
        height: 140px;
    }

    .search-container {
        margin-bottom: 30px;
    }

    .search input {
        padding: 14px 16px 14px 0;
        font-size: 14px;
    }

    .search-icon {
        padding: 0 16px;
    }

    .recently-played-section h2 {
        font-size: 18px;
    }

    .recently-played-games .game-card {
        min-width: 110px;
        max-width: 110px;
    }

    .recently-played-games .game-card img {
        width: 110px;
        height: 110px;
    }

    .all-games-title {
        font-size: 20px;
    }

    .rank-badge {
        padding: 4px 8px;
        font-size: 11px;
    }

    footer {
        padding: 25px 20px;
    }
}

@media (max-width: 480px) {
    .top-played-grid,
    #games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .game-card img,
    #games-grid .game-card img {
        height: 130px;
    }

    .section-header h1 {
        font-size: 22px;
    }
}

@media (hover: none) and (pointer: coarse) {
    .game-card .play-button {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.85;
    }

    .game-card:hover img {
        filter: brightness(0.7);
        transform: none;
    }

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

.settings-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border: none;
    cursor: pointer;
    box-shadow: none !important;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    box-shadow: none !important;
}

.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.settings-modal.active {
    display: flex;
}

.settings-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-header h2 {
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-header h2 i {
    color: var(--accent);
}

.settings-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
}

.settings-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.settings-body {
    padding: 24px;
}

.settings-group {
    margin-bottom: 28px;
}

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

.settings-group h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-group h3 i {
    color: var(--accent);
    font-size: 16px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 10px;
}

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

.setting-row span {
    font-size: 14px;
    font-weight: 500;
}

.music-name {
    font-size: 12px !important;
    color: var(--text-secondary);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.volume-row {
    gap: 12px;
}

.volume-row span {
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
}

.volume-row span:first-child {
    min-width: 20px;
}

.volume-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.settings-action-btn {
    width: 100%;
    padding: 14px 20px;
    background: var(--accent);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.settings-action-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.ui-version-selector {
    display: flex;
    gap: 10px;
}

.ui-version-btn {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ui-version-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #fff;
}

.ui-version-btn.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.fps-counter {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--success);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    font-family: 'Inter', monospace;
    z-index: 9999;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.force-mobile-ui .nav-links {
    display: none !important;
}

body.force-mobile-ui .mobile-menu-btn {
    display: flex !important;
}

body.force-mobile-ui .top-played-grid,
body.force-mobile-ui #games-grid {
    grid-template-columns: repeat(2, 1fr) !important;
}

body.force-mobile-ui .game-card .play-button {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.85;
}

@media (max-width: 480px) {
    .settings-content {
        max-height: 85vh;
    }
    
    .settings-header {
        padding: 18px;
    }
    
    .settings-body {
        padding: 18px;
    }
    
    .ui-version-selector {
        flex-direction: column;
    }
    
    .music-name {
        max-width: 180px;
    }
}
