* { box-sizing: border-box; }
body { margin: 0; background-color: #000; overflow: hidden; }

.hud {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    font-weight: 300;
    z-index: 999;
    pointer-events: none;
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 1.25rem 1.5rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 200px;
}

.hud-title {
    margin: 0 0 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
}

.hud-specs {
    margin: 0 0 1rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    line-height: 1.4;
}

.hud-controls {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.hud-controls li {
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    padding: 0 0.4rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.hud-status {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.75rem;
    font-weight: 500;
    min-height: 1.5rem;
}

.status-warning {
    color: #ff6b6b;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Multiplayer UI */
.multiplayer-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 999;
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.multiplayer-btn:hover {
    background: rgba(50, 50, 50, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
}

.multiplayer-btn.connected {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
}

.settings-btn {
    position: absolute;
    top: 1.5rem;
    right: 9rem;
    z-index: 999;
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    width: 2.5rem;
    height: 2.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-btn:hover {
    background: rgba(50, 50, 50, 0.8);
}

.settings-panel {
    position: absolute;
    top: 4.5rem;
    right: 1.5rem;
    z-index: 1000;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem;
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
}

.settings-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

.settings-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.settings-close:hover {
    color: #fff;
}

.settings-item {
    margin-bottom: 0.75rem;
}

.settings-item label {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.7rem;
    margin-bottom: 0.3rem;
}

.settings-item input[type="range"] {
    width: calc(100% - 2.5rem);
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.settings-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
}

.settings-value {
    display: inline-block;
    width: 2rem;
    text-align: right;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.75rem;
    font-family: 'SF Mono', 'Consolas', monospace;
}

.settings-reset {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0 0.3rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
}

.settings-reset.visible {
    opacity: 1;
    visibility: visible;
}

.settings-reset:hover {
    color: rgba(255, 255, 255, 0.8);
}

.settings-item select {
    width: 100%;
    padding: 0.4rem 0.5rem;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.75rem;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath fill='rgba(255,255,255,0.4)' d='M4 6L1 2h6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 1.5rem;
    transition: background 0.15s ease;
}

.settings-item select:hover {
    background: rgba(255, 255, 255, 0.1);
}

.settings-item select:focus {
    background: rgba(255, 255, 255, 0.1);
}

.settings-item select option {
    background: rgba(40, 40, 40, 0.98);
    color: rgba(255, 255, 255, 0.85);
}

.settings-item select option:checked {
    background: rgba(255, 255, 255, 0.15);
}

/* FPV Indicator */
.fpv-indicator {
    position: absolute;
    top: 4rem;
    right: 1.5rem;
    z-index: 999;
    background: rgba(239, 68, 68, 0.3);
    border: 1px solid rgba(239, 68, 68, 0.6);
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.fpv-indicator.active {
    opacity: 1;
    visibility: visible;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 1003;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.toast.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2rem;
    min-width: 320px;
    max-width: 90vw;
    color: rgba(255, 255, 255, 0.9);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-title {
    margin: 0 0 1.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
}

.modal-section {
    display: none;
}

.modal-section.active {
    display: block;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.modal-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

.modal-btn.primary {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.5);
}

.modal-btn.primary:hover {
    background: rgba(59, 130, 246, 0.4);
}

.modal-btn.danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

.modal-btn.danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

.room-code {
    text-align: center;
    margin: 1.5rem 0;
}

.room-code-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.room-code-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: #fff;
    font-family: 'SF Mono', 'Consolas', monospace;
}

.room-code-url {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    word-break: break-all;
    margin-top: 0.75rem;
}

.copy-url-btn {
    margin-top: 1rem;
    background: rgba(59, 130, 246, 0.3);
    border: 1px solid rgba(59, 130, 246, 0.5);
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.copy-url-btn:hover {
    background: rgba(59, 130, 246, 0.5);
}

.copy-url-btn.copied {
    background: rgba(34, 197, 94, 0.3);
    border-color: rgba(34, 197, 94, 0.5);
}

.waiting-text {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    animation: pulse 2s ease-in-out infinite;
}

.nickname-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    font-family: inherit;
    margin-bottom: 1rem;
}

.nickname-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.nickname-input:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.5);
}

.join-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 1rem;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-family: 'SF Mono', 'Consolas', monospace;
    margin-bottom: 1rem;
}

.join-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 0.1em;
}

.join-input:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.5);
}

/* Score Display */
.score-display {
    position: absolute;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 998;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-display.active {
    opacity: 1;
    visibility: visible;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
}

.score-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 0.25rem;
}

/* Match End Overlay */
.match-end-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
}

.match-end-overlay.active {
    opacity: 1;
    visibility: visible;
}

.match-result {
    font-size: 3.5rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 2rem;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
}

.match-result.victory {
    color: #22c55e;
}

.match-result.defeat {
    color: #ef4444;
}

/* Countdown Overlay */
.countdown-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
}

.countdown-overlay.active {
    opacity: 1;
    visibility: visible;
}

.countdown-number {
    font-size: 8rem;
    font-weight: 700;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.5);
    animation: countdownPulse 1s ease-in-out;
}

@keyframes countdownPulse {
    0% { transform: scale(1.3); opacity: 0; }
    15% { transform: scale(1); opacity: 1; }
    85% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0; }
}

/* Virtual Joysticks */
.joysticks-container {
    position: fixed;
    bottom: 2rem;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 999;
    pointer-events: none;
}

.joysticks-container.visible {
    display: flex;
}

.joystick {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.joystick-base {
    position: relative;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.joystick-stick {
    position: absolute;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: background 0.1s ease;
}

.joystick.active .joystick-stick {
    background: rgba(59, 130, 246, 0.6);
    border-color: rgba(59, 130, 246, 0.8);
}

.joystick-label {
    color: rgba(255, 255, 255, 0.6);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .hud {
        top: 1rem;
        left: 1rem;
        padding: 1rem;
        font-size: 0.85rem;
    }
    
    .multiplayer-btn {
        top: 1rem;
        right: 1rem;
        padding: 0.6rem 1rem;
        font-size: 0.75rem;
    }
}
