@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600&family=Inter:wght@300;400;600;700&display=swap');

:root {
    --bg-color: #000000;
    --text-color: #ffffff;
    --accent-color: #ffffff;
    --glass-bg: rgba(0, 0, 0, 0.90);
    --glass-border: rgba(255, 255, 255, 0.22);
}

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

html, body {
    width: 100%;
    height: 100%;
    height: 100vh;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

.container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ASCII Canvas fills the screen with interactive grab cursor */
#ascii-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
    cursor: grab;
    touch-action: none;
    background-color: #000000;
}

#ascii-canvas:active {
    cursor: grabbing;
}

/* Glassmorphism HUD Panel - Desktop Default */
.hud-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 320px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 22px;
    z-index: 50;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 1px rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    transition: transform 0.25s ease, opacity 0.25s ease, border-radius 0.25s ease, background 0.25s ease;
}

/* Custom sleek scrollbar for Windows, Linux & Android */
.hud-panel::-webkit-scrollbar {
    width: 4px;
}
.hud-panel::-webkit-scrollbar-track {
    background: transparent;
}
.hud-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 4px;
}
.hud-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.45);
}

#hud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    user-select: none;
}

.hud-title-group {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    margin: 0;
    padding: 0;
}

.hud-actions {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 7px !important;
    margin-left: 14px !important;
    flex-shrink: 0 !important;
}

.toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex !important;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.2s, transform 0.15s, border-color 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1;
}

.hud-actions .toggle-btn + .toggle-btn {
    margin-left: 0 !important;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.toggle-btn:active {
    transform: scale(0.92);
}

.audio-btn {
    padding: 0;
}

.speaker-svg {
    display: block;
    pointer-events: none;
    color: currentColor;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.audio-btn.playing {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.25);
}

/* Desktop Minimized State */
.hud-panel.minimized {
    width: auto;
    padding: 10px 18px;
    cursor: pointer;
    border-radius: 28px;
}

.hud-panel.minimized #hud-header {
    margin-bottom: 0;
    gap: 14px;
    display: flex;
    align-items: center;
}

.hud-panel.minimized .hud-title-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
}

.hud-panel.minimized h1 {
    font-size: 13px;
    letter-spacing: 1.5px;
    margin: 0;
    line-height: 1;
}

.hud-panel.minimized .version-tag {
    font-size: 9px;
    letter-spacing: 1px;
    margin: 0 !important;
    line-height: 1;
}

.hud-panel.minimized #hud-collapsible {
    display: none !important;
}

.hud-panel h1 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 2px;
    display: inline-flex;
    align-items: center;
    color: #fff;
    margin: 0;
    padding: 0;
    line-height: 1;
}

.glow {
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.version-tag {
    color: var(--accent-color);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 0 !important;
    padding: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.subtitle {
    font-size: 10px;
    color: #8e8e93;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    line-height: 1.4;
}

.galaxy-selector {
    margin-bottom: 16px;
}

#galaxy-dropdown {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    outline: none;
    cursor: pointer;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: border-color 0.2s, background 0.2s;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 13px;
}

#galaxy-dropdown:hover,
#galaxy-dropdown:focus {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.1);
}

#galaxy-dropdown option {
    background: #0d0d12;
    color: var(--text-color);
}

.stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--glass-border);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Fira Code', monospace;
    font-size: 11px;
}

.stat-row .label {
    color: #71717a;
    letter-spacing: 0.5px;
}

.stat-row .value {
    color: var(--accent-color);
    font-weight: 600;
}

#hud-traffic {
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    font-weight: 700;
}

.credit {
    font-size: 11px;
    line-height: 1.5;
    color: #8e8e93;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.credit strong {
    color: #fff;
    font-weight: 600;
    font-size: 12px;
}

.recommendation {
    margin-top: 6px;
    font-size: 9px;
    color: var(--accent-color);
    font-style: italic;
    opacity: 0.85;
}

/* ========================================================
   Mobile & Touch Responsiveness
   Captures phones in portrait (<= 768px) and landscape (height <= 500px)
   ======================================================== */
