/* ============================================
   GAME PAGE - B4GLASS
   Sistema de visualización de juegos mejorado
   - Fondo dinámico con imagen
   - Multi-ventana (1, 2, 4 juegos)
   - Controles de pantalla completa
   - Búsqueda de juegos en cada ventana
   ============================================ */

/* Layout principal de página de juego */
/* Note: Feed spacing is handled globally in notifications.css */
.game-shell {
    position: relative;
    min-height: 100vh;
    padding: 24px 0 48px;
    margin-top: var(--topbar-height, 64px);
    background: radial-gradient(
        ellipse 120% 100% at 50% 0%,
        var(--bg-radial-1) 0%,
        var(--bg-radial-2) 45%,
        var(--bg-3) 100%
    );
}

/* Thumbnail fallback: full-screen blurred background behind header */
.game-shell--blurred-bg {
    margin-top: 0;
    padding-top: calc(var(--topbar-height, 64px) + 24px);
}

/* Fondo dinámico con imagen del juego */
.game-shell--with-background {
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
}

/* Multi-layer overlay para contraste óptimo (técnica Netflix + Apple) */
.game-shell--with-background::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        /* Scrim superior fuerte para header */
        linear-gradient(
            180deg, 
            rgba(4, 10, 20, 0.95) 0%, 
            rgba(4, 10, 20, 0.75) 15%,
            rgba(4, 10, 20, 0.45) 30%,
            transparent 50%,
            rgba(4, 10, 20, 0.45) 70%,
            rgba(4, 10, 20, 0.85) 100%
        ),
        /* Radial gradient central para contenido */
        radial-gradient(
            ellipse 120% 100% at 50% 50%,
            rgba(6, 14, 28, 0.3) 0%,
            rgba(6, 14, 28, 0.7) 60%,
            rgba(4, 10, 20, 0.85) 100%
        ),
        /* Tint de color de marca */
        radial-gradient(
            ellipse 100% 80% at 50% 0%,
            rgba(var(--tint-color), 0.12) 0%,
            transparent 60%
        );
    backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation)) brightness(0.85);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation)) brightness(0.85);
    z-index: 1;
}

/* Lighter overlay for thumbnail fallback backgrounds - let colors show */
.game-shell--blurred-bg::before {
    background:
        linear-gradient(
            180deg,
            rgba(4, 10, 20, 0.5) 0%,
            rgba(4, 10, 20, 0.2) 20%,
            transparent 50%,
            rgba(4, 10, 20, 0.2) 80%,
            rgba(4, 10, 20, 0.5) 100%
        );
    backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation)) brightness(0.95);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation)) brightness(0.95);
}

/* Overlay adicional para imágenes muy claras */
.game-shell--with-background::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(4, 10, 20, 0.25);
    mix-blend-mode: multiply;
    z-index: 1;
}

/* No extra darkening for thumbnail backgrounds */
.game-shell--blurred-bg::after {
    background: rgba(4, 10, 20, 0.1);
}

/* Indent game-header content so the shield matches topbar width */
.game-shell--blurred-bg .game-header {
    padding: 0 10px;
}

.game-shell__container {
    position: relative;
    z-index: 2;
    max-width: 1200px;
    width: min(1200px, 100% - 48px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Align container with topbar width when background extends behind header */
.game-shell--blurred-bg .game-shell__container {
    width: var(--layout-width);
    max-width: var(--layout-max-width);
}

@media (min-width: 1320px) {
    .game-shell__container {
        max-width: 1320px;
        width: min(1320px, 100% - 128px);
    }
}

/* ============================================
   HEADER - Navegación simple del juego
   ============================================ */
.game-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0;
    margin-bottom: 12px;
    position: relative;
}

/* Shield detrás del header para máximo contraste */
.game-shell--with-background .game-header::before {
    content: '';
    position: absolute;
    inset: -8px -16px;
    background: linear-gradient(
        90deg,
        rgba(4, 10, 20, 0.85) 0%,
        rgba(4, 10, 20, 0.75) 50%,
        rgba(4, 10, 20, 0.6) 100%
    );
    backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    border-radius: var(--radius-btn);
    z-index: -1;
}

.game-shell--blurred-bg .game-header::before {
    inset: -9px 0;
}

.game-header__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-input);
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.game-header__back:hover {
    border-color: rgba(var(--tint-color), 0.4);
    background: rgba(var(--tint-color), 0.12);
    color: var(--primary);
    transform: translateX(-2px);
}

