:root {
    --primary-color: #f7e018; /* Poki yellow */
    --secondary-color: #3b3b3b;
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-light: #777777;
    --border-radius: 16px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

header {
    background-color: var(--card-bg);
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo span {
    color: var(--secondary-color);
}

.search-container {
    flex: 1;
    max-width: 600px;
    margin: 0 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mode-toggle {
    background: #f1f3f4;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mode-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.mode-toggle:hover {
    background: var(--primary-color);
}

.search-bar {
    width: 100%;
    padding: 0.8rem 1.5rem;
    border: 2px solid transparent;
    border-radius: 30px;
    background-color: #f1f3f4;
    font-size: 1rem;
    transition: var(--transition);
}

.search-bar:focus {
    outline: none;
    background-color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(247, 224, 24, 0.2);
}

.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}

.game-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    aspect-ratio: 1 / 1;
    position: relative;
}

.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-hover);
}

.game-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.game-card:hover img {
    filter: brightness(0.9);
}

.game-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    opacity: 0;
    transition: var(--transition);
}

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

.game-title {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Play Page Layout */
.play-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    margin-top: 1rem;
}

.game-viewport {
    background-color: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    aspect-ratio: 16 / 9;
    position: relative;
}

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

.ad-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ad-unit {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
    min-height: 250px;
    overflow: hidden;
}

.ad-horizontal {
    width: 100%;
    min-height: 90px;
    margin-top: 2rem;
}

/* Theater Mode */
.theater-mode header {
    display: none;
}

.theater-mode .play-container {
    grid-template-columns: 1fr;
    margin-top: 0;
}

.theater-mode .ad-sidebar {
    display: none;
}

.theater-mode .game-viewport {
    aspect-ratio: 21 / 9;
    max-height: 90vh;
    border-radius: 0;
}

.theater-mode .container {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.theater-mode #gameTitle {
    display: none;
}

/* Floating Toggles */
.expand-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: var(--transition);
    opacity: 0.6;
}

.game-viewport:hover .expand-btn {
    opacity: 1;
    transform: scale(1.05);
}

.expand-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

@media (max-width: 768px) {
    .expand-btn {
        top: 10px;
        right: 10px;
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        opacity: 0.9;
    }
    .expand-btn span {
        display: none; /* Hide text on mobile to save space */
    }
    .expand-btn svg {
        width: 16px;
        height: 16px;
    }
}

.theater-mode .expand-btn {
    display: none;
}

.floating-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    padding: 0.8rem 1.5rem;
    background: var(--primary-color);
    border: none;
    border-radius: 30px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: none;
    align-items: center;
    gap: 0.6rem;
}

.floating-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.theater-mode .floating-toggle {
    display: block;
}

@media (max-width: 1024px) {
    .play-container {
        grid-template-columns: 1fr;
    }
    .ad-sidebar {
        flex-direction: row;
        justify-content: center;
    }
    .ad-unit {
        flex: 1;
        max-width: 300px;
    }
}

@media (max-width: 768px) {
    header {
        padding: 0.8rem 1rem;
    }
    .logo {
        font-size: 1.2rem;
    }
    .back-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    .container {
        margin: 1rem auto;
    }
    .game-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }
    .game-viewport {
        aspect-ratio: auto;
        height: 350px; /* Fixed height is often better on mobile */
    }
    .theater-mode .game-viewport {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 1000;
        border-radius: 0;
        max-height: none;
    }
    .theater-mode header {
        display: none;
    }
    .theater-mode .container {
        padding: 0;
        margin: 0;
    }
    .theater-mode .game-toolbar {
        display: none;
    }
    #gameTitle {
        font-size: 1.4rem !important;
        margin-bottom: 1rem !important;
    }
    .floating-toggle {
        top: 15px;
        right: 15px;
        padding: 0.8rem;
        background: rgba(247, 224, 24, 0.9);
        color: var(--secondary-color);
        box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    }
    .floating-toggle span {
        display: none; /* Icon only on mobile exit button */
    }
    .ad-unit {
        min-height: 100px;
    }
}
