* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #e94560;
    --primary-hover: #ff6b6b;
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --surface-light: #252540;
    --border: rgba(255,255,255,0.08);
    --text: #e0e0e0;
    --text-muted: #888;
    --radius: 12px;
}

html, body {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

/* Header */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.search-form {
    display: flex;
    max-width: 400px;
    width: 100%;
    gap: 0;
}

.search-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px 0 0 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    outline: none;
    border-right: none;
    min-width: 0;
}

.search-form input::placeholder {
    color: var(--text-muted);
}

.search-form button {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 0 8px 8px 0;
    background: var(--primary);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    white-space: nowrap;
}

.search-form button:hover {
    background: var(--primary-hover);
}

/* Hero Description */
.hero {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 32px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.hero h1 {
    font-size: 26px;
    margin-bottom: 10px;
    font-weight: 800;
    line-height: 1.3;
}

.hero p {
    margin: 0 auto;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.7;
}

/* Layout: Sidebar + Main */
.layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

/* Sidebar */
.sidebar {
    width: 200px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
}

.sidebar-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 700;
}

.category-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.category-list a:hover,
.category-list a.active {
    background: var(--surface-light);
    color: var(--text);
    border-color: var(--border);
}

.category-list a.active {
    border-left: 3px solid var(--primary);
}

.cat-icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
}

.cat-count {
    margin-left: auto;
    font-size: 11px;
    background: var(--surface-light);
    padding: 2px 7px;
    border-radius: 10px;
    color: var(--text-muted);
}

/* Main Content */
.main {
    flex: 1;
    min-width: 0;
}

.section {
    margin-bottom: 40px;
    scroll-margin-top: 90px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 8px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-count {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--surface-light);
    padding: 3px 10px;
    border-radius: 20px;
}

/* Game List Items */
.game-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.game-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
}

.game-item:hover {
    border-color: var(--primary);
    transform: translateX(4px);
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.15);
}

.game-item.hidden {
    display: none !important;
}

.game-thumb {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin-top: 2px;
}

.game-info {
    flex: 1;
    min-width: 0;
}

.game-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.game-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
}

.game-tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(233, 69, 96, 0.15);
    color: var(--primary);
    border: 1px solid rgba(233, 69, 96, 0.3);
    white-space: nowrap;
}

.game-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    word-break: break-word;
}

.game-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.stars {
    color: #ffc107;
    letter-spacing: 1px;
}

.play-btn {
    padding: 8px 18px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
    margin-top: 2px;
}

.play-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 40px 16px 20px;
    margin-top: 40px;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

.footer-brand {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 10px;
}

.footer-about {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.7;
    max-width: 320px;
}

.footer-heading {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text);
    margin-bottom: 14px;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
    cursor: pointer;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-bottom {
    border-top: 1px solid var(--border);
    padding-top: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.footer-bottom a {
    color: var(--text-muted);
    text-decoration: none;
    margin: 0 10px;
    cursor: pointer;
}

.footer-bottom a:hover {
    color: var(--primary);
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    box-shadow: 0 4px 16px rgba(233, 69, 96, 0.4);
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: var(--primary-hover);
    transform: translateY(-4px);
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    justify-content: center;
    align-items: flex-end;
    padding: 0;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    max-width: 100%;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px 20px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h2 {
    color: var(--primary);
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    color: var(--text-muted);
    line-height: 1.7;
    font-size: 14px;
}

.modal-body h4 {
    color: var(--text);
    margin: 16px 0 6px;
    font-size: 15px;
}

/* No results */
.no-results {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
    display: none;
}

.no-results.show {
    display: block;
}

/* ==================== RESPONSIVE ==================== */

/* Tablet */
@media (max-width: 900px) {
    .layout {
        flex-direction: column;
        padding: 20px 16px;
        gap: 20px;
    }

    .sidebar {
        width: 100%;
        position: static;
        top: auto;
    }

    .category-list {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .category-list::-webkit-scrollbar {
        display: none;
    }

    .category-list a {
        white-space: nowrap;
        padding: 8px 14px;
        font-size: 13px;
        border-radius: 20px;
    }

    .category-list a.active {
        border-left: none;
        background: var(--primary);
        color: white;
    }

    .cat-count {
        display: none;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 28px;
    }

    .section {
        scroll-margin-top: 80px;
    }
}

/* Mobile */
@media (max-width: 600px) {
    .topbar {
        padding: 10px 0;
    }

    .topbar-inner {
        flex-wrap: wrap;
        gap: 10px;
    }

    .brand {
        font-size: 20px;
    }

    .search-form {
        max-width: 100%;
        order: 3;
        width: 100%;
    }

    .search-form input {
        font-size: 16px;
        padding: 10px 12px;
    }

    .search-form button {
        padding: 10px 14px;
        font-size: 13px;
    }

    .hero {
        padding: 24px 16px;
    }

    .hero h1 {
        font-size: 22px;
    }

    .hero p {
        font-size: 14px;
    }

    .layout {
        padding: 16px;
        gap: 16px;
    }

    .section {
        margin-bottom: 32px;
        scroll-margin-top: 140px;
    }

    .section-title {
        font-size: 18px;
    }

    .game-item {
        padding: 12px;
        gap: 10px;
    }

    .game-thumb {
        width: 52px;
        height: 52px;
        font-size: 22px;
        border-radius: 8px;
    }

    .game-title {
        font-size: 14px;
    }

    .game-tag {
        font-size: 9px;
        padding: 1px 6px;
    }

    .game-desc {
        font-size: 12px;
    }

    .game-meta {
        gap: 8px;
        font-size: 11px;
    }

    .play-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 24px;
        margin-bottom: 24px;
    }

    .footer-bottom {
        font-size: 12px;
    }

    .footer-bottom a {
        margin: 0 6px;
    }

    .back-to-top {
        width: 40px;
        height: 40px;
        font-size: 16px;
        bottom: 16px;
        right: 12px;
    }

    .modal-box {
        padding: 20px 16px;
        border-radius: 12px 12px 0 0;
    }

    .modal-header h2 {
        font-size: 18px;
    }
}

/* Small Mobile - ensure full display */
@media (max-width: 375px) {
    .game-item {
        align-items: flex-start;
    }

    .game-info {
        width: auto;
        flex: 1;
    }

    .game-title {
        font-size: 13px;
    }

    .game-desc {
        font-size: 11px;
        line-height: 1.4;
    }

    .play-btn {
        align-self: center;
    }
}
.game-thumb {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    flex-shrink: 0;
    margin-top: 2px;
    overflow: hidden;
}
.thumbs {
    width: 100%; height: 100%; object-fit: cover; border-radius: 10px;
}