@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --accent: #23887e;
    --accent-alt: #45b4a8;
    --text: #f8fafc;
    --bg: #000000;
    --hud-glow: 0 0 15px rgba(35, 136, 126, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    overflow: hidden;
    position: fixed;
    /* Prevent scrolling on iOS */
    width: 100%;
    height: 100%;
    touch-action: none;
    /* Prevent browser gestures */
    user-select: none;
    inset: 0;
    min-height: 100dvh;
    height: var(--app-height, 100dvh);
    overscroll-behavior: none;
}

body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    background-size: 100% 4px, 3px 100%;
    z-index: 100;
    pointer-events: none;
    opacity: 0.3;
}

.scanline {
    width: 100%;
    height: 100px;
    z-index: 101;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0) 0%, rgba(35, 136, 126, 0.1) 50%, rgba(0, 0, 0, 0) 100%);
    opacity: 0.1;
    position: absolute;
    bottom: 100%;
    animation: scanline 8s linear infinite;
}

@keyframes scanline {
    0% {
        bottom: 100%;
    }

    100% {
        bottom: -100px;
    }
}

canvas {
    display: block;
    position: fixed;
    inset: 0;
    width: 100%;
    height: var(--app-height, 100dvh);
}

#ui-container {
    position: fixed;
    inset: 0;
    width: 100%;
    height: var(--app-height, 100dvh);
    z-index: 10;
    pointer-events: none;
    overflow: hidden;
}

/* HUD */
.hud-top {
    position: absolute;
    top: max(18px, env(safe-area-inset-top));
    left: max(20px, env(safe-area-inset-left));
    border-left: 2px solid var(--accent);
    padding-left: 20px;
    max-width: min(46vw, 360px);
}

.hud-top h1 {
    font-size: clamp(1rem, 2.2vw, 1.5rem);
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
}

.hud-top p {
    font-size: clamp(0.55rem, 1.2vw, 0.7rem);
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--accent);
    opacity: 0.6;
    animation: blink 2s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 0.2;
    }

    50% {
        opacity: 0.8;
    }
}

.hud-top-right {
    position: absolute;
    top: max(18px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    pointer-events: auto;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.back-btn i {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.back-btn:hover {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    box-shadow: 0 0 30px rgba(0, 242, 255, 0.4);
}

.back-btn:hover i {
    transform: translateX(-5px);
}

/* Instructions */
.instructions {
    position: absolute;
    bottom: 40px;
    left: 40px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.instructions span b {
    color: var(--accent);
}

/* Crosshair */
#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#crosshair::before,
#crosshair::after {
    content: '';
    position: absolute;
    background: var(--accent);
    opacity: 0.5;
}

#crosshair::before {
    width: 1px;
    height: 100%;
    left: 50%;
}

#crosshair::after {
    height: 1px;
    width: 100%;
    top: 50%;
}

/* Planet Info - Glassmorphism */
#planet-info {
    position: absolute;
    bottom: 10%;
    right: 5%;
    width: min(380px, calc(100vw - 32px));
    max-height: calc(var(--app-height, 100dvh) - 160px);
    padding: clamp(22px, 4vw, 40px);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.6s cubic-bezier(0.2, 1, 0.3, 1);
    pointer-events: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    background-image: repeating-linear-gradient(0deg, rgba(35, 136, 126, 0.05) 0px, rgba(35, 136, 126, 0.05) 1px, transparent 1px, transparent 4px);
}

#planet-info.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

#info-category {
    font-size: 0.65rem;
    color: var(--accent);
    letter-spacing: 0.4em;
    text-transform: uppercase;
    margin-bottom: 10px;
    font-weight: 600;
}

#info-title {
    font-size: clamp(1.45rem, 5vw, 2.5rem);
    font-weight: 800;
    line-height: 1;
    margin-bottom: 20px;
    color: #fff;
}

#info-desc {
    font-size: clamp(0.8rem, 2.2vw, 0.9rem);
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 30px;
    font-weight: 300;
}

.enter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 14px 18px;
    background: var(--accent);
    color: #000;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    border-radius: 12px;
    transition: all 0.3s;
}

.enter-btn:hover {
    background: #fff;
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(0, 242, 255, 0.4);
}

