/* Shared CrazyGamesX game-thumbnail tokens. Navigation, avatars and category
   banners are not game thumbnails. Recently Played reuses the standard size. */
:root {
    --gx-game-width: 170px;
    --gx-game-height: 127px;
    --gx-game-ratio: 170 / 127;
    --gx-game-recent-width: var(--gx-game-width);
    --gx-game-recent-height: var(--gx-game-height);
    --gx-game-title-size: 12px;
    --gx-game-title-color: #fff;
    --gx-game-title-padding: 32px 8px 5px;
    --gx-game-image-layer: 1;
    --gx-game-preview-layer: 2;
    --gx-game-caption-layer: 3;
    --gx-game-title-shade: linear-gradient(0deg, #000000eb 0%, #000000b8 26%, #00000042 60%, #00000000 100%);
    --gx-game-glow: 0 0 18px #a63cff80, inset 0 0 0 1px #b764ff;
}

/* Existing grids and asynchronously appended results use the same tokens. */
html.gx-page-preview :is(#game-list-container, .search-results-grid) {
    grid-template-columns: repeat(auto-fill, var(--gx-game-width)) !important;
    justify-content: start;
}
html.gx-page-preview .new-games-list,
html.gx-game-preview :is(.gx-similar-track, .gx-rail-game-grid, .gx-recommended-grid) > a {
    box-sizing: border-box;
    position: relative;
    width: var(--gx-game-width) !important;
    height: var(--gx-game-height) !important;
    min-width: 0;
    overflow: hidden;
    border-radius: 9px;
    isolation: isolate;
}
html.gx-page-preview .new-games-list > img,
html.gx-game-preview :is(.gx-similar-track, .gx-rail-game-grid, .gx-recommended-grid) > a img {
    position: relative;
    z-index: var(--gx-game-image-layer);
    display: block;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    aspect-ratio: var(--gx-game-ratio);
    object-fit: cover;
    border-radius: inherit;
}
html.gx-game-preview .gx-similar-track {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: var(--gx-game-width);
    grid-template-columns: none;
    overflow-x: auto;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
}
html.gx-game-preview .gx-similar-track > a:nth-of-type(n) {
    display: block !important;
    scroll-snap-align: start;
}

/* Profile library/showcase cards come from the shared CMS renderer. Override
   only inside CrazyGamesX; other websites retain their own profile styles. */
html.gx-profile-active .gps-bcg-profile-page .gps-bcg-profile-library,
html.gx-profile-active .gps-bcg-profile-showcase > div {
    grid-template-columns: none !important;
    grid-auto-flow: column;
    grid-auto-columns: var(--gx-game-width);
    max-width: 100%;
    overflow-x: auto;
}
html.gx-profile-active .gps-cp-card,
html.gx-profile-active .gps-cp-card .gps-cp-media {
    box-sizing: border-box;
    width: var(--gx-game-width);
    height: var(--gx-game-height);
}
html.gx-profile-active .gps-cp-card .gps-cp-media {
    aspect-ratio: var(--gx-game-ratio) !important;
}
html.gx-profile-active .gps-cp-card .gps-cp-body {
    position: absolute;
    z-index: var(--gx-game-caption-layer);
    inset: auto 0 0;
    padding: var(--gx-game-title-padding);
    background: var(--gx-game-title-shade);
    opacity: 0;
    transition: opacity .16s ease;
}
html.gx-profile-active .gps-cp-card .gps-cp-body strong {
    margin: 0;
    font-size: var(--gx-game-title-size) !important;
    white-space: nowrap;
    text-shadow: 0 1px 4px #40135c;
}
html.gx-profile-active .gps-cp-card:is(:hover, :focus-visible) .gps-cp-body {
    opacity: 1;
}
html.gx-profile-active .gps-cp-card:is(:hover, :focus-visible) .gps-cp-media {
    box-shadow: var(--gx-game-glow);
}

/* Legacy listing/game templates already supply the stored title in aria-label.
   Reuse it without per-page markup changes, JS, requests or duplicated captions. */
/* The legacy video hover adds a black ::before layer and an inline z-index.
   Disable that second shade; all card captions belong above preview media. */
html.gx-page-preview .new-games-list[aria-label]::before,
html.gx-game-preview :is(.gx-similar-track, .gx-rail-game-grid, .gx-recommended-grid) > a[aria-label]::before {
    content: none !important;
    display: none !important;
}
html.gx-page-preview .new-games-list .video-container,
html.gx-game-preview :is(.gx-similar-track, .gx-rail-game-grid, .gx-recommended-grid) > a .video-container,
.gx-shell .gx-card .gx-card-media video {
    z-index: var(--gx-game-preview-layer) !important;
}
html.gx-page-preview .new-games-list[aria-label]::after,
html.gx-game-preview :is(.gx-similar-track, .gx-rail-game-grid, .gx-recommended-grid) > a[aria-label]::after {
    content: attr(aria-label);
    position: absolute;
    z-index: var(--gx-game-caption-layer);
    inset: auto 0 0;
    padding: var(--gx-game-title-padding);
    background: var(--gx-game-title-shade);
    color: var(--gx-game-title-color);
    font: 700 var(--gx-game-title-size)/1.25 Inter, Arial, sans-serif;
    text-transform: none;
    text-shadow: 0 1px 4px #40135c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    opacity: 0;
    transition: opacity .16s ease;
}
html.gx-page-preview .new-games-list[aria-label] > div.absolute,
html.gx-game-preview :is(.gx-similar-track, .gx-rail-game-grid, .gx-recommended-grid) > a[aria-label] :is(h3, h4, p) {
    display: none !important;
}
html.gx-page-preview .new-games-list[aria-label]:is(:hover, :focus-visible)::after,
html.gx-game-preview :is(.gx-similar-track, .gx-rail-game-grid, .gx-recommended-grid) > a[aria-label]:is(:hover, :focus-visible)::after {
    opacity: 1;
}

/* Homepage cards keep their existing accessible title and play-count badge.
   What's New is a text list: its large labels deliberately remain visible. */
/* One-line captions share truncation across thumbnail layouts; the complete
   stored title remains in the DOM / accessible label. */
.gx-shell .gx-card:not(.gx-whats-new .gx-card) .gx-card-copy strong,
.gx-shell .gx-played-card > .gx-played-name,
html.gx-profile-active .gps-cp-card .gps-cp-body strong,
.gx-profile-active :is(.gx-mission-game, .gx-time-game, .gx-leaderboard-game) > strong {
    display: block;
    min-width: 0;
    color: var(--gx-game-title-color);
    font-size: var(--gx-game-title-size) !important;
    font-weight: 700;
    line-height: 1.25;
    text-transform: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gx-shell .gx-card:not(.gx-whats-new .gx-card) .gx-card-media::after {
    background: none;
}
.gx-shell .gx-card:not(.gx-whats-new .gx-card) .gx-card-copy {
    z-index: var(--gx-game-caption-layer);
    background: none;
    padding: var(--gx-game-title-padding);
}
.gx-shell .gx-card:not(.gx-whats-new .gx-card) .gx-card-copy :is(strong, small),
.gx-shell .gx-played-card > .gx-played-name,
.gx-profile-active :is(.gx-mission-game, .gx-time-game, .gx-leaderboard-game) > strong {
    opacity: 0;
    text-shadow: 0 1px 4px #40135c;
    transition: opacity .16s ease;
}
.gx-shell .gx-card:not(.gx-whats-new .gx-card):is(:hover, :focus-visible) .gx-card-copy {
    background: var(--gx-game-title-shade);
}
.gx-shell .gx-card:not(.gx-whats-new .gx-card):is(:hover, :focus-visible) .gx-card-copy :is(strong, small),
.gx-shell .gx-played-card:is(:hover, :focus-visible) > .gx-played-name,
.gx-profile-active :is(.gx-mission-game, .gx-time-game, .gx-leaderboard-game):is(:hover, :focus-visible) > strong {
    opacity: 1;
}
.gx-shell .gx-played-card > .gx-played-name {
    z-index: var(--gx-game-caption-layer);
    background: var(--gx-game-title-shade);
    padding: var(--gx-game-title-padding);
}
.gx-shell .gx-card:is(:hover, :focus-visible) .gx-card-media,
html.gx-page-preview .new-games-list:is(:hover, :focus-visible),
html.gx-game-preview :is(.gx-similar-track, .gx-rail-game-grid, .gx-recommended-grid) > a:is(:hover, :focus-visible),
.gx-profile-active :is(.gx-mission-game, .gx-time-game, .gx-leaderboard-game):is(:hover, :focus-visible) {
    border-color: #b764ff;
    box-shadow: var(--gx-game-glow);
}
.gx-shell .gx-card:focus-visible,
html.gx-page-preview .new-games-list:focus-visible,
html.gx-game-preview :is(.gx-similar-track, .gx-rail-game-grid, .gx-recommended-grid) > a:focus-visible {
    outline: 2px solid #d5a1ff;
    outline-offset: -2px;
}

/* No hover on touch screens: keep game names readable without a second tap. */
@media (hover: none) {
    html.gx-page-preview .new-games-list[aria-label]::after,
    html.gx-profile-active .gps-cp-card .gps-cp-body,
    html.gx-game-preview :is(.gx-similar-track, .gx-rail-game-grid, .gx-recommended-grid) > a[aria-label]::after,
    .gx-shell .gx-card:not(.gx-whats-new .gx-card) .gx-card-copy :is(strong, small),
    .gx-shell .gx-played-card > .gx-played-name,
    .gx-profile-active :is(.gx-mission-game, .gx-time-game, .gx-leaderboard-game) > strong {
        opacity: 1;
    }
    .gx-shell .gx-card:not(.gx-whats-new .gx-card) .gx-card-copy {
        background: var(--gx-game-title-shade);
    }
}
@media (prefers-reduced-motion: reduce) {
    .gx-shell .gx-card *,
    html.gx-profile-active .gps-cp-card .gps-cp-body,
    html.gx-page-preview .new-games-list::after,
    html.gx-game-preview :is(.gx-similar-track, .gx-rail-game-grid, .gx-recommended-grid) > a::after,
    .gx-profile-active :is(.gx-mission-game, .gx-time-game, .gx-leaderboard-game) > strong {
        transition: none !important;
    }
}
