/* Add these variables to the top of your CSS file */
:root {
    --stable-viewport-height: 100vh;
}

/* For mobile devices, use the stable viewport height */
.is-mobile-device #scanner-panel {
    max-height: calc(var(--stable-viewport-height) * 0.6);
    top: 50%;
    transform: translateY(-50%) translateX(-50%);
}

.is-mobile-device #radar {
    width: min(70vw, calc(var(--stable-viewport-height) * 0.7));
    height: min(70vw, calc(var(--stable-viewport-height) * 0.7));
}

.grayscale {
    -moz-filter: grayscale(100%);
    -webkit-filter: grayscale(100%);
    filter: gray; /* IE6-9 */
    filter: grayscale(100%);
}

/* Prevent scrolling and bouncing on mobile */
html.is-mobile-device {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background-color: black;
    font-family: 'Orbitron', Arial, sans-serif;
}

/* Only prevent pull-to-refresh on the top level */
#game-controls-container,
#toggle-controls-container,
.hud-panel,
.target-bracket {
    overscroll-behavior: none;
}

canvas {
    display: block;
    touch-action: auto;
}

.mobile-only {
    display: inline-flex;
}

.desktop-only {
    display: none;
}

.hud-panel {
    background-color: rgba(0, 35, 66, 0.6);
    border: 1px solid #00a2ff;
    box-shadow: 0 0 10px rgba(0, 162, 255, 0.5);
    border-radius: 4px;
    color: #7fdbff;
    text-shadow: 0 0 5px rgba(127, 219, 255, 0.5);
    pointer-events: none;
    user-select: none;
    z-index: 10;
}

.panel-header {
    padding: 2px 8px;
    font-size: 11px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #00a2ff;
    background-color: rgba(0, 40, 80, 0.6);

}

#info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 400px;
    color: #7fdbff;
    background-color: rgba(0, 35, 66, 0.9); /* Darker background like modal panels */
    border: 2px solid #00a2ff;
    box-shadow: 0 0 20px rgba(0, 162, 255, 0.7);
    padding: 15px;
    border-radius: 6px;
    font-size: 1rem;
    display: none; /* Hidden by default for mobile */
    z-index: 1100; /* Same z-index as modal panels */
    font-family: 'Orbitron', Arial, sans-serif;
    max-height: 80vh; /* Maximum height based on viewport */
    overflow-y: auto; /* Enable scrolling */
}

#info h2 {
    text-align: center;
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #00a2ff;
    padding-bottom: 8px;
}

#ship-panel {
    position: absolute;
    top: 75px; /* Positioned under system name on mobile */
    left: 20px;
    width: 180px; /* Same width as system name panel */
    padding: 0;
}

#ship-stats {
    padding: 4px; /* Reduced padding for mobile */
}

#ship-name {
    font-size: 12px; /* Smaller font for mobile */
    margin-bottom: 5px; /* Reduced spacing for mobile */
    color: #fff;
}

.stat-group {
    margin-bottom: 5px; /* Reduced spacing for mobile */
}

.stat-bar-container {
    position: relative;
    height: 16px; /* Reduced height for mobile */
    background-color: rgba(0, 25, 46, 0.7);
    border: 1px solid #004a77;
    border-radius: 2px;
    overflow: hidden;
}

.stat-bar {
    height: 100%;
    width: 100%;
    float: right;
}

.stat-label {
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px; /* Smaller font for mobile */
    color: #fff;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
    z-index: 2;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.power-bar {
    background: linear-gradient(to left, #8b46ff var(--percent, 100%), transparent var(--percent, 100%));
    border-right: 1px solid rgba(33, 0, 80, 0.7);
}

.speed-container {
    display: flex;
    align-items: center;
    height: 14px; /* Reduced height for mobile */
    background: none;
    border: none;
    justify-content: flex-end;
}

.speed-value {
    position: static;
    transform: none;
    font-size: 11px; /* Smaller font for mobile */
    /*margin-right: 5px;*/
}

#target-panel {
    position: absolute;
    bottom: 20px; /* Moved to bottom on mobile */
    left: 20px; /* Aligned with left edge */
    transform: none; /* Remove the centering transform */
    width: 55vw; /* Reduced width to make space for buttons */
    max-width: 240px;
    padding: 0;
}

#target-info {
    padding: 4px;
}