.game-header__title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex: 1;
    text-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.6),
        0 1px 2px rgba(0, 0, 0, 0.8);
}

.game-header__provider {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.95);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-shadow: 
        0 1px 4px rgba(0, 0, 0, 0.5),
        0 1px 2px rgba(0, 0, 0, 0.7);
}

/* Búsqueda global en header */
.game-header__search {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: auto;
}

.game-header__search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-dim);
    pointer-events: none;
    transition: color 0.2s ease;
    z-index: 2;
}

.game-header__search-input {
    width: 220px;
    height: 40px;
    padding: 0 14px 0 38px;
    border-radius: var(--radius-input);
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-size: 14px;
    font-weight: 400;
    outline: none; /* a11y: focus style via :focus rule box-shadow */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.game-header__search-input::placeholder {
    color: var(--text-dim);
    opacity: 0.8;
}

.game-header__search-input:focus {
    width: 300px;
    border-color: rgba(var(--tint-color), 0.5);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 0 3px rgba(var(--tint-color), 0.1);
}

.game-header__search:focus-within .game-header__search-icon {
    color: var(--primary);
}

.game-header__search-results {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 380px;
    max-height: 480px;
    overflow-y: auto;
    border-radius: var(--radius-btn);
    background: linear-gradient(168deg, var(--glass-grad-1), var(--glass-grad-2));
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    box-shadow: 0 12px 34px rgba(6, 16, 36, 0.45);
    z-index: 100;
    animation: searchDropdownIn 0.2s ease;
}

@keyframes searchDropdownIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-header__search-results::-webkit-scrollbar {
    width: 6px;
}

.game-header__search-results::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.game-header__search-results::-webkit-scrollbar-thumb {
    background: rgba(var(--tint-color), 0.4);
    border-radius: 3px;
}

.game-header__search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--tint-color), 0.6);
}

.game-header__search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.game-header__search-result:last-child {
    border-bottom: none;
}

.game-header__search-result:hover {
    background: rgba(var(--tint-color), 0.12);
}

.game-header__search-result-cover {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-xs);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    border: 1px solid var(--glass-border);
}

.game-header__search-result-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.game-header__search-result-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.game-header__search-result-provider {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.game-header__search-empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
}

/* ============================================
   LAYOUT - Layout principal con stage y sidebar
   ============================================ */
.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 56px;
    gap: 20px;
    align-items: start;
    transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.game-layout.sidebar-expanded {
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 24px;
}

/* Keep recommended section aligned with the game stage (exclude sidebar width) */
.game-layout + .game-recommended{
    width: calc(100% - 56px - 20px);
}

.game-layout.sidebar-expanded + .game-recommended{
    width: calc(100% - 240px - 24px);
}

/* ============================================
   RECOMMENDED GAMES (DESKTOP) - CLEAN VERSION
   ============================================ */
.game-recommended{
    position: relative;
    border-radius: var(--radius-glass);
    background: linear-gradient(168deg, var(--glass-grad-1), var(--glass-grad-2));
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    padding: 16px 16px 14px;
}

.game-recommended__header{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.game-recommended__title{
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.game-recommended__actions{
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-recommended__random-btn{
    appearance: none;
    border: 1px solid rgba(var(--tint-color), 0.28);
    background: linear-gradient(140deg, rgba(var(--tint-color), 0.18), rgba(var(--tint-color), 0.1));
    color: var(--text);
    border-radius: var(--radius-btn);
    padding: 10px 14px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}

.game-recommended__random-btn:focus,
.game-recommended__random-btn:active{
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--focus-color), 0.25);
}

.game-recommended__rail{
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--tint-color), 0.45) rgba(0, 0, 0, 0.2);
}

