/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: 'Poppins', sans-serif;
    color: #333;
    background: #f5f5f5;
    display: flex;
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }

/* === Sidebar === */
.sidebar {
    width: 240px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}
.sidebar-logo {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-logo img { max-height: 40px; }
.sidebar-logo .menu-toggle { display: none; }
.sidebar-nav ul { padding: 8px 0; }
.sidebar-nav li { border-bottom: 1px solid #f0f0f0; }
.sidebar-nav a {
    display: block;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.15s;
}
.sidebar-nav a:hover { background: #f5f5f5; }

/* === Main Content === */
.main-content {
    margin-left: 240px;
    flex: 1;
    min-width: 0;
}

/* === Top Bar === */
.top-bar {
    position: sticky;
    top: 0;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 50;
}
.top-bar .menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
}
.search-box { flex: 1; max-width: 400px; }
.search-box input {
    width: 100%;
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.search-box input:focus { border-color: #4a90d9; }

/* === Language Switcher === */
.lang-switch { position: relative; }
.lang-current {
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
}
.lang-current:hover { background: #f5f5f5; }
.lang-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    overflow: hidden;
    z-index: 70;
    min-width: 140px;
}
.lang-dropdown.open { display: block; }
.lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.85rem;
    transition: background 0.15s;
}
.lang-option:hover { background: #f5f5f5; }
.lang-option.active { background: #e8f0fe; font-weight: 600; }

/* === Search Results === */
.search-results {
    display: none;
    position: absolute;
    top: 52px;
    left: 16px;
    right: 16px;
    max-width: 400px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    max-height: 400px;
    overflow-y: auto;
    z-index: 60;
}
.search-results.active { display: block; }
.search-results a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}
.search-results a:hover { background: #f5f5f5; }
.search-results img { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; }
.search-results .name { font-size: 0.85rem; font-weight: 500; }

/* === Content Area === */
.content-area { padding: 16px; }

/* === Section Title === */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 20px 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.section-title:first-child { margin-top: 0; }
.view-all {
    font-size: 0.8rem;
    font-weight: 400;
    color: #4a90d9;
    text-decoration: underline;
}

/* === Game Grid === */
.game-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}
.game-card {
    display: block;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: transform 0.15s, box-shadow 0.15s;
}
.game-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.game-card-img { aspect-ratio: 1; overflow: hidden; }
.game-card-img img { width: 100%; height: 100%; object-fit: cover; }
.game-card-detail { padding: 6px 8px; }
.game-card-name {
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Rating Stars === */
.rating { font-size: 0.65rem; }
.star { color: #ddd; }
.star.filled { color: #f5a623; }

/* === Hero Section === */
.hero-section {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    margin: 20px 0;
}
.hero-section h1 { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.hero-section p { font-size: 0.9rem; line-height: 1.6; color: #555; }

/* === Games Header === */
.games-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

/* === Subcategories === */
.subcategories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}
.subcategory-tag {
    display: inline-block;
    padding: 4px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 16px;
    font-size: 0.8rem;
    transition: background 0.15s;
}
.subcategory-tag:hover { background: #eee; }

/* === Breadcrumb === */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.8rem;
    padding: 8px 0;
    color: #666;
}
.breadcrumb a { color: #4a90d9; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: #ccc; }
.breadcrumb .current { color: #999; }

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin: 24px 0;
}
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    background: #fff;
    transition: background 0.15s;
}
.page-link:hover { background: #f0f0f0; }
.page-link.active {
    background: #4a90d9;
    color: #fff;
    border-color: #4a90d9;
}
.page-link.dots { border: none; background: none; }

/* === Game Detail === */
.game-detail {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
}
.game-player-area {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 8px;
    background: #1a1a2e;
    border-radius: 8px;
    overflow: hidden;
    padding: 12px;
}
.game-card-hero { text-align: center; }
.game-card-hero img {
    max-width: 320px;
    margin: 0 auto;
    border-radius: 8px;
}
.game-card-hero .game-card-info { padding: 12px; color: #fff; }
.game-card-hero h1 { font-size: 1.3rem; margin-bottom: 8px; }
.play-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 10px 32px;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
}
.play-btn:hover { background: #3a7bc8; }
.recommend-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    align-content: start;
}
.recommend-item img { border-radius: 6px; aspect-ratio: 1; object-fit: cover; }
.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

/* === Game Content (from CMS) === */
.game-content {
    margin-top: 20px;
    line-height: 1.8;
}
.game-content h1 { font-size: 1.4rem; font-weight: 700; margin: 1rem 0; }
.game-content h2 { font-size: 1.2rem; font-weight: 700; margin: 1rem 0; }
.game-content h3,
.game-content h4,
.game-content h5,
.game-content h6 { font-size: 1rem; font-weight: 700; margin: 1rem 0; }
.game-content ol,
.game-content ul { list-style: auto; padding-left: 30px; }
.game-content ol li,
.game-content ul li { list-style: auto; }
.game-content section { padding-bottom: 20px; }

/* === Page Content === */
.page-content {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    line-height: 1.8;
}
.page-content h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 12px; }

/* === Contact Form === */
.contact-form { max-width: 500px; margin-top: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 4px; }
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
}
.form-group input:focus,
.form-group textarea:focus { border-color: #4a90d9; }
.btn-primary {
    display: inline-block;
    padding: 8px 24px;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary:hover { background: #3a7bc8; }

/* === Player Modal === */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 200;
}
.modal-overlay.active { display: flex; flex-direction: column; }
.modal-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #111;
    color: #fff;
}
.modal-title { font-weight: 600; font-size: 1rem; }
.modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
}
.modal-close:hover { color: #f55; }
.modal-body {
    flex: 1;
    background: #000;
    position: relative;
}
.modal-body iframe { display: block; position: relative; z-index: 1; }
.modal-body iframe.loaded + .modal-loading,
.modal-loading.hidden { display: none; }
.modal-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #aaa;
    z-index: 0;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #333;
    border-top-color: #4a90d9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.fallback-link {
    display: none;
    margin-top: 8px;
    padding: 8px 20px;
    background: rgba(255,255,255,0.1);
    border: 1px solid #555;
    border-radius: 6px;
    color: #aaa;
    font-size: 0.85rem;
    transition: background 0.15s;
}
.fallback-link:hover { background: rgba(255,255,255,0.2); color: #fff; }
.fallback-link.visible { display: inline-block; }

/* === Footer === */
.site-footer {
    padding: 20px 16px;
    margin-top: 32px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
    font-size: 0.8rem;
    color: #888;
}
.site-footer nav { margin-top: 8px; display: flex; justify-content: center; gap: 16px; }
.site-footer a { color: #4a90d9; }
.site-footer a:hover { text-decoration: underline; }

/* === Responsive === */
@media (max-width: 1024px) {
    .game-grid { grid-template-columns: repeat(4, 1fr); }
    .game-detail { grid-template-columns: 1fr; }
    .game-sidebar { order: 2; }
    .related-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-logo .menu-toggle { display: block; background: none; border: none; font-size: 1.2rem; cursor: pointer; }
    .main-content { margin-left: 0; }
    .top-bar .menu-toggle { display: block; }
    .game-grid { grid-template-columns: repeat(3, 1fr); }
    .game-player-area { grid-template-columns: 1fr; }
    .recommend-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 480px) {
    .game-grid { grid-template-columns: repeat(2, 1fr); }
    .recommend-grid { grid-template-columns: repeat(3, 1fr); }
}