#target-details {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

#target-name {
    font-size: 12px;
    color: #fff;
}

#target-distance {
    font-size: 12px;
    opacity: 0.8;
}

.health-bar {
    display: flex;
    height: 16px;
    margin-bottom: 4px;
    overflow: hidden;
    border-radius: 2px;
    border: 1px solid #004a77;
    background-color: rgba(0, 25, 46, 0.5);
}

.health-segment {
    position: relative;
    height: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.shield-segment {
    background: linear-gradient(to left, #3a9fff var(--percent, 100%), transparent var(--percent, 100%));
    border-right: 1px solid rgba(0, 40, 80, 0.7);
}

.armor-segment {
    background: linear-gradient(to left, #ffcc00 var(--percent, 100%), transparent var(--percent, 100%));
    border-right: 1px solid rgba(0, 40, 80, 0.7);
}

.hull-segment {
    background: linear-gradient(to left, #ff3333 var(--percent, 100%), transparent var(--percent, 100%));
}

.target-buttons {
    display: flex;
    justify-content: space-between;
    gap: 5px;
    height: 2rem;
}

.target-action-button {
    background-color: rgba(0, 35, 66, 0.8);
    color: #7fdbff;
    border: 1px solid #004a77;
    padding: 3px 4px; /* Reduced padding for mobile */
    cursor: pointer;
    font-family: 'Orbitron', Arial, sans-serif;
    font-size: 10px; /* Smaller font for mobile */
    transition: all 0.2s;
    flex: 1;
    pointer-events: auto;
}

.target-action-button:hover {
    background-color: rgba(0, 162, 255, 0.3);
    border-color: #00a2ff;
}

.target-action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#radar {
    pointer-events: none;

    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    flex-direction: column;
    width: min(70vw, 70vh);
    height: min(70vw, 70vh);
    display: none;
}


#radar-container {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: rgba(0, 35, 66, 0.6);
    border: 1px solid #00a2ff;
    box-shadow: 0 0 10px rgba(0, 162, 255, 0.5);
    position: relative;
    overflow: hidden;
}

#radar-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.radar-circle {
    position: absolute;
    border: 1px solid rgba(127, 219, 255, 0.3);
    border-radius: 50%;
}

.radar-line {
    position: absolute;
    background-color: rgba(127, 219, 255, 0.3);
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    transform-origin: center;
}

.radar-dot {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.radar-sweep {
    position: absolute;
    top: 0;
    left: 50%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, rgba(127, 219, 255, 0.1) 0%, rgba(127, 219, 255, 0) 100%);
    transform-origin: left center;
    animation: radar-sweep 3s infinite linear;
}

@keyframes radar-sweep {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#scanner-panel {
    padding: 0;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    z-index: 200;
    display: none;
    flex-direction: column;
    height: 60%;
    max-height: 500px;
}

.scanner-filters {
    display: flex;
    padding: 8px;
    background-color: rgba(0, 35, 66, 0.8);
    border-bottom: 1px solid #00a2ff;
    z-index: 2;
    pointer-events: auto;
}

.filter-button {
    background-color: rgba(0, 35, 66, 0.8);
    color: #7fdbff;
    border: 1px solid #004a77;
    padding: 4px 4px;
    cursor: pointer;
    font-family: 'Orbitron', Arial, sans-serif;
    font-size: 10px;
    transition: all 0.2s;
    flex: 1;
    margin: 0 2px;
    overflow: hidden;
    min-height: 40px;
}

.filter-button.active {
    background-color: rgba(0, 162, 255, 0.3);
    border-color: #00a2ff;
}

#scanner-scroll-container {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #00a2ff rgba(0, 35, 66, 0.4);
}

