* {
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

body { 
    margin: 0; 
    overflow: hidden; 
    background: #0a0a0c; 
    font-family: 'Courier New', Courier, monospace;
    touch-action: none;
    position: fixed;
    width: 100%;
    height: 100%;
}

canvas { 
    display: block; 
    touch-action: none;
    width: 100%;
    height: 100%;
}

/* Fullscreen Button */
#fullscreen-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(10, 10, 15, 0.85);
    border: 1px solid #2a2a35;
    cursor: pointer;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    touch-action: manipulation;
    pointer-events: auto;
}

#fullscreen-btn:active {
    transform: scale(0.9);
    background: rgba(0, 255, 255, 0.2);
    border-color: #0ff;
}

#fullscreen-btn svg {
    stroke: #0ff;
    transition: stroke 0.2s;
}

#fullscreen-btn:active svg {
    stroke: #fff;
}

/* Orientation Warning Overlay */
#orientation-warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.98);
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.warning-content {
    text-align: center;
    color: #0ff;
    padding: 30px;
}

.rotate-icon {
    font-size: 80px;
    animation: rotate 2s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes rotate {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

.warning-content h2 {
    font-size: 24px;
    margin: 20px 0 10px;
    letter-spacing: 2px;
}

.warning-content p {
    font-size: 14px;
    color: #888;
    margin-bottom: 30px;
}

.continue-btn {
    background: rgba(0, 255, 255, 0.2);
    border: 1px solid #0ff;
    color: #0ff;
    padding: 12px 25px;
    font-family: monospace;
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    touch-action: manipulation;
}

/* Performance Badge */
#performance-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 255, 255, 0.2);
    border-left: 3px solid #0ff;
    padding: 5px 12px;
    font-size: 8px;
    color: #0ff;
    z-index: 25;
    backdrop-filter: blur(4px);
    pointer-events: none;
    border-radius: 3px;
    font-weight: bold;
    letter-spacing: 1px;
}

#hud, #data-overlay {
    position: absolute;
    color: #888da8;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 10;
}

#hud {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 10px;
    box-sizing: border-box;
    width: 100%;
}

.stat-box {
    background: rgba(15, 15, 20, 0.85);
    border: 1px solid #2a2a35;
    padding: 6px 12px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    backdrop-filter: blur(4px);
}

.stat-value { 
    color: #fff; 
    font-weight: bold; 
    margin-left: 5px;
}

#fuel-bar-container {
    background: rgba(15, 15, 20, 0.85);
    border: 1px solid #2a2a35;
    padding: 6px 12px;
    min-width: 120px;
    backdrop-filter: blur(4px);
}

#fuel-bar {
    width: 100%;
    height: 8px;
    background: #2a2a35;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

#fuel-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #0ff, #0f0);
    transition: width 0.2s, background 0.3s;
    border-radius: 4px;
}

.fuel-warning { 
    color: #ff4444; 
    animation: pulse 1s infinite; 
}

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

#data-overlay {
    bottom: 15px;
    left: 15px;
    font-size: 8px;
    line-height: 1.3;
    background: rgba(10, 10, 15, 0.7);
    padding: 8px 12px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

#minimap-container {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 130px;
    height: 130px;
    background: rgba(10, 10, 15, 0.85);
    border: 1px solid #2a2a35;
    border-radius: 12px;
    backdrop-filter: blur(5px);
    z-index: 20;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

#minimap-title {
    position: absolute;
    top: 5px;
    left: 8px;
    font-size: 7px;
    color: #0ff;
    letter-spacing: 1px;
    font-weight: bold;
    text-transform: uppercase;
    z-index: 21;
    pointer-events: none;
}

canvas#minimap {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    display: block;
}

/* Mobile Controls Hint */
#mobile-controls-hint {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 255, 255, 0.15);
    border: 1px solid #0ff;
    border-radius: 30px;
    padding: 10px 20px;
    backdrop-filter: blur(8px);
    z-index: 25;
    display: none;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); visibility: hidden; }
}

#hint-text {
    color: #0ff;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1px;
}

#hint-dismiss {
    color: #0ff;
    font-size: 16px;
    cursor: pointer;
    font-weight: bold;
    padding: 5px;
}

#planet-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(10, 10, 15, 0.98);
    border: 2px solid #0ff;
    padding: 20px 20px;
    width: 85%;
    max-width: 350px;
    color: white;
    display: none;
    text-align: center;
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.3);
    z-index: 100;
    backdrop-filter: blur(10px);
}

#planet-popup h3 { 
    margin: 10px 0; 
    color: #0ff; 
    letter-spacing: 2px; 
    font-size: 22px;
}

