@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: #030305;
    --text-color: #ffffff;
    --accent-color: #bb86fc;
    --glass-bg: rgba(10, 10, 15, 0.78);
    --glass-border: rgba(255, 255, 255, 0.09);
}

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

html, body {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

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

/* ASCII Canvas fills the screen */
#ascii-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
}

/* 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;
}

#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;
}

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

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

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

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

.hud-panel.minimized #hud-header {
    margin-bottom: 0;
    gap: 14px;
}

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

.hud-panel h1 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 2px;
    display: inline-block;
    color: #fff;
}

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

.version-tag {
    color: var(--accent-color);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
}

.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;
}

.credit {
    font-size: 11px;
    line-height: 1.5;
    color: #8e8e93;
}

.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.9);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.08);
    }

    /* 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: 9999px;
        background: rgba(10, 10, 15, 0.88);
        border: 1px solid rgba(187, 134, 252, 0.35);
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7), 0 0 15px rgba(187, 134, 252, 0.2);
        cursor: pointer;
        overflow: hidden;
    }

    .hud-panel.minimized #hud-header {
        margin-bottom: 0;
        gap: 12px;
    }

    .hud-panel.minimized .hud-title-group {
        flex-direction: row;
        align-items: baseline;
        gap: 8px;
    }

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

    .hud-panel.minimized .version-tag {
        font-size: 9px;
    }

    .hud-panel.minimized .toggle-btn {
        width: 24px;
        height: 24px;
        font-size: 13px;
        background: rgba(187, 134, 252, 0.2);
        border-color: rgba(187, 134, 252, 0.4);
    }

    .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;
    }
}