#scanner-scroll-container::-webkit-scrollbar {
    width: 6px;
}

#scanner-scroll-container::-webkit-scrollbar-track {
    background: rgba(0, 35, 66, 0.4);
}

#scanner-scroll-container::-webkit-scrollbar-thumb {
    background-color: #00a2ff;
    border-radius: 3px;
}

.scanner-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    margin: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s;
    pointer-events: auto;
}

.scanner-item:hover {
    background-color: rgba(0, 162, 255, 0.3);
}

.scanner-item.selected {
    background-color: rgba(0, 162, 255, 0.5);
}

.scanner-icon {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 10px;
}

.scanner-name {
    flex-grow: 1;
    font-size: 12px;
}

.scanner-distance {
    color: rgba(127, 219, 255, 0.7);
    font-size: 11px;
    min-width: 70px;
    text-align: right;
}

.scanner-type {
    color: rgba(127, 219, 255, 0.5);
    font-size: 11px;
    min-width: 70px;
    text-align: right;
    margin-right: 10px;
}

/* Scanner bottom close button - only for mobile */
.scanner-bottom-close {
    margin-top: 10px;
    background-color: rgba(0, 35, 66, 0.8);
    color: #7fdbff;
    border: 1px solid #004a77;
    border-radius: 4px;
    padding: 8px 12px;
    text-align: center;
    font-family: 'Orbitron', Arial, sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    display: block;
    pointer-events: auto;
}

.scanner-bottom-close:hover, .scanner-bottom-close:active {
    background-color: rgba(0, 162, 255, 0.3);
    border-color: #00a2ff;
}

#location-indicator {
    position: absolute;
    top: 30px; /* Adjusted to clear the build signature */
    left: 20px;
    padding: 6px 8px; /* Reduced padding for mobile */
    text-align: left;
    font-size: 10px; /* Smaller font for mobile */
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px; /* Reduced letter spacing for mobile */
    max-width: 165px; /* Limit width for mobile */
    white-space: normal; /* Allow text wrapping */
    overflow: visible; /* Allow overflow */
    text-overflow: clip; /* No ellipsis needed since we wrap */
    line-height: 1.2; /* Tighter line height */
    height: auto; /* Auto height to accommodate wrapped text */
}

#targeting-brackets {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.target-bracket {
    position: absolute;
    border: 1px solid #ff3333;
    width: 40px;
    height: 40px;
    transition: all 0.1s;
}

.target-bracket.friendly {
    border-color: #33ff33;
}

.target-bracket.neutral {
    border-color: #ffcc00;
}

.bracket-corner {
    position: absolute;
    width: 10px;
    height: 10px;
    border-color: inherit;
    border-style: solid;
    border-width: 0;
}

.bracket-label {
    position: absolute;
    top: -20px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: inherit;
}

.bracket-distance {
    position: absolute;
    bottom: -20px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: inherit;
}

#damage-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(255, 0, 0, 0) 70%, rgba(255, 0, 0, 0.5) 100%);
    opacity: 0;
    pointer-events: none;
    z-index: 6;
    transition: opacity 0.2s;
}

#warp-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(0, 162, 255, 0) 0%, rgba(0, 162, 255, 0.5) 100%);
    opacity: 0;
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.5s;
}

#docking-interface {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%; /* Change to percentage width */
    max-width: 350px; /* Set maximum width to the original value */
    background-color: rgba(0, 35, 66, 0.9);
    border: 2px solid #00a2ff;
    box-shadow: 0 0 20px rgba(0, 162, 255, 0.7);
    border-radius: 6px;
    font-family: 'Orbitron', Arial, sans-serif;
    color: #fff;
    z-index: 1000;
    display: none;
}

