:root {
    --color-bg: #050814;
    --color-panel: rgba(10, 16, 30, 0.85);
    --color-panel-border: rgba(0, 240, 255, 0.3);
    --color-text-main: #e0f2f1;
    --color-text-muted: #8ab4f8;
    --color-primary: #00f0ff;
    --color-primary-glow: rgba(0, 240, 255, 0.6);
    --color-accent: #ff003c;
    --color-accent-glow: rgba(255, 0, 60, 0.6);
    --color-secondary: #7a04eb;

    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Rajdhani', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    padding: 2rem;
    position: relative;
}

/* Background Effects */
.stars-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(1px 1px at 20px 30px, #ffffff, rgba(0, 0, 0, 0)),
        radial-gradient(1px 1px at 40px 70px, #ffffff, rgba(0, 0, 0, 0)),
        radial-gradient(1.5px 1.5px at 90px 40px, #ffffff, rgba(0, 0, 0, 0)),
        radial-gradient(2px 2px at 160px 120px, rgba(255, 255, 255, 0.8), rgba(0, 0, 0, 0));
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0.3;
    z-index: -2;
}

.grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(var(--color-panel-border) 1px, transparent 1px),
        linear-gradient(90deg, var(--color-panel-border) 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.1;
    z-index: -1;
    transform: perspective(500px) rotateX(60deg) translateY(-100px) translateZ(-200px);
    transform-origin: top center;
}

.container {
    max-width: 900px;
    width: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 1rem;
}

h1.glitch {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--color-primary);
    text-transform: uppercase;
    position: relative;
    text-shadow: 0 0 10px var(--color-primary-glow);
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--color-text-muted);
    letter-spacing: 1px;
    margin-top: 0.5rem;
    text-transform: uppercase;
}

/* Panels */
.panel {
    background: var(--color-panel);
    border: 1px solid var(--color-panel-border);
    border-radius: 4px;
    backdrop-filter: blur(10px);
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 240, 255, 0.05);
}

.panel::before,
.panel::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border: 2px solid var(--color-primary);
    transition: all 0.3s ease;
}

.panel::before {
    top: -1px;
    left: -1px;
    border-right: none;
    border-bottom: none;
}

.panel::after {
    bottom: -1px;
    right: -1px;
    border-left: none;
    border-top: none;
}

.panel-header {
    background: rgba(0, 240, 255, 0.1);
    border-bottom: 1px solid var(--color-panel-border);
    padding: 0.8rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--color-primary);
    letter-spacing: 2px;
}

/* Tabs */
.tab-header {
    display: flex;
    gap: 1rem;
    padding: 0;
    justify-content: flex-start;
}

.tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-size: 1.1rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tab-btn:hover {
    color: var(--color-text-main);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-primary);
    text-shadow: 0 0 10px var(--color-primary-glow);
    background: rgba(0, 240, 255, 0.05);
}

.tab-content {
    display: none !important;
}

.tab-content.active {
    display: flex !important;
    flex-direction: column;
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-desc {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    text-align: center;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
    font-style: italic;
}

.mt-1 {
    margin-top: 1rem;
}

.panel-content {
    padding: 2rem;
}

/* Controls */
.controls .panel-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.specific-controls {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

/* Buttons */
.btn {
    font-family: var(--font-heading);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
    transition: all 0.3s ease;
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn.primary {
    padding: 1.2rem;
    font-size: 1.2rem;
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    box-shadow: 0 0 15px var(--color-primary-glow) inset;
}

.btn.primary:hover {
    background: var(--color-primary);
    color: var(--color-bg);
    box-shadow: 0 0 25px var(--color-primary-glow);
    text-shadow: none;
}

.btn.secondary {
    padding: 0.8rem;
    font-size: 0.9rem;
    min-height: 44px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-main);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn.secondary:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(0, 240, 255, 0.1);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.5rem;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--color-accent);
    transform: scale(1.1);
    text-shadow: 0 0 10px var(--color-accent-glow);
}

/* Output Area */
.output-section.hidden {
    display: none;
}

#result-container {
    font-size: 1.2rem;
    line-height: 1.6;
}

