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

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* ── UNIFIED COLOR SYSTEM ── */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #f59e0b;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;

    /* ── UNIFIED CORNER RADII (4 Standard Tokens) ── */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    /* ── UNIFIED TYPE SCALE (6 Standard Tokens) ── */
    --font-xs: 12px;
    --font-sm: 14px;
    --font-base: 15px;
    --font-md: 18px;
    --font-lg: 20px;
    --font-xl: 24px;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 6px 16px rgba(0,0,0,0.08);
}

body {
    max-width: 1100px;
    margin: 0 auto;
    background-color: var(--bg-page);
    color: var(--text-main);
    font-family: "Fredoka", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: var(--font-base);
    line-height: 1.5;
    min-height: 100vh;
    box-shadow: 0 0 30px rgba(0,0,0,0.04);
    position: relative;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

ul, li {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

/* ── UNIFIED BUTTON SYSTEM ── */
.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.15s;
}

.btn-icon:active {
    transform: scale(0.92);
    background: #e2e8f0;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    color: #ffffff;
    font-size: var(--font-sm);
    font-weight: 700;
    padding: 8px 18px;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: transform 0.15s, box-shadow 0.2s;
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-secondary {
    background: #eff6ff;
    color: var(--primary);
    font-size: var(--font-sm);
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(37, 99, 235, 0.15);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.15s;
}

.btn-secondary:hover {
    background: #dbeafe;
}

/* ── HEADER BAR ── */
.headerbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background-color: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.site-title {
    font-size: var(--font-lg);
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.site-title .logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: var(--font-md);
}

/* ── SEARCH BAR ── */
.search-container {
    padding: 12px 20px 4px;
    background: var(--bg-card);
}

.search-box {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: var(--radius-md);
    padding: 8px 14px;
    border: 1.5px solid transparent;
    transition: all 0.2s ease;
    max-width: 600px;
    margin: 0 auto;
}

.search-box:focus-within {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-box svg {
    color: var(--text-muted);
    margin-right: 10px;
    flex-shrink: 0;
}

.search-box input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: var(--font-sm);
    font-family: inherit;
    color: var(--text-main);
    outline: none;
}

/* ── SIDEBARS & OVERLAY MASK ── */
.mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mask.show {
    display: block;
    opacity: 1;
}

#sidebar1, #sidebar2 {
    position: fixed;
    top: 0;
    width: 290px;
    max-width: 80vw;
    height: 100vh;
    background: var(--bg-card);
    z-index: 2001;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 30px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#sidebar1 { left: 0; transform: translateX(-100%); }
#sidebar1.show { transform: translateX(0); }
#sidebar2 { right: 0; transform: translateX(100%); }
#sidebar2.show { transform: translateX(0); }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
    font-weight: 700;
    font-size: var(--font-md);
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-nav {
    padding: 15px 12px;
    flex: 1;
}

.sidebar-section-title {
    font-size: var(--font-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 10px 12px 6px;
}

.sidebar-nav ul li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-weight: 600;
    font-size: var(--font-base);
    transition: all 0.15s ease;
}

.sidebar-nav ul li a:hover, .sidebar-nav ul li a.active {
    background-color: #eff6ff;
    color: var(--primary);
}

.share-options {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.share-btn-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: var(--font-sm);
    cursor: pointer;
    border: none;
    width: 100%;
    color: #ffffff;
    transition: transform 0.15s;
}

.share-btn-item:active { transform: scale(0.97); }
.share-copy { background: #334155; }
.share-wa { background: #25d366; }
.share-tg { background: #0088cc; }
.share-tw { background: #000000; }
.share-fb { background: #1877f2; }

/* ── HERO PROMO BANNER (.topbar) ── */
.topbar {
    position: relative;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    margin: 14px 20px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.06);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.topbar .img-box {
    position: relative;
    width: 100%;
    height: 170px;
    background: #0f172a;
    overflow: hidden;
}

.topbar .img-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.topbar .icon-tag {
    position: absolute;
    top: 12px;
    left: 12px;
    font-size: var(--font-xs);
    font-weight: 700;
    color: #fff;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #ef4444, #f97316);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.topbar .desc {
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar .desc-info h3 {
    font-size: var(--font-md);
    font-weight: 700;
    color: #0f172a;
}

.topbar .desc-info p {
    font-size: var(--font-sm);
    color: var(--text-muted);
}

/* ── SECTION TITLE BAR (.sortTitle) ── */
.sortTitle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px 8px;
}

.sortTitle h2, .sortTitle h3 {
    font-size: var(--font-md);
    color: #0f172a;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sortTitle-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── POPULAR GAMES CAROUSEL WITH DESKTOP ARROWS (#pop) ── */
#pop {
    margin-bottom: 12px;
    position: relative;
}

.pop-carousel-wrap {
    position: relative;
    padding: 0 20px;
}

#pop .pop-scroll {
    width: 100%;
    overflow-x: auto;
    padding: 6px 0 10px;
    display: flex;
    gap: 14px;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

#pop .pop-scroll::-webkit-scrollbar {
    height: 4px;
}

#pop .pop-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: var(--radius-full);
}

/* Unified Popular Card Style matching site aesthetic */
.pop-card {
    flex: 0 0 130px;
    scroll-snap-align: start;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    padding: 10px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: transform 0.15s, box-shadow 0.2s;
}

.pop-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.pop-card .detailImg {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    background: #e2e8f0;
}

.pop-card .detailImg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pop-card .pop-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(15, 23, 42, 0.85);
    color: #ffe082;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    backdrop-filter: blur(4px);
}

.pop-card h4 {
    color: var(--text-main);
    font-size: var(--font-sm);
    font-weight: 600;
    margin-top: 6px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pop-card .pop-plays {
    font-size: var(--font-xs);
    color: var(--text-muted);
    text-align: center;
    margin-top: 2px;
}

.pop-nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: var(--font-sm);
    color: var(--text-main);
    transition: all 0.15s;
}

.pop-nav-btn:hover {
    background: #f1f5f9;
    color: var(--primary);
}

/* ── RECENTLY PLAYED (#recent) ── */
#recent {
    margin-bottom: 12px;
}

#recent .recent-scroll {
    width: 100%;
    overflow-x: auto;
    padding: 4px 20px 8px;
    display: flex;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

#recent .recent-scroll::-webkit-scrollbar {
    display: none;
}

.recent-item {
    flex: 0 0 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.recent-item img {
    width: 58px;
    height: 58px;
    border-radius: var(--radius-md);
    object-fit: cover;
    box-shadow: var(--shadow-sm);
    border: 2px solid #ffffff;
}

.recent-item span {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 58px;
    text-align: center;
}

/* ── RESPONSIVE CATEGORIZED GAMES GRID (.gameList) ── */
.gameList {
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 16px;
}

@media (min-width: 640px) {
    .gameList {
        grid-template-columns: repeat(4, 1fr);
    }
    .pop-card {
        flex: 0 0 140px;
    }
}

@media (min-width: 900px) {
    .gameList {
        grid-template-columns: repeat(6, 1fr);
    }
    .pop-card {
        flex: 0 0 150px;
    }
}

.gameList li a {
    display: block;
    background: var(--bg-card);
    padding: 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.2s;
}

.gameList li a:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.gameList .detailImg {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #e2e8f0;
    position: relative;
}

.gameList .detailImg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gameList li a h3 {
    text-align: center;
    line-height: 18px;
    max-height: 36px;
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-main);
    margin-top: 6px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.gameList li a p {
    font-size: var(--font-xs);
    color: var(--text-muted);
    text-align: center;
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.gameList li a p span {
    color: var(--accent);
    font-weight: 700;
}

/* ── COLLAPSIBLE ADS & ZERO-GAP HANDLING ── */
.ad-slot-wrapper {
    text-align: center;
    margin: 10px auto;
    min-height: 0;
    max-width: 100%;
}

.ad-slot-wrapper:empty,
div[id^="div-gpt-ad-"]:empty,
iframe:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
}

/* ── FLOATING LUCKY GIFT BUTTON (.go-other) ── */
.go-other {
    width: 52px;
    height: 52px;
    position: fixed;
    z-index: 500;
    left: 18px;
    bottom: 24px;
    cursor: pointer;
    background: linear-gradient(135deg, #ef4444, #f97316);
    border-radius: 50%;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: var(--font-xl);
    animation: scaleAni 1.5s ease-in-out infinite alternate;
}

@keyframes scaleAni {
    0% { transform: scale(1) translateY(0); }
    100% { transform: scale(1.08) translateY(-4px); }
}

/* ── SITE DESCRIPTION / SEO (#site-description) ── */
#site-description {
    margin: 18px 20px;
    background: var(--bg-card);
    padding: 18px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

#site-description h3 {
    font-size: var(--font-md);
    color: #0f172a;
    font-weight: 700;
    margin-bottom: 8px;
}

#site-description p {
    font-size: var(--font-sm);
    color: var(--text-muted);
    line-height: 1.6;
}

/* ── FOOTER ── */
.foot {
    text-align: center;
    font-size: var(--font-md);
    font-weight: 700;
    color: var(--text-main);
    margin-top: 20px;
    margin-bottom: 8px;
}

.foot .name {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.foot_link {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-xs);
    line-height: 20px;
    margin-bottom: 10px;
}

.foot_link a {
    color: var(--primary);
    margin: 0 4px;
    font-weight: 500;
}

.copy {
    text-align: center;
    font-size: var(--font-xs);
    color: var(--text-muted);
    padding: 0 10px 24px;
}

/* ── TOAST MESSAGE ── */
.toast-msg {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #0f172a;
    color: #ffffff;
    padding: 10px 22px;
    border-radius: var(--radius-full);
    font-size: var(--font-sm);
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.toast-msg.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── GAME PLAYER (game.html) ── */
.game-header {
    background: var(--bg-card);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.game-player-wrap {
    margin: 14px 20px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #0f172a;
    position: relative;
    aspect-ratio: 16 / 10;
    min-height: 380px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

@media (max-width: 600px) {
    .game-player-wrap {
        aspect-ratio: 1 / 1;
        min-height: 300px;
        margin: 10px;
    }
}

.game-player-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: #000;
}

.game-play-overlay {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.game-play-overlay::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
}

.overlay-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 20px;
}

.overlay-thumb {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-lg);
    border: 3px solid #ffffff;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    margin: 0 auto 14px;
    object-fit: cover;
}

.overlay-content h2 {
    color: #ffffff;
    font-size: var(--font-xl);
    font-weight: 700;
    margin-bottom: 16px;
}

.game-controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px 4px;
}

.game-meta-card {
    margin: 12px 20px;
    background: var(--bg-card);
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.game-meta-card h3 {
    font-size: var(--font-md);
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 6px;
}

.game-meta-card p {
    font-size: var(--font-sm);
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 14px;
}

.game-details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: var(--radius-md);
}

.game-detail-item {
    font-size: var(--font-sm);
}

.game-detail-item .label {
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 6px;
}

.game-detail-item .val {
    color: var(--text-main);
    font-weight: 600;
}

/* ── CATEGORY TAB FILTER (games.html) ── */
.category-tabs-scroll {
    overflow-x: auto;
    padding: 10px 20px;
    display: flex;
    gap: 8px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.category-tabs-scroll::-webkit-scrollbar {
    display: none;
}

.cat-tab-btn {
    white-space: nowrap;
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-muted);
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.cat-tab-btn.active {
    background: var(--primary);
    color: #ffffff;
}

/* ── STATIC PAGES ── */
.static-page-content {
    margin: 16px 20px;
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.static-page-content h1 {
    font-size: var(--font-xl);
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.static-page-content h2 {
    font-size: var(--font-md);
    font-weight: 700;
    color: #1e293b;
    margin-top: 18px;
    margin-bottom: 6px;
}

.static-page-content p {
    font-size: var(--font-sm);
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 12px;
}