#docking-interface h2 {
    text-align: center;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #00a2ff;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 18px;
}

.docking-button {
    display: block;
    width: 94%;
    padding: 12px;
    margin: 10px;
    background-color: rgba(0, 80, 160, 0.8);
    border: 1px solid #00a2ff;
    border-radius: 4px;
    color: #7fdbff;
    font-family: 'Orbitron', Arial, sans-serif;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.docking-button:hover {
    background-color: rgba(0, 120, 200, 0.8);
    transform: scale(1.02);
}

.docking-button:active {
    transform: scale(0.98);
}

#close-docking {
    background-color: rgba(100, 30, 30, 0.8);
    border-color: #ff6666;
}

#close-docking:hover {
    background-color: rgba(150, 50, 50, 0.8);
}

/* Updated Mission Panel for mobile-first approach */
.mission-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%; /* Changed from fixed 500px to 90% for mobile */
    max-width: 450px; /* Added max-width for very small screens */
    background-color: rgba(0, 35, 66, 0.9);
    border: 2px solid #00a2ff;
    box-shadow: 0 0 30px rgba(0, 162, 255, 0.7);
    border-radius: 6px;
    color: #fff;
    z-index: 1000;
    display: none;
    font-family: 'Orbitron', Arial, sans-serif;
}

.mission-content {
    padding: 15px; /* Reduced from 25px */
    text-align: center;
}

.mission-panel h2 {
    margin: 0 0 15px 0; /* Reduced from 20px */
    padding-bottom: 8px; /* Reduced from 10px */
    border-bottom: 1px solid #00a2ff;
    text-transform: uppercase;
    letter-spacing: 1px; /* Reduced from 2px */
    font-size: 18px; /* Reduced from 20px */
    text-shadow: 0 0 10px rgba(0, 162, 255, 0.7);
}

.mission-panel p {
    margin: 10px 0; /* Reduced from 12px */
    font-size: 14px; /* Reduced from 16px */
    line-height: 1.4; /* Reduced from 1.5 */
    color: #7fdbff;
}

.mission-button {
    display: block;
    width: 90%; /* Increased from 80% */
    margin: 20px auto 10px auto; /* Reduced top margin */
    padding: 12px; /* Reduced from 15px */
    background-color: rgba(0, 80, 160, 0.8);
    border: 1px solid #00a2ff;
    border-radius: 4px;
    color: #fff;
    font-family: 'Orbitron', Arial, sans-serif;
    font-size: 14px; /* Reduced from 16px */
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px; /* Reduced from 2px */
}

.mission-button:hover {
    background-color: rgba(0, 120, 200, 0.8);
    box-shadow: 0 0 15px rgba(0, 162, 255, 0.7);
    transform: scale(1.05);
}

.mission-button:active {
    transform: scale(0.98);
}

/* Updated info panel with hide button */
.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.info-header h2 {
    margin: 0;
}

.hide-button {
    background-color: rgba(0, 50, 100, 0.7);
    color: #7fdbff;
    border: 1px solid #00a2ff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.hide-button:hover {
    background-color: rgba(0, 120, 200, 0.8);
}

/* Toggle Controls Container */
#toggle-controls-container {
    position: absolute;
    top: 30px;
    right: 20px;
    display: flex;
    gap: 5px;
    z-index: 100;
}

/* Fix toggle controls position on short screens */
@media (max-height: 350px) {
    #toggle-controls-container {
        right: 85px; /* Move left to avoid overlap with dock button */
    }
}

/* Responsive layout for toggle controls on small screens */
@media (max-width: 410px) {
    #toggle-controls-container {
        width: 130px; /* Width to fit 3 buttons in first row (30px each + 5px gaps) */
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    #toggle-controls-container > div {
        margin-bottom: 5px; /* Add space between rows */
    }

    /* This will make the last button (sound toggle) wrap to second row and align right */
    #sound-toggle {
        margin-left: auto;
    }
}

