/* style.css - Poki Style Premium CSS for Cocos Games */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&display=swap');

:root {
    --bg-base: #f4f6f8; /* Light gray Poki-like background */
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-primary: #00bfff; /* Bright blue Poki style */
    --accent-hover: #009ee0;
    
    --ad-bg: #e2e8f0;
    --ad-border: #cbd5e1;
    
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --radius-full: 9999px;
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles & Resets */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Fredoka', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 70px; /* Ad space */
    overflow-x: hidden;
}

body.is-playing {
    padding-bottom: 0;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button, input { font-family: inherit; border: none; outline: none; }
.hidden { display: none !important; }

/* Layout Containers */
.container {
    width: 100%;
    max-width: 1200px; /* Poki is usually compact and dense */
    margin: 0 auto;
    padding: 0 1rem;
}

/* Typography Utilities */
.text-gradient {
    background: linear-gradient(135deg, #00bfff, #9333ea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}

/* Navbar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    padding: 0.75rem 0;
    margin-bottom: 2rem;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    cursor: pointer;
    color: var(--text-primary);
}

.logo-icon {
    font-size: 2.2rem;
    transition: transform 0.3s ease;
}

.logo:hover .logo-icon {
    transform: rotate(-15deg) scale(1.1);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Search Box */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    background: #f1f5f9;
    border: 2px solid transparent;
    color: var(--text-primary);
    padding: 0.6rem 2.5rem 0.6rem 1.2rem;
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 500;
    width: 250px;
    transition: var(--transition);
}

.search-input:focus {
    background: #ffffff;
    border-color: var(--accent-primary);
    box-shadow: 0 4px 15px rgba(0, 191, 255, 0.2);
    width: 300px;
}

.search-icon {
    position: absolute;
    right: 15px;
    color: var(--text-secondary);
    pointer-events: none;
}

/* Language Dropdown */
.lang-dropdown {
    position: relative;
    cursor: pointer;
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: #f1f5f9;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    transition: var(--transition);
}

.lang-dropdown:hover .lang-toggle {
    color: var(--text-primary);
    background: #e2e8f0;
}

.lang-menu {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 0.5rem;
    min-width: 120px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition);
    z-index: 101;
}

.lang-dropdown:hover .lang-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-menu-item {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.lang-menu-item:hover {
    background: #f8fafc;
    color: var(--accent-primary);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 1rem 1rem 2rem;
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: 1.2rem;
    max-width: 700px;
    margin: 0 auto;
    font-weight: 600;
}

.mobile-search {
    display: none;
    margin-bottom: 1.5rem;
}

.mobile-search .search-input {
    width: 100%;
    padding: 0.8rem 1.5rem;
    font-size: 1.1rem;
}

@media (max-width: 768px) {
    .search-box { display: none; }
    .mobile-search { display: flex; position: relative;}
    .mobile-search::after {
        content: '\f002';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        position: absolute;
        right: 1.5rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-secondary);
    }
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.filter-btn {
    background: #ffffff;
    border: 2px solid transparent;
    color: var(--text-secondary);
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    transition: var(--transition);
}

.filter-btn:hover {
    transform: translateY(-2px);
    color: var(--text-primary);
    box-shadow: 0 6px 12px rgba(0,0,0,0.05);
}

.filter-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 6px 15px rgba(0, 191, 255, 0.3);
}

.game-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    background: rgba(15, 23, 42, 0.72);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    backdrop-filter: blur(6px);
}

/* Game Grid (Dense Poki Style) */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    grid-auto-flow: dense;
    grid-auto-rows: 178px;
    gap: 1rem;
    margin-bottom: 3rem;
}

@media (min-width: 1024px) {
    .game-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        grid-auto-rows: 198px;
        gap: 1.25rem;
    }
}

@media (max-width: 640px) {
    .game-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-auto-rows: 118px;
        gap: 0.5rem;
    }
}

/* Game Card */
.game-card {
    background: var(--bg-card);
    border-radius: 1.25rem;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.04);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
    height: 100%;
}

.game-card:hover {
    transform: scale(1.05) translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    z-index: 5;
}

.game-media {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: #e2e8f0;
}

.game-card.rank-2 {
    grid-column: span 2;
}

.game-card.rank-3 {
    grid-column: span 2;
    grid-row: span 2;
}

.game-card.rank-2,
.game-card.rank-3 {
    border: 2px solid rgba(0, 191, 255, 0.18);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.game-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center center;
    transition: transform 0.3s ease;
}

.game-card.rank-2 .game-img,
.game-card.rank-3 .game-img {
    object-fit: contain;
    background: #eef2f7;
}

.game-card:hover .game-img {
    transform: scale(1.1);
}

.game-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 191, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.game-card:hover .game-overlay {
    opacity: 1;
}

