:root {
    --primary: #e84393;
    --secondary: #fd79a8;
    --accent: #fab1a0;
    --dark: #2d3436;
    --light: #fff9fa;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #d63031;
    --shadow: 0 5px 15px rgba(0,0,0,0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--light);
    color: var(--dark);
    min-height: 100vh;
    padding-top: 80px;
    padding-bottom: 20px;
    touch-action: manipulation;
    overflow-x: hidden; /* Previene el scroll horizontal */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: var(--light);
    box-shadow: var(--shadow);
    z-index: 100;
    animation: fadeInDown 0.5s ease;
}

.logo {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    background: linear-gradient(45deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
    text-decoration: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 5px;
}

.menu-dot {
    width: 5px;
    height: 5px;
    background-color: var(--primary);
    border-radius: 50%;
}

.menu {
    position: fixed;
    top: 70px;
    right: 20px;
    background-color: white;
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 15px;
    z-index: 101;
    display: none;
    animation: fadeIn 0.3s ease;
}

.menu.active {
    display: block;
}

.menu-item {
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    text-decoration: none;
    color: var(--dark);
}

.menu-item:hover {
    background-color: rgba(232, 67, 147, 0.1);
    color: var(--primary);
}

.menu-item i {
    font-size: 18px;
}

.section-title {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--primary);
    position: relative;
    padding-bottom: 10px;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: linear-gradient(45deg, var(--primary), var(--accent));
    border-radius: 3px;
}

.categories {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding: 10px 0;
    margin-bottom: 20px;
    scrollbar-width: thin;
}

.categories::-webkit-scrollbar {
    height: 5px;
}

.categories::-webkit-scrollbar-track {
    background: var(--light);
}

.categories::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 5px;
}

.category {
    padding: 8px 15px;
    background-color: white;
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.category:hover, .category.active {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    color: white;
    transform: translateY(-2px);
}

.search-container {
    display: flex;
    margin-bottom: 20px;
}

.search-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #eee;
    border-radius: 10px 0 0 10px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s;
    -webkit-appearance: none;
}

.search-input:focus {
    border-color: var(--primary);
}

.search-btn {
    padding: 0 20px;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 0 10px 10px 0;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    -webkit-appearance: none;
}

.search-btn:hover {
    opacity: 0.9;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    min-height: 200px; /* Para que el loader se vea bien */
}

.game-card {
    background-color: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}

.game-thumbnail {
    width: 100%;
    height: 150px;
    object-fit: cover;
    transition: transform 0.3s;
    background-color: #eee;
}

.game-card:hover .game-thumbnail {
    transform: scale(1.05);
}

.game-info {
    padding: 15px;
}

.game-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 16px;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-description {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 40px; /* 14px * 1.6 line-height * 2 lines */
}

.game-actions {
    display: flex;
    gap: 10px;
}

.btn {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 14px;
    text-decoration: none;
    -webkit-appearance: none;
}

.btn-primary {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    color: white;
}

.btn-secondary {
    background-color: #f1f2f6;
    color: var(--dark);
}

.btn-secondary:hover {
    background-color: #dfe6e9;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.btn:disabled {
    background-color: #b2bec3;
    cursor: not-allowed;
    transform: none;
    opacity: 0.7;
}

.game-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    z-index: 1000;
    flex-direction: column;
}

.viewer-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    color: white;
    flex-shrink: 0;
}

.viewer-title {
    font-weight: 600;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viewer-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
    -webkit-appearance: none;
    flex-shrink: 0;
}

.viewer-close:hover {
    background-color: rgba(255,255,255,0.2);
    transform: rotate(90deg);
}

.game-iframe {
    width: 100%;
    height: 100%; /* El flex-grow lo estira */
    border: none;
    background-color: #000;
}

.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px;
    grid-column: 1 / -1;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(0,0,0,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    z-index: 999;
}

/* Contenedor de AdSense */
.ad-container {
    width: 100%;
    padding: 20px 0;
    margin: 10px 0;
    background-color: #f1f2f6;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    color: #999;
}

/* Paginación */
.pagination-container {
    display: none; /* Oculto por defecto */
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
}

.pagination-container span {
    font-weight: 600;
    color: var(--dark);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Estilos para móviles */
@media (max-width: 768px) {
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
    .game-thumbnail {
        height: 120px;
    }
    .section-title {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .games-grid {
        grid-template-columns: 1fr;
    }
    .logo {
        font-size: 22px;
    }
}