#graphics-toggle, #color-toggle {
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
}

#sound-toggle {
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
}

.sound-button {
    background-color: rgba(0, 35, 66, 0.8);
    color: #7fdbff;
    border: 1px solid #00a2ff;
    box-shadow: 0 0 10px rgba(0, 162, 255, 0.5);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.sound-button:hover {
    background-color: rgba(0, 162, 255, 0.3);
}

.sound-button.muted .sound-icon:after {
    position: absolute;
}

#build-signature {
    position: absolute;
    top: 5px; /* Positioned at the very top */
    left: 50%; 
    transform: translateX(-50%);
    width: 90%; /* Wider for mobile */
    font-size: 10px; /* Smaller font for mobile */
    letter-spacing: 0.5px;
    color: rgba(127, 219, 255, 0.6);
    background-color: rgba(0, 25, 45, 0.35);
    border-radius: 4px;
    padding: 3px 6px;
    z-index: 10;
    font-family: 'Orbitron', Arial, sans-serif;
    font-weight: 300;
    backdrop-filter: blur(2px);
    line-height: 1.2; /* Added line height for better readability */
    text-align: center;
}

#build-signature .divider {
    margin: 0 4px;
    opacity: 0.7;
}

#build-signature a {
    color: rgba(127, 219, 255, 0.7);
    text-decoration: none;
    transition: color 0.2s, opacity 0.2s;
}

#build-signature a:hover {
    color: rgba(255, 255, 255, 0.9);
}

#help-toggle {
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
}

.help-button {
    background-color: rgba(0, 35, 66, 0.8);
    color: #7fdbff;
    border: 1px solid #00a2ff;
    box-shadow: 0 0 10px rgba(0, 162, 255, 0.5);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.help-button:hover {
    background-color: rgba(0, 162, 255, 0.3);
}

/* Game Controls Container and Columns */
#game-controls-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.controls-column {
    display: flex;
    flex-direction: column-reverse; /* Buttons from bottom to top */
    gap: 8px;
}

.game-control-button {
    background-color: rgba(0, 35, 66, 0.85);
    color: #7fdbff;
    border: 1px solid #00a2ff;
    box-shadow: 0 0 8px rgba(0, 162, 255, 0.5), inset 0 0 15px rgba(0, 100, 200, 0.3);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    overflow: hidden;
}

.game-control-button:hover {
    background-color: rgba(0, 60, 100, 0.9);
    border-color: #3fb8ff;
    box-shadow: 0 0 12px rgba(0, 162, 255, 0.7), inset 0 0 20px rgba(0, 120, 240, 0.4);
    transform: scale(1.05);
}

.game-control-button:active, .game-control-button.button-active {
    transform: scale(0.95);
    background-color: rgba(0, 80, 140, 0.95);
    box-shadow: 0 0 8px rgba(0, 162, 255, 0.6), inset 0 0 10px rgba(0, 140, 255, 0.5);
}

.control-icon {
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

/* Special styling for text-based icons to make them more visually appealing */
#emergency-stop .control-icon,
#increase-throttle .control-icon,
#reduce-throttle .control-icon {
    font-size: 26px;
    font-weight: bold;
}

#toggle-radar .control-icon {
    font-size: 30px; /* Larger for the concentric circles */
}

#cycle-targets .control-icon {
    font-size: 28px; /* Larger for the crosshair */
}

.graphics-button {
    background-color: rgba(0, 35, 66, 0.8);
    color: #7fdbff;
    border: 1px solid #00a2ff;
    box-shadow: 0 0 10px rgba(0, 162, 255, 0.5);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.graphics-button:hover {
    background-color: rgba(0, 162, 255, 0.3);
}

.modal-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%; /* Changed to percentage for mobile-first */
    max-width: 400px; /* Original max width */
    background-color: rgba(0, 35, 66, 0.9);
    border: 2px solid #00a2ff;
    box-shadow: 0 0 20px rgba(0, 162, 255, 0.7);
    border-radius: 6px;
    font-family: 'Orbitron', Arial, sans-serif;
    color: #fff;
    z-index: 1100;
    display: none;
}

