:root {
    /* Cyberpunk Colors */
    --bg-primary: rgba(5, 5, 8, 0.85); /* Transparent panel */
    --bg-secondary: #050505; /* Solid dark background */
    --bg-solid: #0A0A0F; /* Elements background */
    --text-primary: #e0e0e0;
    --text-secondary: #00f3ff;
    --accent-primary: #00f3ff;
    --accent-secondary: #ff003c;
    --border-color: #00f3ff;
    --hover-color: #00c3cc;
    
    /* App background color (controls 3D mostly, 2D will override) */
    --app-bg: #050505;
    
    /* Fonts */
    --font-code: 'VT323', monospace;
    --font-main: 'Rajdhani', sans-serif;
}

/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
}

body, html {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--app-bg);
    color: var(--text-primary);
}

/* Top Navigation Bar — matched to VoidRun proportions */
.top-nav {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 42px;
    background-color: rgba(5, 5, 5, 0.88);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    color: var(--accent-primary);
    font-family: var(--font-code);
    z-index: 1000;
    border-bottom: 1px solid var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.nav-title {
    font-family: var(--font-code);
    font-size: 22px;
    letter-spacing: 2.5px;
}

.nav-status {
    color: #4af626; /* Green for online */
    font-family: var(--font-code);
    font-size: 16px;
    letter-spacing: 1.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    text-shadow: 0 0 5px #4af626;
    animation: blink 2s infinite;
}

.nav-accent {
    color: var(--accent-secondary); /* Red */
    font-family: var(--font-code);
    text-shadow: 0 0 8px rgba(255, 0, 60, 0.6);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Canvas container */
#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--app-bg);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: none;
}

/* 3D container */
#container3D {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background-color: var(--app-bg);
}

/* Controls panel */
.controls-panel {
    position: absolute;
    top: 52px;
    right: 20px;
    overflow-y: auto;
    max-width: 320px;
    max-height: calc(100vh - 72px);
    background-color: var(--bg-primary);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 0;
    padding: 20px;
    box-shadow: inset 0 0 20px rgba(0, 243, 255, 0.05), 0 10px 30px rgba(0, 0, 0, 0.8);
    z-index: 100;
    border: 1px solid var(--accent-primary);
    color: var(--text-primary);
    font-family: var(--font-main);
    width: 320px;
    transition: all 0.3s ease;
}

.controls-panel::-webkit-scrollbar {
    width: 6px;
}
.controls-panel::-webkit-scrollbar-track {
    background: var(--bg-solid);
}
.controls-panel::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 0;
}
.controls-panel::-webkit-scrollbar-thumb:hover {
    background: var(--hover-color);
}

.controls-panel.collapsed {
    width: 42px !important;
    height: 42px !important;
    overflow: hidden;
    padding: 8px !important;
}

.controls-panel.collapsed .panel-content {
    display: none;
}


.toggle-panel {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--accent-primary);
    cursor: pointer;
    font-size: 18px;
    z-index: 101;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    transition: all 0.2s;
}

.toggle-panel:hover {
    background-color: var(--accent-primary);
    color: #000;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.4);
}

.controls-panel.collapsed .toggle-panel {
    top: 7px;
    right: 7px;
}

h2 {
    margin-bottom: 15px;
    color: var(--accent-secondary);
    font-size: 26px;
    padding-right: 30px;
    font-family: var(--font-code);
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 8px rgba(255, 0, 60, 0.5);
    font-weight: 400;
}

.control-group {
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(0, 243, 255, 0.2);
    padding-bottom: 20px;
}

.control-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 14px;
}

select, button, input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 10px;
    border-radius: 0;
    border: 1px solid rgba(0, 243, 255, 0.3);
    background-color: var(--bg-solid);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    font-family: var(--font-main);
    letter-spacing: 1px;
}

select {
    cursor: pointer;
    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='%2300f3ff' 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 8px center;
    background-size: 16px;
    padding-right: 30px;
}

select:hover, input[type="text"]:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px rgba(0, 243, 255, 0.2);
}

select:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px rgba(0, 243, 255, 0.4);
}

button {
    background-color: transparent;
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    cursor: pointer;
    font-weight: 700;
    text-transform: uppercase;
    font-family: var(--font-main);
    position: relative;
    overflow: hidden;
}

button:hover {
    background-color: var(--accent-primary);
    color: #000;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.5);
}

button:disabled {
    background-color: rgba(255, 255, 255, 0.05);
    color: #555;
    border-color: #333;
    cursor: not-allowed;
    box-shadow: none;
}

