:root {
    --primary: #00f3ff;
    --secondary: #e600ff;
    --dark: #02020a;
    --hud-cyan: rgba(0, 243, 255, 0.7);
    --hud-glow: 0 0 10px rgba(0, 243, 255, 0.5);
    --warn: #ff3333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body,
html {
    width: 100vw;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    background-color: var(--dark);
    font-family: 'Rajdhani', sans-serif;
    color: white;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    /* Prevent scroll on mobile */
}

/* Base Canvas */
canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    outline: none;
}

/* === LOADING SCREEN === */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 1s ease-out;
}

.loader-ring {
    width: 80px;
    height: 80px;
    border: 2px solid transparent;
    border-top-color: var(--primary);
    border-bottom-color: var(--secondary);
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    position: absolute;
}

.loader-inner {
    width: 60px;
    height: 60px;
    border: 2px solid transparent;
    border-left-color: var(--primary);
    border-right-color: var(--secondary);
    border-radius: 50%;
    animation: spin-reverse 0.8s linear infinite;
    margin-bottom: 40px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes spin-reverse {
    0% {
        transform: rotate(360deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

/* Glitch Text Effect */
.glitch {
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 4px;
    color: var(--primary);
    text-shadow: var(--hud-glow);
    font-size: 24px;
    position: relative;
    margin-bottom: 20px;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark);
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--secondary);
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim 3s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -2px 0 var(--primary);
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 2.5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% {
        clip: rect(10px, 9999px, 86px, 0);
    }

    10% {
        clip: rect(66px, 9999px, 8px, 0);
    }

    20% {
        clip: rect(48px, 9999px, 26px, 0);
    }

    30% {
        clip: rect(82px, 9999px, 19px, 0);
    }

    40% {
        clip: rect(22px, 9999px, 44px, 0);
    }

    50% {
        clip: rect(51px, 9999px, 60px, 0);
    }

    60% {
        clip: rect(5px, 9999px, 82px, 0);
    }

    70% {
        clip: rect(49px, 9999px, 49px, 0);
    }

    80% {
        clip: rect(14px, 9999px, 41px, 0);
    }

    90% {
        clip: rect(78px, 9999px, 62px, 0);
    }

    100% {
        clip: rect(4px, 9999px, 61px, 0);
    }
}

.progress-bar {
    width: 300px;
    height: 4px;
    background: rgba(0, 243, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

#progress-fill {
    width: 0%;
    height: 100%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
    transition: width 0.1s;
}

/* === HUD SYSTEM === */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 10;
}

.hud-top-left {
    position: absolute;
    top: 30px;
    left: 40px;
}

.hud-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    color: var(--primary);
    font-weight: 900;
    letter-spacing: 6px;
    text-shadow: var(--hud-glow);
    border-left: 4px solid var(--primary);
    padding-left: 15px;
    margin-bottom: 5px;
}

.hud-subtitle {
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 2px;
    margin-left: 19px;
}

.hud-warning {
    margin-top: 15px;
    margin-left: 19px;
    font-family: 'Share Tech Mono', monospace;
    color: var(--warn);
    border: 1px solid var(--warn);
    background: rgba(255, 51, 51, 0.2);
    padding: 5px 15px;
    display: inline-block;
    animation: flash 1s infinite alternate;
}

.hidden {
    display: none !important;
}

@keyframes flash {
    from {
        opacity: 0.3;
    }

    to {
        opacity: 1;
        box-shadow: 0 0 10px var(--warn);
    }
}

.hud-top-right {
    position: absolute;
    top: 30px;
    right: 40px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: flex-end;
}

.hud-panel {
    background: rgba(0, 5, 20, 0.5);
    border: 1px solid rgba(0, 243, 255, 0.3);
    padding: 10px 20px;
    border-radius: 4px;
    backdrop-filter: blur(4px);
    position: relative;
    overflow: hidden;
}

.hud-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--primary);
}

.stat-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 4px;
    letter-spacing: 1px;
}

.stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    color: var(--primary);
    text-shadow: var(--hud-glow);
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.unit {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.text-green {
    color: #00ff66;
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.5);
}

/* Reticle */
.hud-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
}

#reticle {
    position: relative;
    width: 60px;
    height: 60px;
}

.reticle-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: var(--hud-glow);
}

.reticle-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 1px dashed rgba(0, 243, 255, 0.4);
    border-radius: 50%;
    animation: rotate-slow 10s linear infinite;
}

#reticle::before,
#reticle::after {
    content: '';
    position: absolute;
    background: rgba(0, 243, 255, 0.6);
}

#reticle::before {
    top: 50%;
    left: -15px;
    right: -15px;
    height: 1px;
    transform: translateY(-50%);
}

