:root {
    --primary-color: #6c5ce7;
    --secondary-color: #f5f5f5;
    --text-color: #000000;
    --text-light: #666666;
    --white: #ffffff;
    --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Poppins', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #f9f9f9;
}

header ~ *:not(footer) {
    flex: 1;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
header {
    background-color: var(--white);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    padding: 10px 0;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.logo {
    font-family: 'Fredoka One', cursive;
    color: var(--primary-color);
    font-size: 28px;
    text-decoration: none;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.logo-icon {
    display: inline-block;
    width: 30px;
    height: 30px;
    background: var(--primary-color);
    border-radius: 8px;
    margin-right: 10px;
    color: white;
    text-align: center;
    line-height: 30px;
    font-size: 18px;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c5ce7;
    cursor: pointer;
    order: 2;
}

.mobile-search-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #6c5ce7;
    cursor: pointer;
    order: 1;
    margin-right: 15px;
}

nav ul {
    display: flex;
    list-style: none;
    align-items: center;
}

nav li {
    margin-left: 30px;
}

nav a {
    text-decoration: none;
    color: #6c5ce7;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

nav a:hover {
    color: #333;
}

nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    bottom: -5px;
    left: 0;
    transition: var(--transition);
}

nav a:hover::after {
    width: 100%;
}

/* Search Styles */
.search-container {
    position: relative;
    margin-left: 20px;
}

.search-input {
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid #ddd;
    width: 200px;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    width: 250px;
}

.search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6c5ce7;
    cursor: pointer;
}

.mobile-search-container {
    display: none;
    width: 100%;
    padding: 10px 20px;
    background-color: var(--white);
    position: fixed;
    top: 70px;
    left: 0;
    z-index: 999;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: var(--transition);
}

.mobile-search-container.active {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mobile-search-input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid #ddd;
    transition: var(--transition);
}

.mobile-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

body.game-open .search-container{
    display: none;
}

/* Games Section */
.games-section {
    padding: 60px 10px 20px;
    background-image: url('img/back.webp');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
    margin-top: 5%;
}

.games-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.games-section .container {
    position: relative;
    z-index: 1;
}

.section-title {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.5rem;
    font-weight: 700;
}

/* Updated Games Grid Layout */
.games-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Updated Game Cards */
.game-card {
    background-color: var(--white);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    opacity: 1;
    transform: none;
    animation: fadeIn 0.5s ease-out;
    aspect-ratio: 1/1; /* Maintain square shape */
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.game-image {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    top: 0;
    left: 0;
}

a{
    text-decoration: none;
}

/* Special Cards */
.special-card-wrapper {
    grid-column: span 2;
    aspect-ratio: 2/1; /* Wider aspect ratio for special cards */
}

.game-card.special-card,
.game-card.premium-card {
    aspect-ratio: 2/1; /* Match the wrapper */
}

/* When special card is present, show 2 normal cards alongside */
.special-card-wrapper + .game-card,
.special-card-wrapper + .game-card + .game-card, 
.special-card-wrapper + .game-card + .game-card + .game-card, 
.special-card-wrapper + .game-card + .game-card + .game-card + .game-card {
    grid-column: span 1;
}

/* Game Detail View */
.game-detail-container {
  display: none;
  position: fixed;
  top: 70px; /* Below header */
  left: 0;
  width: 100%;
  height: calc(100vh - 70px);
  background: white;
  z-index: 999;
  overflow-y: auto;
}

.game-header {
  padding: 15px 20px;
  background: var(--primary-color);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-content {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  scroll-margin-top: 100px;
}

.game-iframe-container {
  position: relative;
  width: 100%;
  height: 50vh;
  min-height: 360px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  margin-bottom: 30px;
  margin-top: -5%;
  background-color: transparent;
  border: 1px solid transparent;
  scroll-margin-top: 80px;
}

.game-iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Hide footer when game is open */
body.game-open footer {
  display: none;
}

.fullscreen-btn {
    position: absolute;
    bottom: 5px;
    right: 3px;
    background-color: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.fullscreen-btn:hover {
    background-color: rgba(0,0,0,0.8);
}

.back-to-games {
    display: block;
    text-align: center;
    margin: 20px auto;
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 30px;
    text-decoration: none;
    max-width: 200px;
    transition: var(--transition);
}

.back-to-games:hover {
    background-color: #5a4bc7;
    transform: translateY(-2px);
}

/* Special Card Styling */
.special-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
    margin-right: 8px;
}

.game-card.special-card .special-badge {
    background-color: #6c5ce7;
    color: white;
}

.game-card.premium-card .special-badge {
    background-color: #fdcb6e;
    color: #2d3436;
}

.game-card.special-card h3,
.game-card.premium-card h3 {
    font-size: 1.3rem;
    text-align: center;
    margin-top: -1%;
}

.game-card.special-card {
    border: 3px solid #6c5ce7;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.game-card.premium-card {
    border: 3px solid #fdcb6e;
    box-shadow: 0 4px 12px rgba(253, 203, 110, 0.3);
}

/* No results message */
.no-results {
    text-align: center;
    color: var(--text-color);
    font-size: 1.2rem;
    grid-column: 1 / -1;
    padding: 40px 0;
    display: none;
}

/* About Section */
.about-section {
    padding: 80px 20px;
    background-color: var(--white);
}

.about-container {
    max-width: 900px;
    margin: 0 auto;
}

.about-section h2 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 20px;
    text-align: center;
}

.about-section p {
    color: var(--text-light);
    margin-bottom: 20px;
    line-height: 1.8;
    text-align: left;
}

/* FAQ Section */
.faq-section {
    padding: 60px 20px;
    background-color: #f9f9f9;
}

.faq-container {
    max-width: 900px;
    margin: 0 auto;
}

.faq-section h2 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 30px;
    text-align: center;
}

.faq-item {
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

.faq-question {
    background-color: var(--white);
    padding: 15px 20px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-answer {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    background-color: #f5f5f5;
}

.faq-answer.active {
    padding: 15px 20px;
    max-height: 200px;
}

.faq-toggle {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.faq-item.active .faq-toggle {
    transform: rotate(180deg);
}

/* Footer Styles */
footer {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 50px 0 20px;
    text-align: center;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer-logo {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--white);
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 30px;
}

.footer-nav a {
    color: var(--white);
    text-decoration: none;
    margin: 0 15px 10px;
    font-size: 0.9rem;
    transition: var(--transition);
}

.footer-nav a:hover {
    color: black;
}

.footer-categories {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 30px;
}

.footer-categories a {
    color: white;
    text-decoration: none;
    margin: 0 10px 10px;
    font-size: 0.85rem;
    transition: var(--transition);
}

.footer-categories a:hover {
    color: black;
}

.social-links {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--white);
    margin: 0 10px;
    transition: var(--transition);
}

.social-links a:hover {
    background-color: var(--primary-color);
    transform: translateY(-3px);
}

.copyright {
    font-size: 0.85rem;
    color: white;
    margin-top: 20px;
}

/* Fullscreen styles */
:-webkit-full-screen .game-iframe-container {
    width: 100%;
    height: 100%;
    padding-bottom: 0;
}

:-moz-full-screen .game-iframe-container {
    width: 100%;
    height: 100%;
    padding-bottom: 0;
}

:-ms-fullscreen .game-iframe-container {
    width: 100%;
    height: 100%;
    padding-bottom: 0;
}

:fullscreen .game-iframe-container {
    width: 100%;
    height: 100%;
    padding-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .games-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .special-card-wrapper {
        grid-column: span 3;
    }
    
    .special-card-wrapper + .game-card {
        grid-column: span 1;
    }
    
    .special-card-wrapper + .game-card + .game-card {
        display: none;
    }
}

@media (max-width: 768px) {
    .game-iframe-container{
        margin-top: -14%;
    }

    body.game-open .mobile-search-btn{
        display: none;
    }
    
    .mobile-menu-toggle {
        display: block;
    }

    .mobile-search-btn {
        display: block;
    }

    nav {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 70px);
        background-color: var(--white);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        transition: var(--transition);
    }

    nav.active {
        left: 0;
    }

    nav ul {
        flex-direction: column;
        align-items: center;
    }

    nav li {
        margin: 15px 0;
    }

    .search-container {
        display: none;
    }
    
    .games-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .game-card {
        aspect-ratio: 1/1; /* Maintain square shape */
    }
    
    .special-card-wrapper {
        grid-column: span 2;
        aspect-ratio: 2/1; /* Wider aspect ratio for special cards */
    }
    
    .game-card.special-card,
    .game-card.premium-card {
        aspect-ratio: 2/1; /* Match the wrapper */
    }
}

@media (max-width: 480px) {
    header .container {
        justify-content: flex-end;
    }

    .logo {
        margin-right: auto;
    }
    
    .games-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .game-card {
        aspect-ratio: 1/1; /* Maintain square shape */
    }

    .special-card-wrapper {
        grid-column: span 2;
        aspect-ratio: 2/1; /* Wider aspect ratio for special cards */
    }
    
    .game-info h3 {
        font-size: 0.9rem;
    }
    
    .section-title {
        font-size: 2rem;
    }
}

/* Related Games Section - Full Width with Responsive Grid */
.related-games {
    padding: 40px 0;
    position: relative;
    width: 100%;
    margin: 0;
    background-image: url('img/back.webp');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.related-games::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.related-games .container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.related-games h3 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8rem;
}

/* Main Grid Layout */
.related-games-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    width: 100%;
}

/* Special Card Layout (when special card exists) */
.related-games-grid.has-special-card {
    grid-template-columns: repeat(6, 1fr);
}

/* Special Card Styling */
.related-games-grid .special-card-wrapper {
    grid-column: span 1;
    aspect-ratio: 1/1;
}

.related-games-grid .game-card {
    background-color: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    aspect-ratio: 1/1;
}

.related-games-grid .game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.related-games-grid .game-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.related-games-grid .game-info {
    padding: 12px;
    text-align: center;
}

.related-games-grid .game-info h3 {
    color: var(--primary-color);
    font-size: 1rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Special/Premium Card Specific Styles */
.related-games-grid .game-card.special-card,
.related-games-grid .game-card.premium-card {
    position: relative;
    aspect-ratio: 1/1;
}

.related-games-grid .special-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
    margin-right: 8px;
}

.related-games-grid .game-card.special-card .special-badge {
    background-color: #6c5ce7;
    color: white;
}

.related-games-grid .game-card.premium-card .special-badge {
    background-color: #fdcb6e;
    color: #2d3436;
}

.related-games-grid .game-card.special-card h3,
.related-games-grid .game-card.premium-card h3 {
    font-size: 1.3rem;
    text-align: center;
    margin-top: -1%;
}

.related-games-grid .game-card.special-card {
    border: 3px solid #6c5ce7;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.related-games-grid .game-card.premium-card {
    border: 3px solid #fdcb6e;
    box-shadow: 0 4px 12px rgba(253, 203, 110, 0.3);
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    /* Desktop with special card - 4 normal cards */
    .related-games-grid.has-special-card {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .related-games-grid.has-special-card .special-card-wrapper {
        grid-column: span 1;
    }
    
    .related-games-grid.has-special-card .game-card:not(.special-card):not(.premium-card) {
        grid-column: span 1;
    }
    
    /* Hide extra cards to maintain 4 normal + 1 special layout */
    .related-games-grid.has-special-card .game-card:nth-child(n+6) {
        display: none;
    }
}

/* Mobile View (under 768px) */
@media (max-width: 768px) {
    /* Default grid - 2 normal cards per row */
    .related-games-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Adjust image heights */
    .related-games-grid .game-image {
        height: 100%;
    }
    
    /* Ensure we show 2 normal cards per row after special card */
    .related-games-grid.has-special-card {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    /* Normal cards after special card */
    .related-games-grid .special-card-wrapper + .game-card {
        grid-column: span 1;
    }
}

@media (max-width: 480px) {
    .related-games-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .related-games-grid .game-info h3 {
        font-size: 0.9rem;
    }

    

    .related-games-grid.has-special-card {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }
}