.modal-content {
    padding: 15px; /* Reduced padding for mobile */
}

.modal-content h2 {
    text-align: center;
    margin: 0 0 15px 0; /* Reduced margin for mobile */
    padding-bottom: 8px; /* Reduced padding for mobile */
    border-bottom: 1px solid #00a2ff;
    text-transform: uppercase;
    letter-spacing: 1px; /* Reduced letter spacing for mobile */
    font-size: 16px; /* Reduced font size for mobile */
}

.settings-options {
    margin-bottom: 15px; /* Reduced margin for mobile */
}

.setting-option {
    margin: 10px 0; /* Reduced margin for mobile */
    padding: 6px; /* Reduced padding for mobile */
    border-radius: 4px;
    transition: background-color 0.2s;
    font-size: 13px; /* Smaller font for mobile */
}

.setting-option:hover {
    background-color: rgba(0, 162, 255, 0.1);
}

.setting-option input[type="radio"] {
    margin-right: 10px;
}

.modal-buttons {
    display: flex;
    justify-content: space-between;
    gap: 8px; /* Reduced gap for mobile */
}

.modal-buttons .docking-button {
    padding: 8px; /* Reduced padding for mobile */
    font-size: 13px; /* Smaller font for mobile */
}

/* Style the initial quality notification */
.quality-notification {
    background-color: rgba(66, 33, 0, 0.9) !important; /* Darker orange background */
    border: 1px solid #ff7700 !important; /* Bright orange border */
    box-shadow: 0 0 10px rgba(255, 119, 0, 0.7) !important; /* Orange glow */
    color: #ffcc99 !important; /* Light orange text */
    width: 85% !important; /* Mobile-first width */
    max-width: 450px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    font-size: 16px !important; /* Smaller font for mobile */
    padding: 10px !important; /* Reduced padding for mobile */
    text-align: center !important;
}

/* Changelog styles */
#build-signature span:first-child {
    cursor: pointer;
    transition: color 0.2s, opacity 0.2s;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

#build-signature span:first-child:hover {
    color: rgba(255, 255, 255, 0.9);
}

#changelog-modal {
    display: none;
    z-index: 2000;
    max-width: 600px;
    max-height: 80vh;
    color: #7fdbff;
}

.changelog-content {
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    padding: 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px 10px;
    border-bottom: 1px solid #00a2ff;
}

.modal-header h2 {
    margin: 0;
    padding: 0;
    border: none;
}

.close-button {
    background: none;
    border: 1px solid #004a77;
    color: #7fdbff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.close-button:hover {
    background-color: rgba(0, 162, 255, 0.3);
    border-color: #00a2ff;
}

.changelog-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px 20px;
    max-height: 60vh;
    scrollbar-width: thin;
    scrollbar-color: #00a2ff rgba(0, 35, 66, 0.4);
}

.changelog-body::-webkit-scrollbar {
    width: 6px;
}

.changelog-body::-webkit-scrollbar-track {
    background: rgba(0, 35, 66, 0.4);
}

.changelog-body::-webkit-scrollbar-thumb {
    background-color: #00a2ff;
    border-radius: 3px;
}

.changelog-entry {
    font-size: 14px;
    margin-bottom: 25px;
    animation: fadeIn 0.5s;
}

.changelog-entry h3 {
    margin: 0 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(0, 162, 255, 0.3);
    color: #7fdbff;
}

.changelog-entry ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.changelog-entry li {
    margin: 8px 0;
    padding-left: 20px;
    position: relative;
    line-height: 1.5;
}

.changelog-entry li:before {
    content: "•";
    position: absolute;
    left: 5px;
    color: #00a2ff;
}