/* Arrow indicator - positioned on parent to avoid overflow clipping */
.game-recommended::after{
    content: '';
    position: absolute;
    left: 50%;
    top: 52px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 16px solid #fff;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
}

.game-recommended.is-spinning::after{
    opacity: 1;
}

.game-recommended__rail::-webkit-scrollbar{
    height: 8px;
}

.game-recommended__rail::-webkit-scrollbar-track{
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-full);
}

.game-recommended__rail::-webkit-scrollbar-thumb{
    background: rgba(var(--tint-color), 0.45);
    border-radius: var(--radius-full);
}

.game-recommended__track{
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.game-recommended__card{
    flex: 0 0 auto;
    width: 150px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    text-align: left;
    color: var(--text);
}

.game-recommended__card:focus,
.game-recommended__card:active{
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--focus-color), 0.25);
}

.game-recommended__cover{
    display: block;
    width: 100%;
    height: 92px;
    background-size: cover;
    background-position: center;
    border-bottom: 1px solid var(--glass-border);
}

.game-recommended__meta{
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 10px 11px;
}

.game-recommended__name{
    font-size: 13px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-recommended__provider{
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-recommended__selection{
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* Ensure the native [hidden] attribute works even if display is set above */
.game-recommended__selection[hidden]{
    display: none !important;
}

.game-recommended__selection-title{
    color: var(--text);
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.game-recommended__selection-actions{
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.game-recommended.is-spinning .game-recommended__random-btn,
.game-recommended.is-spinning .game-recommended__spin-again-btn,
.game-recommended.is-spinning .game-recommended__play-btn{
    opacity: 0.55;
    pointer-events: none;
}

@media (max-width: 768px) {
    .game-recommended{
        display: none;
    }
}

@media (max-width: 1200px) {
    .game-layout {
        grid-template-columns: minmax(0, 1fr) 56px;
    }
    
    .game-layout.sidebar-expanded {
        grid-template-columns: minmax(0, 1fr) 220px;
    }

    .game-sidebar {
        position: sticky;
        top: 92px;
        width: auto;
    }
}

@media (max-width: 768px) {
    .game-layout {
        grid-template-columns: 1fr;
    }

    .game-sidebar {
        display: none;
    }
    
    .game-fab {
        display: flex;
    }
}

/* ============================================
   SIDEBAR - Barra lateral derecha con controles
   ============================================ */
.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 6px;
    border-radius: var(--radius-sm);
    background: linear-gradient(168deg, var(--glass-grad-1), var(--glass-grad-2));
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    box-shadow: 0 12px 34px rgba(6, 16, 36, 0.34);
    position: relative;
    width: 56px;
    overflow: visible;
}

/* Refuerzo de contraste en sidebar con fondo claro */
.game-shell--with-background .game-sidebar {
    background: 
        linear-gradient(168deg, 
            rgba(10, 18, 36, 0.92), 
            rgba(6, 14, 28, 0.88)
        );
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 12px 34px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.08);
}


.game-sidebar__section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.game-sidebar__title {
    display: none;
}

.game-sidebar__buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-wrap: nowrap;
}

.game-sidebar__buttons--vertical {
    flex-direction: column;
    gap: 6px;
}

.game-sidebar__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
    border-radius: var(--radius-input);
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    min-width: 44px;
    min-height: 44px;
    position: relative;
    box-sizing: border-box;
}

.game-sidebar__btn:hover {
    border-color: rgba(var(--tint-color), 0.32);
    background: rgba(var(--tint-color), 0.1);
    color: var(--text);
    transform: translateY(-1px);
}

.game-sidebar__btn--active {
    border-color: rgba(var(--tint-color), 0.46);
    background: linear-gradient(140deg, rgba(var(--tint-color), 0.2), rgba(var(--tint-color), 0.12));
    color: var(--text);
    box-shadow: 0 5px 14px rgba(var(--tint-color), 0.24);
}

.game-sidebar__btn--fullscreen {
    background: linear-gradient(140deg, rgba(var(--tint-color), 0.18), rgba(41, 189, 255, 0.12));
    border-color: rgba(var(--tint-color), 0.32);
}

.game-sidebar__btn--fullscreen:hover {
    background: linear-gradient(140deg, rgba(var(--tint-color), 0.26), rgba(41, 189, 255, 0.2));
    border-color: rgba(var(--tint-color), 0.5);
    box-shadow: 0 8px 22px rgba(var(--tint-color), 0.28);
}

.game-sidebar__btn svg {
    flex-shrink: 0;
    display: block;
    width: 20px;
    height: 20px;
    margin: 0;
    padding: 0;
}

.game-sidebar__btn span {
    display: none;
}

/* Tooltips mejorados para sidebar colapsada */
.game-sidebar__btn[title] {
    position: relative;
}

.game-sidebar__btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    right: calc(100% + 12px);
    left: auto;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.85));
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: var(--radius-xs);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    pointer-events: none;
    animation: tooltipFadeIn 0.2s ease;
}

