/* --- Reset & Global Variables --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-color: #79f5dd;           /* Vibrant turquoise background */
    --card-radius: 20px;          /* Smooth rounded corners */
    --card-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --logo-tss-color: #1a4f8b;     /* Dark navy blue for 'TSS' */
    --logo-games-color: #00a896;   /* Teal for 'Games' */
}

body {
    background: url('../images/gamebg.webp');
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-color: var(--bg-color);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

.main-container {
    width: 100%;
    max-width: 1300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* --- Main Grid Layout --- */
.game-grid {
    display: grid;
    /* 5 primary columns with flexible scaling */
    grid-template-columns: repeat(5, 1fr);
    grid-auto-rows: 150px;
    gap: 14px;
}

/* Base style for every grid tile */
.grid-block {
    background-color: #ffffff;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grid-block:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

/* Placeholder Styling (Replace with <img> elements in practice) */
.img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e1f7f2;
    color: #4a7a72;
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
    padding: 10px;
}

/* --- Spanning Rules for Specific Layout Blocks --- */

/* Top-Left TSS Logo Block */
.logo-utility {
    grid-column: span 1;
    grid-row: span 1;
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: #ffffff;
}

.logo-box {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tss-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 0.9;
}

.tss-logo .tss {
    font-size: 2.2rem;
    font-weight: 800;
    color: #AA0641;
    letter-spacing: -1px;
}

.tss-logo .games {
    font-size: 1.3rem;
    font-weight: 700;
    color: #c14545;
}

/* User & Search Buttons inside Logo Tile */
.icon-buttons {
    display: flex;
    gap: 8px;
    height: 36px;
    margin-top: 6px;
}

.icon-btn {
    flex: 1;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
}

.icon-btn.login {
    background: linear-gradient(2deg, #f175e5, #0e24b0);
}

.icon-btn.search {
    background: linear-gradient(2deg, #75f19a, #0e77b0);
}

.icon-btn.login::before {
    content: "👤";
    font-size: 1rem;
}

.icon-btn.search::before {
    content: "🔍";
    font-size: 0.9rem;
}

/* Featured / Large Hero Games */
.character-tile {
    grid-column: span 2;
    grid-row: span 2;
}

.gate-gates {
    grid-column: span 1;
    grid-row: span 2;
}

.top-row-3 {
    position: relative;
}

.title-overlay {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.4);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    backdrop-filter: blur(4px);
    text-align: center;
}

.second-column-top {
    grid-column: span 1;
    grid-row: span 2;
}

.right-col-2 {
    grid-column: span 1;
    grid-row: span 2;
}

.large-wide {
    grid-column: span 2;
    grid-row: span 1;
}

/* --- Footer URL Overlay Style --- */
.footer-url {
    background: rgba(0, 0, 0, 0.65);
    color: #ffffff;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: monospace;
    width: fit-content;
    margin-top: 4px;
}

/* --- Responsive Layout for Mobile/Tablets --- */
@media (max-width: 900px) {
    .game-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .game-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 120px;
    }

    .character-tile,
    .gate-gates,
    .second-column-top {
        grid-column: span 2;
        grid-row: span 1;
    }
}

/* --- Categories Section Styling --- */
.categories-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-top: 20px;
}

.category-card {
    background-color: #ffffff;
    border-radius: 18px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 75px;
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}

/* Category Icon Styling */
.category-icon {
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

/* For actual image icons instead of emojis, use this rule:
.category-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
} 
*/

/* Category Text */
.category-title {
    color: #1a2b49;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    line-height: 1.2;
    text-transform: uppercase;
}

/* Custom 2x2 Grid Icon for "All Categories" */
.category-icon.grid-icon {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
    width: 28px;
    height: 28px;
}

.category-icon.grid-icon span {
    background-color: #0075ff;
    border-radius: 4px;
}

.category-card.special-all .category-title {
    color: #0075ff;
}

/* Responsive adjust for Categories */
@media (max-width: 900px) {
    .categories-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .categories-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .category-card {
        padding: 8px 12px;
    }

    .category-title {
        font-size: 0.68rem;
    }
}

/* All Games Tile Styling */
.all-games-tile {
    background: linear-gradient(135deg, #ffffff 0%, #eef6ff 100%);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px stroke #0075ff;
}

.all-games-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.all-games-icon {
    font-size: 2.2rem;
    line-height: 1;
}

.all-games-text {
    color: #0075ff;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

/* --- About TSS Games Card Section --- */
.about-card-container {
    width: 100%;
    margin-top: 25px;
    margin-bottom: 30px;
}

.about-card {
    background-color: #ffffff;
    border-radius: 20px;
    padding: 40px 48px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Section Tag / Sub-heading */
.about-card .sub-heading {
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: #1a4f8b; /* Matching your TSS branding blue */
    text-transform: uppercase;
}

/* Main H1 Title */
.about-card .main-heading {
    font-size: 2.2rem;
    font-weight: 800;
    color: #0d1e38;
    line-height: 1.15;
    margin-top: -6px;
    margin-bottom: 8px;
}

/* Content Paragraphs */
.about-card .description {
    font-size: 1.05rem;
    line-height: 1.6;
    color: #3e4d68;
    font-weight: 400;
}

/* Emphasized Keywords for SEO */
.about-card .description strong {
    color: #0d1e38;
    font-weight: 700;
}

/* Call to Action Line */
.about-card .cta-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0d1e38;
    margin-top: 4px;
}

/* --- Mobile / Tablet Responsiveness --- */
@media (max-width: 768px) {
    .about-card {
        padding: 24px 20px;
        border-radius: 16px;
        gap: 12px;
    }

    .about-card .main-heading {
        font-size: 1.6rem;
    }

    .about-card .description,
    .about-card .cta-text {
        font-size: 0.95rem;
    }
}

/* --- Footer Styling --- */
.tss-footer {
    width: 100%;
    background-color: #ffffff;
    border-radius: 20px;
    padding: 36px 40px 20px 40px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* FAQ Block */
.footer-faq {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.faq-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #0d1e38;
}

.faq-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.faq-item h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1a4f8b;
    margin-bottom: 6px;
}

.faq-item p {
    font-size: 0.88rem;
    color: #4a5a70;
    line-height: 1.45;
}

.footer-divider {
    border: none;
    border-top: 1px solid #e8eef5;
    margin: 4px 0;
}

/* Footer Main Layout */
.footer-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 40px;
}

/* Brand Section */
.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 280px;
}

.footer-logo {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.footer-logo .tss {
    font-size: 1.8rem;
    font-weight: 800;
    color: #1a4f8b;
}

.footer-logo .games {
    font-size: 1.3rem;
    font-weight: 700;
    color: #00a896;
}

.brand-tagline {
    font-size: 0.88rem;
    color: #61738d;
}

/* Social Media Icons */
.social-links {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.social-icon {
    width: 38px;
    height: 38px;
    background-color: #f0f4f8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1rem;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.social-icon:hover {
    background-color: #e1e9f2;
    transform: translateY(-2px);
}

/* Navigation Link Columns */
.footer-nav {
    display: flex;
    gap: 60px;
}

.nav-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.column-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: #0d1e38;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-column ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-column a {
    text-decoration: none;
    font-size: 0.88rem;
    color: #4a5a70;
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-column a:hover {
    color: #0075ff;
}

/* Bottom Bar */
.footer-bottom {
    text-align: center;
    padding-top: 12px;
    border-top: 1px solid #e8eef5;
    font-size: 0.8rem;
    color: #8393a7;
}

/* --- Responsive Adjustments --- */
@media (max-width: 850px) {
    .faq-grid {
        grid-template-columns: 1fr;
    }

    .footer-main {
        flex-direction: column;
        gap: 28px;
    }

    .footer-nav {
        gap: 30px;
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 500px) {
    .tss-footer {
        padding: 24px 20px 16px 20px;
    }

    .footer-nav {
        flex-direction: column;
        gap: 20px;
    }
}

.logo-link{
    text-decoration: none;
}

.primary-text-color{
    color:#AA0641;
}

/* --- Floating Container (Keeps it positioned in grid or fixed on page) --- */
.floating-mascot-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 100;
    /* Continuous floating & bobbing animation */
    animation: floatAround 4s ease-in-out infinite alternate;
}

/* --- Cartoon Mascot Styling --- */
.cartoon-mascot {
    font-size: 3.5rem;
    position: absolute;
    top: -25px;
    left: -15px;
    z-index: 2;
    filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.2));
    /* Slight wiggle effect on the mascot */
    animation: mascotWiggle 3s ease-in-out infinite alternate;
}

/* --- Speech Bubble Card Styling --- */
.tss-bubble-card {
    background: #ffffff;
    border-radius: 24px;
    padding: 16px 20px 14px 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), 
                0 4px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    position: relative;
    border: 3px solid #ffffff;
}

/* Speech Bubble Tail/Pointer (pointing left toward character) */
.tss-bubble-card::before {
    content: "";
    position: absolute;
    top: 20px;
    left: -14px;
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-right: 15px solid #ffffff; /* Matches card background */
}

/* --- Typography & Colors matching your screenshot --- */
.tss-logo {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.tss-logo .tss {
    font-size: 2.2rem;
    font-weight: 900;
    color: #a00037; /* Deep magenta/red from your screenshot */
    letter-spacing: -0.5px;
}

.tss-logo .games {
    font-size: 1.5rem;
    font-weight: 700;
    color: #cb4040; /* Lighter red accent */
}

/* --- Gradient Buttons from Screenshot --- */
.icon-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
}

.icon-btn {
    flex: 1;
    height: 42px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, filter 0.15s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.icon-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* Purple Gradient Button */
.icon-btn.login {
    background: linear-gradient(135deg, #4d3bd1 0%, #d34ecf 100%);
}

.icon-btn.login::before {
    content: "👤";
    font-size: 1.1rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* Cyan/Teal Gradient Button */
.icon-btn.search {
    background: linear-gradient(135deg, #1fa2ff 0%, #12d8fa 50%, #a6ffcb 100%);
}

.icon-btn.search::before {
    content: "🔍";
    font-size: 1.1rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* --- CSS Animations for Movement --- */

/* Smooth floating around movement */
@keyframes floatAround {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }
    33% {
        transform: translate(8px, -12px) rotate(1.5deg);
    }
    66% {
        transform: translate(-6px, -6px) rotate(-1deg);
    }
    100% {
        transform: translate(4px, -16px) rotate(1deg);
    }
}

/* Subtle mascot bounce */
@keyframes mascotWiggle {
    0% {
        transform: translateY(0) scale(1);
    }
    100% {
        transform: translateY(-5px) scale(1.05) rotate(-5deg);
    }
}

/* --- Viewport Floating Container --- */
.viewport-floating-wrapper {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999; /* Keeps it on top of all games and sections */
    pointer-events: auto;
    display: inline-flex;
    align-items: center;

    /* Continuous smooth movement across the whole screen */
    animation: travelAcrossScreen 25s ease-in-out infinite alternate;
}

/* Pause floating movement when user hovers so they can click buttons easily */
.viewport-floating-wrapper:hover {
    animation-play-state: paused;
}

/* --- Mascot Character Styling --- */
.cartoon-mascot {
    font-size: 3.5rem;
    position: absolute;
    top: -22px;
    left: -15px;
    z-index: 2;
    filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25));
    animation: mascotBob 3s ease-in-out infinite alternate;
}

/* --- Speech Bubble Card --- */
.tss-bubble-card {
    background: #ffffff;
    border-radius: 24px;
    padding: 14px 22px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    border: 3px solid #ffffff;
}

/* Speech Bubble Tail */
.tss-bubble-card::before {
    content: "";
    position: absolute;
    top: 22px;
    left: -14px;
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-right: 15px solid #ffffff;
}

/* --- Logo & Text --- */
.tss-logo {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.tss-logo .tss {
    font-size: 2.2rem;
    font-weight: 900;
    color: #a00037;
    letter-spacing: -0.5px;
}

.tss-logo .games {
    font-size: 1.5rem;
    font-weight: 700;
    color: #cb4040;
}

/* --- Gradient Buttons --- */
.icon-buttons {
    display: flex;
    gap: 10px;
    width: 100%;
}

.icon-btn {
    flex: 1;
    height: 40px;
    min-width: 65px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    transition: transform 0.15s ease;
}

.icon-btn:hover {
    transform: scale(1.08);
}

.icon-btn.login {
    background: linear-gradient(135deg, #4d3bd1 0%, #d34ecf 100%);
}
.icon-btn.login::before {
    content: "👤";
    font-size: 1rem;
}

.icon-btn.search {
    background: linear-gradient(135deg, #1fa2ff 0%, #12d8fa 50%, #a6ffcb 100%);
}
.icon-btn.search::before {
    content: "🔍";
    font-size: 1rem;
}

/* --- Keyframe Movements Across Screen --- */

/* Travel Path around screen corners & center */
@keyframes travelAcrossScreen {
    0% {
        transform: translate(0vw, 0vh) rotate(0deg);
    }
    20% {
        transform: translate(65vw, 10vh) rotate(3deg);
    }
    40% {
        transform: translate(70vw, 65vh) rotate(-2deg);
    }
    60% {
        transform: translate(20vw, 75vh) rotate(4deg);
    }
    80% {
        transform: translate(45vw, 35vh) rotate(-3deg);
    }
    100% {
        transform: translate(80vw, 5vh) rotate(2deg);
    }
}

/* Character Idle Wiggle */
@keyframes mascotBob {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    100% {
        transform: translateY(-6px) rotate(-6deg);
    }
}

/* Ensure the grid block container handles clipping properly */
.grid-block {
    position: relative;
    overflow: hidden; /* Clips image corners to match border-radius */
    display: flex;    /* Removes any default inline-block spacing bugs */
}

/* Make images scale and crop seamlessly to fill the tile */
.grid-block img {
    width: 100%;
    height: 100%;
    object-fit: cover;    /* Fills the block entirely without distorting aspect ratio */
    object-position: center; /* Centers the focal point of the image */
    display: block;
}

/* Force the Load More tile to stay at the very end of the CSS Grid */
.all-games-tile {
    order: 9999;
}

/* Card Container to contrast against sky background */
.cat-header-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: rgb(203 22 239 / 85%); /* Dark slate background with high contrast */
    backdrop-filter: blur(8px); /* Glass blur effect */
    padding: 20px 30px;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 650px;
    margin: 20px auto;
}

/* Crisp White Text for High Contrast */
.cat-title {
    font-size: clamp(24px, 5vw, 36px);
    font-weight: 900;
    color: #ffffff !important;
    margin: 0;
    line-height: 1.1;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Glowing Neon Badge */
.cat-sub-badge {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #00d2ff; /* Bright electric blue */
    background: rgba(0, 210, 255, 0.15);
    border: 1px solid rgba(0, 210, 255, 0.4);
    padding: 4px 14px;
    border-radius: 20px;
}

/* Bold Icon Badges */
.cat-badge-icon {
    font-size: 22px;
    background: #ffffff;
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cat-icon-stack {
    display: flex;
    gap: 10px;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .cat-header-card {
        padding: 14px 18px;
        gap: 10px;
        width: 90%;
    }
    
    .cat-badge-icon {
        width: 38px;
        height: 38px;
        font-size: 18px;
        border-radius: 10px;
    }

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

/* Multi-column grid optimized for thousands of text items */
.category-text-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    padding: 20px 0;
}

.category-text-card {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f4f5f7;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 12px 10px;
    text-decoration: none;
    color: #222;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    transition: all 0.2s ease;
}

.category-text-card:hover {
    background-color: #b300ff;
    color: #ffffff;
    border-color: #b300ff;
    transform: translateY(-2px);
}

/* Layout container */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 15px;
}

/* Home Page Game Grid System */
.game-grid-genre {
    display: grid;
    /* Responsive auto-fill grid matching homepage tile layout */
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

/* Single Game Card */
.game-card {
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* Thumbnail aspect ratio */
.game-thumbnail {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background-color: #e2e8f0;
}

.game-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Game Title under Image */
.game-info {
    padding: 8px 6px;
    text-align: center;
}

.game-title {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
    display: -webkit-box;
    -webkit-line-clamp: 1; /* Truncate text if title is too long */
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
}

/* Mobile Adjustments */
@media (max-width: 480px) {
    .game-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
}

/* Dynamic Asymmetric Grid Container */
.game-grid-masonry {
    display: grid;
    /* Defines dense base grid tracks */
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    grid-auto-rows: 110px;
    grid-auto-flow: dense; /* Fills empty holes created by large items automatically */
    gap: 12px;
    padding: 15px 0;
}

/* Base Game Card */
.game-card {
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: #ffffff;
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.game-card:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

/* --- Random Size Classes --- */

/* 1. Small (Default 1x1) */
.game-card.card-small {
    grid-column: span 1;
    grid-row: span 1;
}

/* 2. Wide (2 Columns x 1 Row) */
.game-card.card-wide {
    grid-column: span 2;
    grid-row: span 1;
}

/* 3. Tall (1 Column x 2 Rows) */
.game-card.card-tall {
    grid-column: span 1;
    grid-row: span 2;
}

/* 4. Large Feature Tile (2 Columns x 2 Rows) */
.game-card.card-large {
    grid-column: span 3;
    grid-row: span 3;
}

/* Image fills entire height/width of varying card sizes */
.game-thumbnail {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000000;
}

.game-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Overlay Game Title at Bottom */
.game-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 8px 6px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
    text-align: center;
}

.game-title {
    font-size: 11px;
    font-weight: 800;
    color: #ffffff;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
}

/* Mobile Adjustments */
@media (max-width: 500px) {
    .game-grid-masonry {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        grid-auto-rows: 85px;
        gap: 8px;
    }
}

/* Container Layout */
.single-game-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 15px;
}

.game-header {
    text-align: center;
    margin-bottom: 15px;
}

.game-main-title {
    font-size: clamp(22px, 4vw, 32px);
    font-weight: 900;
    color: #0f172a;
    margin: 0;
}

/* 16:9 Game Screen Container */
.game-player-wrapper {
    background: #0f172a;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    margin-bottom: 30px;
}

.game-iframe-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background: #000000;
}

.game-iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Game Control Bar */
.game-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #1e293b;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.game-meta-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mini-thumb {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
}

.game-name {
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
}

/* Action Button */
.control-btn {
    background: #0075ff;
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.control-btn:hover {
    background: #005cc8;
    transform: translateY(-2px);
}

/* Details Card */
.game-details-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
}

.game-details-card h2 {
    font-size: 20px;
    margin-top: 0;
    color: #1e293b;
}

.game-description {
    color: #475569;
    font-size: 14px;
    line-height: 1.6;
}

/* Related Games Grid */
.related-games-section {
    margin-top: 30px;
}

.section-title {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 16px;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
}

.related-card {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease;
}

.related-card:hover {
    transform: translateY(-3px);
}

.related-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

.related-card span {
    font-size: 11px;
    font-weight: 700;
    color: #1e293b;
    padding: 6px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .game-controls-bar {
        padding: 10px 14px;
    }
    .game-name {
        display: none; /* Hide title in bar on phones to save space */
    }
}

/* Container positioning */
.single-game-header {
    width: 100%;
    margin: 15px 0 20px;
    display: flex;
    justify-content: center;
    padding: 0 15px;
    box-sizing: border-box;
}

/* Glassmorphism Card Box for high contrast against sky/bright backgrounds */
.header-card-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.82); /* Dark slate semi-transparent bg */
    backdrop-filter: blur(10px); /* Smooth blur effect */
    padding: 14px 28px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    max-width: 900px;
    text-align: center;
}

/* Neon Top Pill Badge */
.game-type-badge {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #00d2ff; /* Electric cyan color */
    background: rgba(0, 210, 255, 0.12);
    border: 1px solid rgba(0, 210, 255, 0.3);
    padding: 3px 12px;
    border-radius: 20px;
}

/* Main Heading Title */
.game-main-title {
    font-size: clamp(20px, 4.5vw, 32px);
    font-weight: 900;
    color: #ffffff !important; /* Force pure white for maximum readability */
    margin: 0;
    line-height: 1.25;
    letter-spacing: 0.3px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .header-card-box {
        padding: 12px 18px;
        border-radius: 14px;
        width: 100%;
    }
}

/* Container Layout */
.single-game-container {
    max-width: 1400px; /* Expanded max-width to comfortably fit game + 300px sidebar */
    margin: 0 auto;
    padding: 20px 15px 80px; /* Bottom padding accounts for mobile sticky footer */
}

/* Two-Column Desktop Grid Layout */
.game-layout-grid {
    display: grid;
    grid-template-columns: 1fr 300px; /* Main content + 300px sidebar */
    gap: 25px;
    align-items: start;
}

.game-main-content {
    min-width: 0; /* Prevents iframe overflow breaking grid */
}

/* Desktop 300x600 Sidebar Ad */
.desktop-ad-sidebar {
    display: block;
}

.sticky-ad-wrapper {
    position: sticky;
    top: 20px; /* Sticks to the top of screen as the user scrolls */
}

.ad-box-300x600 {
    width: 300px;
    height: 600px;
    background: #0f172a;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.ad-label, .mobile-ad-label {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.ad-placeholder-300x600 {
    color: #94a3b8;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

/* Hide Mobile Footer Ad on Desktop */
.mobile-sticky-footer-ad {
    display: none;
}

/* --- MOBILE & TABLET RESPONSIVENESS --- */
@media (max-width: 1024px) {
    /* Switch layout to single column on tablet/mobile */
    .game-layout-grid {
        grid-template-columns: 1fr;
    }

    /* Hide 300x600 desktop ad sidebar on screens < 1024px */
    .desktop-ad-sidebar {
        display: none !important;
    }

    /* Show 320x50 Sticky Footer Ad on Mobile */
    .mobile-sticky-footer-ad {
        display: flex;
        justify-content: center;
        align-items: center;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 65px;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(8px);
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        z-index: 9999;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.3);
    }

    .mobile-ad-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 320px;
        height: 50px;
    }

    .ad-placeholder-320x50 {
        width: 320px;
        height: 50px;
        background: #1e293b;
        color: #94a3b8;
        font-size: 12px;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
    }
}

/* Ensure the grid column allows sticky behavior */
.game-layout-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 25px;
    align-items: start; /* CRITICAL: Allows child sidebar to expand full height without stretching */
}

/* Sidebar Wrapper */
.desktop-ad-sidebar {
    display: block;
    height: 100%; /* Spans full height of the parent grid */
}

/* Sticky Container */
.sticky-ad-wrapper {
    position: -webkit-sticky; /* For Safari compatibility */
    position: sticky;
    top: 20px; /* Offset distance from top of browser window when scrolling */
    z-index: 10;
}

/* 300x600 Ad Box Styling */
.ad-box-300x600 {
    width: 300px;
    height: 600px;
    background: #0f172a;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

/* --- DESKTOP (Screens 1025px and larger) --- */
@media screen and (min-width: 1025px) {
    .game-layout-grid {
        display: grid;
        grid-template-columns: 1fr 300px; /* Game left, 300px Ad right */
        gap: 25px;
        align-items: start;
    }
    
    .desktop-ad-sidebar {
        display: block;
    }
}

/* --- MOBILE & TABLET (Screens 1024px and smaller) --- */
@media screen and (max-width: 1024px) {
    .game-layout-grid {
        display: block; /* Stacks everything top-to-bottom on mobile */
        width: 100%;
    }

    .desktop-ad-sidebar {
        display: none !important; /* Hides 300x600 sidebar on small screens */
    }
}

/* --- Overlay Backdrop --- */
.search-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.search-drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* --- Full Height Left Drawer --- */
.search-drawer {
    position: fixed;
    top: 0;
    left: -380px; /* Hidden off-screen to the left */
    width: 350px;
    max-width: 85vw; /* Safe width on narrow mobile screens */
    height: 100vh;
    background: #0f172a; /* Dark sleek slate theme */
    z-index: 99999;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Slide in state */
.search-drawer.active {
    transform: translateX(380px);
}

/* --- Header & Close Button --- */
.search-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.search-drawer-header h3 {
    color: #ffffff;
    font-size: 18px;
    font-weight: 800;
    margin: 0;
}

.close-drawer-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-drawer-btn:hover {
    background: #ef4444;
}

/* --- Input Field --- */
.search-input-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
}

#gameSearchInput {
    width: 100%;
    background: #1e293b;
    border: 2px solid rgba(255, 255, 255, 0.1);
    padding: 14px 40px 14px 16px;
    border-radius: 12px;
    color: #ffffff;
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

#gameSearchInput:focus {
    border-color: #00d2ff;
}

.search-clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    display: none;
}

