.games {
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
    text-align: center;
}

.games::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(180deg, var(--bg-color) 0%, var(--bg-secondary) 100%);
    z-index: 1;
}

.games::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255, 107, 53, 0.05) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 1;
}

.games .container {
    position: relative;
    z-index: 2;
    overflow-x: visible;
}

.games h2 {
    margin-bottom: 2rem;
}

.games h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--gradient-primary);
    border-radius: 20px;
    z-index: 10;
}

/* Category Toggle Buttons */
.category-toggle {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    position: relative;
    z-index: 3;
}

.category-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: rgba(51, 51, 56, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-width: 120px;
    justify-content: center;
}

.category-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
}

.category-btn:hover {
    border-color: rgba(255, 107, 53, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.15);
}

.category-btn:hover::before {
    left: 0;
}

.category-btn.active {
    background: var(--gradient-primary);
    color: white;
    border-color: rgba(255, 107, 53, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.25);
}

.category-btn.active::before {
    left: 0;
}

.category-btn svg {
    transition: transform 0.3s ease;
}

.category-btn:hover svg,
.category-btn.active svg {
    transform: scale(1.1);
}

/* Category button text - hidden on mobile */
.category-btn-text {
    transition: opacity 0.3s ease;
}

/* Mobile responsive category buttons */
@media (max-width: 768px) {
    .category-btn {
        width: 60px;
        height: 60px;
        min-width: 60px;
        padding: 0;
        border-radius: 50%;
        gap: 0;
        justify-content: center;
        align-items: center;
    }
    
    .category-btn-text {
        display: none;
    }
    
    .category-btn svg {
        width: 24px;
        height: 24px;
    }
    
    .category-toggle {
        gap: 1.5rem;
        margin-bottom: 2.5rem;
    }
}

/* Enhanced mobile button interactions */
@media (max-width: 768px) {
    .category-btn:hover {
        transform: translateY(-3px) scale(1.05);
    }
    
    .category-btn.active {
        transform: translateY(-3px) scale(1.05);
    }
    
    .category-btn:active {
        transform: translateY(-1px) scale(0.95);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .category-btn:hover {
        transform: none;
    }
    
    .category-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    .category-btn.active {
        transform: scale(1.02);
    }
}

/* Ensure circular buttons maintain shape at all resolutions */
@media (max-width: 768px) {
    .category-btn {
        aspect-ratio: 1 / 1; /* Ensures perfect circle */
        overflow: hidden;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .category-btn * {
        flex-shrink: 0;
    }
}

/* Category button text - hidden on mobile */
.category-btn-text {
    transition: opacity 0.3s ease;
}

/* Mobile responsive category buttons */
@media (max-width: 768px) {
    .category-btn {
        width: 60px;
        height: 60px;
        min-width: 60px;
        padding: 0;
        border-radius: 50%;
        gap: 0;
        justify-content: center;
        align-items: center;
    }
    
    .category-btn-text {
        display: none;
    }
    
    .category-btn svg {
        width: 24px;
        height: 24px;
    }
    
    .category-toggle {
        gap: 1.5rem;
        margin-bottom: 2.5rem;
    }
}

@media (max-width: 480px) {
    .category-btn {
        width: 55px;
        height: 55px;
        min-width: 55px;
        max-width: 55px;
        min-height: 55px;
        max-height: 55px;
        border-radius: 50% !important;
        padding: 0 !important;
        flex-shrink: 0;
        flex-grow: 0;
    }
    
    .category-btn svg {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }
    
    .category-toggle {
        gap: 1.25rem;
        margin-bottom: 2rem;
        flex-wrap: nowrap;
    }
}

@media (max-width: 375px) {
    .category-btn {
        width: 50px;
        height: 50px;
        min-width: 50px;
        max-width: 50px;
        min-height: 50px;
        max-height: 50px;
        border-radius: 50% !important;
        padding: 0 !important;
        flex-shrink: 0;
        flex-grow: 0;
    }
    
    .category-btn svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }
    
    .category-toggle {
        gap: 1rem;
        flex-wrap: nowrap;
    }
}

/* Specific styles for very narrow screens */
@media (max-width: 360px) {
    .category-btn {
        width: 48px;
        height: 48px;
        min-width: 48px;
        max-width: 48px;
        min-height: 48px;
        max-height: 48px;
        border-radius: 50% !important;
        padding: 0 !important;
        flex-shrink: 0;
        flex-grow: 0;
    }
    
    .category-btn svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
    }
    
    .category-toggle {
        gap: 0.875rem;
        padding: 0 0.5rem;
        flex-wrap: nowrap;
    }
}

