body {
    margin: 0;
    overflow: hidden;
    background-color: #87CEEB;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
}

/* Prevent text selection and default tap highlights on interactive elements */
.btn, 
.mobile-btn, 
.sub-btn, 
.station-btn, 
.color-swatch,
.customization-input {
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none;      /* IE 10+ */
    user-select: none;          /* Standard */
    
    /* Disables the blue/gray highlight box that appears on tap in mobile browsers */
    -webkit-tap-highlight-color: transparent;
    
    /* Prevents the browser from showing the "Copy/Paste" callout on long-press */
    -webkit-touch-callout: none;
}

/* Ensure inputs still allow text entry if you want users to type their Callsign */
#player-name-input {
    -webkit-user-select: text;
    user-select: text;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 15px;
    padding: 30px;
    box-sizing: border-box;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
}





#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 100;
    backdrop-filter: blur(5px);
}

#pause-overlay h1 {
    font-size: 48px;
    margin-bottom: 10px;
    letter-spacing: 5px;
    font-weight: 300;
}

.btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 24px;
    font-size: 18px;
    cursor: pointer;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
    margin-top: 20px;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.customization-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 280px;
    backdrop-filter: blur(10px);
}

.customization-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.customization-label {
    font-size: 14px;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.customization-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 16px;
    outline: none;
    width: 100%;
}

.customization-input:focus {
    border-color: rgba(255, 255, 255, 0.5);
}

/* Hide number input spinners */
input[type=number].customization-input::-webkit-inner-spin-button,
input[type=number].customization-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number].customization-input {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Android TV UI Focus */
.tv-focused {
    transform: scale(1.1) !important;
    outline: 4px solid yellow !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8) !important;
}

.color-swatch.tv-focused,
.station-btn.tv-focused,
.btn.tv-focused {
    transform: scale(1.15) !important;
}

.color-picker-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    max-width: 140px;
}

.color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.8);
}

.color-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transform: scale(1.15);
}

#cockpit-ui {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 8px;
    backdrop-filter: blur(8px);
    color: white;
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 50;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    box-sizing: border-box;
}

.cockpit-grid {
    display: grid;
    grid-template-columns: auto auto auto;
    grid-template-rows: auto auto;
    column-gap: 25px;
    row-gap: 8px;
}

.cockpit-module {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.cockpit-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    width: 35px;
    text-align: right;
}

.cockpit-value {
    font-size: 14px;
    font-weight: bold;
    font-family: 'Courier New', Courier, monospace;
    color: #FFD700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    min-width: 60px;
}

#station-name {
    font-weight: bold;
    color: #FFD700;
    display: inline-block;
    width: 120px;
}

#radio-panel {
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 4px;
}

#radio-panel:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

.station-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    min-width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0 4px;
    touch-action: none;
}

.station-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.station-btn.active {
    background: #FFD700;
    color: #000;
    border-color: #FFD700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.station-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

#yt-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 220px;
    height: 124px;
    background: #111;
    border: 4px solid #222;
    border-bottom-width: 8px;
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(0, 0, 0, 1);
    overflow: hidden;
    display: none;
    z-index: 49;
    transition: opacity 0.3s;
}

#debug-menu {
    position: absolute;
    top: 100px;
    left: 30px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    font-family: monospace;
    display: none;
    z-index: 100;
    pointer-events: auto;
    width: 200px; /* Added fixed width for consistency */
}

#debug-telemetry {
    position: absolute;
    top: 100px;
    right: 30px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    font-family: monospace;
    display: none;
    z-index: 100;
    pointer-events: auto;
    width: 220px;
}

#debug-menu button {
    background: #444;
    color: white;
    border: none;
    padding: 5px 10px;
    margin: 2px;
    cursor: pointer;
    border-radius: 4px;
}

#debug-menu button.active {
    background: #FFD700;
    color: black;
}

