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

body {
    font-family: 'Orbitron', sans-serif;
    background: #0a0a0a;
    color: #fff;
    overflow: hidden;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Screens */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.screen.active {
    display: flex;
}

/* Home Screen */
.home-container {
    text-align: center;
    padding: 20px;
}

.game-title {
    font-size: 4rem;
    background: linear-gradient(135deg, #00ff88, #00ccff, #ff00cc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(0, 255, 136, 0.5);
    margin-bottom: 40px;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { filter: drop-shadow(0 0 20px rgba(0, 255, 136, 0.5)); }
    to { filter: drop-shadow(0 0 40px rgba(0, 204, 255, 0.8)); }
}

.username-section {
    margin-bottom: 30px;
}

#username-input {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    padding: 15px 25px;
    width: 300px;
    max-width: 90vw;
    border: 2px solid #00ff88;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    text-align: center;
    outline: none;
    transition: all 0.3s;
}

#username-input:focus {
    border-color: #00ccff;
    box-shadow: 0 0 20px rgba(0, 204, 255, 0.5);
}

#username-input::placeholder {
    color: #666;
}

.main-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    padding: 20px 60px;
    background: linear-gradient(135deg, #00ff88, #00ccff);
    border: none;
    border-radius: 15px;
    color: #000;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.main-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.7);
}

.main-btn:active {
    transform: scale(0.98);
}

.bottom-buttons {
    margin-top: 40px;
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.side-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    padding: 12px 25px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #444;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
}

.side-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #00ff88;
}

/* Modal */
.modal {
    background: rgba(20, 20, 30, 0.95);
    padding: 40px;
    border-radius: 20px;
    border: 2px solid #333;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #00ff88;
}

.modal h3 {
    margin: 20px 0 10px;
    font-size: 1rem;
    color: #888;
}

.back-btn {
    font-family: 'Orbitron', sans-serif;
    width: 100%;
    margin-top: 30px;
    padding: 15px;
    font-size: 1.1rem;
    background: #333;
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
}

.back-btn:hover {
    background: #444;
}

/* Customize Screen */
.color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.color-option:hover,
.color-option.selected {
    border-color: #fff;
    transform: scale(1.1);
}

.pattern-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.pattern-option {
    padding: 10px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.pattern-option:hover,
.pattern-option.selected {
    border-color: #00ff88;
    background: rgba(0, 255, 136, 0.2);
}

.preview-section {
    margin-top: 20px;
    text-align: center;
}

#preview-canvas {
    background: #111;
    border-radius: 10px;
    border: 1px solid #333;
}

/* Settings */
.setting-group {
    margin-bottom: 25px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #222;
}

.setting-row label {
    font-size: 0.9rem;
}

.setting-row select,
.setting-row input[type="range"] {
    background: #222;
    border: 1px solid #444;
    color: #fff;
    padding: 8px;
    border-radius: 5px;
    font-family: 'Orbitron', sans-serif;
}

.setting-row input[type="range"] {
    width: 120px;
}

.setting-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Game Canvas */
#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Leaderboard */
#leaderboard {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 20px;
    border-radius: 10px;
    border: 1px solid #333;
    min-width: 200px;
    z-index: 50;
}

#leaderboard h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #ffd700;
}

#leaderboard-list {
    list-style: none;
    font-size: 0.85rem;
}

#leaderboard-list li {
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #222;
}

#leaderboard-list li:last-child {
    border-bottom: none;
}

#leaderboard-list li.current-player {
    color: #00ff88;
    font-weight: bold;
}

#leaderboard-list .rank {
    width: 25px;
    color: #888;
}

#leaderboard-list .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 10px;
}

#leaderboard-list .score {
    color: #00ccff;
}

/* Player Stats */
#player-stats {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 20px;
    border-radius: 10px;
    border: 1px solid #333;
    z-index: 50;
}

#player-stats div {
    font-size: 0.9rem;
    margin: 5px 0;
}

#mana-value {
    color: #00ff88;
    font-weight: bold;
}

#rank-value {
    color: #ffd700;
}

/* Mobile Controls */
#mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    pointer-events: none;
    z-index: 60;
}

#mobile-controls.hidden {
    display: none;
}

#joystick-container {
    position: absolute;
    bottom: 30px;
    left: 30px;
    pointer-events: auto;
}

#joystick-base {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

#joystick-stick {
    width: 50px;
    height: 50px;
    background: rgba(0, 255, 136, 0.6);
    border: 2px solid #00ff88;
    border-radius: 50%;
    position: absolute;
    transition: transform 0.05s;
}

#boost-button {
    position: absolute;
    bottom: 40px;
    right: 30px;
    width: 100px;
    height: 100px;
    background: rgba(255, 100, 100, 0.3);
    border: 3px solid rgba(255, 100, 100, 0.6);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: bold;
    pointer-events: auto;
    transition: all 0.1s;
}

#boost-button:active,
#boost-button.active {
    background: rgba(255, 100, 100, 0.6);
    transform: scale(0.95);
}

/* Death Overlay */
#death-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#death-overlay.hidden {
    display: none;
}

.death-content {
    text-align: center;
    padding: 40px;
}

.death-content h2 {
    font-size: 3rem;
    color: #ff4444;
    margin-bottom: 20px;
}

.death-content p {
    font-size: 1.5rem;
    margin-bottom: 30px;
}

#final-score {
    color: #00ff88;
}

.death-content .main-btn {
    margin-bottom: 15px;
}

.death-content .side-btn {
    display: block;
    width: 200px;
    margin: 0 auto;
}

/* Responsive */
@media (max-width: 768px) {
    .game-title {
        font-size: 2.5rem;
    }
    
    #leaderboard {
        top: 10px;
        right: 10px;
        padding: 10px 15px;
        min-width: 150px;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }
    
    #leaderboard h3 {
        font-size: 0.85rem;
    }
    
    #leaderboard-list {
        font-size: 0.75rem;
    }
    
    #player-stats {
        top: 10px;
        left: 10px;
        padding: 10px 15px;
    }
    
    #player-stats div {
        font-size: 0.8rem;
    }
    
    .modal {
        padding: 25px;
    }
}