.tag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    margin-right: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tag.feature {
    background-color: rgba(0, 153, 51, 0.3);
    border: 1px solid rgba(0, 204, 102, 0.7);
    color: #00ff66;
}

.tag.bugfix {
    background-color: rgba(204, 51, 0, 0.3);
    border: 1px solid rgba(255, 102, 0, 0.7);
    color: #ff6633;
}

.tag.improvement {
    background-color: rgba(0, 102, 204, 0.3);
    border: 1px solid rgba(51, 153, 255, 0.7);
    color: #33ccff;
}

.tag.performance {
    background-color: rgba(153, 51, 204, 0.3);
    border: 1px solid rgba(204, 102, 255, 0.7);
    color: #cc99ff;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 900;
    display: none;
    animation: fadeIn 0.3s;
}

/* Mobile Panel Overlay and Close Button Styles */
.mobile-close-button {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 30px;
    height: 30px;
    background-color: rgba(0, 35, 66, 0.8);
    color: #7fdbff;
    border: 1px solid #00a2ff;
    box-shadow: 0 0 10px rgba(0, 162, 255, 0.5);
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: auto;
}

.mobile-close-button:hover, .mobile-close-button:active {
    background-color: rgba(0, 120, 200, 0.8);
}

/* Make scanner items more touchable */
.scanner-item {
    padding: 12px 8px;
    margin: 3px 8px;
}

/* Mobile/Desktop Controls Info Styling */
.mobile-controls-info {
    display: block; /* Shown by default on mobile */
}

.desktop-controls-info {
    display: none; /* Hidden by default on mobile */
}

.controls-section {
    margin-bottom: 15px;
}

.controls-section h3 {
    margin: 0 0 5px 0;
    font-size: 14px;
    color: #33ccff;
    text-transform: uppercase;
}

.controls-section p {
    margin: 0;
    line-height: 1.6;
}

.tip {
    margin-top: 10px;
    padding: 8px;
    background-color: rgba(0, 162, 255, 0.1);
    border-left: 2px solid #00a2ff;
    font-size: 12px;
}

.mobile-controls-info .control-icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    text-align: center;
    background-color: rgba(0, 35, 66, 0.8);
    border: 1px solid #00a2ff;
    border-radius: 50%;
    margin-right: 8px;
    font-size: 14px;
    line-height: 24px;
    vertical-align: middle;
}

/* Smartphone horizontal */
@media (min-width: 667px) and (max-width: 932px) and (min-height: 344px) and (max-height: 540px) {
    #info {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-height: 90vh;
        max-width: 90vw;
        overflow-y: auto;
    }

    .mobile-controls-info {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .controls-section {
        width: 32%; /* Change to roughly 1/3 width */
        margin-bottom: 10px;
    }

    .controls-section h3 {
        font-size: 12px;
    }

    .controls-section p {
        font-size: 12px;
        line-height: 1.4;
    }

    .tip {
        width: 100%;
        margin-top: 5px;
        font-size: 11px;
        padding: 5px;
    }

    .mobile-controls-info .control-icon {
        width: 20px;
        height: 20px;
        font-size: 12px;
        line-height: 20px;
        margin-right: 5px;
    }

    /* Adjust build signature for horizontal mobile */
    #build-signature {
        width: auto;
        max-width: 50%;
        top: 3px;
    }

    /* Move up system name and ship status panels */
    #location-indicator {
        top: 20px;
    }

    #ship-panel {
        top:65px;
    }

    /* Move up toggle controls */
    #toggle-controls-container {
        top: 20px;
    }

    /* Optimize controls panel for landscape */
    .mobile-controls-info {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .controls-section {
        width: 32%; /* Show 3 columns side by side */
        margin-bottom: 10px;
    }

    .tip {
        width: 100%;
    }

    /* Make sure the panel is scrollable if needed */
    #info {
        max-height: 80vh;
        max-width: 90vw;
        overflow-y: auto;
    }

    .game-control-button {
        width: 50px;
        height: 50px;
    }
}