#clearBtn, #clearPathBtn {
    color: var(--accent-secondary);
    border-color: var(--accent-secondary);
}

#clearBtn:hover, #clearPathBtn:hover {
    background-color: var(--accent-secondary);
    color: #000;
    box-shadow: 0 0 15px rgba(255, 0, 60, 0.5);
}

.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.button-group button {
    flex: 1;
    margin-bottom: 0;
}

/* Toggle switches */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
    margin-left: 10px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-solid);
    border: 1px solid rgba(0, 243, 255, 0.3);
    transition: .3s;
    border-radius: 0;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: var(--accent-primary);
    opacity: 0.45;
    transition: .3s;
    border-radius: 0;
}

input:checked + .slider {
    background-color: rgba(0, 243, 255, 0.2);
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px rgba(0, 243, 255, 0.4);
}

input:checked + .slider:before {
    transform: translateX(22px);
    background-color: var(--accent-primary);
    opacity: 1;
    box-shadow: 0 0 8px var(--accent-primary), 0 0 16px var(--accent-primary);
}

.toggle-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    background: var(--bg-solid);
    border: 1px solid rgba(0, 243, 255, 0.1);
    padding: 10px 12px;
    border-radius: 0;
    font-weight: 500;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.size-slider {
    flex: 1;
    width: 100%;
    height: 2px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(0, 243, 255, 0.3);
    outline: none;
    border-radius: 0;
}

.size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 18px;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 0 5px var(--accent-primary);
}

#gridSizeValue {
    min-width: 65px;
    font-size: 14px;
    color: var(--accent-primary);
    font-family: var(--font-code);
    text-align: right;
}

/* Legend */
.legend {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
}

.color-box {
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: inset 0 0 3px rgba(0,0,0,0.5);
}

/* Status info */
.status-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background-color: var(--bg-primary);
    backdrop-filter: blur(5px);
    color: var(--accent-primary);
    font-family: var(--font-code);
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.15);
    z-index: 100;
    max-width: 400px;
    font-size: 20px;
    text-transform: uppercase;
}

/* Tutorial dialog */
.tutorial {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translate(-50%, 0);
    background-color: var(--bg-primary);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 30px;
    border-radius: 0;
    box-shadow: inset 0 0 20px rgba(0, 243, 255, 0.1), 0 10px 40px rgba(0, 0, 0, 0.9);
    z-index: 200;
    max-width: 600px;
    width: 90%;
    display: none;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.tutorial.show {
    display: block;
    animation: fadeIn 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.tutorial h3 {
    margin-bottom: 20px;
    color: var(--accent-secondary);
    font-size: 28px;
    font-family: var(--font-code);
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(255, 0, 60, 0.4);
    border-bottom: 1px solid rgba(255, 0, 60, 0.3);
    padding-bottom: 10px;
}

.tutorial p {
    margin-bottom: 15px;
    line-height: 1.6;
    font-size: 16px;
    color: var(--text-primary);
}

.tutorial ul {
    margin-left: 20px;
    margin-bottom: 25px;
}

.tutorial li {
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
}

.tutorial li::marker {
    color: var(--accent-primary);
}

.tutorial button {
    margin-top: 10px;
    width: auto;
    padding: 10px 30px;
    font-size: 16px;
}

/* Algorithm info */
.algorithm-info {
    padding: 15px;
    background-color: var(--bg-solid);
    margin-bottom: 15px;
    font-size: 18px;
    color: var(--accent-primary);
    font-family: var(--font-code);
    border: 1px dashed rgba(0, 243, 255, 0.3);
    line-height: 1.4;
    text-transform: uppercase;
}



.shortcut-list {
    font-size: 14px;
    color: var(--text-primary);
    font-family: var(--font-main);
}

.shortcut-list p {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 243, 255, 0.1);
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    padding: 2px 8px;
    font-family: var(--font-code);
    font-size: 16px;
    min-width: 24px;
    height: 24px;
    box-shadow: 0 0 5px rgba(0, 243, 255, 0.2);
}

/* Media queries */
@media (max-width: 768px) {
    .controls-panel {
        max-width: 260px;
        padding: 15px;
    }
    
    .tutorial {
        width: 95%;
        padding: 20px;
    }
    
    .status-info {
        max-width: 300px;
        font-size: 16px;
    }
}

.panel-content {
    opacity: 1;
    transition: opacity 0.3s ease;
    width: 100%;
    visibility: visible;
}

.panel-title {
    margin-top: 10px;
    margin-bottom: 20px;
}