body {
    background: linear-gradient(135deg, #FF6B35 0%, #F7931E 25%, #FDC830 50%, #F37335 75%, #C644FC 100%);
    background-attachment: fixed;
    font-family: 'Inter', sans-serif;
}

/* Keep card corners stable even if utility vars fail to hydrate */
.rounded-card {
    border-radius: 1rem !important;
}

.game-card {
    border-radius: 1rem;
    overflow: hidden;
    isolation: isolate;
}

.game-card > img {
    border-radius: inherit;
    display: block;
}

/* Smooth hover transition for cards */
.game-card {
    transition: transform 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.game-card:hover {
    transform: scale(1.05);
    z-index: 10;
}

/* Game title overlay animation */
.game-title-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    padding: 1rem;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), opacity 0.3s ease;
    pointer-events: none;
}

.group:hover .game-title-overlay {
    transform: translateY(0);
    opacity: 1;
}

.game-title-overlay span {
    display: block;
    width: 100%;
    color: white;
    font-weight: 900;
    font-size: 0.875rem;
    line-height: 1.25rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
}

@media (min-width: 640px) {
    .game-title-overlay span {
        font-size: 1rem;
    }
}

/* Paginator styles */
.paginator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.paginator-button {
    min-width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 0.875rem;
    color: #243447;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 7px 10px 4px rgba(93, 107, 132, 0.3);
    border: none;
}

.paginator-button:hover:not(.disabled):not(.active) {
    transform: translateY(-2px);
    box-shadow: 0 14px 20px 8px rgba(93, 107, 132, 0.2);
    background: #f3f4f6;
}

.paginator-button.active {
    background: #0092ff;
    color: white;
}

.paginator-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.paginator-button svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Category card hover effects */
.category-card {
    transition: transform 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.category-card:hover {
    transform: translateY(-4px);
    z-index: 10;
}

.category-card:hover .game-card {
    box-shadow: 0 14px 20px 8px rgba(93, 107, 132, 0.4);
}

/* Grid layout improvements for merged cards */
.auto-rows-fr {
    grid-auto-rows: minmax(0, 1fr);
}

/* Ensure merged cards maintain aspect ratio on mobile */
@media (max-width: 640px) {
    .col-span-2 {
        grid-column: span 2;
    }

    .row-span-2 {
        grid-row: span 2;
    }

    .col-span-3 {
        grid-column: span 3;
    }

    .row-span-3 {
        grid-row: span 3;
    }
}

/* Hide scrollbar for horizontal scrolling areas if any */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Autocomplete dropdown */
#desktopAutocomplete,
#mobileAutocomplete {
    max-height: 400px;
    overflow-y: auto;
}

/* Load More button */
.load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    padding: 0.875rem 2rem;
    background: white;
    border-radius: 1rem;
    font-weight: 800;
    font-size: 1rem;
    color: #243447;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 7px 10px 4px rgba(93, 107, 132, 0.3);
    border: none;
    font-family: 'Inter', sans-serif;
}

.load-more-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 14px 20px 8px rgba(93, 107, 132, 0.2);
    background: linear-gradient(135deg, #0092ff, #00d4ff);
    color: white;
}

.load-more-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* Image loading optimization */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* ==============================
   Game Overlay (in-page player)
   ============================== */
.game-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #FF6B35 0%, #F7931E 25%, #FDC830 50%, #F37335 75%, #C644FC 100%);
    animation: gameOverlayIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.game-overlay.closing {
    animation: gameOverlayOut 0.3s ease forwards;
}

@keyframes gameOverlayIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes gameOverlayOut {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.95); }
}

.game-overlay-close-fab {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 0.75rem);
    right: calc(env(safe-area-inset-right) + 0.75rem);
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    border-radius: 9999px;
    background: rgba(15, 23, 42, 0.72);
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    backdrop-filter: blur(8px);
}

.game-overlay-close-fab:hover {
    transform: translateY(-2px);
    background: rgba(15, 23, 42, 0.86);
}

.game-overlay-close-fab:active {
    transform: scale(0.96);
}

