:root {
    --bg-charcoal-dark: #121212;
    --bg-charcoal-light: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --neon-teal: #00f2ea;
    --neon-green: #39ff14;
    --accent-red: #ff4757;
    --accent-green: #2ed573;
    --accent-gold: #ffd700;
    --font-family: 'Poppins', sans-serif;
    --border-radius-card: 12px;
    --border-radius-control: 8px;
    --transition-speed: 0.3s;
}

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

html, body {
    height: 100%; /* Ensure html and body take full viewport height */
    overflow: hidden; /* Prevent overall page scrollbar */
}

body {
    background-color: var(--bg-charcoal-dark);
    color: var(--text-primary);
    font-family: var(--font-family);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

.site-header {
    background-color: #1a1a1a;
    padding: 1rem 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 2px solid var(--neon-teal);
}

.site-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--neon-teal);
    text-shadow: 0 0 5px var(--neon-teal), 0 0 10px var(--neon-teal), 0 0 20px rgba(0, 242, 234, 0.5);
}

.site-logo {
    height: 50px;
    object-fit: contain;
}

#admin-login-btn {
    position: absolute;
    top: 50%;
    right: 2rem;
    transform: translateY(-50%);
    background-color: var(--bg-charcoal-light);
    color: var(--neon-teal);
    border: 1px solid var(--neon-teal);
    border-radius: var(--border-radius-control);
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color var(--transition-speed), box-shadow var(--transition-speed);
}

#admin-login-btn:hover {
    background-color: var(--neon-teal);
    color: var(--bg-charcoal-dark);
    box-shadow: 0 0 8px var(--neon-teal);
}

.site-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    overflow-y: auto; /* Allow content inside to scroll */
}

.main-content {
    padding: 2rem;
    flex: 1;
    width: 100%;
    margin: 0 auto;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1.5rem;
    background-color: var(--bg-charcoal-light);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius-card);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
    flex-grow: 1;
    min-width: 250px;
}

.search-container .bi-search {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
}

#search-box, .filter-container select {
    background-color: var(--bg-charcoal-dark);
    border: 1px solid #333;
    color: var(--text-primary);
    border-radius: var(--border-radius-control);
    font-family: var(--font-family);
    font-size: 1rem;
    padding: 0.75rem 1rem;
    transition: all var(--transition-speed) ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

#search-box {
    padding-left: 3rem;
    width: 100%;
}

#search-box:focus, .filter-container select:focus {
    outline: none;
    border-color: var(--neon-teal);
    box-shadow: 0 0 8px var(--neon-teal), inset 0 2px 4px rgba(0,0,0,0.2);
}

#search-box:hover, .filter-container select:hover {
    transform: translateY(-2px);
}

.filter-container {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.filter-btn {
    background-color: var(--bg-charcoal-dark);
    border: 1px solid #333;
    color: var(--text-secondary);
    border-radius: var(--border-radius-control);
    padding: 0.75rem 1.2rem;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.filter-btn:hover {
    color: var(--text-primary);
    border-color: #555;
    transform: translateY(-2px);
}

.filter-btn.active {
    background-color: var(--neon-teal);
    color: var(--bg-charcoal-dark);
    border-color: var(--neon-teal);
    box-shadow: 0 0 8px var(--neon-teal);
}

.section-title {
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    color: var(--neon-green);
    border-bottom: 2px solid #333;
    padding-bottom: 0.5rem;
}

.user-games-footer-text {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.95rem;
    padding-top: 1rem;
    border-top: 1px dashed #333;
}

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

.game-card {
    background-color: var(--bg-charcoal-light);
    border-radius: var(--border-radius-card);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    text-align: center;
    height: 240px; /* Fixed height to ensure all cards in the grid are the same height */
    justify-content: flex-start; /* Align content to the top within the fixed height */
}

.game-card:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(0, 242, 234, 0.2);
}

.game-card.recommended {
    border: 2px solid var(--accent-gold);
}

.game-card.recommended:hover {
    box-shadow: 0 0 20px var(--accent-gold);
}

.game-card__icon-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
    cursor: pointer;
}

.game-card__icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.game-card__image {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.game-card__content {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.game-card__title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    word-wrap: break-word; /* Ensure long words break */
    /* Limit title to 2 lines, show ellipsis if longer */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;  
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3; /* Explicit line height for consistent height calculation */
    min-height: calc(1.1rem * 1.3 * 2); /* Reserve space for 2 lines of text */
}

.game-card__description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;  
    overflow: hidden;
    text-overflow: ellipsis;
    /* Ensure description has enough space for 3 lines, show ellipsis if longer */
    min-height: calc(0.8rem * 1.6 * 3); /* Reserve space for 3 lines of text */
    line-height: 1.6; /* Explicit line height for consistent height calculation */
}

.game-card__fav-icon {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 1.25rem;
    color: var(--neon-green);
    background-color: rgba(30, 30, 30, 0.95);
    border-radius: 50%;
    padding: 0.25rem;
    line-height: 1;
    transition: transform var(--transition-speed);
    z-index: 2;
}

.game-card.recommended .game-card__fav-icon {
    color: var(--accent-gold);
}

.game-card__fav-icon:hover {
    transform: scale(1.2);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem; /* Reduced vertical padding */
    margin-top: 3rem;
}

.pagination button {
    background-color: var(--bg-charcoal-light);
    border: 1px solid #333;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.pagination button:hover {
    background-color: #333;
    transform: translateY(-3px);
}

.pagination button.active {
    background-color: var(--neon-teal);
    color: var(--bg-charcoal-dark);
    border-color: var(--neon-teal);
    box-shadow: 0 0 8px var(--neon-teal);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.hidden {
    display: none !important; /* Use !important to ensure it overrides other display properties */
}

.no-results-message {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 2rem;
    grid-column: 1 / -1; /* Make it span all columns in the grid */
}

/* Responsive Design */
@media (max-width: 768px) {
    .site-logo {
        height: 40px;
    }
    .site-title {
        font-size: 2rem;
    }
    .main-content {
        padding: 1.5rem;
        flex-grow: 1;
    }
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
    }
    #search-box {
        min-width: unset;
        width: 100%;
    }
    .filter-container {
        justify-content: center;
    }

    .game-viewer__footer {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }

    .game-viewer__footer h2 {
        font-size: 1.2rem;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .game-viewer__footer-controls {
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .site-header {
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    #admin-login-btn {
        position: static;
        transform: none;
        margin-top: 0.5rem;
        display: block;
        width: 100%;
        text-align: center;
    }
    .game-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 1rem;
    }
}