:root {
    --bg-color: #020617;
    --accent-color: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.4);
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: white;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

#utility-buttons {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 5;
}

#utility-buttons button {
    padding: 8px 16px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#utility-buttons button:hover {
    background: var(--accent-color);
    color: black;
}

.stat-box {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    padding: 16px 24px;
    border-radius: 16px;
    min-width: 200px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
    transition: transform 0.3s ease;
}

.stat-box:hover {
    transform: translateY(-2px);
    border-color: rgba(56, 189, 248, 0.3);
}

.stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

#fuel-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

#fuel-bar {
    height: 100%;
    background: var(--accent-color);
    width: 100%;
    transition: width 0.1s linear;
}

#message-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.8);
    padding: 40px;
    border-radius: 24px;
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    z-index: 10;
}

#message-title {
    font-size: 48px;
    font-weight: 800;
    margin: 0;
}

#message-subtitle {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.7);
}

button {
    background: var(--accent-color);
    color: black;
    border: none;
    padding: 12px 32px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    pointer-events: auto;
}

button:hover {
    transform: scale(1.05);
    background: white;
}

#controls-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

.key {
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 2px 6px;
    margin-right: 4px;
    color: white;
}

/* Leaderboard Styles */
#leaderboard-container {
    margin-top: 20px;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 10px;
    font-size: 14px;
}

.leaderboard-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-row:last-child {
    border-bottom: none;
}

.rank {
    color: var(--accent-color);
    font-weight: bold;
    width: 30px;
}

.name {
    flex-grow: 1;
    text-align: left;
    margin-left: 10px;
}

.time {
    font-family: 'JetBrains Mono', monospace;
}

#nickname-input-container {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
    width: 100%;
}

input[type="text"] {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    padding: 10px;
    border-radius: 8px;
    color: white;
    text-align: center;
    font-size: 16px;
    outline: none;
}

input[type="text"]:focus {
    border-color: var(--accent-color);
}

/* Feedback Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 30px;
    border-radius: 20px;
    width: 320px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    pointer-events: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--accent-color);
}

.form-group {
    margin-bottom: 15px;
}

.form-group input, 
.form-group textarea {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.btn-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 20px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: none;
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 20px;
    width: 100%;
    height: 120px;
    display: none; /* Hidden by default on desktop */
    justify-content: space-between;
    padding: 0 40px;
    box-sizing: border-box;
    pointer-events: none; /* Let clicks pass through empty space */
}

@media (max-width: 1024px) {
    #mobile-controls {
        display: flex;
    }
    #controls-hint {
        display: none; /* Hide keyboard hints on mobile */
    }
    
    /* Scale down HUD for mobile */
    #hud {
        gap: 5px;
        top: 10px;
        left: 10px;
    }
    .stat-box {
        padding: 8px 12px;
        min-width: 100px;
        border-radius: 10px;
    }
    .stat-label {
        font-size: 8px;
        margin-bottom: 2px;
    }
    .stat-value {
        font-size: 12px;
    }
}

.control-group-left {
    display: flex;
    gap: 20px;
    pointer-events: auto;
}

.touch-btn {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    font-size: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
    transition: background 0.1s, transform 0.1s;
}

.touch-btn:active, .touch-btn.active {
    background: rgba(56, 189, 248, 0.4);
    border-color: var(--accent-color);
    transform: scale(0.95);
}

#btn-thrust {
    width: 100px;
    height: 100px;
    background: rgba(239, 68, 68, 0.2); /* Reddish tint for thrust */
    font-size: 40px;
    pointer-events: auto;
}

#btn-thrust:active, #btn-thrust.active {
    background: rgba(239, 68, 68, 0.5);
}