.game-sidebar__btn[title]:hover::before {
    content: '';
    position: absolute;
    right: calc(100% + 6px);
    left: auto;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: rgba(0, 0, 0, 0.95);
    z-index: 1001;
    pointer-events: none;
    animation: tooltipFadeIn 0.2s ease;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(5px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* ============================================
   SIDEBAR TOURNAMENT POPOVER
   ============================================ */
.game-sidebar__popover {
    display: none;
    position: absolute;
    right: calc(100% + 12px);
    top: 0;
    width: 280px;
    padding: 16px;
    border-radius: var(--radius-sm);
    background: linear-gradient(168deg, var(--glass-grad-1), var(--glass-grad-2));
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    box-shadow: 0 12px 34px rgba(6, 16, 36, 0.34);
    z-index: 1000;
    animation: tooltipFadeIn 0.2s ease;
}

.game-shell--with-background .game-sidebar__popover {
    background: linear-gradient(168deg, rgba(10, 18, 36, 0.92), rgba(6, 14, 28, 0.88));
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.game-sidebar__popover.is-open {
    display: block;
}

.game-sidebar__popover-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--glass-border);
}

.game-sidebar__popover-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.game-sidebar__popover-prize {
    font-size: 12px;
    color: var(--text-secondary);
}

.game-sidebar__popover-prize strong {
    color: var(--accent);
}

.game-sidebar__popover-body {
    margin-bottom: 12px;
}

.game-sidebar__popover-status {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 10px;
    border-radius: var(--radius-input);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.game-sidebar__popover-rank {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--radius-input);
    background: rgba(34, 211, 238, 0.08);
    border: 1px solid rgba(34, 211, 238, 0.2);
    margin-bottom: 8px;
}

.game-sidebar__popover-rank-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.game-sidebar__popover-rank-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}

.game-sidebar__popover-above {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--radius-input);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 8px;
}

.game-sidebar__popover-above-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.game-sidebar__popover-above-info {
    text-align: right;
}

.game-sidebar__popover-above-name {
    font-size: 12px;
    color: var(--text);
    font-weight: 500;
}

.game-sidebar__popover-above-score {
    font-size: 11px;
    color: var(--text-secondary);
}

.game-sidebar__popover-footer {
    display: flex;
    gap: 8px;
}

.game-sidebar__popover-footer a,
.game-sidebar__popover-footer button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.game-sidebar__popover-link {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border) !important;
    color: var(--text);
}

.game-sidebar__popover-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

.game-sidebar__popover-join {
    background: linear-gradient(135deg, var(--action-1), var(--action-2));
    color: var(--action-text);
}

