/* CSS Reset and Global Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f7f9fb;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
}

/* 1. Header Styles */
header {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 50;
}

/* Mobile Default: Header content stacks vertically */
.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.logo {
    font-size: 28px;
    font-weight: 800;
    color: #4f46e5; /* Indigo */
    text-decoration: none;
    flex-shrink: 0;
}
.logo-beta {
    color: #f59e0b; /* Yellow */
}

/* Search and Categories Wrapper */
.tools-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 12px;
}

.search-input {
    width: 89%;
    padding: 10px 16px;
    border: 1px solid #ccc;
    border-radius: 9999px; /* Full rounded pill shape */
    font-size: 14px;
    outline: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* Category Navigation (Pills) */
.category-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto; /* Enable horizontal scrolling on small screens */
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px; /* Space for hidden scrollbar */
}
/* Hide scrollbar visually on all browsers */
.category-nav::-webkit-scrollbar {
    height: 0;
}
.category-nav {
    scrollbar-width: none; /* Firefox */
}

.category-pill {
    display: block;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 9999px;
    text-decoration: none;
    background-color: #eef2ff; /* Light Indigo */
    color: #4f46e5; /* Indigo */
    flex-shrink: 0; /* Important: prevents pills from shrinking on mobile */
    transition: background-color 0.2s, color 0.2s;
}
.category-pill:hover, .category-pill.active {
    background-color: #4f46e5;
    color: #fff;
}

/* Desktop/Tablet Media Query (Custom breakpoint, e.g., 1024px) */
@media (min-width: 1024px) {
    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    .tools-wrapper {
        flex-direction: row;
        width: auto;
        max-width: 900px;
        gap: 16px;
    }
    .search-input-wrapper {
        width: 384px; /* Fixed max width for search on desktop */
        flex-shrink: 0;
    }
    .category-nav {
        width: auto;
        padding-bottom: 0;
        overflow-x: visible; /* Disable horizontal scrolling on desktop */
    }
}

/* 2. Main Content and Grid */
main {
    flex-grow: 1;
    padding: 24px 0;
}
h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    text-align: center;
    color: #1f2937;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.game-tile {
    display: block;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border 0.3s;
    border: 2px solid transparent;
}
.game-tile:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.15);
    border-color: #4f46e5;
}

.game-image-wrapper {
    height: 192px; /* Fixed height for image area */
    overflow: hidden;
}
.game-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}
.game-tile:hover .game-image {
    transform: scale(1.1);
}

.game-details {
    padding: 16px;
}
.game-details h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #1f2937;
}
.game-details p {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 40px; /* fixed height for 2 lines */
}

.tag {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    margin-right: 8px;
    margin-top: 4px;
}
.tag-yellow { background-color: #fef3c7; color: #b45309; }
.tag-red { background-color: #fee2e2; color: #b91c1c; }
.tag-green { background-color: #d1fae5; color: #065f46; }
.tag-blue { background-color: #dbeafe; color: #1e40af; }
.tag-purple { background-color: #ede9fe; color: #5b21b6; }
.tag-sky { background-color: #e0f2fe; color: #075985; }

/* 3. Site Description Block (New CSS) */
.site-description-block {
    margin-top: 48px;
    padding: 32px;
    background-color: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.description-title {
    font-size: 20px;
    font-weight: 700;
    color: #4f46e5;
    margin-bottom: 16px;
    border-bottom: 2px solid #eef2ff;
    padding-bottom: 8px;
}

.description-text {
    font-size: 14px;
    line-height: 1.6;
    color: #4b5563;
    margin-bottom: 12px;
}

/* 4. Footer */
footer {
    background-color: #1f2937; /* Dark Gray */
    color: #e5e7eb;
    padding: 24px 0;
    margin-top: auto; /* Pushes footer to the bottom */
}
.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
}
.footer-links a {
    color: #9ca3af;
    text-decoration: none;
    font-size: 14px;
    margin: 0 8px;
    transition: color 0.2s;
}
.footer-links a:hover {
    color: #6366f1; /* Indigo Hover */
}

@media (min-width: 768px) {
    .footer-content {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }
}

/* Utility for hiding tiles during search */
.hidden-tile {
    display: none !important;
}