.dev-title {
    font-family: var(--font-heading);
    color: var(--color-accent);
    font-size: 1.8rem;
    margin-bottom: 1rem;
    border-bottom: 1px dashed var(--color-accent);
    padding-bottom: 0.5rem;
    display: inline-block;
}

.dev-block {
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-left: 3px solid var(--color-primary);
    animation: slideIn 0.4s ease forwards;
    opacity: 0;
    transform: translateX(-20px);
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.dev-label {
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 0.3rem;
}

.dev-value {
    color: var(--color-text-main);
}

.sub-roll {
    margin-top: 0.5rem;
    margin-left: 1.5rem;
    font-size: 1rem;
    border-left: 2px solid var(--color-secondary);
    padding-left: 1rem;
    animation-delay: 0.2s;
}

.sub-roll .dev-label {
    color: var(--color-secondary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--color-accent);
    color: #fff;
    padding: 1rem 2rem;
    font-family: var(--font-heading);
    text-transform: uppercase;
    border-radius: 4px;
    box-shadow: 0 0 20px var(--color-accent-glow);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-panel-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* NPC Specific styling */
.npc-btn {
    background: rgba(122, 4, 235, 0.1);
    border-color: var(--color-secondary);
    color: var(--color-text-main);
    width: 100%;
    margin-bottom: 1.5rem;
    box-shadow: inset 0 0 10px rgba(122, 4, 235, 0.2);
}

.npc-btn:hover {
    background: var(--color-secondary);
    color: #fff;
    box-shadow: 0 0 20px rgba(122, 4, 235, 0.6);
}

/* History Panel */
.history-panel {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 240, 255, 0.1);
    border-radius: 4px;
    padding: 1rem;
}

.history-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: 0.8rem;
    letter-spacing: 1px;
}

.history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.history-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-text-main);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-family: var(--font-heading);
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.2s ease;
    text-transform: uppercase;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.history-item:hover {
    background: rgba(0, 240, 255, 0.1);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.history-empty {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.9rem;
    font-style: italic;
}

/* ========================================= */
/* Responsive Design / Mobile Adjustments    */
/* ========================================= */
@media screen and (max-width: 768px) {
    body {
        padding: 1rem;
    }

    h1.glitch {
        font-size: 2.2rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    /* Fix Tab overflow */
    .tab-header {
        flex-direction: column;
        gap: 0;
        border-bottom: 1px solid var(--color-panel-border);
    }

    .tab-btn {
        width: 100%;
        text-align: center;
        padding: 1rem;
        border-bottom: none;
        border-left: 2px solid transparent;
    }

    .tab-btn.active {
        border-bottom: none;
        border-left: 2px solid var(--color-primary);
    }

    /* Fix controls wrapping */
    .specific-controls {
        grid-template-columns: 1fr;
    }

    .btn.primary {
        font-size: 1rem;
        padding: 1rem;
    }
}

/* ========================================= */
/* Ecosystem FAB Switcher                    */
/* ========================================= */
.system-fab-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
}

.system-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(10, 16, 30, 0.9);
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    box-shadow: 0 0 15px var(--color-primary-glow);
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.system-fab-container:hover .system-fab, .system-fab-container.active .system-fab {
    transform: scale(1.1);
    box-shadow: 0 0 25px var(--color-primary-glow);
    background: var(--color-primary);
    color: var(--color-bg);
}

.system-dropdown {
    position: absolute;
    bottom: calc(100% + 1rem);
    right: 0;
    background: var(--color-panel);
    border: 1px solid var(--color-panel-border);
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0, 240, 255, 0.05);
    min-width: 220px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

.system-fab-container.active .system-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.system-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 2px;
    text-decoration: none;
    color: var(--color-text-main);
    transition: all 0.2s;
}

.system-link:hover, .system-link:focus-visible {
    background: rgba(0, 240, 255, 0.1);
    outline: none;
}

.system-link.active {
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid var(--color-primary);
    box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.2);
}

.system-icon {
    font-size: 1.5rem;
}

.system-info strong {
    display: block;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--color-primary);
    font-size: 1rem;
    line-height: 1.1;
    letter-spacing: 1px;
}

.system-info span {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-muted);
}