.game-sidebar__popover-join:hover {
    background: linear-gradient(135deg, var(--action-2), var(--action-1));
    box-shadow: 0 4px 12px var(--action-shadow);
}

/* Suppress CSS tooltip when popover is open */
.game-sidebar__btn--tournament.is-open::after,
.game-sidebar__btn--tournament.is-open::before {
    content: none !important;
    display: none !important;
}

/* Pulse animation for tournament button */
.game-sidebar__btn--pulse {
    animation: tournamentPulse 2s ease-in-out infinite;
}

@keyframes tournamentPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.3);
    }
    50% {
        box-shadow: 0 0 12px 4px rgba(34, 211, 238, 0.2);
    }
}

/* ============================================
   FAB - Floating Action Button para móvil
   ============================================ */
.game-fab {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
}

.game-fab__trigger {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-round);
    background: linear-gradient(135deg, rgba(var(--tint-color), 0.9), rgba(var(--tint-color), 0.7));
    border: none;
    box-shadow: 0 8px 24px rgba(var(--tint-color), 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.game-fab__trigger:hover,
.game-fab__trigger:focus {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(var(--tint-color), 0.5);
}

.game-fab__trigger svg {
    width: 24px;
    height: 24px;
    color: #fff;
    transition: transform 0.3s ease;
}

.game-fab.is-open .game-fab__trigger svg {
    transform: rotate(45deg);
}

.game-fab__menu {
    position: absolute;
    bottom: 72px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.game-fab.is-open .game-fab__menu {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

.game-fab__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--glass-grad-1), var(--glass-grad-2));
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    box-shadow: 0 8px 24px rgba(6, 16, 36, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.game-fab__item:hover {
    background: linear-gradient(135deg, rgba(var(--tint-color), 0.2), rgba(var(--tint-color), 0.1));
    border-color: rgba(var(--tint-color), 0.4);
    transform: translateX(-4px);
}

.game-fab__item svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
    flex-shrink: 0;
}

.game-fab__item span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.game-fab__item--primary {
    background: linear-gradient(135deg, rgba(var(--tint-color), 0.9), rgba(var(--tint-color), 0.7));
    border-color: rgba(var(--tint-color), 0.4);
}

.game-fab__item--primary svg,
.game-fab__item--primary span {
    color: #fff;
}

@media (max-width: 480px) {
    .game-fab {
        bottom: 16px;
        right: 16px;
    }
    
    .game-fab__trigger {
        width: 48px;
        height: 48px;
    }
    
    .game-fab__trigger svg {
        width: 20px;
        height: 20px;
    }
}

/* ============================================
   STAGE - Contenedor principal del juego
   ============================================ */
.game-stage {
    position: relative;
    border-radius: var(--radius-card);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    background: rgba(8, 18, 36, 0.85);
    box-shadow:
        0 32px 70px rgba(4, 12, 32, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Mejor contraste en stage con fondo claro */
.game-shell--with-background .game-stage {
    background: rgba(8, 18, 36, 0.92);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow:
        0 32px 70px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Vista single - LANDSCAPE OPTIMIZED */
.game-stage--single {
    /* Use aspect-ratio with max-height to prevent portrait-like dimensions */
    aspect-ratio: 16 / 9;
    width: 100%;
    /* Calculate height based on viewport to ensure landscape */
    min-height: min(580px, calc(100vw * 9 / 16));
    max-height: calc(100vh - 200px);
    position: relative;
}

/* Ensure the game window fills the stage completely */
.game-stage--single .game-window {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Ensure iframe always gets landscape dimensions */
.game-stage--single .game-window__frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    /* Force minimum width to prevent portrait detection */
    min-width: 320px;
}

/* Vista multi (2 o 4 ventanas) */
.game-stage--multi {
    display: grid;
    gap: 1px;
    background: rgba(255, 255, 255, 0.06);
    min-height: 720px;
}

.game-stage--multi-2 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 1fr;
}

.game-stage--multi-4 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

/* ============================================
   GAME WINDOW - Ventana individual de juego
   ============================================ */
.game-window {
    position: relative;
    background: rgba(0, 0, 0, 0.76);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.game-main {
    min-width: 0;
}

.game-window--empty {
    background: rgba(10, 24, 48, 0.55);
    border: 2px dashed var(--glass-border);
}

.game-window--loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Header de cada ventana (visible en modo multi) */
.game-window__header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(160deg, var(--glass-grad-1), var(--glass-grad-2));
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    gap: 10px;
}

.game-stage--multi .game-window__header {
    display: flex;
}

.game-window__title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-window__title--placeholder {
    color: rgba(255, 255, 255, 0.35);
    font-style: italic;
}

.game-window__actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.game-window__btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.game-window__btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: scale(1.05);
}

.game-window__btn--fullscreen {
    color: var(--primary);
    border-color: rgba(var(--tint-color), 0.24);
}

.game-window__btn--fullscreen:hover {
    background: rgba(var(--tint-color), 0.16);
    border-color: rgba(var(--tint-color), 0.42);
}

.game-window__btn--close {
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.24);
}

.game-window__btn--close:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.45);
}

