/* ========================================================
   MicroGameLab - Estilos Globales, Tipografías y Gamificación
   Inspirado en Minijuegos, Poki y Steam Arcade
   ======================================================== */

/* 1. TIPOGRAFÍAS AUTOALOJADAS (100% RGPD COMPLIANT) */
@font-face {
    font-family: 'Fredoka';
    src: url('/assets/fonts/fredoka-600.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Fredoka';
    src: url('/assets/fonts/fredoka-700.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Nunito';
    src: url('/assets/fonts/nunito-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Nunito';
    src: url('/assets/fonts/nunito-700.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Nunito';
    src: url('/assets/fonts/nunito-800.woff2') format('woff2');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-main: #0a0d16;
    --bg-sidebar: #111524;
    --bg-card: #161b2e;
    --bg-card-hover: #1e253e;
    --bg-input: #0d111d;
    --border: #232c45;
    --border-highlight: #00f0ff;
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    
    --neon-cyan: #00f0ff;
    --neon-pink: #ec4899;
    --neon-purple: #a855f7;
    --neon-amber: #f59e0b;
    --neon-orange: #fb923c;
    --neon-green: #10b981;
    
    --text-main: #ffffff;
    --text-secondary: #cbd5e1;
    --text-muted: #8492a6;
    
    --font-display: 'Fredoka', cursive, system-ui, sans-serif;
    --font-body: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    --radius: 14px;
    --radius-sm: 8px;
    --sidebar-width: 250px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    overflow-x: hidden;
    overflow-x: clip;
    max-width: 100vw;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--neon-cyan);
    outline-offset: 2px;
}

body {
    background-color: var(--bg-main);
    background-image: radial-gradient(rgba(99, 102, 241, 0.08) 1.5px, transparent 1.5px);
    background-size: 24px 24px;
    color: var(--text-main);
    font-family: var(--font-body);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    letter-spacing: -0.3px;
}

a { color: inherit; text-decoration: none; transition: 0.18s ease-in-out; }
img { max-width: 100%; display: block; }

/* =========================================
   2. NAVBAR SUPERIOR & HEADER GAMIFICADO
   ========================================= */
.navbar {
    background: rgba(17, 21, 36, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 2px solid #20273c;
    position: sticky;
    top: 0;
    z-index: 100;
    height: 66px;
    display: flex;
    align-items: center;
}
.nav-container {
    width: 100%;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-logo {
    height: 42px;
    width: 42px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid rgba(0, 240, 255, 0.4);
    box-shadow: 0 0 16px rgba(0, 240, 255, 0.3);
    transition: transform 0.2s ease;
}
.brand:hover .brand-logo {
    transform: scale(1.08) rotate(-4deg);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.6);
}
.brand-text {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #ffffff 40%, var(--neon-cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

/* Botón Hamburguesa / Toggle Menú */
.sidebar-toggle-btn {
    background: #0d111d;
    border: 1px solid #26304a;
    color: #cbd5e1;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.15s ease-in-out;
    flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
    color: #00f0ff;
    border-color: #00f0ff;
    background: rgba(0, 240, 255, 0.1);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.25);
}

/* Buscador central */
.nav-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #0d111d;
    border: 1px solid #232c45;
    border-radius: 9999px;
    padding: 8px 18px;
    width: 360px;
    transition: 0.2s;
}
.nav-search:focus-within {
    border-color: #00f0ff;
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.2);
    width: 400px;
}
.nav-search input {
    background: transparent;
    border: none;
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    width: 100%;
    outline: none;
}
.nav-search input::placeholder { color: #64748b; }

/* Banderas para Idiomas */
.lang-flags {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #0d111d;
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid #232c45;
}
.flag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 5px;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1;
    filter: grayscale(0.5);
    opacity: 0.7;
    transition: 0.2s;
}
.flag-btn:hover, .flag-btn.active {
    filter: grayscale(0);
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

/* Badges Gamificados en Header */
.header-streak-badge {
    background: linear-gradient(135deg, #431407, #240c03);
    border: 1px solid #ea580c;
    color: #fb923c;
    font-family: var(--font-display);
    font-weight: 700;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 0 12px rgba(234, 88, 12, 0.25);
}
.header-level-badge {
    background: linear-gradient(135deg, #1e1b4b, #12182b);
    border: 1px solid #6366f1;
    color: #a5b4fc;
    font-family: var(--font-display);
    font-weight: 700;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.25);
}
.header-coins-badge {
    background: linear-gradient(135deg, #332104, #181104);
    border: 1px solid #f59e0b;
    color: #fde047;
    font-family: var(--font-display);
    font-weight: 800;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.28);
    transition: transform 0.2s, box-shadow 0.2s;
}
.header-coins-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 18px rgba(245, 158, 11, 0.45);
}
.mgl-coin-svg {
    width: 15px;
    height: 15px;
    vertical-align: -2px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 4px rgba(250, 204, 21, 0.45));
}
.guest-coins-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.header-guest-pill {
    background: linear-gradient(135deg, #271d05, #141005);
    border: 1px solid #f59e0b;
    color: #fde047;
    font-family: var(--font-display);
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 12.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}
.header-guest-pill:hover {
    background: #f59e0b;
    color: #000;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

/* Botón e Icono de Usuario */
.user-avatar-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: #0d111d;
    border: 1px solid #232c45;
    border-radius: 9999px;
    color: #e2e8f0;
    font-size: 13.5px;
    font-weight: 700;
    transition: 0.2s;
}
.user-avatar-btn:hover {
    border-color: #00f0ff;
    color: #ffffff;
    background: rgba(0, 240, 255, 0.1);
}
.user-avatar-btn.active {
    border-color: #4f46e5;
    background: #1b2133;
}
.user-name-tag { color: #38bdf8; font-weight: 800; font-family: var(--font-display); }
.logout-icon-btn {
    padding: 6px 8px;
    color: #94a3b8;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
}
.logout-icon-btn:hover { color: var(--danger); background: rgba(239, 68, 68, 0.15); }

/* =========================================
   3. SIDEBAR IZQUIERDA RETRÁCTIL
   ========================================= */
.app-layout {
    display: flex;
    flex: 1;
    width: 100%;
}
.sidebar-left {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 66px;
    height: calc(100vh - 66px);
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Estado Colapsado / Retráctil */
.app-layout.sidebar-collapsed .sidebar-left,
html.preload-sidebar-collapsed .app-layout .sidebar-left {
    width: 68px;
}

.app-layout.sidebar-collapsed .sidebar-text,
.app-layout.sidebar-collapsed .sidebar-badge,
.app-layout.sidebar-collapsed .sidebar-section-title,
.app-layout.sidebar-collapsed .sidebar-footer,
html.preload-sidebar-collapsed .app-layout .sidebar-text,
html.preload-sidebar-collapsed .app-layout .sidebar-badge,
html.preload-sidebar-collapsed .app-layout .sidebar-section-title,
html.preload-sidebar-collapsed .app-layout .sidebar-footer {
    display: none !important;
}

.app-layout.sidebar-collapsed .sidebar-link,
html.preload-sidebar-collapsed .app-layout .sidebar-link {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
    border-left: none;
}

.app-layout.sidebar-collapsed .sidebar-link.active,
html.preload-sidebar-collapsed .app-layout .sidebar-link.active {
    border-left: none;
    background: #242c44;
    border-radius: 8px;
}

.app-layout.sidebar-collapsed .sidebar-icon,
html.preload-sidebar-collapsed .app-layout .sidebar-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border-radius: 8px;
    transition: background 0.15s, transform 0.15s;
}

.app-layout.sidebar-collapsed .sidebar-link:hover .sidebar-icon,
html.preload-sidebar-collapsed .app-layout .sidebar-link:hover .sidebar-icon {
    background: rgba(0, 240, 255, 0.15);
    transform: scale(1.15);
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.sidebar-section-title {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 10px 10px 4px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    color: #cbd5e1;
    transition: 0.15s;
}
.sidebar-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(3px);
}
.sidebar-link.active {
    background: #1e263d;
    color: #00f0ff;
    border-left: 3px solid #00f0ff;
}
.sidebar-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badges en la barra lateral */
.sidebar-badge {
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    text-transform: uppercase;
}
.badge-cyan { background: #083344; color: #38bdf8; border: 1px solid #0284c7; }
.badge-orange { background: #431407; color: #fb923c; border: 1px solid #ea580c; }
.badge-green { background: #064e3b; color: #4ade80; border: 1px solid #16a34a; }
.badge-yellow { background: #422006; color: #fde047; border: 1px solid #ca8a04; }
.badge-purple { background: #3b0764; color: #c084fc; border: 1px solid #9333ea; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    text-align: center;
}
.sidebar-badge-ia {
    display: inline-block;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(0, 240, 255, 0.15));
    border: 1px solid rgba(0, 240, 255, 0.3);
    color: #38bdf8;
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 800;
    font-family: var(--font-display);
}

/* =========================================
   4. CONTENIDO PRINCIPAL & COMPONENTES HERO
   ========================================= */
.main-content {
    flex: 1;
    padding: 26px 32px;
    min-width: 0;
    max-width: 1680px;
    margin: 0 auto;
    width: 100%;
}

.main-content.game-mode-main {
    padding: 10px 18px 28px;
    max-width: 100%;
}

/* Banner de Aversión a la Pérdida (Invitados) */
.retention-alert-banner {
    background: linear-gradient(135deg, #1e1b4b 0%, #151c2e 100%);
    border: 1px solid #4f46e5;
    border-radius: var(--radius);
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.2);
}
.retention-alert-content {
    display: flex;
    align-items: center;
    gap: 14px;
}
.retention-icon { font-size: 26px; }
.retention-title { font-family: var(--font-display); font-size: 15px; font-weight: 700; color: #ffffff; }
.retention-sub { font-size: 13px; color: #cbd5e1; }

/* MOSAICO HERO & BENTO SUPERIOR */
.hero-mosaic {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
    margin-bottom: 32px;
}
.home-top-bento {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 22px;
}
@media (max-width: 992px) {
    .hero-mosaic { grid-template-columns: 1fr; }
    .home-top-bento { grid-template-columns: 1fr !important; }
}

/* Hero Principal: Juego del Día */
.hero-main-card {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 340px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 30px;
    border: 2px solid #2a3553;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    background-size: cover;
    background-position: center;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.hero-main-card:hover {
    border-color: #00f0ff;
    box-shadow: 0 16px 45px rgba(0, 240, 255, 0.25);
}
.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(10, 13, 22, 0.2) 0%, rgba(10, 13, 22, 0.75) 50%, rgba(10, 13, 22, 0.96) 100%);
    z-index: 1;
}
.hero-content {
    position: relative;
    z-index: 2;
    max-width: 580px;
}
.hero-badge-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.hero-badge-today {
    background: linear-gradient(135deg, #00f0ff, #0284c7);
    color: #000;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 9999px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.hero-category-tag {
    font-size: 12px;
    font-weight: 800;
    color: #a5b4fc;
    text-transform: uppercase;
}
.hero-game-title {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 10px;
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}
.hero-game-desc {
    font-size: 14.5px;
    color: #cbd5e1;
    margin-bottom: 20px;
    line-height: 1.45;
}
.hero-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.countdown-box {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(13, 17, 29, 0.85);
    border: 1px solid #2a3553;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 12.5px;
    color: #94a3b8;
    font-weight: 700;
}
.countdown-digits {
    color: #00f0ff;
    font-family: monospace;
    font-size: 14px;
    font-weight: 800;
}

/* Hero Secundario: Reto Diario del Día (Daily Challenge) */
.hero-challenge-card {
    background: linear-gradient(135deg, #1b2033 0%, #131726 100%);
    border: 2px solid #ca8a04;
    border-radius: var(--radius);
    padding: 26px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(202, 138, 4, 0.15);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.hero-challenge-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.6), 0 0 25px rgba(202, 138, 4, 0.25);
}
.challenge-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}
.challenge-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 9999px;
    text-transform: uppercase;
}
.challenge-reward {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid #f59e0b;
    color: #fde047;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 8px;
}
.challenge-title {
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 10px;
}
.challenge-target {
    font-size: 13.5px;
    color: #cbd5e1;
    margin-bottom: 18px;
}
.challenge-target strong {
    color: #38bdf8;
}
.challenge-reset-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    border-top: 1px solid #2a3553;
    font-size: 12.5px;
    color: #94a3b8;
}

.daily-challenge-card {
    background: linear-gradient(135deg, #1b2033 0%, #131726 100%);
    border: 2px solid #ca8a04;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(202, 138, 4, 0.14);
}
.challenge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(245, 158, 11, 0.16);
    border: 1px solid rgba(245, 158, 11, 0.45);
    color: #fde047;
    font-family: var(--font-display);
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 11px;
    border-radius: 999px;
    text-transform: uppercase;
}
.challenge-xp-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000;
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 8px;
}

/* =========================================
   5. FILA "SIGUE JUGANDO" (RECENTLY PLAYED)
   ========================================= */
.continue-playing-section {
    margin-bottom: 32px;
}
.continue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.continue-card {
    background: #14192b;
    border: 1px solid #232c45;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    transition: 0.2s;
}
.continue-card:hover {
    border-color: #00f0ff;
    background: #1c233c;
    transform: translateY(-2px);
}
.continue-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}
.continue-info {
    flex: 1;
    min-width: 0;
}
.continue-title {
    font-family: var(--font-display);
    font-size: 13.5px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.continue-action {
    font-size: 11px;
    color: #00f0ff;
    font-weight: 800;
}

/* =========================================
   6. GRID DE JUEGOS VIVO (ESTILO POKI / MINI)
   ========================================= */
.section-title {
    font-family: var(--font-display);
    font-size: 23px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.game-card:hover {
    transform: translateY(-6px) scale(1.015);
    border-color: #00f0ff;
    box-shadow: 0 14px 30px rgba(0, 240, 255, 0.22);
}

.game-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #0d111d;
    overflow: hidden;
}

.game-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.game-thumb-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: radial-gradient(circle at center, #232c45, #0d111d);
}

/* Botón flotante ▶ que aparece en Hover */
.play-hover-btn {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 13, 22, 0.4);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2;
}

.play-hover-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #00f0ff;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 900;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.8);
    transform: scale(0.7);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.game-card:hover .play-hover-btn {
    opacity: 1;
}

.game-card:hover .play-hover-icon {
    transform: scale(1);
}

/* Insignias sobre la portada */
.game-card-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    font-family: var(--font-display);
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.badge-float-orange { background: #ea580c; color: #fff; }
.badge-float-cyan { background: #0284c7; color: #fff; }
.badge-float-yellow { background: #ca8a04; color: #000; }

.game-body {
    padding: 14px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.game-cat {
    font-size: 11px;
    color: #38bdf8;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.game-title {
    font-family: var(--font-display);
    font-size: 16.5px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #ffffff;
    line-height: 1.25;
}

.game-meta {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid #20273c;
}

/* =========================================
   7. BOTONES & ELEMENTOS INTERACTIVOS
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: 10px;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: 0.18s ease;
}
.btn-primary { 
    background: linear-gradient(135deg, #6366f1, #4f46e5); 
    color: white; 
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover { 
    background: linear-gradient(135deg, #4f46e5, #4338ca); 
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.55);
    transform: translateY(-2px);
}
.btn-neon {
    background: linear-gradient(135deg, #00f0ff, #0284c7);
    color: #000;
    box-shadow: 0 4px 18px rgba(0, 240, 255, 0.4);
}
.btn-neon:hover {
    background: linear-gradient(135deg, #38bdf8, #00f0ff);
    box-shadow: 0 6px 25px rgba(0, 240, 255, 0.7);
    transform: translateY(-2px);
}
.btn-secondary { 
    background: #1b2133; 
    color: white; 
    border: 1px solid var(--border); 
}
.btn-secondary:hover { 
    background: #252e46; 
    border-color: #3b476b;
}
.btn-outline {
    background: transparent;
    color: #cbd5e1;
    border: 1px solid var(--border);
}
.btn-outline:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--neon-cyan);
    color: #ffffff;
}
.btn-sm { padding: 6px 14px; font-size: 12.5px; border-radius: 8px; }

/* Formularios */
.form-box {
    max-width: 440px;
    margin: 40px auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
}
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: #cbd5e1; }
.form-control {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 14px;
}
.form-control:focus { outline: none; border-color: #00f0ff; }

/* Notificaciones Toast flotantes */
.toast-hud {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #0d121f;
    border: 2px solid #10b981;
    color: #ffffff;
    padding: 14px 22px;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.8), 0 0 15px rgba(16, 185, 129, 0.4);
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9999;
    animation: toastPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes toastPop {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================================
   8. FEED DE ACTIVIDAD SOCIAL
   ========================================= */
.activity-feed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 36px;
}
.activity-item {
    background: #14192b;
    border: 1px solid #232c45;
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}
.activity-avatar { font-size: 22px; }
.activity-text { flex: 1; color: #cbd5e1; }
.activity-text strong { color: #ffffff; }

/* =========================================
   9. BARRA DE NAVEGACIÓN MÓVIL INFERIOR Y DRAWER
   ========================================= */
.mobile-search-toggle-btn {
    display: none;
    background: #0d111d;
    border: 1px solid #26304a;
    color: #cbd5e1;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
}

.mobile-search-bar {
    background: #0d111d;
    border-bottom: 1px solid #232c45;
    padding: 10px 14px;
    position: sticky;
    top: 66px;
    z-index: 99;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 16, 0.72);
    backdrop-filter: blur(4px);
    z-index: 1040;
}
.sidebar-backdrop.active {
    display: block;
}

.forum-layout-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 30px;
}

.exit-mobile-fullscreen-btn {
    display: none;
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2147483645;
    background: rgba(9, 13, 22, 0.85);
    border: 1px solid rgba(0, 240, 255, 0.55);
    color: #ffffff;
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
}

.game-stage-box.mobile-fullscreen-active {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    max-height: none !important;
    z-index: 99999 !important;
    border-radius: 0 !important;
    border: none !important;
}

.game-stage-box.mobile-fullscreen-active .game-cockpit-topbar,
.game-stage-box.mobile-fullscreen-active .game-cockpit-bottombar {
    display: none !important;
}

.game-stage-box.mobile-fullscreen-active .exit-mobile-fullscreen-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
}

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(17, 21, 36, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid #232c45;
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
}
.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    gap: 2px;
}
.mobile-nav-item.active, .mobile-nav-item:hover {
    color: #00f0ff;
}
.mobile-nav-icon {
    font-size: 20px;
}

@media (max-width: 992px) {
    .forum-layout-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .nav-search {
        width: 220px;
    }
    .nav-search:focus-within {
        width: 250px;
    }
    .header-level-badge .xp-detail {
        display: none;
    }
}

@media (max-width: 768px) {
    .navbar {
        height: 58px;
    }
    .nav-container {
        padding: 0 10px;
        gap: 8px;
    }
    .brand {
        gap: 8px;
    }
    .brand-logo {
        width: 34px;
        height: 34px;
    }
    .brand-text {
        font-size: 16px;
    }
    .nav-search {
        display: none;
    }
    .mobile-search-toggle-btn {
        display: inline-flex;
    }
    .mobile-search-bar {
        top: 58px;
    }
    .header-level-badge {
        display: none;
    }
    .header-streak-badge {
        padding: 4px 8px;
        font-size: 11.5px;
    }
    .header-streak-badge .streak-label {
        display: none;
    }
    .header-coins-badge {
        padding: 4px 8px;
        font-size: 11.5px;
    }
    .header-coins-badge .coins-label {
        display: none;
    }
    .header-guest-pill {
        padding: 4px 9px;
        font-size: 11px;
    }
    .header-guest-pill #guestXpCount,
    .header-guest-pill .guest-pill-sep:not(.guest-coin-sep) {
        display: none;
    }
    .user-avatar-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
    .user-avatar-btn .user-name-tag,
    .user-avatar-btn .login-hint,
    .nav-admin-btn .admin-btn-text {
        display: none;
    }
    .lang-flags {
        padding: 3px 5px;
        gap: 3px;
    }
    .flag-btn {
        font-size: 14px;
        padding: 2px 4px;
    }

    /* Drawer lateral móvil funcional al pulsar el botón hamburguesa */
    .sidebar-left,
    .app-layout.sidebar-collapsed .sidebar-left,
    html.preload-sidebar-collapsed .app-layout .sidebar-left {
        display: flex !important;
        position: fixed;
        top: 58px;
        left: 0;
        bottom: 60px;
        height: calc(100vh - 118px);
        height: calc(100dvh - 118px);
        width: 270px !important;
        z-index: 1050;
        transform: translateX(-105%);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 16px 0 40px rgba(0, 0, 0, 0.8);
    }
    .app-layout.mobile-sidebar-open .sidebar-left {
        transform: translateX(0) !important;
    }
    .app-layout.mobile-sidebar-open .sidebar-text,
    .app-layout.mobile-sidebar-open .sidebar-section-title,
    .app-layout.mobile-sidebar-open .sidebar-footer {
        display: block !important;
    }
    .app-layout.mobile-sidebar-open .sidebar-badge:not([style*="display:none"]):not([style*="display: none"]):not(:empty) {
        display: inline-block !important;
    }
    .app-layout.mobile-sidebar-open .sidebar-link {
        justify-content: flex-start !important;
        padding: 10px 12px !important;
        gap: 12px !important;
    }

    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea,
    .form-control {
        font-size: 16px;
    }

    .mobile-bottom-nav { display: flex; }
    .main-content { padding: 14px 12px 84px; }
    .main-content.game-mode-main { padding: 8px 8px 80px; }
    .retention-alert-banner {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 14px;
        gap: 10px;
    }
    .retention-alert-banner .btn {
        width: 100%;
    }
    .hero-main-card { min-height: 250px; padding: 18px 16px; }
    .hero-game-title { font-size: 22px; }
    .hero-challenge-card { padding: 18px 16px; }
    .game-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .form-box { margin: 20px auto; padding: 22px 16px; }
    .toast-hud { left: 12px; right: 12px; bottom: 72px; font-size: 13px; padding: 12px 16px; }
}

@media (max-width: 420px) {
    .brand-text {
        display: none;
    }
}

/* Footer */
.site-footer {
    background: #090c14;
    border-top: 1px solid var(--border);
    padding: 24px;
    margin-top: auto;
}
.footer-container {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

/* 10. PUBLICIDAD Y ESCENARIO INMERSIVO DEL JUEGO */
.ad-slot { margin: 8px auto 32px; max-width: 970px; min-height: 100px; text-align: center; }
.ad-slot-game { width: 100%; max-width: 100%; min-height: 230px; margin: 0; flex-shrink: 0; }
.ad-label { display: block; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: #5b6783; margin-bottom: 4px; }
.ad-unit { min-height: 90px; }
.ad-placeholder { min-height: 90px; display: flex; align-items: center; justify-content: center; border: 1px dashed #2a3553; border-radius: 10px; color: #5b6783; font-size: 12px; background: rgba(255,255,255,0.02); }
.ad-slot-game .ad-unit, .ad-slot-game .ad-placeholder { min-height: 215px; background: rgba(13, 18, 32, 0.7); }
@media (max-width: 768px) { .ad-slot { min-height: 60px; } .ad-unit, .ad-placeholder { min-height: 50px; } }

/* Contenedor principal de la Ficha de Juego (Cockpit Panorámico Sin Scroll Inicial) */
.game-page-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

.game-cockpit-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 16px;
    align-items: stretch;
    width: 100%;
}

.game-cockpit-grid.cinema-active {
    grid-template-columns: 1fr;
}

.game-cockpit-grid.cinema-active .game-cockpit-sidebar {
    display: none;
}

.game-stage-box {
    position: relative;
    background: #050811;
    border-radius: 14px;
    overflow: hidden;
    border: 2px solid #26314d;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.78), 0 0 32px rgba(99, 102, 241, 0.14);
    width: 100%;
    height: calc(100vh - 88px);
    min-height: 540px;
    max-height: 880px;
    display: flex;
    flex-direction: column;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.game-cockpit-grid.cinema-active .game-stage-box {
    border-color: #00f0ff;
    box-shadow: 0 24px 65px rgba(0, 0, 0, 0.92), 0 0 42px rgba(0, 240, 255, 0.25);
}

.game-cockpit-topbar {
    height: 52px;
    padding: 0 16px;
    background: linear-gradient(90deg, #0d1324 0%, #141c34 100%);
    border-bottom: 1px solid #232d48;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.game-frame-viewport {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: none;
    display: block;
    background: #040710;
}

.game-cockpit-bottombar {
    height: 38px;
    padding: 0 16px;
    background: #0a0e1b;
    border-top: 1px solid #1e2740;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    font-size: 12.5px;
}

.game-cockpit-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: calc(100vh - 88px);
    min-height: 540px;
    max-height: 880px;
}

.scoreboard-card {
    background: linear-gradient(165deg, #151c30 0%, #0e1322 100%);
    border: 1px solid #2b3758;
    border-radius: 14px;
    padding: 16px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.45);
}

.scoreboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex: 1;
    padding-right: 4px;
}

.scoreboard-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 11px;
    border-radius: 9px;
    background: rgba(9, 13, 22, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
}

.scoreboard-row.rank-1 {
    background: linear-gradient(90deg, rgba(250, 204, 21, 0.16), rgba(9, 13, 22, 0.7));
    border-color: rgba(250, 204, 21, 0.45);
}
.scoreboard-row.rank-2 {
    background: linear-gradient(90deg, rgba(226, 232, 240, 0.12), rgba(9, 13, 22, 0.7));
    border-color: rgba(226, 232, 240, 0.3);
}
.scoreboard-row.rank-3 {
    background: linear-gradient(90deg, rgba(251, 146, 60, 0.14), rgba(9, 13, 22, 0.7));
    border-color: rgba(251, 146, 60, 0.35);
}

/* Rejilla inferior bajo el juego (solo al hacer scroll) */
.game-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    align-items: start;
    margin-top: 24px;
}

@media (max-width: 1100px) {
    .game-cockpit-grid {
        grid-template-columns: 1fr;
    }
    .game-stage-box {
        height: clamp(440px, 72vh, 680px);
        min-height: 440px;
    }
    .game-cockpit-sidebar {
        height: auto;
        min-height: 0;
        max-height: none;
    }
    .game-details-grid {
        grid-template-columns: 1fr;
    }
    .cockpit-cinema-btn {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .game-stage-box {
        height: clamp(390px, 68dvh, 560px);
        min-height: 380px;
        border-radius: 12px;
    }
    .game-cockpit-topbar {
        height: auto;
        min-height: 46px;
        padding: 8px 10px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .cockpit-title-group {
        width: 100%;
        flex: 1 1 100%;
    }
    .cockpit-game-h1 {
        font-size: 16px !important;
    }
    .cockpit-plays-count,
    .cockpit-cat-name {
        display: none;
    }
    .cockpit-actions-group {
        width: 100%;
        justify-content: space-between;
    }
    .cockpit-actions-group .btn {
        flex: 1;
        justify-content: center;
        padding: 6px 8px !important;
        font-size: 12px;
    }
    .game-cockpit-bottombar {
        height: auto;
        min-height: 34px;
        padding: 6px 10px;
        flex-wrap: wrap;
        gap: 6px;
        font-size: 11.5px;
    }
    .cockpit-instr-sep,
    .cockpit-instr-inline {
        display: none;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .game-stage-box {
        height: calc(100dvh - 16px);
        min-height: 260px;
    }
}
