:root {
    --bg-dark: #06080c;
    --sidebar-bg: #0c0f16;
    --accent-primary: #00f2ff; /* Nexa Blue/Cyan */
    --accent-secondary: #7000ff; /* Purple for depth */
    --accent-glow: rgba(0, 242, 255, 0.3);
    --card-bg: rgba(18, 22, 31, 0.6);
    --sidebar-width: 260px;
    --top-height: 80px;
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
}

body {
    background-color: var(--bg-dark);
    color: #fff;
    font-family: 'Outfit', sans-serif;
    margin: 0;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at 20% 30%, rgba(0, 242, 255, 0.05) 0%, transparent 40%),
                radial-gradient(circle at 80% 70%, rgba(112, 0, 255, 0.05) 0%, transparent 40%);
    z-index: -1;
    pointer-events: none;
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar - Collapsible */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(255,255,255,0.05);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    z-index: 2000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar.collapsed .sidebar-logo {
    font-size: 0; /* Oculta texto */
    padding: 0;
    justify-content: center;
}

.sidebar.collapsed .sidebar-logo::before {
    content: "AGS";
    font-size: 1.1rem;
    color: var(--accent-primary);
}

.sidebar.collapsed .side-link span,
.sidebar.collapsed .sidebar-label {
    display: none;
}

.sidebar.collapsed .side-link {
    justify-content: center;
    padding: 15px 0;
}

.sidebar-toggle {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    align-self: center;
    margin-bottom: 25px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

.sidebar-toggle:hover { 
    background: var(--accent-primary);
    transform: scale(1.1);
}

.sidebar-logo {
    font-weight: 900;
    font-size: 1.2rem;
    color: #fff;
    text-decoration: none;
    margin-bottom: 40px;
    padding: 0 10px;
    letter-spacing: -1px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
}

.sidebar-logo span { color: var(--accent-primary); }

.sidebar-section {
    margin-top: 30px;
}

.sidebar-label {
    padding: 0 15px;
    font-size: 0.7rem;
    color: #555;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 15px;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    color: #888;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: 0.2s;
    margin-bottom: 5px;
}

.side-link:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.side-link.active {
    background: rgba(0, 242, 255, 0.1);
    color: var(--accent-primary);
    box-shadow: inset 0 0 10px rgba(0, 242, 255, 0.1);
}

.side-link i {
    font-size: 1.1rem;
    width: 25px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.side-link:hover i {
    transform: scale(1.2) rotate(-10deg);
    color: var(--accent-primary);
    text-shadow: 0 0 10px var(--accent-glow);
}

/* Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0; /* Importante para flex responsivo */
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-dark);
}

.main-content.expanded {
    margin-left: 80px;
}

.container {
    padding: 30px 40px;
    max-width: 1400px;
}

.top-nav {
    height: var(--top-height);
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(6, 8, 12, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    position: sticky;
    top: 0;
    z-index: 900;
}

.search-box {
    background: #12161f;
    border: 1px solid rgba(255,255,255,0.1);
    padding: 10px 20px;
    border-radius: 10px;
    width: 400px;
    color: #fff;
}

.user-block {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 700;
}

/* Game Grid - Optimized Size */
.game-list {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* Forzar siempre 5 columnas en PC */
    gap: 25px;
}

@media (max-width: 1200px) {
    .game-list { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .game-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .game-list { grid-template-columns: 1fr; }
}

.game-item {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    height: 100%;
    animation: fadeInUp 0.6s ease backwards;
}

.game-item:hover {
    transform: translateY(-10px) scale(1.02);
    border-color: rgba(0, 242, 255, 0.5);
    box-shadow: 0 20px 40px rgba(0,0,0,0.6), 0 0 25px rgba(0, 242, 255, 0.2);
}

.game-item:hover .game-thumb {
    filter: brightness(1.2);
}

.game-thumb {
    width: 100%;
    height: 140px;
    background: #000;
    background-size: cover !important;
    background-position: center !important;
    flex-shrink: 0;
    position: relative;
    border-bottom: 1px solid var(--glass-border);
}

.game-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-secondary);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 900;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.game-info {
    padding: 15px 20px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center; /* Centrar todo el contenido horizontalmente */
    text-align: center;
}

.game-info h3 {
    margin: 0 0 5px 0;
    font-size: 1.15rem;
    font-weight: 800;
}

.game-category {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(0, 242, 255, 0.1);
    color: var(--accent-primary);
    font-size: 0.65rem;
    font-weight: 800;
    border-radius: 5px;
    text-transform: uppercase;
    margin-bottom: 15px;
}

.game-info p {
    color: #888;
    font-size: 0.8rem;
    margin-bottom: 15px;
}

.btn {
    display: block;
    width: 100%;
    max-width: 160px;
    text-align: center;
    padding: 10px;
    background: var(--accent-primary);
    color: var(--bg-dark); /* Contrast better on cyan */
    text-decoration: none;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: 0.3s;
    margin-top: auto; 
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20%;
    height: 200%;
    background: rgba(255,255,255,0.2);
    transform: rotate(30deg);
    transition: 0.5s;
}

.btn:hover::after {
    left: 120%;
}

.btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
}

