/* ==========================================================================
   GARGANTUA — Schwarzschild Black Hole Raytracer
   Sci-Fi Astrophysics HUD & Cyberpunk Interface Styling (Mobile & Desktop Responsive)
   ========================================================================== */

:root {
    --color-bg: #010206;
    --color-cyan: #00f0ff;
    --color-cyan-glow: rgba(0, 240, 255, 0.45);
    --color-amber: #ff9d00;
    --color-amber-glow: rgba(255, 157, 0, 0.5);
    --color-orange: #ff5500;
    --color-white: #e6f1ff;
    --color-text-dim: #7086a6;
    
    --panel-bg: rgba(6, 12, 24, 0.76);
    --panel-border: rgba(0, 240, 255, 0.25);
    --panel-border-active: rgba(0, 240, 255, 0.7);
    --panel-glow: 0 0 24px rgba(0, 240, 255, 0.08);

    --font-mono: 'JetBrains Mono', 'Fira Code', 'Roboto Mono', 'SF Mono', Consolas, monospace;
    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--color-bg);
    color: var(--color-white);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.4;
    letter-spacing: 0.5px;
    position: fixed;
}

#webglCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
    touch-action: none;
}

/* ==========================================================================
   HUD Overlay & Glassmorphism Panels
   ========================================================================== */

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

.hud-overlay {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Glass Panels */
.hud-panel {
    position: absolute;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--panel-glow);
    padding: 12px 16px;
    border-radius: 6px;
    pointer-events: auto;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.hud-panel:hover {
    border-color: var(--panel-border-active);
    box-shadow: 0 0 28px rgba(0, 240, 255, 0.16);
}

.hud-top-left {
    top: 18px;
    left: 18px;
    max-width: 380px;
}

.hud-top-right {
    top: 18px;
    right: 18px;
    min-width: 290px;
}

.hud-bottom-left {
    bottom: 80px;
    left: 18px;
    max-width: 440px;
}

.hud-bottom-right {
    bottom: 80px;
    right: 18px;
    max-width: 320px;
}

/* Headers & Titles */
.hud-header {
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(0, 240, 255, 0.15);
    padding-bottom: 6px;
}

.hud-header.right-align {
    text-align: right;
}

.hud-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--color-cyan);
    background: rgba(0, 240, 255, 0.12);
    border: 1px solid var(--color-cyan);
    padding: 2px 6px;
    border-radius: 3px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.hud-badge.accent {
    color: var(--color-amber);
    border-color: var(--color-amber);
    background: rgba(255, 157, 0, 0.12);
}

.hud-badge.warning {
    color: #ff3366;
    border-color: #ff3366;
    background: rgba(255, 51, 102, 0.12);
}

.hud-title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #ffffff;
    text-shadow: 0 0 16px var(--color-cyan-glow);
    margin: 2px 0;
}

.hud-subtitle {
    font-size: 10px;
    color: var(--color-text-dim);
    letter-spacing: 0.8px;
    display: block;
}

/* FPS Indicator */
.hud-fps-box {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 2px;
}

.hud-fps-num {
    font-size: 24px;
    font-weight: 800;
    color: var(--color-cyan);
    text-shadow: 0 0 12px var(--color-cyan-glow);
}

.hud-fps-unit {
    font-size: 11px;
    color: var(--color-text-dim);
}

/* Metric Grids */
.hud-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
}

.hud-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.hud-metric.right-align {
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
}

.hud-label {
    color: var(--color-text-dim);
    letter-spacing: 0.5px;
}

.hud-value {
    color: var(--color-white);
    font-weight: 600;
}

.hud-value.highlight {
    color: var(--color-amber);
    font-size: 13px;
    font-weight: 700;
    text-shadow: 0 0 8px var(--color-amber-glow);
}

/* Horizon Distance Bar Indicator */
.hud-bar-container {
    margin-top: 10px;
    padding-top: 6px;
    border-top: 1px dashed rgba(0, 240, 255, 0.18);
}

.hud-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: var(--color-text-dim);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.hud-bar-track {
    position: relative;
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.hud-bar-fill {
    height: 100%;
    width: 50%;
    background: linear-gradient(90deg, #ff3366, var(--color-amber) 30%, var(--color-cyan));
    box-shadow: 0 0 10px var(--color-cyan-glow);
    transition: width 0.1s linear;
}

.hud-bar-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
}

.horizon-mark {
    left: 4%;
    background: #ff3366;
    box-shadow: 0 0 6px #ff3366;
}

.isco-mark {
    left: 12%;
    background: var(--color-amber);
    box-shadow: 0 0 6px var(--color-amber);
}

/* Center Reticle */
.hud-center-reticle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 130px;
    height: 130px;
    pointer-events: none;
}

.reticle-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px dashed rgba(0, 240, 255, 0.3);
}

.outer-ring {
    width: 100px;
    height: 100px;
    border-style: solid;
    border-color: rgba(0, 240, 255, 0.15);
}

.inner-ring {
    width: 44px;
    height: 44px;
    border: 1px solid rgba(0, 240, 255, 0.4);
}

.reticle-crosshair {
    position: absolute;
    background: rgba(0, 240, 255, 0.6);
}

.ch-top { top: 0; left: 50%; width: 1px; height: 12px; transform: translateX(-50%); }
.ch-bottom { bottom: 0; left: 50%; width: 1px; height: 12px; transform: translateX(-50%); }
.ch-left { left: 0; top: 50%; width: 12px; height: 1px; transform: translateY(-50%); }
.ch-right { right: 0; top: 50%; width: 12px; height: 1px; transform: translateY(-50%); }