/* Iframe del juego */
.game-window__frame {
    flex: 1;
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
}

/* Búsqueda de juegos en ventana vacía */
.game-window__search {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    padding: 24px 20px 20px;
    background: rgba(10, 24, 48, 0.6);
    backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    overflow: hidden;
}

.game-window__search-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-round);
    background: rgba(var(--tint-color), 0.14);
    color: var(--primary);
    flex-shrink: 0;
}

.game-window__search-icon svg {
    width: 24px;
    height: 24px;
}

.game-window__search-input {
    width: 100%;
    max-width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 14px;
    text-align: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.game-window__search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.game-window__search-input:focus {
    outline: none;
    border-color: rgba(var(--tint-color), 0.52);
    background: rgba(var(--tint-color), 0.08);
    box-shadow: 0 0 0 3px rgba(var(--tint-color), 0.18);
}

.game-window__results {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    min-height: 0;
}

.game-window__results::-webkit-scrollbar {
    width: 6px;
}

.game-window__results::-webkit-scrollbar-thumb {
    background: rgba(0, 214, 255, 0.32);
    border-radius: var(--radius-full);
}

.game-window__result {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(var(--tint-color), 0.22);
    background: linear-gradient(160deg, var(--glass-grad-1), rgba(10, 24, 48, 0.78));
    box-shadow: 0 8px 24px rgba(2, 12, 28, 0.45);
    color: var(--text);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    text-align: left;
    flex-shrink: 0;
}

.game-window__result:hover,
.game-window__result:focus {
    border-color: rgba(var(--tint-color), 0.5);
    box-shadow: 0 16px 38px rgba(2, 18, 44, 0.55);
    transform: translateY(-1px);
    outline: none;
}

.game-window__result-cover {
    display: block;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-btn);
    background-size: cover;
    background-position: center;
    background-color: rgba(12, 28, 52, 0.9);
}

.game-window__result-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.game-window__result-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.game-window__result-provider {
    font-size: 11px;
    color: rgba(206, 222, 255, 0.65);
    line-height: 1.2;
}

.game-window__results-empty {
    width: 100%;
    padding: 14px 18px;
    border-radius: var(--radius-pill);
    background: rgba(6, 18, 42, 0.72);
    border: 1px dashed var(--glass-border);
    color: rgba(210, 224, 250, 0.78);
    text-align: center;
    font-size: 14px;
}


/* ============================================
   MODO PANTALLA COMPLETA - SOLUCIÓN DEFINITIVA
   ============================================
   
   Strategy: Use CSS Grid with place-items: center to perfectly
   center the game iframe both horizontally and vertically.
   
   The iframe maintains 16:9 aspect ratio and scales to fit
   the viewport while staying centered.
   ============================================ */

