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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    color: #e8e8e8;
    margin: 0;
    padding: 20px 0;
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
}

.game-container {
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: min(3vh, 20px) min(3vw, 20px);
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: min(90vw, 500px);
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
    min-height: auto;
}

.nav-menu {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.nav-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.admin-link {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: #ffa500;
    text-decoration: none;
    padding: 10px;
    border-radius: 50%;
    border: 2px solid #ffa500;
    font-size: 1.2em;
    transition: all 0.3s ease;
    z-index: 1000;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-link:hover {
    background: rgba(255, 165, 0, 0.2);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 165, 0, 0.5);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.username {
    color: #00ff88;
    font-weight: 600;
    font-size: 16px;
}

.logout-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.welcome-message {
    text-align: center;
    margin: 10px 0 20px 0;
    padding: 15px;
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.1), rgba(0, 204, 106, 0.1));
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 15px;
    color: #00ff88;
    font-weight: 600;
    font-size: 16px;
}

h1 {
    font-size: 2.2rem;
    font-weight: 300;
    margin-bottom: 12px;
    letter-spacing: 2px;
    background: linear-gradient(45deg, #00ff88, #00cc6a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
}

.subtitle {
    font-size: 1.1rem;
    font-weight: 400;
    margin-bottom: 24px;
    color: #b8b8b8;
    letter-spacing: 1px;
    font-style: italic;
}

.game-info {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    margin-bottom: 24px;
    font-size: 0.9rem;
    font-weight: 500;
    gap: 12px;
}

.score, .player-info, .players-online {
    background: rgba(0, 255, 136, 0.1);
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid rgba(0, 255, 136, 0.2);
    backdrop-filter: blur(10px);
    color: #00ff88;
    text-align: center;
}

#gameCanvas {
    border: 2px solid rgba(0, 255, 136, 0.3);
    border-radius: 16px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    margin: 2vh 0;
    max-width: 100%;
    height: auto;
}

.controls {
    margin-top: 20px;
    font-size: 0.9rem;
    opacity: 0.7;
    font-weight: 300;
}

.controls p {
    margin: 6px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 12px;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-status {
    margin-top: 16px;
    font-size: 1.1rem;
    font-weight: 400;
    min-height: 32px;
    letter-spacing: 0.5px;
}

.game-over {
    color: #ff4757;
    text-shadow: 0 0 10px rgba(255, 71, 87, 0.5);
}

.game-ready {
    color: #00ff88;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.mobile-controls {
    margin-top: 20px;
}

.start-btn {
    background: linear-gradient(45deg, #00ff88, #00cc6a);
    color: #0f0f23;
    border: none;
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 16px;
    cursor: pointer;
    margin-bottom: 24px;
    box-shadow: 0 8px 24px rgba(0, 255, 136, 0.3);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.start-btn:hover, .start-btn:active {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 255, 136, 0.4);
    background: linear-gradient(45deg, #00ff88, #00dd77);
}

.direction-pad {
    display: grid;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 10px;
    max-width: 200px;
    margin: 0 auto;
}

.middle-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.dir-btn {
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
    border: 1px solid rgba(0, 255, 136, 0.3);
    padding: 16px;
    font-size: 1.4rem;
    font-weight: 300;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    backdrop-filter: blur(10px);
}

.dir-btn:hover, .dir-btn:active {
    background: rgba(0, 255, 136, 0.2);
    border-color: rgba(0, 255, 136, 0.5);
    transform: scale(0.95);
    box-shadow: 0 4px 16px rgba(0, 255, 136, 0.2);
}

.up {
    grid-column: 2;
}

.left {
    grid-column: 1;
}

.right {
    grid-column: 3;
}

.down {
    grid-column: 2;
}

@media (max-width: 600px) {
    body {
        padding: 10px 0;
        align-items: flex-start;
    }
    
    .game-container {
        padding: min(2vh, 15px);
        max-width: 95vw;
        margin-top: 0;
    }
    
    .nav-menu {
        gap: 10px;
        margin-bottom: 20px;
        flex-wrap: wrap;
    }
    
    .nav-btn {
        padding: 8px 16px;
        font-size: 14px;
        flex: 1;
        min-width: 80px;
        text-align: center;
    }
    
    .user-profile {
        flex: 100%;
        justify-content: center;
        margin-top: 10px;
    }
    
    .username {
        font-size: 14px;
    }
    
    .logout-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .welcome-message {
        font-size: 14px;
        padding: 10px;
        margin: 5px 0 15px 0;
    }
    
    h1 {
        font-size: 1.8rem;
        margin-bottom: 15px;
    }
    
    #gameCanvas {
        width: 300px;
        height: 300px;
    }
    
    .game-info {
        grid-template-columns: 1fr;
        gap: 1vh;
        font-size: 3vw;
    }
    
    .controls {
        font-size: 3.5vw;
        margin: 1vh 0;
    }
    
    .controls p {
        font-size: 0.9rem;
        padding: 6px 12px;
    }
    
    .mobile-controls {
        gap: 2vh;
        margin: 2vh 0;
    }
    
    .start-btn {
        padding: 2vh 4vw;
        font-size: 4vw;
    }
    
    .direction-pad {
        width: min(30vw, 120px);
        height: min(30vw, 120px);
    }
    
    .dir-btn {
        width: min(8vw, 35px);
        height: min(8vw, 35px);
        font-size: 4vw;
        padding: 20px;
    }
    
    .leaderboard {
        font-size: 3vw;
    }
    
    .leaderboard-item {
        padding: 1vh 2vw;
    }
}

.leaderboard {
    margin-top: 24px;
    background: rgba(0, 255, 136, 0.05);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(0, 255, 136, 0.2);
    backdrop-filter: blur(10px);
}

.leaderboard h3 {
    margin: 0 0 16px 0;
    color: #00ff88;
    font-size: 1.1rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#leaderboardList {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
}

.leaderboard-item.current-player {
    background: rgba(0, 255, 136, 0.15);
    border-color: rgba(0, 255, 136, 0.3);
}

.leaderboard-rank {
    font-weight: 600;
    color: #00ff88;
    min-width: 24px;
}

.leaderboard-name {
    flex: 1;
    text-align: left;
    margin-left: 12px;
}

.leaderboard-score {
    font-weight: 500;
    color: #00ff88;
}