.game-overlay-body {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.game-overlay-iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

.game-overlay-loading {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #FF6B35, #F7931E, #FDC830, #C644FC);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity 0.5s ease;
}

.game-overlay-loading.loaded {
    opacity: 0;
    pointer-events: none;
}

.game-overlay-loading-media {
    position: relative;
    width: 84px;
    height: 84px;
    display: grid;
    place-items: center;
}

.game-overlay-spinner {
    position: absolute;
    inset: 0;
    width: 84px;
    height: 84px;
    border: 4px solid rgba(255, 255, 255, 0.28);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    will-change: transform;
}

.game-overlay-loading-icon {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.game-overlay-loading-text {
    color: white;
    font-weight: 700;
    font-size: 1.125rem;
    margin-top: 1.25rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@media (max-width: 640px) {
    .game-overlay-close-fab {
        top: calc(env(safe-area-inset-top) + 0.5rem);
        right: calc(env(safe-area-inset-right) + 0.5rem);
        width: 2.25rem;
        height: 2.25rem;
    }
}

/* ==============================
   Game Detail Page
   ============================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:root {
    --game-detail-panel-radius: 1.5rem;
    --game-detail-player-max-width: 960px;
    --game-detail-player-max-height: 540px;
}

.game-detail-shell {
    display: grid;
    gap: 1.5rem;
}

.game-detail-page {
    position: relative;
}

.game-detail-breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.95rem;
    font-weight: 800;
}

.game-detail-breadcrumb-home {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #ffffff;
    font-weight: 900;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    transition: opacity 0.2s ease;
}

.game-detail-breadcrumb-home:hover {
    opacity: 0.82;
}

.game-detail-breadcrumb-separator {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 700;
}

.game-detail-breadcrumb-current {
    color: #ffffff;
    font-weight: 900;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.game-detail-panel {
    background: rgba(255, 255, 255, 0.96);
    border-radius: var(--game-detail-panel-radius);
    box-shadow: 0 14px 20px 8px rgba(93, 107, 132, 0.25);
}

.game-detail-player-panel {
    overflow: hidden;
    background: transparent;
    border-radius: var(--game-detail-panel-radius);
    box-shadow: none;
}

.game-detail-player-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
}

.game-detail-player-frame {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: var(--game-detail-player-max-width);
    max-height: var(--game-detail-player-max-height);
    margin-inline: auto;
}

.game-iframe-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0f172a;
}

.game-iframe {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    overflow: hidden;
}

.game-detail-sidebar {
    padding: 1.5rem;
    color: #243447;
}

.game-detail-title {
    margin-top: 1rem;
    color: #111827;
    font-size: clamp(1.25rem, 1.6vw, 1.75rem);
    font-weight: 700;
    line-height: 1.15;
}

.game-detail-summary {
    margin-top: 1rem;
    color: #475569;
    font-size: 1rem;
    line-height: 1.75;
}

.game-detail-section {
    padding: 1.5rem;
}

.game-detail-chip-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.625rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.25rem;
}

.game-detail-chip {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    border-radius: 9999px;
    white-space: nowrap;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #243447;
    font-size: 0.875rem;
    font-weight: 800;
    padding: 0.625rem 1.1rem;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.game-detail-chip:hover {
    background: #f8fafc;
    border-color: #d1d5db;
}

.game-fullscreen-button {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    display: inline-grid;
    place-items: center;
    align-items: center;
    border: 0;
    border-radius: 9999px;
    background: rgba(15, 23, 42, 0.72);
    color: #ffffff;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    z-index: 20;
    backdrop-filter: blur(8px);
}

.game-fullscreen-button:hover {
    transform: translateY(-2px);
    background: rgba(15, 23, 42, 0.86);
}

body.game-fullscreen-active {
    overflow: hidden;
}

.game-iframe-container.game-pseudo-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    margin: 0;
    border-radius: 0;
    z-index: 9999;
    background: #000;
}

.game-iframe-container:fullscreen,
.game-iframe-container:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    aspect-ratio: auto !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: #000;
}

.game-iframe-container.game-pseudo-fullscreen .game-iframe {
    width: 100%;
    height: 100%;
}

.game-iframe-container.game-pseudo-fullscreen .game-fullscreen-button {
    top: auto;
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
}


.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #FF6B35, #F7931E, #FDC830, #C644FC);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-media {
    position: relative;
    width: 88px;
    height: 88px;
    display: grid;
    place-items: center;
}

.loading-spinner {
    position: absolute;
    inset: 0;
    width: 88px;
    height: 88px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.loading-text {
    color: white;
    font-weight: 700;
    font-size: 1.125rem;
    margin-top: 1.5rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    animation: pulse 1.5s ease-in-out infinite;
}

@media (max-width: 640px) {
    .game-detail-player-stage {
        padding: 0;
    }

    .game-detail-player-frame {
        width: 100%;
    }

    .game-fullscreen-button {
        right: 0.75rem;
        bottom: 0.75rem;
        width: 2.5rem;
        height: 2.5rem;
    }

}