/* Loading Overlay */
#loading {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 1s ease;
}

.warp-loader {
    width: min(200px, 70vw);
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.warp-loader::after {
    content: '';
    position: absolute;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--accent);
    animation: warp 1.5s ease-in-out infinite;
}

@keyframes warp {
    100% {
        left: 100%;
    }
}

#loading p {
    margin-top: 30px;
    font-size: 0.7rem;
    letter-spacing: 0.5em;
    text-transform: uppercase;
    color: var(--accent);
    padding: 0 24px;
    text-align: center;
}



/* Joystick */
#joystick-container {
    position: absolute;
    bottom: max(32px, env(safe-area-inset-bottom));
    left: max(24px, env(safe-area-inset-left));
    width: clamp(92px, 18vw, 120px);
    height: clamp(92px, 18vw, 120px);
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(0, 242, 255, 0.2);
    border-radius: 50%;
    backdrop-filter: blur(10px);
    display: none;
    /* Only on mobile */
    pointer-events: auto;
    z-index: 100;
}

#joystick-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 42%;
    height: 42%;
    background: var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
    pointer-events: none;
}

@media (max-width: 992px) {
    #joystick-container {
        display: block;
    }
}

/* Navigation Compass */
#nav-compass {
    position: absolute;
    top: 150px;
    left: 40px;
    display: flex;
    align-items: center;
    gap: 20px;
    opacity: 0.8;
    pointer-events: none;
}

.compass-ring {
    width: 60px;
    height: 60px;
    border: 2px solid rgba(0, 242, 255, 0.2);
    border-radius: 50%;
    position: relative;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.1), inset 0 0 10px rgba(0, 242, 255, 0.1);
}

.compass-ring::after {
    content: '';
    position: absolute;
    inset: 5px;
    border: 1px solid rgba(0, 242, 255, 0.1);
    border-radius: 50%;
}

.compass-ring::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.1), transparent);
    border-radius: 60px 60px 0 0;
    pointer-events: none;
}

.compass-arrow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 20px;
    background: var(--accent);
    transform: translate(-50%, -50%) rotate(0deg);
    transform-origin: center;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    box-shadow: 0 0 10px var(--accent);
    margin-top: -10px;
    /* Offset to rotate around center */
    transition: transform 0.1s linear;
}

.nav-data {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#nav-target-name {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #fff;
}

#nav-target-dist {
    font-size: 0.6rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--accent);
}

/* Minimap */
#minimap-container {
    position: absolute;
    bottom: 40px;
    right: 40px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    pointer-events: none;
}

#minimap {
    width: 160px;
    height: 160px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(35, 136, 126, 0.4);
    border-radius: 50%;
    position: relative;
    backdrop-filter: blur(10px);
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(35, 136, 126, 0.3), 0 0 20px rgba(0, 0, 0, 0.5);
}

#minimap::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent 0%, rgba(35, 136, 126, 0.2) 10%, transparent 11%);
    animation: radar-sweep 4s linear infinite;
    pointer-events: none;
}

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

    to {
        transform: rotate(360deg);
    }
}

#minimap::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle, transparent 30%, rgba(35, 136, 126, 0.05) 31%, transparent 32%),
        radial-gradient(circle, transparent 60%, rgba(35, 136, 126, 0.05) 61%, transparent 62%);
    pointer-events: none;
}

.dot {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s linear;
}

.dot.sun {
    width: 12px;
    height: 12px;
    background: #ffaa00;
    box-shadow: 0 0 10px #ffaa00;
    z-index: 2;
}

.dot.planet {
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
}

.dot.ship {
    width: 10px;
    height: 10px;
    background: #fff;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    box-shadow: 0 0 10px #fff;
    z-index: 3;
    transition: none;
    /* Instant rotation */
}

.minimap-label {
    font-size: 0.6rem;
    color: var(--accent);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    font-weight: 700;
    opacity: 0.8;
}



/* ===========================================
   RESPONSIVE DESIGN — workspace.css
   Breakpoints: 992 | 768 | 640 | 480 | 360 + landscape
   =========================================== */