@media (max-width: 768px), (max-height: 500px) {
    /* When HUD is open on mobile: floating bottom card */
    .hud-panel {
        position: fixed;
        top: auto;
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
        left: 14px;
        right: 14px;
        width: auto;
        max-width: 420px;
        margin: 0 auto;
        max-height: calc(75dvh - env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        border-radius: 20px;
        padding: 16px 18px;
        background: rgba(10, 10, 15, 0.92);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.08);
        transition: background 0.2s ease, border-color 0.2s ease, opacity 0.15s ease;
    }

    /* When HUD is MINIMIZED on mobile: sleek floating capsule/pill */
    .hud-panel.minimized {
        position: fixed;
        top: auto;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: max-content;
        max-width: calc(100vw - 32px);
        height: auto;
        padding: 8px 16px;
        border-radius: 20px; /* Unified 20px radius: eliminates circle transition artifact */
        background: rgba(10, 10, 15, 0.88);
        border: 1px solid rgba(255, 255, 255, 0.25);
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7), 0 0 15px rgba(255, 255, 255, 0.15);
        cursor: pointer;
        overflow: hidden;
        transition: background 0.2s ease, border-color 0.2s ease, opacity 0.15s ease, transform 0.15s ease;
        animation: pillPulse 4s infinite ease-in-out;
    }

    .hud-panel.minimized:active {
        transform: translateX(-50%) scale(0.96);
    }

    @keyframes pillPulse {
        0%, 100% {
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7), 0 0 12px rgba(255, 255, 255, 0.15);
            border-color: rgba(255, 255, 255, 0.25);
        }
        50% {
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8), 0 0 18px rgba(255, 255, 255, 0.3);
            border-color: rgba(255, 255, 255, 0.45);
        }
    }

    .hud-panel.minimized #hud-header {
        margin-bottom: 0;
        gap: 10px;
        display: flex;
        align-items: center;
    }

    .hud-panel.minimized .hud-title-group {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        margin: 0;
        padding: 0;
    }

    .hud-panel.minimized h1 {
        font-size: 12px;
        letter-spacing: 1px;
        margin: 0;
        line-height: 1;
    }

    .hud-panel.minimized .version-tag {
        font-size: 9px;
        margin: 0 !important;
        line-height: 1;
    }

    .hud-panel.minimized .hud-actions {
        display: inline-flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        margin-left: 8px !important;
    }

    .hud-panel.minimized .toggle-btn {
        width: 24px;
        height: 24px;
        font-size: 13px;
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.35);
    }

    .hud-panel.minimized .speaker-svg {
        width: 12px;
        height: 12px;
    }

    .hud-panel.minimized #hud-collapsible {
        display: none !important;
    }

    /* Small font adjustments when expanded on mobile */
    .hud-panel h1 {
        font-size: 14px;
    }

    .subtitle {
        font-size: 9px;
        margin-bottom: 8px;
    }

    .stats {
        gap: 5px;
        margin-bottom: 12px;
        padding-bottom: 10px;
    }

    .stat-row {
        font-size: 10px;
    }

    .credit {
        font-size: 10px;
    }

    .credit strong {
        font-size: 11px;
    }
}

/* Landscape Phones specifically (short screen height) */
@media (max-height: 500px) and (min-width: 501px) {
    .hud-panel {
        left: auto;
        right: calc(14px + env(safe-area-inset-right, 0px));
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        margin: 0;
        width: 290px;
        max-height: calc(100dvh - 24px);
        transform: none;
    }

    .hud-panel.minimized {
        left: auto;
        right: calc(16px + env(safe-area-inset-right, 0px));
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        transform: none;
    }
}

/* ========================================================
   Sleek Minimalist Entry Overlay (Almost-Transparent)
   ======================================================== */
.entry-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.entry-overlay.dismissed {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.entry-card {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    background: rgba(0, 0, 0, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.30);
    border-radius: 999px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8), 0 0 24px rgba(255, 255, 255, 0.10);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    animation: subtleFloat 3s infinite ease-in-out;
    max-width: 92vw;
    box-sizing: border-box;
}

.entry-overlay:hover .entry-card {
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.9), 0 0 32px rgba(255, 255, 255, 0.25);
    transform: scale(1.03);
}

.entry-pulse-dot {
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 8px #ffffff;
    animation: dotPulse 1.6s infinite ease-in-out;
}

.entry-text {
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    letter-spacing: 2px;
    color: #ffffff;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    white-space: nowrap;
}

@media (max-width: 640px) {
    .entry-card {
        padding: 12px 20px;
        gap: 9px;
    }
    .entry-text {
        font-size: 9.5px;
        letter-spacing: 1.2px;
    }
}

/* Desktop HUD Shortcuts Hint Row */
.hud-shortcuts-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    margin-bottom: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    font-size: 9.5px;
    color: rgba(255, 255, 255, 0.65);
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 0.5px;
    user-select: none;
}

.hud-shortcuts-hint kbd {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 9px;
    color: #ffffff;
    font-weight: bold;
    font-family: inherit;
}

/* Hide keyboard hints on touch/mobile devices */
@media (hover: none) and (pointer: coarse) {
    .hud-shortcuts-hint {
        display: none !important;
    }
}

@keyframes dotPulse {
    0%, 100% { transform: scale(0.85); opacity: 0.5; }
    50% { transform: scale(1.25); opacity: 1; box-shadow: 0 0 12px #ffffff; }
}

@keyframes subtleFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}