@media (max-width: 900px) {
    .sidebar { width: 80px; }
    .sidebar span, .sidebar-logo span { display: none; }
    .main-content { margin-left: 80px; }
    .search-box { width: 200px; }
}

/* Theater Mode - Game Viewer */
.theater-container {
    padding: 30px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-window {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
    overflow: hidden;
    position: relative;
    max-height: 80vh;
}

.game-window iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.game-header-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.game-meta {
    display: flex;
    gap: 30px;
    color: #888;
    font-size: 0.9rem;
}

/* Leaderboard - Rankings Table */
.rank-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 15px;
    overflow: hidden;
}

.rank-table th {
    background: rgba(255,255,255,0.05);
    padding: 15px 25px;
    text-align: left;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

.rank-table td {
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-weight: 600;
}

.rank-table tr:hover { background: rgba(0, 242, 255, 0.05); }

/* XP Level Bar */
.xp-bar-container {
    width: 200px;
    height: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 5px;
}

.xp-bar-fill {
    height: 100%;
    background: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
    transition: width 0.5s;
}

.sidebar .side-link i {
    transition: transform 0.3s ease;
}

.sidebar .side-link:hover i {
    transform: scale(1.3) rotate(-10deg);
    color: var(--accent-primary);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Auth Specific Styles */
.auth-container { max-width: 400px; margin: 60px auto; background: var(--card-bg); backdrop-filter: blur(15px); border: 1px solid var(--glass-border); border-radius: 24px; padding: 40px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); }
.auth-tabs { display: flex; gap: 20px; margin-bottom: 30px; justify-content: center; }
.tab { color: var(--text-secondary); cursor: pointer; font-weight: 600; font-size: 1.1rem; transition: all 0.3s; padding-bottom: 5px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--accent-primary); border-bottom-color: var(--accent-primary); }
.form-group { margin-bottom: 20px; text-align: left; }
.form-group label { display: block; color: var(--text-secondary); margin-bottom: 8px; font-size: 0.9rem; }
.form-group input { width: 100%; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); border-radius: 12px; padding: 12px 15px; color: white; outline: none; transition: border-color 0.3s; }
.form-group input:focus { border-color: var(--accent-primary); }
.auth-btn { width: 100%; margin-top: 10px; }
#message { margin-top: 20px; font-size: 0.9rem; min-height: 1.2em; }
.hidden { display: none; }

/* Game Emulator Styles */
.emu-container { background: #000; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.emu-container iframe { border: none; width: 100%; height: 100%; max-height: 600px; box-shadow: 0 0 50px rgba(0, 242, 255, 0.2); }
.controls-panel { background: var(--card-bg); padding: 25px; border-radius: 15px; border: 1px solid rgba(255,255,255,0.05); display: flex; gap: 30px; margin-top: 20px; align-items: center; }
.key-hint { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 0.9rem; transition: 0.2s; cursor: pointer; user-select: none; }
.key-cap { background: #12151c; border: 1px solid rgba(255,255,255,0.2); padding: 5px 12px; border-radius: 5px; box-shadow: 0 3px 0 rgba(255,255,255,0.1); }

@keyframes xpPop {
  0% { transform: translateY(20px); opacity: 0; }
  20% { transform: translateY(0); opacity: 1; }
  80% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-20px); opacity: 0; }
}
.xp-toast {
  position: fixed; bottom: 30px; right: 30px;
  background: linear-gradient(45deg, #00f2ff, #7000ff);
  color: white; padding: 10px 20px; border-radius: 50px;
  font-weight: 800; font-size: 0.9rem; z-index: 9999;
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
  animation: xpPop 3s forwards;
}

.game-window:focus-within { border-color: var(--accent-primary) !important; box-shadow: 0 0 20px rgba(0,242,255,0.3); }
#nes-canvas:focus { outline: none; }
.key-hint:hover { transform: translateY(-2px); color: var(--accent-primary); }
.key-hint:active { transform: translateY(1px); opacity: 0.7; }

/* Theater Mode */
.theater-active .sidebar { transform: translateX(-100%); }
.theater-active .main-content { margin-left: 0 !important; }
.theater-active .top-nav { display: none; }
.theater-active .game-window { height: 85vh; border-radius: 0; border: none; }