/* Show mobile controls at tablet breakpoint */
@media (max-width: 992px) {
    .gyro-btn {
        display: flex;
    }

    #joystick-container {
        display: block;
    }
}

/* ── 768px: Mobile ── */
@media (max-width: 768px) {
    #nav-compass {
        top: auto;
        bottom: 180px;
        left: 20px;
        transform: scale(0.8);
    }

    #planet-info {
        padding: 20px;
        top: 50%;
        left: 50%;
        bottom: auto;
        right: auto;
        transform: translate(-50%, -50%) scale(0.9);
        width: 85%;
        max-width: 340px;
        max-height: calc(var(--app-height, 100dvh) - 120px);
        overflow-y: auto;
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
        pointer-events: auto;
        text-align: center;
    }

    #planet-info.active {
        transform: translate(-50%, -50%) scale(1);
    }

    #info-title {
        font-size: 1.8rem;
    }

    #info-desc {
        font-size: 0.8rem;
        margin-bottom: 20px;
    }

    .instructions {
        display: none;
    }

    #crosshair {
        width: 30px;
        height: 30px;
    }

    #minimap-container {
        bottom: max(18px, env(safe-area-inset-bottom));
        right: max(12px, env(safe-area-inset-right));
    }
}

/* ── 640px: Small mobile ── */
@media (max-width: 640px) {
    .hud-top {
        max-width: calc(100vw - 96px);
        padding-left: 12px;
    }

    .hud-top p,
    .hud-stats {
        display: none;
    }

    .hud-top-right {
        top: max(14px, env(safe-area-inset-top));
        right: max(14px, env(safe-area-inset-right));
    }

    .back-btn {
        width: 44px;
        height: 44px;
        justify-content: center;
        padding: 0;
        border-radius: 50%;
    }

    .back-btn span {
        display: none;
    }

    #planet-info {
        width: calc(100vw - 28px);
        max-height: calc(var(--app-height, 100dvh) - 150px);
        border-radius: 16px;
    }

    #info-category {
        letter-spacing: 0.22em;
    }

    .enter-btn {
        letter-spacing: 0.12em;
    }
}

/* ── 480px: Extra-small mobile ── */
@media (max-width: 480px) {
    #planet-info {
        top: auto;
        left: 14px;
        right: 14px;
        bottom: calc(max(18px, env(safe-area-inset-bottom)) + 116px);
        width: auto;
        max-width: none;
        max-height: calc(var(--app-height, 100dvh) - 210px);
        text-align: left;
        transform: translateY(20px);
    }

    #planet-info.active {
        transform: translateY(0);
    }

    #joystick-container {
        bottom: max(16px, env(safe-area-inset-bottom));
        left: max(14px, env(safe-area-inset-left));
        width: 92px;
        height: 92px;
    }

    #minimap-container {
        bottom: max(16px, env(safe-area-inset-bottom));
        right: max(10px, env(safe-area-inset-right));
    }

    #minimap {
        width: 104px;
        height: 104px;
    }

    .minimap-label {
        display: none;
    }
}

/* ── 360px: Tiny phones ── */
@media (max-width: 360px) {
    #minimap {
        width: 88px;
        height: 88px;
    }

    #joystick-container {
        width: 84px;
        height: 84px;
    }
}

/* ── Landscape / short viewport ── */
@media (max-height: 540px) and (orientation: landscape) {
    .hud-top {
        top: 12px;
        left: 14px;
    }

    .hud-top p,
    .hud-stats,
    .minimap-label {
        display: none;
    }

    .hud-top-right {
        top: 12px;
        right: 14px;
    }

    .back-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0 12px;
    }

    #planet-info {
        top: 68px;
        right: 14px;
        bottom: auto;
        left: auto;
        width: min(320px, calc(50vw - 18px));
        max-height: calc(var(--app-height, 100dvh) - 84px);
        padding: 16px;
        text-align: left;
        transform: translateX(24px);
    }

    #planet-info.active {
        transform: translateX(0);
    }

    #joystick-container {
        width: 82px;
        height: 82px;
        bottom: 12px;
        left: 14px;
    }

    #minimap-container {
        bottom: 12px;
        right: 14px;
    }

    #minimap {
        width: 92px;
        height: 92px;
    }
}