/* Tablet vertical or Tablet vertical, or Desktop common*/
@media (min-height: 1024px) and (max-height: 1366px) and (min-width: 600px) and (max-width: 1024px),
(min-width: 1024px) and (max-width: 1366px) and (min-height: 600px) and (max-height: 1024px),
(min-width: 1367px) and (min-height: 600px) {
    .game-control-button {
        width: 60px;
        height: 60px;
    }

    .controls-column {
        gap: 12px;
    }

    #radar {
        display: block;
        position: absolute;
        top: auto;
        bottom: 180px;
        left: 20px;
        transform: none;
        width: 240px;
        height: 240px;
        pointer-events: none;
    }

    #hide-radar {
        display: none;
    }

    /*#toggle-radar {*/
    /*    pointer-events: none;*/
    /*    background-color: rgba(131, 131, 131, 0.13);*/
    /*    color: rgba(171, 171, 171, 0.36);*/
    /*    border: 1px solid rgba(176, 176, 176, 0.48);*/
    /*    box-shadow: 0 0 10px rgba(189, 189, 189, 0.36);*/
    /*}*/

    #location-indicator {
        top: 20px;
        font-size: 12px;
        letter-spacing: 2px;
        max-width: 225px;
        width: 240px;
    }

    .target-action-button {
        padding: 4px 4px;
        font-size: 12px;
    }

    #ship-panel {
        width: 240px;
    }

    #ship-name {
        font-size: 14px;
        margin-bottom: 8px;
    }

    #ship-stats {
        padding: 8px;
    }

    #build-signature {
        top: auto;
        bottom: 5px;
        width: auto;
        font-size: 12px;
    }

    .health-bar {
        height: 22px;
    }

    .panel-header {
        padding: 5px 8px;
        font-size: 14px;
    }
    .health-segment {
        font-size: 14px;
    }

    .modal-content h2 {
        margin: 0 0 20px 0;
        padding-bottom: 10px;
        letter-spacing: 2px;
        font-size: 18px;
    }

    .quality-notification {
        font-size: 16px !important;
        padding: 15px !important;
    }

    .mission-panel {
        width: 500px; /* Original width */
    }

    .mission-content {
        padding: 25px; /* Original padding */
    }

    .mission-panel h2 {
        margin: 0 0 20px 0;
        padding-bottom: 10px;
        letter-spacing: 2px;
        font-size: 20px;
    }

    .mission-panel p {
        margin: 12px 0;
        font-size: 16px;
        line-height: 1.5;
    }

    .mission-button {
        width: 80%;
        margin: 25px auto 10px auto;
        padding: 15px;
        font-size: 16px;
        letter-spacing: 2px;
    }

    #toggle-controls-container {
        top:20px;
    }

    #scanner-panel {
        max-width: 60%;
    }
}

/* Desktop*/
@media (min-width: 1367px) and (min-height: 600px) {
    #scanner-panel {
        position: absolute;
        transform: none;
        display: flex;
        top: 20px;
        right: 20px;
        width: 350px;
        height: 400px;
        flex-direction: column;
        left: auto;
    }

    .mobile-close-button {
        display: none;
    }
    .scanner-bottom-close {
        display: none;
    }


    /*#toggle-scanner {*/
    /*    pointer-events: none;*/
    /*    background-color: rgba(131, 131, 131, 0.13);*/
    /*    color: rgba(171, 171, 171, 0.36);*/
    /*    border: 1px solid rgba(176, 176, 176, 0.48);*/
    /*    box-shadow: 0 0 10px rgba(189, 189, 189, 0.36);*/
    /*}*/

    #toggle-controls-container {
        right: 390px;
        gap: 10px;
    }

    .mobile-only {
        display: none;
    }

    .desktop-only {
        display: inline-flex;
    }
}