/* Screen glare effect over the video */
#yt-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.2) 100%);
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.9);
    border-radius: 4px;
}

/* Mobile Controls Redesign */
#mobile-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 500px;
    display: flex;
    gap: 10px;
    z-index: 60;
}

.mobile-btn {
    flex: 1;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.mobile-btn svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
    opacity: 0.9;
}

.mobile-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

.mobile-btn.active {
    background: #FFD700;
    color: #000;
    border-color: #FFD700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.menu-container {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
}

.menu-container .mobile-btn {
    width: 100%;
}

/* The Sub-Menu Animation */
.menu-items {
    position: absolute;
    bottom: 60px; /* Reduced from 75px to close the 15px gap */
    display: flex;
    flex-direction: column;
    gap: 15px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%; /* Match trigger button width */
    padding-bottom: 15px; /* Maintain visual gap while ensuring container covers the space */
}

.menu-container.expanded .menu-items {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* The Chevron Rotation */
#chevron-icon {
    transition: transform 0.4s ease;
}

.menu-container.expanded #chevron-icon {
    transform: rotate(180deg);
}

.sub-btn {
    width: 100%;
    height: 60px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sub-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}




#online-players {
    position: absolute;
    top: 100px;
    right: 30px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    width: 180px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

#online-players.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#online-title {
    font-size: 10px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 2px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
}

.player-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    margin-bottom: 4px;
    color: #eee;
}

.player-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 110px;
}

.player-info {
    display: flex;
    gap: 8px;
    align-items: center;
}

.player-dist {
    font-family: monospace;
    font-size: 11px;
    color: #FFD700;
    min-width: 45px;
    text-align: right;
}

.player-dir {
    font-family: monospace;
    font-size: 11px;
    color: #aaa;
    min-width: 25px;
    text-align: right;
}

.player-self {
    color: #fff;
    font-weight: bold;
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1a1a2e 0%, #0f0f1a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
    transition: opacity 0.8s ease-out, visibility 0.8s;
}

.loading-content {
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 40px 20px;
    border-radius: 24px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
    max-width: 450px;
    width: 90%;
    box-sizing: border-box;
}

.loading-title {
    font-size: 32px;
    font-weight: 200;
    letter-spacing: 12px;
    line-height: 1.6;
    margin: 0 0 40px 0;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    text-transform: uppercase;
}

.loading-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin: 20px 0;
    overflow: hidden;
}

#loading-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 0 10px rgba(79, 172, 254, 0.8);
    transition: width 0.4s ease;
}

#loading-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 0;
}

#begin-btn {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.2);
    }

    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(255, 255, 255, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

@media (max-width: 1024px) {
    .desktop-only {
        display: none !important;
    }


    #cockpit-ui {
        top: 0px;
        bottom: auto;
        left: 0;
        transform: none;
        width: 100%;
        border-radius: 0;
        border-top: none;
        border-left: none;
        border-right: none;
        justify-content: center;
        padding: 5px 10px;
    }

    @media (max-width: 500px) {
        #cockpit-ui {
            padding: 4px 8px;
            gap: 10px;
        }

        .cockpit-grid {
            column-gap: 12px;
            row-gap: 4px;
        }

        .cockpit-label {
            width: 28px;
            font-size: 8px;
        }

        .cockpit-value {
            font-size: 11px;
            min-width: 45px;
        }
        
        #station-name {
            font-size: 10px;
            width: 100px;
        }
    }

    .loading-content {
        padding: 40px 20px;
    }

    .loading-title {
        font-size: 24px;
        letter-spacing: 6px;
    }
}

/* TV Overscan Safety Margin */
@media screen and (tv) {
    #mobile-controls {
        display: none !important;
    }

    #cockpit-ui,
    #ui-layer {
        margin: 5%;
        width: 90% !important;
        height: 90% !important;
        box-sizing: border-box;
    }

    #ui-layer {
        position: absolute;
        top: 0;
        left: 0;
    }
}