:root {
    --primary-color: #00C853;
    --bg-color: #E8F5E9;
    --header-bg: #00C853;
    --text-color: #1B5E20;
    --card-bg: #FFFFFF;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
    --radius-md: 16px;
    --font-main: 'Cairo', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding-top: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Header Card (Poki Style) */
.header-card {
    background: var(--primary-color);
    border-radius: var(--radius-md);
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    box-shadow: var(--shadow-sm);
    color: white;
    cursor: default;
}

.header-card-logo {
    font-size: 1.2rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    margin-top: 10px;
}

.header-card-icons {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    width: 100%;
    justify-content: center;
}

.header-icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.header-icon-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

.header-icon-btn svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

/* Search Bar */
.search-bar-container {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: white;
    padding: 10px 20px;
    box-shadow: var(--shadow-sm);
    z-index: 999;
    display: none;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.search-bar-container.active {
    display: block;
    transform: translateY(0);
}

#searchInput {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid #eee;
    border-radius: 25px;
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#searchInput:focus {
    border-color: var(--primary-color);
}

/* Category Items */
.category-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    border-bottom: 1px solid #eee;
    color: var(--text-color);
    font-size: 0.95rem;
}

.category-item:hover {
    background: #f5f5f5;
    padding-left: 25px;
}

.category-item.active {
    background: var(--primary-color);
    color: #fff;
}

.category-item:last-child {
    border-bottom: none;
}

/* Category Menu */
.category-menu {
    position: fixed;
    top: 80px;
    left: 20px;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 998;
    display: none;
    flex-direction: column;
    min-width: 220px;
    max-width: 280px;
    max-height: 500px;
    overflow-y: auto;
    border-radius: 12px;
    border: 2px solid var(--primary-color);
}

.category-menu.active {
    display: flex;
}

/* Scrollbar styling for category menu */
.category-menu::-webkit-scrollbar {
    width: 6px;
}

.category-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.category-menu::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.category-menu::-webkit-scrollbar-thumb:hover {
    background: #00a843;
}

/* Main Content */
.container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 15px;
    flex: 1;
    width: 100%;
}

/* Games Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    grid-auto-flow: dense;
}

/* Game Page Grid - 3 columns: side | player | side */
#gamePageGrid {
    display: grid;
    grid-template-columns: 160px 1fr 160px;
    gap: 15px;
    align-items: start;
}

.side-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.side-column .game-card {
    width: 100%;
}

#gamePageGrid .game-player-card {
    grid-column: 2;
    justify-self: center;
}

/* Game Card */
.game-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    aspect-ratio: 1 / 1;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.game-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s;
}

.game-card:hover .game-thumb {
    transform: scale(1.1);
}

.game-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    padding: 10px;
    color: white;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.game-card:hover .game-info {
    opacity: 1;
}

.game-title {
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
}

/* Game Player Card */
.game-player-card {
    background: #fff;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 800px;
    margin: 10px auto 0;
    aspect-ratio: 16 / 9;
}

.game-player-frame-container {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
}

.game-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: #000;
    position: absolute;
    top: 0;
    left: 0;
}

.game-player-meta {
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-top: 1px solid #eee;
}

.game-player-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.game-player-back {
    font-size: 0.9rem;
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 600;
}

/* Fullscreen Button */
.fullscreen-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}

.fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Fullscreen mode styles */
.game-player-card:fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border: none;
    border-radius: 0;
}

.game-player-card:fullscreen .game-player-frame-container {
    height: 100%;
}

/* Footer */
.main-footer {
    background: var(--primary-color);
    height: 50px;
    margin-top: auto;
    width: 100%;
}

/* Ad Placeholder */
.ad-placeholder {
    background: #f0f0f0;
    border-radius: var(--radius-md);
    width: 100%;
    height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: var(--shadow-sm);
    border: 2px dashed #ddd;
}

/* Fix Header Card size in side columns */
.side-column .header-card {
    width: 100%;
    max-width: 160px;
    height: 160px;
    margin-bottom: 15px;
}

/* Responsive */
@media (max-width: 768px) {
    #gamePageGrid {
        grid-template-columns: 1fr;
    }

    .side-column {
        display: none;
    }

    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .game-player-card {
        aspect-ratio: 16 / 10;
        min-height: auto;
        height: auto;
    }
}