@media (max-width: 320px) {
    .category-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        max-width: 44px;
        min-height: 44px;
        max-height: 44px;
        border-radius: 50% !important;
    }
    
    .category-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .category-toggle {
        gap: 0.75rem;
        padding: 0 0.25rem;
    }
}

/* Carousel Wrapper */
.carousel-wrapper {
    position: relative;
    overflow: hidden;
    min-height: 500px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.games-carousel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.games-carousel.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: all;
}

.games-carousel.exit-left {
    opacity: 0;
    transform: translateX(-100px);
}

.games-carousel.exit-right {
    opacity: 0;
    transform: translateX(100px);
}

/* Container safety measures to prevent cropping */
.games .container {
    overflow-x: visible;
    position: relative;
}

.carousel-wrapper {
    overflow: visible; /* Allow arrows to be visible */
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Ensure proper spacing around carousel content */
@media (max-width: 1024px) {
    .games .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (max-width: 768px) {
    .games .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

@media (max-width: 480px) {
    .games .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Mobile responsive adjustments - updated for circular buttons */
@media (max-width: 768px) {
    .category-toggle {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 1.5rem;
        margin-bottom: 2.5rem;
        padding: 0 1rem;
    }
}

/* Additional mobile improvements */
@media (max-width: 480px) {
    .carousel-wrapper {
        min-height: 480px;
        padding: 0 0.5rem;
        overflow: visible;
    }
    
    .games-carousel {
        padding: 0;
        margin: 0;
    }
    
    .games-container {
        margin: 0;
        border-radius: 12px;
    }
    
    .carousel-nav {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
    }
    
    .carousel-nav-row {
        gap: 2rem;
        margin: 1rem 0 0.5rem 0;
        padding: 0 1rem;
    }
    
    .carousel-indicators {
        margin-top: 0.5rem;
        gap: 0.4rem;
    }
    
    /* Ensure the category buttons have proper spacing */
    .category-toggle {
        margin-bottom: 2rem;
        padding: 0 1rem;
    }
}

/* Tablet specific adjustments */
@media (min-width: 481px) and (max-width: 1024px) {
    .carousel-wrapper {
        padding: 0 1.5rem;
    }
    
    .carousel-nav-row {
        gap: 2.5rem;
        margin: 1.25rem 0 0.75rem 0;
    }
}

.games-container {
    flex: 1;
    overflow: hidden;
    border-radius: 15px;
    position: relative;
}

.games-grid {
    display: flex;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 2rem;
    padding: 0 1rem;
}

.game-card {
    flex: 0 0 calc(100% / 3 - 1.5rem); /* Default: 3 cards per view */
    max-width: 320px;
    min-width: 0;
    background: rgba(51, 51, 56, 0.25);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    position: relative;
    transform-style: preserve-3d;
    cursor: grab;
    display: flex;
    flex-direction: column;
    min-height: 410px;
    max-height: 450px;
    overflow: hidden;
}

.game-card:active {
    cursor: grabbing;
}

.carousel-nav {
    background: rgba(51, 51, 56, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    flex-shrink: 0;
}

.carousel-nav:hover {
    background: rgba(255, 107, 53, 0.8);
    transform: scale(1.1);
    border-color: rgba(255, 107, 53, 0.4);
}

.carousel-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: scale(1);
}

.carousel-nav:disabled:hover {
    background: rgba(51, 51, 56, 0.8);
    border-color: rgba(255, 255, 255, 0.12);
}

.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    width: 100%;
    position: absolute;
    bottom: -30px;
    left: 0;
}

/* Desktop layout: indicators positioned absolutely below carousel */
@media (min-width: 1025px), (min-width: 769px) and (orientation: landscape) {
    .carousel-indicators {
        position: absolute;
        bottom: -35px;
        left: 0;
        width: 100%;
        margin-top: 0;
    }
    
    .carousel-wrapper {
        padding-bottom: 50px; /* Space for indicators */
        min-height: 500px;
    }
}

/* Mobile/tablet layout: indicators as flex items */
@media (max-width: 1024px) and (orientation: portrait), (max-width: 768px) {
    .carousel-indicators {
        position: static;
        margin-top: 0.75rem;
        margin-bottom: 0;
        order: 3; /* Position after nav-row on mobile */
    }
    
    .carousel-wrapper {
        padding-bottom: 0;
    }
}

@media (max-width: 480px) {
    .carousel-indicators {
        position: static;
        margin-top: 0.5rem;
        gap: 0.4rem;
        bottom: auto;
    }
}

.indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.indicator.active {
    background: var(--accent-color);
    transform: scale(1.2);
}

/* Responsive indicator sizing */
@media (max-width: 480px) {
    .indicator {
        width: 6px;
        height: 6px;
    }
}

@media (max-width: 375px) {
    .indicator {
        width: 5px;
        height: 5px;
    }
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    border-radius: 20px;
}

.game-card:hover {
    transform: translateY(-15px) rotateX(5deg) rotateY(5deg);
    border-color: rgba(255, 107, 53, 0.4);
    background: rgba(51, 51, 56, 0.35);
}

.game-card:hover::before {
    opacity: 0.03;
}

.game-card img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), max-height 0.3s;
    position: relative;
    z-index: 2;
    max-height: 180px;
}

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

.game-card-content {
    padding: 2rem;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
    overflow: hidden;
    min-height: 0;
}

.game-content-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.game-text-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 1rem;
}

