/* ============================================================
 * APK Download Portal - Main Stylesheet
 * Mobile-first, 400px centered layout
 * Uses CSS Custom Properties from themes.css for theming
 * PHP 7.4+ Native | Zero Framework | Zero Dependency
 * ============================================================ */

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

body {
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Inter', Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { font-family: 'Poppins', 'Inter', Arial, sans-serif; font-weight: 600; }
h1, h2, h3 { color: var(--text-heading); }

a { color: var(--text-link); text-decoration: none; }
a:hover { color: var(--text-link-hover); }
img { max-width: 100%; height: auto; border: 0; }

/* Wrapper */
.wrapper { max-width: 400px; margin: 0 auto; background: var(--bg-body); min-height: 100vh; }

/* ============================================================
 * HEADER
 * ============================================================ */
.header { padding: 0; border-bottom: 1px solid var(--border-default); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; }

.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { color: var(--logo-color); font-size: 20px; }
.logo a { font-size: 18px; font-weight: bold; color: var(--logo-color); }
.logo a:hover { color: var(--logo-hover); }

.header-nav { display: flex; gap: 6px; }
.header-nav a { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; background: var(--nav-icon-bg); border-radius: 6px; color: var(--nav-icon-color); font-size: 13px; transition: all 0.15s; }
.header-nav a:hover { background: var(--nav-icon-hover-bg); color: var(--nav-icon-hover-color); }

/* Search */
.search-form { display: flex; gap: 6px; padding: 0 12px 12px; }
.search-wrapper { flex: 1; position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; z-index: 1; }
.search-input { width: 100%; padding: 9px 14px 9px 35px; background: var(--bg-input); border: 1px solid var(--border-input); color: var(--text-primary); border-radius: 6px; font-size: 14px; outline: none; transition: border-color 0.2s; }
.search-input:focus { border-color: var(--accent); }
.search-btn { display: inline-flex; align-items: center; gap: 5px; padding: 9px 14px; background: var(--btn-primary-bg); color: var(--btn-primary-text); border: none; border-radius: 6px; font-size: 13px; font-weight: bold; cursor: pointer; white-space: nowrap; }
.search-btn:hover { background: var(--btn-primary-hover); }

/* ============================================================
 * SORT BAR
 * ============================================================ */
.sort-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 12px; font-size: 11px; border-bottom: 1px solid var(--border-default); }
.sort-label { color: var(--text-secondary); margin-right: 4px; display: flex; align-items: center; gap: 4px; }
.sort-link { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 4px; color: var(--text-secondary); font-size: 11px; background: var(--bg-surface); transition: all 0.15s; }
.sort-link:hover { color: var(--text-link-hover); background: var(--bg-hover); }
.sort-link.active { background: var(--accent); color: var(--btn-primary-text); }

/* Results Info */
.results-info { padding: 8px 12px; font-size: 11px; color: var(--text-secondary); border-bottom: 1px solid var(--border-default); }
.results-info strong { color: var(--text-link-hover); }
.results-info .fas { margin-right: 4px; color: var(--text-muted); }

/* ============================================================
 * GAME CARD
 * ============================================================ */
.game-card { padding: 14px 12px; border-bottom: 1px solid var(--border-default); transition: background 0.15s; }
.game-card:hover { background: var(--accent-soft); }

.game-card-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.game-title { font-size: 16px; }
.game-title a { color: var(--text-heading); }
.game-title a:hover { color: var(--text-link-hover); }
.game-id-badge { font-size: 10px; color: var(--text-muted); background: var(--bg-surface); padding: 1px 6px; border-radius: 8px; }

.game-content { display: flex; gap: 10px; margin-bottom: 10px; }
.game-thumb { flex-shrink: 0; width: 90px; height: 90px; }
.game-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; border: 1px solid var(--border-default); }
.game-desc-wrapper { flex: 1; min-width: 0; }
.game-desc { font-size: 12px; color: var(--text-secondary); text-align: justify; line-height: 1.6; }

/* Game Meta */
.game-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; align-items: center; font-size: 11px; }