.play-icon {
    font-size: 3rem;
    color: white;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
    transform: scale(0.5);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.game-card:hover .play-icon {
    transform: scale(1);
}

@media (max-width: 640px) {
    .game-overlay { display: none; }
}

.game-info {
    padding: 0.5rem 0.5rem 0.75rem;
    text-align: center;
    background: #ffffff;
}

.game-title {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

@media (max-width: 640px) {
    .game-card,
    .game-card.rank-2 {
        grid-column: span 1;
        grid-row: span 1;
        border: 0;
        box-shadow: 0 4px 8px rgba(0,0,0,0.04);
    }

    .game-card.rank-3 {
        grid-column: span 2;
        grid-row: span 2;
    }

    .game-card.rank-2 .game-img,
    .game-card.rank-3 .game-img {
        object-fit: cover;
        background: #e2e8f0;
    }

    .game-info {
        padding: 0.4rem 0.35rem 0.5rem;
    }

    .game-title {
        font-size: 0.8rem;
        line-height: 1.15;
    }

    .game-card.rank-3 .game-title {
        font-size: 0.9rem;
    }
}

@media (max-width: 420px) {
    .game-grid {
        grid-auto-rows: 112px;
        gap: 0.45rem;
    }
}

/* Load More */
.load-more-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 4rem;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    padding: 1rem 2.5rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(0, 191, 255, 0.3);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 191, 255, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Game Player View */
#game-view {
    display: none; 
    flex-direction: column;
    width: 100%;
}

#game-view.active {
    display: flex;
}

.player-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: #ffffff;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-weight: 700;
    cursor: pointer;
    font-size: 1rem;
    background: #f1f5f9;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-back:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.player-title {
    font-size: 1.25rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
    min-width: 0;
    text-align: center;
}

.toolbar-spacer {
    width: 50px;
    flex-shrink: 0;
}

.player-frame-wrapper {
    width: 100%;
    height: clamp(520px, calc(100vh - 230px), 720px);
    height: clamp(520px, calc(100dvh - 230px), 720px);
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    body.is-playing .navbar {
        margin-bottom: 0.75rem;
        padding: 0.55rem 0;
    }

    body.is-playing .logo {
        font-size: 1.35rem;
    }

    body.is-playing .logo-icon {
        width: 30px;
        height: 30px;
    }

    .player-toolbar {
        border-radius: 0;
        box-shadow: none;
        border-top: 1px solid #e2e8f0;
        border-bottom: 1px solid #e2e8f0;
        margin: 0 -1rem 0.75rem;
        padding: 0.55rem 1rem;
    }

    .btn-back {
        padding: 0.45rem 0.75rem;
        font-size: 0.95rem;
    }

    .player-title {
        flex: 1;
        max-width: none;
        font-size: 1rem;
    }

    .toolbar-spacer {
        display: none;
    }

    .player-frame-wrapper {
        height: calc(100vh - 132px);
        height: calc(100dvh - 132px); 
        border-radius: 0;
        margin: 0 -1rem; /* Full bleed on mobile */
        width: calc(100% + 2rem);
    }
}

.player-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Sections */
.section-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 3rem 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.section-title i {
    color: #ff3366; 
}

/* Layout Utilities for views */
#home-view { display: none; }
#home-view.active { display: block; }

/* 1. Sticky Bottom Banner Ad */
.ad-sticky-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: var(--ad-bg);
    border-top: 1px solid var(--ad-border);
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

body.is-playing .ad-sticky-bottom {
    display: none;
}

.footer {
    text-align: center;
    padding: 2rem 1rem 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: auto;
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }

    .game-grid {
        gap: 0.45rem;
    }

    .game-title {
        font-size: 0.74rem;
    }

    .player-toolbar {
        margin-left: -0.75rem;
        margin-right: -0.75rem;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .player-frame-wrapper {
        margin-left: -0.75rem;
        margin-right: -0.75rem;
        width: calc(100% + 1.5rem);
    }
}

@media (max-width: 900px) and (orientation: landscape) {
    body.is-playing .navbar {
        display: none;
    }

    .player-toolbar {
        margin-top: 0;
    }

    .player-frame-wrapper {
        height: calc(100vh - 52px);
        height: calc(100dvh - 52px);
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 12px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9; 
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1; 
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8; 
}

/* Card Entry Animation */
@keyframes popIn {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}
.game-card {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
}
.game-card:nth-child(1) { animation-delay: 0.05s; }
.game-card:nth-child(2) { animation-delay: 0.1s; }
.game-card:nth-child(3) { animation-delay: 0.15s; }
.game-card:nth-child(4) { animation-delay: 0.2s; }
.game-card:nth-child(5) { animation-delay: 0.25s; }
.game-card:nth-child(6) { animation-delay: 0.3s; }
.game-card:nth-child(7) { animation-delay: 0.35s; }
.game-card:nth-child(8) { animation-delay: 0.4s; }
.game-card:nth-child(9) { animation-delay: 0.45s; }
.game-card:nth-child(n+10) { animation-delay: 0.5s; }