#planet-icon {
    font-size: 45px;
}

.share-btn {
    margin-top: 15px;
    background: #0ff;
    border: none;
    color: #000;
    padding: 14px 20px;
    font-family: inherit;
    cursor: pointer;
    font-size: 13px;
    font-weight: 900;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    border-radius: 10px;
    text-transform: uppercase;
    touch-action: manipulation;
}

.share-btn:active { 
    transform: scale(0.97); 
    background: #fff; 
}

.social-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

.social-btn {
    padding: 12px;
    font-size: 10px;
    font-weight: bold;
    background: #2a2a35;
    color: white;
    border: 1px solid #444;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-transform: uppercase;
    touch-action: manipulation;
}

.social-btn:active { 
    background: #444;
    transform: scale(0.97);
}

#toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #0ff;
    color: #000;
    padding: 10px 20px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 8px;
    display: none;
    z-index: 4000;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    white-space: nowrap;
    max-width: 90%;
    white-space: normal;
    text-align: center;
}

#screenshot-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    overflow-y: auto;
}

#preview-img {
    max-width: 100%;
    max-height: 35vh;
    border: 2px solid #0ff;
    border-radius: 12px;
    margin-bottom: 15px;
}

.exit-x {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #0ff;
    font-size: 24px;
    cursor: pointer;
    font-weight: bold;
    padding: 5px;
    line-height: 1;
    z-index: 101;
}

.exit-x:hover { color: #fff; }

.guide-text {
    color: #888;
    font-size: 9px;
    margin-top: 10px;
    text-transform: uppercase;
}

#game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.96);
    border: 3px solid #ff4444;
    padding: 25px 20px;
    text-align: center;
    z-index: 3000;
    display: none;
    border-radius: 20px;
    width: 85%;
    max-width: 320px;
    backdrop-filter: blur(10px);
}

#game-over h2 { 
    color: #ff4444; 
    margin-bottom: 15px;
    font-size: 20px;
}

#game-over p {
    font-size: 13px;
    margin: 8px 0;
}

#game-over button {
    background: #0ff;
    border: none;
    padding: 12px 25px;
    margin-top: 15px;
    font-weight: bold;
    cursor: pointer;
    font-family: monospace;
    font-size: 14px;
    border-radius: 10px;
    width: 100%;
    touch-action: manipulation;
}

#blackhole-warning {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff00ff;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 0 20px #ff00ff;
    pointer-events: none;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s;
    white-space: nowrap;
    text-align: center;
}

/* Fullscreen specific styles */
:-webkit-full-screen #fullscreen-btn svg {
    stroke: #fff;
}

:fullscreen #fullscreen-btn svg {
    stroke: #fff;
}

/* Landscape mode adjustments */
@media (orientation: landscape) {
    #hud {
        bottom: 10px;
        gap: 6px;
    }
    
    .stat-box, #fuel-bar-container {
        padding: 4px 10px;
        font-size: 8px;
    }
    
    #data-overlay {
        bottom: 10px;
        left: 10px;
        font-size: 7px;
    }
    
    #minimap-container {
        top: 50px;
        right: 10px;
        width: 100px;
        height: 100px;
    }
    
    #planet-popup {
        max-width: 300px;
        padding: 15px;
    }
    
    #fullscreen-btn {
        top: 10px;
        left: 10px;
        width: 35px;
        height: 35px;
    }
}

/* Portrait mode warning trigger */
@media (orientation: portrait) and (max-width: 768px) {
    #orientation-warning {
        display: flex;
    }
}

/* Tablet and larger screens */
@media (min-width: 768px) and (orientation: landscape) {
    #minimap-container {
        width: 180px;
        height: 180px;
    }
    
    .stat-box, #fuel-bar-container {
        padding: 10px 15px;
        font-size: 11px;
    }
    
    #fuel-bar-container {
        min-width: 150px;
    }
    
    #data-overlay {
        font-size: 11px;
    }
    
    #mobile-controls-hint {
        bottom: 100px;
    }
    
    #hint-text {
        font-size: 14px;
    }
    
    #fullscreen-btn {
        width: 45px;
        height: 45px;
    }
}

/* Dark mode safe area for notches */
@supports (padding-top: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    #minimap-container {
        top: calc(15px + env(safe-area-inset-top));
        right: calc(15px + env(safe-area-inset-right));
    }
    
    #data-overlay {
        bottom: calc(15px + env(safe-area-inset-bottom));
        left: calc(15px + env(safe-area-inset-left));
    }
    
    #fullscreen-btn {
        top: calc(15px + env(safe-area-inset-top));
        left: calc(15px + env(safe-area-inset-left));
    }
}

/* Performance optimizations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}