* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #0a0e1a 0%, #1a1f35 50%, #0d1525 100%);
    font-family: 'Orbitron', sans-serif;
    color: #e0f7ff;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0, 150, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 150, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* Pantalla de bienvenida */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.welcome-overlay.hidden {
    display: none;
}

.welcome-modal {
    background: linear-gradient(180deg, #0d1525 0%, #0a0e1a 100%);
    border: 2px solid #00d4ff;
    border-radius: 12px;
    padding: 50px;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.3);
}

.welcome-modal h1 {
    font-size: 2rem;
    color: #00d4ff;
    margin-bottom: 10px;
}

.welcome-logo-link {
    display: inline-block;
    margin-bottom: 15px;
    max-width: min(180px, 45vw);
}

.welcome-logo {
    height: 24px;
    max-height: 6vw;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    opacity: 0.9;
}

.welcome-logo:hover {
    opacity: 1;
}

@media (max-width: 600px) {
    .welcome-logo {
        height: 20px;
        max-height: 8vw;
    }
}

.welcome-modal p {
    color: #a0c4d4;
    margin-bottom: 25px;
}

.welcome-modal form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.welcome-modal input {
    padding: 12px 20px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    background: rgba(0, 50, 80, 0.6);
    border: 1px solid #00d4ff;
    border-radius: 8px;
    color: #e0f7ff;
    width: 250px;
}

.welcome-modal input::placeholder {
    color: #608090;
}

.welcome-modal input:focus {
    outline: none;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
}

.welcome-modal .btn {
    padding: 12px 40px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #00d4ff;
    background: rgba(0, 50, 80, 0.6);
    border: 1px solid #00d4ff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.welcome-modal .btn:hover {
    background: rgba(0, 212, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
}

/* Layout principal */
.app-layout {
    display: grid;
    grid-template-columns: 200px 1fr 220px;
    grid-template-rows: 60px 1fr;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* Header: logo, nombre, reloj */
.player-header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background: rgba(0, 30, 50, 0.6);
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
}

.header-logo-link {
    flex-shrink: 0;
}

.header-logo {
    height: 36px;
    width: auto;
    opacity: 0.9;
}

.header-logo:hover {
    opacity: 1;
}

.player-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #00d4ff;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.header-clock {
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: #00d4ff;
    letter-spacing: 2px;
    flex-shrink: 0;
}

/* Sidebars */
.sidebar {
    background: rgba(0, 20, 40, 0.8);
    border-right: 1px solid rgba(0, 212, 255, 0.2);
    padding: 20px;
    overflow-y: auto;
}

.sidebar-right {
    border-right: none;
    border-left: 1px solid rgba(0, 212, 255, 0.2);
}

.sidebar h2 {
    font-size: 0.9rem;
    color: #00d4ff;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
}

/* Lista de juegos */
.games-list {
    list-style: none;
}

.games-list li {
    margin-bottom: 8px;
}

.game-link {
    display: block;
    padding: 10px 12px;
    color: #a0c4d4;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.game-link:hover {
    background: rgba(0, 212, 255, 0.1);
    color: #00d4ff;
}

.game-link.active {
    background: rgba(0, 212, 255, 0.2);
    color: #00d4ff;
    border: 1px solid #00d4ff;
}

/* Área central */
.main-content {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
}

.game-frame-container {
    width: 100%;
    max-width: 700px;
    height: 100%;
    min-height: 500px;
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 10, 20, 0.5);
}

#gameFrame {
    width: 100%;
    height: 100%;
    min-height: 500px;
    border: none;
}

/* Ranking */
.ranking-subtitle {
    font-size: 0.75rem;
    color: #608090;
    margin-bottom: 12px;
}

.difficulty-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 15px;
}

.difficulty-tab {
    padding: 6px 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    color: #00d4ff;
    background: rgba(0, 50, 80, 0.6);
    border: 1px solid #00d4ff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.difficulty-tab:hover {
    background: rgba(0, 212, 255, 0.2);
}

.difficulty-tab.active {
    background: #00d4ff;
    color: #0a0e1a;
}

.ranking-list {
    list-style: none;
    counter-reset: ranking;
}

.ranking-list li {
    counter-increment: ranking;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(0, 30, 50, 0.5);
    border-radius: 6px;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ranking-list li::before {
    content: counter(ranking) ".";
    font-weight: 700;
    color: #00d4ff;
    margin-right: 8px;
}

.ranking-list .rank-name {
    color: #e0f7ff;
}

.ranking-list .rank-time {
    color: #00d4ff;
    font-size: 0.75rem;
}

.ranking-empty {
    color: #608090;
    font-size: 0.85rem;
    padding: 20px;
    text-align: center;
}

.ranking-actions {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-small {
    padding: 8px 12px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    color: #00d4ff;
    background: rgba(0, 50, 80, 0.6);
    border: 1px solid #00d4ff;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: rgba(0, 212, 255, 0.2);
}

@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 60px auto 1fr auto;
    }

    .sidebar-left {
        order: 2;
        border-right: none;
        border-bottom: 1px solid rgba(0, 212, 255, 0.2);
    }

    .main-content {
        order: 3;
    }

    .sidebar-right {
        order: 4;
        border-left: none;
        border-top: 1px solid rgba(0, 212, 255, 0.2);
    }
}