.game-card h3 {
    margin-bottom: 0.75rem;
    color: var(--text-color);
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    word-wrap: break-word;
    hyphens: auto;
}

.game-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.3;
    font-size: clamp(0.6rem, 2vw, 0.8rem);
    word-wrap: break-word;
    hyphens: auto;
    flex: 1;
    display: flex;
    align-items: flex-start;
    overflow: hidden;
}

.game-link {
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
}

.downloads {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: rgba(255, 107, 53, 0.1);
    color: var(--accent-color);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid rgba(255, 107, 53, 0.2);
    transition: all 0.3s ease;
}

.downloads:hover {
    background: rgba(255, 107, 53, 0.2);
    border-color: rgba(255, 107, 53, 0.4);
    transform: translateY(-2px);
}

.game-status {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    backdrop-filter: blur(10px);
}

.game-status.coming-soon {
    background: var(--gradient-accent);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.game-status.available {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.game-link {
    text-decoration: none;
    color: inherit;
}

.downloads {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: rgba(255, 107, 53, 0.1);
    color: var(--accent-color);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid rgba(255, 107, 53, 0.2);
    transition: all 0.3s ease;
}

.downloads:hover {
    background: rgba(255, 107, 53, 0.2);
    border-color: rgba(255, 107, 53, 0.4);
    transform: translateY(-2px);
}

/* Responsive carousel: adjust card width per view */
.game-card {
    flex: 0 0 calc(100% / 3 - 1.5rem); /* Default: 3 cards per view */
    max-width: 320px;
    min-width: 0;
    background: rgba(51, 51, 56, 0.25);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    position: relative;
    transform-style: preserve-3d;
    cursor: grab;
    display: flex;
    flex-direction: column;
    min-height: 410px;
    max-height: 450px;
    overflow: hidden;
}

@media (max-width: 900px) {
    .game-card {
        flex: 0 0 calc(100% / 2 - 1.5rem); /* 2 cards per view on tablet */
    }
}

@media (max-width: 480px) {
    .game-card {
        flex: 0 0 100%; /* 1 card per view on mobile */
        max-width: 100%;
    }
}

/* Touch device support */
.game-card.touch-active {
    transform: translateY(-10px) !important;
    border-color: rgba(255, 107, 53, 0.4);
    background: rgba(51, 51, 56, 0.35);
}

.game-card.touch-active::before {
    opacity: 0.03;
}

.game-card.touch-active img {
    transform: scale(1.05);
}

/* Enhanced button interactions for touch devices */
.downloads:active {
    background: rgba(255, 107, 53, 0.3);
    border-color: rgba(255, 107, 53, 0.6);
    transform: translateY(-2px) scale(0.95);
}

/* Touch-friendly hover alternatives */
@media (hover: none) and (pointer: coarse) {
    .game-card:hover {
        transform: none;
        border-color: rgba(255, 255, 255, 0.12);
        background: rgba(51, 51, 56, 0.25);
    }
    
    .game-card:hover::before {
        opacity: 0;
    }
    
    .game-card:hover img {
        transform: none;
    }
    
    .downloads:hover {
        background: rgba(255, 107, 53, 0.1);
        border-color: rgba(255, 107, 53, 0.2);
        transform: none;
    }
    
    /* Use active states instead */
    .game-card:active {
        transform: translateY(-5px);
        border-color: rgba(255, 107, 53, 0.3);
        background: rgba(51, 51, 56, 0.3);
    }
    
    .downloads:active {
        background: rgba(255, 107, 53, 0.3);
        border-color: rgba(255, 107, 53, 0.6);
        transform: translateY(-2px) scale(0.95);
    }
}

/* Improve button tap targets for mobile */
@media (max-width: 768px) {
    .downloads {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        min-height: 44px; /* Minimum touch target size */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .game-card {
        display: flex;
        flex-direction: column;
    }
    .game-card-content {
        display: flex;
        flex-direction: column;
        flex: 1;
    }
    .game-link {
        margin-top: auto;
    }
}

@media (max-width: 900px) {
    .game-card {
        flex: 0 0 calc(100% / 2 - 1rem); /* 2 cards per view on tablet portrait */
        max-width: 360px;
    }
}

@media (max-width: 480px) {
    .game-card {
        flex: 0 0 100%; /* 1 card per view on mobile portrait */
        max-width: 100%;
    }
    .games-grid {
        gap: 1rem;
        padding: 0 0.5rem;
    }
}

/* Responsive: Move carousel arrows below for mobile/tablet portrait */
@media (max-width: 1024px) and (orientation: portrait), (max-width: 768px) {
    .games-carousel {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }
    
    .games-container {
        order: 1;
        margin: 0;
    }
    
    .carousel-nav-row {
        display: flex !important;
        justify-content: center;
        align-items: center;
        gap: 1.5rem;
        margin: 1rem 0 0.5rem 0;
        order: 2;
    }
    
    .carousel-indicators {
        order: 3;
        margin-top: 0.75rem;
        margin-bottom: 0;
    }
    
    .carousel-nav {
        position: static;
        margin: 0;
        width: 50px;
        height: 50px;
        flex-shrink: 0;
    }
    
    /* Hide desktop arrows completely on mobile/tablet */
    .desktop-arrow {
        display: none !important;
    }
    
    /* Ensure carousel wrapper has enough space */
    .carousel-wrapper {
        min-height: 520px;
        padding: 0 1rem;
    }
}

/* Desktop: show side arrows, hide nav row */
@media (min-width: 1025px), (min-width: 769px) and (orientation: landscape) {
    .carousel-nav-row {
        display: none !important;
    }
    .desktop-arrow {
        display: flex !important;
        position: static;
        margin: 0;
    }
    
    .games-carousel {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
    }
    
    .games-container {
        order: 0;
    }
}

/* Mobile/tablet portrait: show nav row, hide side arrows */
@media (max-width: 1024px) and (orientation: portrait), (max-width: 768px) {
    .desktop-arrow {
        display: none !important;
    }
    .carousel-nav-row {
        display: flex !important;
    }
}

/* If .game-card is at max height, shrink font and image further */
.game-card[max-height="450px"] img {
    max-height: 140px;
}

.game-card[max-height="450px"] h3 {
    font-size: clamp(0.7rem, 2vw, 0.9rem);
}

.game-card[max-height="450px"] p {
    font-size: clamp(0.55rem, 1.8vw, 0.7rem);
    line-height: 1.2;
}

/* Enhanced touch targets for very small screens */
@media (max-width: 375px) {
    .carousel-nav {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
    
    .carousel-nav-row {
        gap: 1.5rem;
        margin: 0.75rem 0 0.25rem 0;
        padding: 0 0.5rem;
    }
    
    .carousel-indicators {
        margin-top: 0.4rem;
        gap: 0.3rem;
    }
    
    .category-btn {
        width: 160px;
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
    
    .category-toggle {
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }
    
    .carousel-wrapper {
        min-height: 450px;
        padding: 0 0.25rem;
    }
}

/* Add accessibility improvements for mobile circular buttons */
@media (max-width: 768px) {
    .category-btn {
        position: relative;
    }
    
    /* Tooltip for mobile circular buttons */
    .category-btn::after {
        content: attr(data-tooltip);
        position: absolute;
        top: -40px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.8);
        color: white;
        padding: 0.25rem 0.5rem;
        border-radius: 4px;
        font-size: 0.75rem;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 1000;
    }
    
    .category-btn:hover::after,
    .category-btn:focus::after {
        opacity: 1;
    }
}

