/* Fonts loaded via HTML for performance */

:root {
    --primary: #4f46e5;
    /* Darkened from #6366f1 for AA contrast (4.5:1+) */
    --primary-hover: #4338ca;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --nav-height: 70px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Navigation */
nav {
    height: var(--nav-height);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
}

.search-container {
    flex: 1;
    max-width: 500px;
    margin: 0 2rem;
}

#search-input {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid #334155;
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 9999px;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: var(--primary);
}

/* Category Bar */
.category-bar {
    display: flex;
    gap: 0.75rem;
    padding: 1.5rem 2rem;
    overflow-x: auto;
    scrollbar-width: none;
    white-space: nowrap;
    background: linear-gradient(to bottom, #0b0f1a, transparent);
    position: sticky;
    top: 64px;
    z-index: 50;
}

.category-bar::-webkit-scrollbar {
    display: none;
}

.category-tag {
    background: #1e293b;
    padding: 0.6rem 1.25rem;
    border-radius: 99px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-weight: 700;
    font-size: 0.85rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-tag:hover {
    background: #334155;
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.category-tag.active {
    background: linear-gradient(135deg, #0284c7, #4f46e5);
    /* Darkened for AA contrast */
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
    transform: translateY(-2px) scale(1.05);
}

/* Main Content */
main {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.ad-slot-leaderboard {
    width: 100%;
    height: 90px;
    background: #1e293b;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    border: 1px dashed #475569;
    color: var(--text-muted);
}

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

.game-card {
    background: var(--card-bg);
    border-radius: 1rem;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    border: 1px solid #334155;
    display: flex;
    flex-direction: column;
}

.game-thumb-wrap {
    width: 100%;
    aspect-ratio: 4/3;
    overflow: hidden;
    position: relative;
}

.game-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.game-info {
    padding: 1rem;
    background: var(--card-bg);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.game-card:hover {
    transform: translateY(-8px);
    z-index: 10;
    border-color: var(--primary);
}

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

.game-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.game-tags {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


/* Game View Specific Styles */
.game-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.game-player-container {
    background: #000;
    width: 100%;
    height: 93vh;
    min-height: 900px;
    max-height: none;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid #334155;
    position: relative;
}

#game-container {
    overflow: hidden;
    position: relative;
}

/* Ensure any internal game containers fill the arcade box 
   but allow games to use flexbox (don't force display: block) */
#game-container>* {
    width: 100% !important;
    height: 100% !important;
    position: relative;
    border: none;
}

#cyber-canvas {
    display: block !important;
}

.game-details {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 1.5rem;
    border: 1px solid #334155;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1rem 0;
}

.tag {
    background: #0f172a;
    padding: 0.4rem 1rem;
    border-radius: 99px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border: 1px solid #334155;
}

.tag.clickable {
    cursor: pointer;
    transition: all 0.2s;
}

.tag.clickable:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.author-line {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.how-to-play {
    background: rgba(99, 102, 241, 0.05);
    padding: 1.5rem;
    border-radius: 1rem;
    border-left: 4px solid var(--primary);
    margin: 1rem 0 2rem 0;
}

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

.similar-card {
    text-decoration: none;
    color: white;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.2s;
}

.similar-card:hover {
    transform: scale(1.05);
}

.similar-card img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: 0.75rem;
    border: 1px solid #334155;
}

.similar-card span {
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
}

/* Ad Modal */
#ad-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.ad-modal-content {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: 2rem;
    text-align: center;
    max-width: 500px;
    width: 90%;
    border: 1px solid var(--primary);
    box-shadow: 0 0 50px rgba(99, 102, 241, 0.3);
}

/* Mobile Friendly - End of file for precedence */
@media (max-width: 768px) {
    nav {
        padding: 0 1rem;
    }

    .search-container {
        display: none;
    }

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

    main {
        padding: 0;
        margin-top: 0 !important;
        max-width: 100%;
    }

    .hide-mobile {
        display: none !important;
    }

    .game-player-container {
        aspect-ratio: auto !important;
        height: 95dvh !important;
        min-height: 700px !important;
        max-height: none !important;
        border-radius: 0 !important;
        overflow: hidden !important;
        border: none !important;
    }

    .game-details {
        padding: 1.5rem 1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .game-layout {
        gap: 0 !important;
        min-height: auto;
    }

    .similar-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- Landscape Game Mode Utilities --- */
body.landscape-game .game-player-container {
    height: 93vh;
    min-height: 900px;
}

/* Prompt rotation on mobile portrait */
@media screen and (orientation: portrait) and (max-width: 768px) {
    body.landscape-game .game-player-container::after {
        content: "🔄 Rotate your device to Landscape for the best experience.";
        position: absolute;
        inset: 0;
        background: rgba(2, 6, 23, 0.95);
        color: #38bdf8;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 2rem;
        font-weight: 800;
        font-size: 1.25rem;
        z-index: 1000;
        backdrop-filter: blur(10px);
    }
}

/* Full-bleed layout on mobile landscape */
@media screen and (orientation: landscape) and (max-height: 600px) {
    body.landscape-game nav {
        display: none !important;
    }
    
    body.landscape-game main {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100%;
    }
    
    body.landscape-game .game-layout {
        gap: 0 !important;
    }
    
    body.landscape-game .game-player-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        min-height: 100vh !important;
        border-radius: 0 !important;
        border: none !important;
        margin: 0 !important;
        aspect-ratio: auto !important;
        z-index: 9999 !important;
    }
    
    body.landscape-game {
        overflow: hidden !important;
    }
}