/* Main fullscreen container - uses CSS Grid for perfect centering */
.game-shell--fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 99999 !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #000 !important;
    width: 100vw !important;
    width: 100dvw !important; /* Dynamic viewport for mobile */
    height: 100vh !important;
    height: 100dvh !important; /* Dynamic viewport for mobile */
    overflow: hidden !important;
}

.game-shell--fullscreen .game-shell__container {
    max-width: none !important;
    width: 100% !important;
    height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    gap: 0 !important;
}

/* Hide all UI elements in fullscreen */
.game-shell--fullscreen .game-header,
.game-shell--fullscreen .game-sidebar,
.game-shell--fullscreen .game-fab,
.game-shell--fullscreen .game-window__header {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Layout becomes a full-viewport grid for centering */
.game-shell--fullscreen .game-layout {
    display: grid !important;
    place-items: center !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #000 !important;
}

/* Stage fills the layout and centers the game window */
.game-shell--fullscreen .game-stage {
    display: grid !important;
    place-items: center !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    aspect-ratio: unset !important;
    background: #000 !important;
    box-shadow: none !important;
    position: relative !important;
    min-height: unset !important;
    max-height: unset !important;
}

.game-shell--fullscreen .game-stage--single {
    aspect-ratio: unset !important;
    min-height: unset !important;
}

/* Game window: FILL SCREEN COMPLETELY */
.game-shell--fullscreen .game-window {
    position: fixed !important; /* Changed from absolute to fixed to guarantee viewport relative */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    /* Remove all aspect ratio constraints to prevent cropping */
    aspect-ratio: unset !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    background: #000 !important;
    overflow: visible !important; /* Changed to visible to show exit button */
    z-index: 100000 !important; /* Ensure it's on top */
}

/* Exit button inside game-window in fullscreen */
.game-shell--fullscreen .game-window .game-fullscreen-exit {
    position: fixed !important;
    top: 16px !important;
    right: 16px !important;
    z-index: 2147483647 !important;
}

/* Iframe fills the game window completely */
.game-shell--fullscreen .game-window__frame {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    background: #000 !important;
}

/* Remove old media query constraints */
/* Multi-window fullscreen - grid layout */
.game-shell--fullscreen .game-stage--multi {
    display: grid !important;
    place-items: center !important;
    width: 100vw !important;
    height: 100vh !important;
    gap: 2px !important;
}

.game-shell--fullscreen .game-stage--multi-2 {
    grid-template-columns: 1fr 1fr !important;
}

.game-shell--fullscreen .game-stage--multi-4 {
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: 1fr 1fr !important;
}

.game-shell--fullscreen .game-stage--multi .game-window {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 16 / 9 !important;
}

.game-shell--fullscreen .game-stage--multi .game-window__frame {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* Native fullscreen on iframe element directly */
.game-window__frame:fullscreen,
.game-window__frame:-webkit-full-screen,
.game-window__frame:-moz-full-screen,
.game-window__frame:-ms-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    border: none !important;
    background: #000 !important;
    object-fit: contain !important;
}

/* Body state when in fullscreen */
body.game-fullscreen-active {
    overflow: hidden !important;
}

body.game-fullscreen-active .topbar,
body.game-fullscreen-active .global-header,
body.game-fullscreen-active .site-footer,
body.game-fullscreen-active .site-footer-bottom,
body.game-fullscreen-active footer:not(.game-shell) {
    display: none !important;
    visibility: hidden !important;
}

/* Exit fullscreen button overlay - Always visible in fullscreen */
.game-fullscreen-exit {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2147483647; /* Maximum z-index to ensure visibility above everything */
    width: 48px;
    height: 48px;
    border-radius: var(--radius-btn);
    background: rgba(20, 20, 20, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.2s ease, background 0.2s ease;
    backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.1);
}

.game-fullscreen-exit:hover {
    background: rgba(0, 0, 0, 0.85);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.game-fullscreen-exit svg {
    width: 24px;
    height: 24px;
}

/* Exit button hover effect */
.game-fullscreen-exit:hover {
    opacity: 1;
}

/* Fade after 3s of inactivity, show on hover */
.game-fullscreen-exit.is-faded {
    opacity: 0.4;
}

.game-fullscreen-exit.is-faded:hover {
    opacity: 1;
}

/* ESC hint */
.game-fullscreen-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100000;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: var(--radius-xs);
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
    -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--material-saturation));
}