.meta-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: bold; }
.meta-badge.age { background: var(--danger); color: #fff; }
.meta-badge.censored { background: var(--badge-bg); color: var(--badge-text); }
.meta-badge.uncensored { background: var(--success); color: #fff; padding: 3px 8px; border-radius: 4px; opacity: 0.85; }

.meta-tag { display: inline-flex; align-items: center; gap: 3px; color: var(--text-link); font-size: 11px; padding: 2px 6px; background: var(--accent-soft); border-radius: 3px; }
.meta-tag:hover { background: var(--accent); color: var(--btn-primary-text); }

.meta-year { display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); font-size: 11px; }

/* Game Actions */
.game-actions { display: flex; justify-content: space-between; align-items: center; }

.btn-view { display: inline-flex; align-items: center; gap: 6px; padding: 7px 18px; background: var(--btn-primary-bg); color: var(--btn-primary-text); border-radius: 5px; font-size: 13px; font-weight: bold; cursor: pointer; }
.btn-view:hover { background: var(--btn-primary-hover); color: var(--btn-primary-text); }

.game-stats { font-size: 11px; color: var(--text-secondary); display: flex; gap: 12px; }
.game-stats span { display: flex; align-items: center; gap: 3px; }

/* ============================================================
 * PAGINATION
 * ============================================================ */
.page_block { display: flex; flex-wrap: wrap; gap: 4px; padding: 16px 10px; justify-content: center; border-bottom: 1px solid var(--border-default); }
.page_list, .page_list_sel { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 6px; cursor: pointer; transition: all 0.15s; }
.page_list { background: var(--bg-surface); }
.page_list:hover { background: var(--bg-hover); }
.page_list_sel { background: var(--accent); }
.page_text, .page_text_sel { font-size: 13px; font-weight: bold; }
.page_text a { color: var(--text-secondary); display: block; width:100%; height:100%; text-align:center; line-height:32px; }
.page_text a:hover { color: var(--text-primary); }
.page_text_sel { color: var(--btn-primary-text); }

/* ============================================================
 * CATEGORY FILTERS
 * ============================================================ */
.category-filters { padding: 16px 12px; }
.filter-section { margin-bottom: 16px; }
.filter-section h3 { font-size: 13px; color: var(--text-heading); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.filter-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-tag { display: inline-block; padding: 5px 12px; background: var(--tag-bg); border: 1px solid var(--tag-border); border-radius: 16px; font-size: 11px; color: var(--tag-text); transition: all 0.15s; }
.filter-tag:hover { border-color: var(--accent); color: var(--text-link); }
.filter-tag.active { background: var(--tag-active-bg); color: var(--tag-active-text); border-color: var(--tag-active-bg); }

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

/* ============================================================
 * GAME DETAIL PAGE
 * ============================================================ */
.game-detail { padding: 0 10px; }

.breadcrumb { display: flex; align-items: center; gap: 6px; padding: 12px 0; font-size: 12px; color: var(--text-secondary); border-bottom: 1px solid var(--border-default); flex-wrap: wrap; }
.breadcrumb a { color: var(--text-link); display: flex; align-items: center; gap: 4px; }
.breadcrumb a:hover { color: var(--text-link-hover); }
.breadcrumb-sep { font-size: 9px; color: var(--text-muted); }
.breadcrumb-current { color: var(--text-secondary); }

.game-full { padding: 15px 0; }

.game-title-main { font-size: 20px; margin-bottom: 15px; color: var(--text-heading); }

.game-thumb-large { position: relative; margin-bottom: 15px; }
.game-thumb-large img { width: 100%; border-radius: 6px; border: 1px solid var(--border-default); }
.thumb-overlay { position: absolute; bottom: 8px; right: 8px; }
.overlay-badge { background: rgba(0,0,0,0.7); color: var(--warning); padding: 3px 10px; border-radius: 4px; font-size: 11px; display: flex; align-items: center; gap: 5px; }

/* Info Table */
.game-info-table { background: var(--bg-surface); border-radius: 8px; padding: 14px 16px; margin-bottom: 18px; border: 1px solid var(--border-default); }
.info-row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dotted var(--border-default); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.info-label .fas, .info-label .fab { color: var(--text-muted); }
.info-value { color: var(--text-primary); }
.info-value a { color: var(--text-link); }
.age-badge { background: var(--danger); color: #fff; padding: 2px 10px; border-radius: 4px; font-size: 12px; font-weight: bold; }

.game-description-full { margin-bottom: 18px; line-height: 1.6; text-align: justify; }
.game-description-full h2 { font-size: 16px; margin-bottom: 10px; color: var(--text-heading); display: flex; align-items: center; gap: 8px; }

.game-tags { margin-bottom: 18px; }
.game-tags h3 { font-size: 14px; margin-bottom: 8px; color: var(--text-heading); display: flex; align-items: center; gap: 7px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; background: var(--tag-bg); border: 1px solid var(--tag-border); border-radius: 16px; font-size: 12px; color: var(--text-link); margin: 3px; transition: all 0.15s; }
.tag:hover { background: var(--accent); color: var(--btn-primary-text); border-color: var(--accent); }

/* Screenshots */
.game-screenshots { margin-bottom: 20px; }
.game-screenshots h3 { font-size: 14px; margin-bottom: 10px; color: var(--text-heading); display: flex; align-items: center; gap: 7px; }
.screenshot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.screenshot-grid img { width: 100%; border-radius: 6px; border: 1px solid var(--border-default); cursor: pointer; }

/* Download */
.download-section { padding: 10px 0 20px; text-align: center; }
.btn-download { display: inline-flex; align-items: center; gap: 10px; padding: 14px 36px; background: var(--danger); color: #fff; font-size: 16px; font-weight: bold; border-radius: 8px; text-decoration: none; transition: background 0.2s; }
.btn-download:hover { background: var(--btn-danger-hover); color: #fff; }
.btn-download-size { font-size: 12px; background: rgba(0,0,0,0.2); padding: 2px 10px; border-radius: 10px; font-weight: normal; }
.no-download { color: var(--text-secondary); display: flex; align-items: center; justify-content: center; gap: 6px; }

/* Related Games */
.related-games { padding: 16px 0; border-top: 2px solid var(--border-default); margin-top: 20px; }
.related-games h2 { font-size: 16px; margin-bottom: 14px; color: var(--text-heading); display: flex; align-items: center; gap: 8px; }
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.related-item { text-align: center; }
.related-thumb { width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 6px; border: 1px solid var(--border-default); margin-bottom: 6px; }
.related-thumb img { width: 100%; height: 100%; object-fit: cover; }
.related-title { font-size: 11px; color: var(--text-secondary); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ============================================================
 * A-Z LIST PAGE
 * ============================================================ */
.alphabet-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 14px 0; border-bottom: 1px solid var(--border-default); margin-bottom: 18px; }
.alpha-link { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: var(--bg-surface); color: var(--text-link); border-radius: 5px; font-size: 12px; font-weight: bold; }
.alpha-link:hover { background: var(--accent); color: var(--btn-primary-text); }
.alpha-link.disabled { color: var(--text-muted); cursor: default; background: var(--bg-surface); }
.alpha-group { margin-bottom: 24px; }
.alpha-heading { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border-default); padding-bottom: 8px; margin-bottom: 12px; }
.alpha-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; background: var(--warning); color: var(--btn-primary-text); border-radius: 6px; font-size: 16px; font-weight: bold; padding: 0 6px; }
.alpha-count { font-size: 12px; color: var(--text-secondary); }

.game-list-simple { list-style: none; padding: 0; }
.game-list-simple li { padding: 8px 0; border-bottom: 1px dotted var(--bg-surface); }
.game-list-simple a { color: var(--text-link); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.game-list-simple a:hover { color: var(--text-link-hover); }
.list-icon { color: var(--text-muted); font-size: 12px; width: 18px; text-align: center; }

.page-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 15px; }

.main-content h1 { font-size: 18px; color: var(--text-heading); margin: 14px 0; display: flex; align-items: center; gap: 8px; padding: 0 12px; }
.main-content h1 .fas { font-size: 18px; }

/* ============================================================
 * STATIC PAGES
 * ============================================================ */
.static-page { padding: 0 12px; }
.static-page-title { font-size: 20px; margin: 16px 0; padding-bottom: 10px; border-bottom: 1px solid var(--border-default); color: var(--text-heading); display: flex; align-items: center; gap: 10px; }
.static-page h2 { font-size: 16px; margin-top: 22px; margin-bottom: 10px; color: var(--text-heading); display: flex; align-items: center; gap: 8px; }
.static-page h3 { font-size: 14px; margin-top: 16px; margin-bottom: 8px; color: var(--text-link-hover); display: flex; align-items: center; gap: 7px; }
.static-page p { margin-bottom: 12px; line-height: 1.7; font-size: 13px; }
.static-page ul, .static-page ol { margin: 10px 0 10px 22px; }
.static-page li { margin-bottom: 8px; font-size: 13px; }
.sitemap-section { margin-bottom: 18px; }
.sitemap-section h3 { font-size: 14px; margin-bottom: 8px; color: var(--text-link-hover); display: flex; align-items: center; gap: 7px; }
.sitemap-section ul { margin-left: 18px; }
.sitemap-section li { padding: 4px 0; }

.main-content { min-height: 60vh; }

/* ============================================================
 * FOOTER
 * ============================================================ */
.footer { text-align: center; padding: 20px 12px; border-top: 2px solid var(--border-default); margin-top: 20px; font-size: 11px; color: var(--text-secondary); }
.footer-warning { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 12px; color: var(--text-link-hover); font-size: 11px; }
.footer-nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; }
.footer-nav a { color: var(--text-link); font-size: 11px; display: flex; align-items: center; gap: 4px; }
.footer-nav a:hover { color: var(--text-link-hover); }
.copyright { color: var(--text-muted); display: flex; align-items: center; justify-content: center; gap: 6px; }

/* ============================================================
 * LANGUAGE SWITCHER
 * ============================================================ */
.lang-switcher { position: relative; display: inline-block; }
.lang-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 6px; color: var(--text-secondary); cursor: pointer; font-size: 12px; font-family: 'Inter', sans-serif; transition: border-color 0.15s; }
.lang-toggle:hover { border-color: var(--accent); }
.lang-arrow { font-size: 8px; color: var(--text-muted); margin-left: 2px; }
.lang-label { max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-dropdown { position: absolute; top: 100%; right: 0; margin-top: 4px; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 6px; padding: 4px; list-style: none; min-width: 150px; z-index: 999; display: none; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.lang-switcher:hover .lang-dropdown, .lang-dropdown.show { display: block; }
.lang-dropdown li { padding: 0; }
.lang-dropdown li a { display: flex; align-items: center; gap: 8px; padding: 7px 12px; color: var(--text-secondary); font-size: 12px; border-radius: 4px; transition: background 0.15s; text-decoration: none; }
.lang-dropdown li a:hover { background: var(--accent-soft); color: var(--text-link); }
.lang-dropdown li.active a { color: var(--text-link); font-weight: 600; }

/* ============================================================
 * THEME SWITCHER
 * ============================================================ */
.theme-switcher { display: inline-flex; align-items: center; gap: 4px; }
.theme-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; font-size: 13px; background: var(--bg-surface); color: var(--text-secondary); transition: all 0.15s; padding: 0; }
.theme-btn:hover { border-color: var(--accent); color: var(--text-link); }
.theme-btn.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ============================================================
 * FLAG ICONS (CSS-only, no images)
 * ============================================================ */
.flag-icon { display: inline-block; width: 20px; height: 14px; border-radius: 2px; flex-shrink: 0; background-size: cover; background-position: center; }
.flag-gb  { background: linear-gradient(#012169 22%, transparent 22% 78%, #012169 78%), linear-gradient(90deg, #C8102E 38%, transparent 38% 62%, #C8102E 62%), linear-gradient(#012169 38%, transparent 38% 62%, #012169 62%), linear-gradient(90deg, #C8102E 22%, transparent 22% 78%, #C8102E 78%), #fff; }
.flag-cn  { background: #DE2910; position: relative; }
.flag-cn::after { content: ''; position: absolute; top: 2px; left: 2px; width: 6px; height: 6px; background: #FFDE00; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.flag-jp  { background: #fff; position: relative; }
.flag-jp::after { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 8px; height: 8px; background: #BC002D; border-radius: 50%; }
.flag-es  { background: linear-gradient(#C60B1E 25%, #FFC400 25% 50%, #C60B1E 50% 75%, #FFC400 75%); }
.flag-br  { background: #009B3A; position: relative; }
.flag-br::after { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 10px; height: 10px; background: #FEDF00; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.flag-ru  { background: linear-gradient(#fff 33%, #0039A6 33% 66%, #D52B1E 66%); }

/* ============================================================
 * EMOJI ICON SYSTEM
 * ============================================================ */
.icon-16 { font-size: 16px; display: inline-block; width: 18px; text-align: center; }
.icon-20 { font-size: 18px; display: inline-block; width: 20px; text-align: center; }

.icon-home::before             { content: '🏠'; }
.icon-search::before           { content: '🔍'; }
.icon-download::before         { content: '📥'; }
.icon-star::before             { content: '⭐'; }
.icon-folder::before           { content: '📁'; }
.icon-tag::before              { content: '🏷️'; }
.icon-clock::before            { content: '🕐'; }
.icon-eye::before              { content: '👁️'; }
.icon-dashboard::before        { content: '📊'; }
.icon-gamepad::before          { content: '🎮'; }
.icon-lock::before             { content: '🔒'; }
.icon-settings::before         { content: '⚙️'; }
.icon-logout::before           { content: '🚪'; }
.icon-edit::before             { content: '✏️'; }
.icon-delete::before           { content: '🗑️'; }
.icon-plus::before             { content: '➕'; }
.icon-check::before            { content: '✅'; }
.icon-cross::before            { content: '❌'; }
.icon-warning::before          { content: '⚠️'; }
.icon-info::before             { content: 'ℹ️'; }
.icon-link::before             { content: '🔗'; }
.icon-calendar::before         { content: '📅'; }
.icon-list::before             { content: '📋'; }
.icon-filter::before           { content: '🔽'; }
.icon-back::before             { content: '⬅️'; }
.icon-next::before             { content: '➡️'; }
.icon-user::before             { content: '👤'; }
.icon-shield::before           { content: '🛡️'; }
.icon-rocket::before           { content: '🚀'; }
.icon-database::before         { content: '🗄️'; }
.icon-category::before         { content: '📦'; }

/* ============================================================
 * ICON HELPERS
 * ============================================================ */
i.bi { display: inline-block; vertical-align: -0.125em; }
.bi-lg { font-size: 1.25em; }
.bi-xl { font-size: 1.5em; }
.bi-2x { font-size: 2em; }

/* ============================================================
 * SCROLLBAR (themed)
 * ============================================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