/* --- Live Results List --- */
.search-results-container {
    flex: 1;
    overflow-y: auto;

    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

/* Scrollbar styling */
.search-results-container::-webkit-scrollbar {
    width: 6px;
}
.search-results-container::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px;
}

/* Placeholder Message */
.search-placeholder-msg {
    text-align: center;
    color: #64748b;
    font-size: 14px;
    margin-top: 40px;
}

/* Live Result Item Cards */
.search-result-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #1e293b;
    padding: 10px;
    border-radius: 10px;
    text-decoration: none;
    transition: transform 0.2s, background 0.2s;
}

.search-result-card:hover {
    background: #334155;
    transform: translateX(4px);
}

.search-result-card img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
}

.search-result-info {
    display: flex;
    flex-direction: column;
}

.search-result-title {
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
}

.search-result-genre {
    color: #00d2ff;
    font-size: 11px;
    margin-top: 2px;
}

/* Drawer Overlay */
.drawer-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99998;
    opacity: 0; visibility: hidden;
    transition: all 0.3s ease;
}
.drawer-overlay.active { opacity: 1; visibility: visible; }

/* Slide Drawer Container */
.profile-drawer {
    position: fixed;
    top: 0; left: -380px;
    width: 350px; max-width: 85vw; height: 100vh;
    background: #0f172a;
    z-index: 99999;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    display: flex; flex-direction: column;
    padding: 20px; box-sizing: border-box;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.profile-drawer.active { transform: translateX(380px); }

/* Header */
.drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
}
.drawer-header h3 { color: #fff; margin: 0; font-size: 18px; }

/* Logged Out Google Card */
.login-prompt-card {
    text-align: center;
    background: #1e293b;
    padding: 25px 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.login-icon { font-size: 40px; margin-bottom: 10px; }
.login-prompt-card h4 { color: #fff; margin: 0 0 8px; font-size: 18px; }
.login-prompt-card p { color: #94a3b8; font-size: 13px; line-height: 1.5; margin-bottom: 20px; }

/* Google Button */
.google-login-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: #ffffff; color: #1e293b;
    padding: 12px 20px; border-radius: 12px;
    text-decoration: none; font-weight: 700; font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.2s, background 0.2s;
}
.google-login-btn:hover { transform: translateY(-2px); background: #f8fafc; }

/* Logged In User Card */
.user-profile-card {
    display: flex; align-items: center; gap: 12px;
    background: #1e293b; padding: 12px; border-radius: 14px;
    margin-bottom: 20px;
}
.user-avatar { width: 42px; height: 42px; border-radius: 50%; }
.user-info { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.user-name { color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { color: #64748b; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn { color: #ef4444; font-size: 12px; text-decoration: none; font-weight: 700; }

/* Played Games List */
.played-games-section h4 { color: #00d2ff; margin: 0 0 12px; font-size: 14px; letter-spacing: 0.5px; }
.played-games-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; max-height: calc(100vh - 200px); }

.played-game-item {
    display: flex; align-items: center; gap: 12px;
    background: #1e293b; padding: 8px 12px; border-radius: 10px;
    text-decoration: none; transition: background 0.2s;
}
.played-game-item:hover { background: #334155; }
.played-game-item img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.played-game-item span { color: #fff; font-size: 13px; font-weight: 700; }