.game-shell--fullscreen .game-fullscreen-hint {
    animation: hintFadeInOut 3s ease-in-out forwards;
}

@keyframes hintFadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .game-shell__container {
        padding: 0 16px;
    }

    .game-stage--single {
        min-height: 500px;
    }

    .game-stage--multi {
        min-height: 600px;
    }
}

@media (max-width: 768px) {
    .game-shell {
        padding: 70px 0 24px;
    }

    .game-shell--blurred-bg {
        padding-top: calc(var(--topbar-height, 56px) + 70px);
    }

    .game-shell__container {
        padding: 0 12px;
        gap: 16px;
    }

    .game-header {
        gap: 12px;
        margin-bottom: 16px;
    }

    .game-header__title {
        font-size: 1.3rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .game-header__search-input {
        width: 180px;
    }
    
    .game-header__search-input:focus {
        width: 240px;
    }
    
    .game-header__search-results {
        width: 320px;
    }

    .game-stage--single {
        min-height: 420px;
    }

    .game-stage--multi {
        min-height: 500px;
    }

}

/* Optimizaciones para vista de 4 ventanas */
.game-stage--multi-4 .game-window__search {
    padding: 16px 12px 12px;
    gap: 12px;
}

.game-stage--multi-4 .game-window__search-icon {
    width: 40px;
    height: 40px;
}

.game-stage--multi-4 .game-window__search-icon svg {
    width: 20px;
    height: 20px;
}

.game-stage--multi-4 .game-window__search-input {
    padding: 10px 14px;
    font-size: 13px;
}

.game-stage--multi-4 .game-window__result {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 10px;
    padding: 6px 10px;
}

.game-stage--multi-4 .game-window__result-cover {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-input);
}

.game-stage--multi-4 .game-window__result-title {
    font-size: 12px;
}

.game-stage--multi-4 .game-window__result-provider {
    font-size: 10px;
}

@media (max-width: 640px) {
    .game-stage--multi-2,
    .game-stage--multi-4 {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(2, 1fr);
        min-height: 600px;
    }

    .game-window__search {
        padding: 20px;
    }

    .game-window__search-icon {
        width: 48px;
        height: 48px;
    }

}

@media (max-width: 480px) {
    .game-shell {
        padding: 60px 0 20px;
    }

    .game-shell--blurred-bg {
        padding-top: calc(var(--topbar-height, 56px) + 60px);
    }

    .game-header__back {
        width: 36px;
        height: 36px;
    }

    .game-header__title {
        font-size: 1.1rem;
    }
    
    .game-header__provider {
        font-size: 0.75rem;
    }
    
    .game-header__search {
        position: fixed;
        top: 70px;
        right: 12px;
        z-index: 50;
    }
    
    .game-header__search-icon {
        left: 50%;
        transform: translateX(-50%);
    }
    
    .game-header__search-input {
        width: 40px;
        padding: 0;
        text-indent: -9999px;
        background: rgba(255, 255, 255, 0.08);
    }
    
    .game-header__search-input:focus {
        width: calc(100vw - 80px);
        padding: 0 14px 0 38px;
        text-indent: 0;
    }
    
    .game-header__search:focus-within .game-header__search-icon {
        left: 12px;
        transform: none;
    }
    
    .game-header__search-results {
        width: calc(100vw - 24px);
        right: -12px;
    }

    .game-stage--single {
        min-height: 320px;
    }

    .game-stage--multi {
        min-height: 400px;
    }
}