.reticle-bracket {
    position: absolute;
    width: 10px;
    height: 10px;
    border-color: var(--color-cyan);
    border-style: solid;
}

.bracket-tl { top: 16px; left: 16px; border-width: 2px 0 0 2px; }
.bracket-tr { top: 16px; right: 16px; border-width: 2px 2px 0 0; }
.bracket-bl { bottom: 16px; left: 16px; border-width: 0 0 2px 2px; }
.bracket-br { bottom: 16px; right: 16px; border-width: 0 2px 2px 0; }

.reticle-dist {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--color-cyan);
    letter-spacing: 1px;
    white-space: nowrap;
    text-shadow: 0 0 8px var(--color-cyan-glow);
}

/* Keyboard Shortcuts Grid */
.hud-shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px 12px;
}

.hud-shortcut {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--color-text-dim);
}

kbd {
    display: inline-block;
    background: rgba(0, 240, 255, 0.12);
    border: 1px solid rgba(0, 240, 255, 0.35);
    color: var(--color-cyan);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

/* ==========================================================================
   Floating Action Toolbar (Bottom Center)
   ========================================================================== */

.hud-floating-bar-wrapper {
    position: absolute;
    bottom: 16px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 20;
    pointer-events: none;
    padding: 0 12px;
    padding-bottom: env(safe-area-inset-bottom, 8px);
}

.hud-floating-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    padding: 6px 10px;
    background: rgba(6, 12, 24, 0.85);
    border: 1px solid rgba(0, 240, 255, 0.28);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.hud-floating-bar::-webkit-scrollbar {
    display: none;
}

.hud-btn {
    background: rgba(14, 25, 45, 0.7);
    border: 1px solid rgba(0, 240, 255, 0.2);
    color: var(--color-white);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    touch-action: manipulation;
}

.hud-btn:active, .hud-btn:hover {
    background: rgba(0, 240, 255, 0.2);
    border-color: var(--color-cyan);
    box-shadow: 0 0 14px var(--color-cyan-glow);
    color: #ffffff;
}

.hud-btn.active {
    background: rgba(0, 240, 255, 0.28);
    border-color: var(--color-cyan);
    color: var(--color-cyan);
    box-shadow: 0 0 14px var(--color-cyan-glow);
}

/* ==========================================================================
   lil-gui Sci-Fi Theme Customization
   ========================================================================== */

.lil-gui {
    --background-color: rgba(6, 12, 24, 0.92) !important;
    --text-color: #d1e2ff !important;
    --title-background-color: rgba(0, 240, 255, 0.18) !important;
    --widget-color: rgba(14, 25, 45, 0.95) !important;
    --hover-color: rgba(0, 240, 255, 0.28) !important;
    --focus-color: #00f0ff !important;
    --number-color: #ff9d00 !important;
    --string-color: #00f0ff !important;
    --font-family: var(--font-mono) !important;
    --font-size: 11px !important;
    border: 1px solid rgba(0, 240, 255, 0.35) !important;
    backdrop-filter: blur(18px) !important;
    -webkit-backdrop-filter: blur(18px) !important;
    border-radius: 6px !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8) !important;
}

.lil-gui .title {
    font-weight: 700 !important;
    letter-spacing: 0.8px !important;
    color: #ffffff !important;
    text-shadow: 0 0 8px var(--color-cyan-glow) !important;
}

.lil-gui.root {
    position: fixed !important;
    top: 18px !important;
    right: 320px !important;
    max-height: calc(100vh - 100px) !important;
    overflow-y: auto !important;
    z-index: 30 !important;
    touch-action: pan-y !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.35);
    border-radius: 2px;
}

/* ==========================================================================
   Responsive Breakpoints & Mobile Optimization
   ========================================================================== */

@media (max-width: 1080px) {
    .lil-gui.root {
        right: 14px !important;
        top: 14px !important;
        max-height: calc(100vh - 120px) !important;
    }
    .hud-top-right, .hud-bottom-right {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .hud-panel {
        padding: 10px 12px;
    }
    .hud-top-left {
        top: 12px;
        left: 12px;
        max-width: 280px;
    }
    .hud-bottom-left {
        bottom: 74px;
        left: 12px;
        right: 12px;
        max-width: none;
    }
    .hud-title {
        font-size: 17px;
    }
    .hud-metric {
        font-size: 10px;
    }
    .hud-center-reticle {
        transform: translate(-50%, -50%) scale(0.72);
    }
    .lil-gui.root {
        right: 10px !important;
        left: 10px !important;
        top: auto !important;
        bottom: 74px !important;
        width: auto !important;
        max-height: 55vh !important;
    }
    .hud-btn {
        padding: 5px 10px;
        font-size: 10.5px;
    }
}

@media (max-width: 480px) {
    .hud-top-left {
        top: 8px;
        left: 8px;
        right: 8px;
        max-width: none;
    }
    .hud-bottom-left {
        bottom: 66px;
        left: 8px;
        right: 8px;
    }
    .hud-center-reticle {
        transform: translate(-50%, -50%) scale(0.6);
    }
    .hud-floating-bar-wrapper {
        bottom: 8px;
    }
    .hud-btn {
        padding: 4px 8px;
        font-size: 10px;
    }
}