#reticle::after {
    left: 50%;
    top: -15px;
    bottom: -15px;
    width: 1px;
    transform: translateX(-50%);
}

@keyframes rotate-slow {
    to {
        transform: rotate(360deg);
    }
}

/* Controls Panel */
.hud-bottom-center {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
}

.controls-panel {
    background: linear-gradient(0deg, rgba(0, 5, 20, 0.8) 0%, rgba(0, 5, 20, 0.1) 100%);
    padding: 15px 30px;
    border-radius: 8px;
    border-bottom: 2px solid var(--primary);
    display: flex;
    gap: 30px;
    backdrop-filter: blur(2px);
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.key-cap {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    color: white;
    min-width: 28px;
    text-align: center;
}

.key-cap.wide {
    padding: 4px 20px;
}

.control-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 1px;
}

.control-icon {
    font-size: 20px;
    margin-bottom: -4px;
}

/* === MOBILE ZONES === */
#mobile-controls {
    display: none;
    /* Controlled by JS */
}

#joystick-zone {
    position: absolute;
    bottom: 50px;
    left: 50px;
    width: 150px;
    height: 150px;
    z-index: 20;
}

#touch-look-zone {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    z-index: 15;
}

/* Responsive adjustments */

/* === SCANNER AND ANALYSIS === */
#scan-prompt {
    position: absolute;
    top: 65px;
    text-align: center;
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid var(--primary);
    padding: 10px 20px;
    border-radius: 4px;
    animation: pulse-border 1.5s infinite;
}

#scan-prompt.hidden {
    display: none !important;
}

.prompt-text {
    font-size: 14px;
    color: var(--primary);
    font-weight: bold;
    letter-spacing: 2px;
}

.prompt-action {
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    color: white;
    margin-top: 5px;
}

.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

@keyframes pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 243, 255, 0.4);
    }

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

    100% {
        box-shadow: 0 0 0 0 rgba(0, 243, 255, 0);
    }
}

#analysis-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(2, 2, 10, 0.85);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
}

#analysis-modal.hidden {
    display: none !important;
}

.modal-content {
    background: rgba(0, 10, 30, 0.9);
    border: 2px solid var(--primary);
    box-shadow: var(--hud-glow);
    width: 600px;
    max-width: 90vw;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transform: scale(0.9);
    animation: pop-in 0.3s forwards;
}

@keyframes pop-in {
    to {
        transform: scale(1);
    }
}

.modal-header {
    background: var(--primary);
    color: #000;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    padding: 10px 20px;
    letter-spacing: 3px;
}

.modal-body {
    padding: 30px;
    position: relative;
    color: white;
}

.scan-line-anim {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(0, 243, 255, 0.8);
    box-shadow: 0 0 10px var(--primary);
    animation: scan 3s infinite linear;
}

@keyframes scan {
    0% {
        top: 0;
        opacity: 1;
    }

    90% {
        top: 100%;
        opacity: 1;
    }

    100% {
        top: 100%;
        opacity: 0;
    }
}

.modal-body h3 {
    font-size: 32px;
    color: white;
    letter-spacing: 2px;
    text-shadow: 0 0 5px white;
    margin-bottom: 5px;
}

.planet-type {
    font-family: 'Share Tech Mono', monospace;
    color: var(--secondary);
    font-size: 16px;
    margin-bottom: 20px;
}

.planet-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px dashed rgba(0, 243, 255, 0.3);
}

.stat-lbl {
    font-family: 'Share Tech Mono', monospace;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

.stat-val {
    font-family: 'Orbitron', sans-serif;
    color: var(--primary);
    font-size: 18px;
    margin-left: 10px;
}

.planet-desc {
    font-size: 16px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
}

.modal-footer {
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.5);
    text-align: right;
    border-top: 1px solid rgba(0, 243, 255, 0.2);
}

.close-btn {
    font-family: 'Orbitron', sans-serif;
    color: var(--primary);
    cursor: pointer;
    letter-spacing: 2px;
    font-size: 14px;
    transition: color 0.2s;
}

.close-btn:hover {
    color: white;
}

@media (max-width: 768px) {
    .hud-title {
        font-size: 18px;
    }

    .hud-subtitle {
        font-size: 10px;
    }

    .hud-top-left {
        top: 20px;
        left: 20px;
    }

    .hud-top-right {
        top: 20px;
        right: 20px;
        transform: scale(0.8);
        transform-origin: top right;
    }

    .controls-panel {
        gap: 15px;
        padding: 10px 15px;
        transform: scale(0.9);
        bottom: 20px;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
        background: rgba(0, 243, 255, 0.3);
        padding: 5px 10px;
        border-radius: 4px;
        margin-top: 8px;
        cursor: pointer;
    }
}