:root {
    --bg-color: #050a14;
    --card-bg: rgba(15, 23, 42, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --color-base: #00ff88;
    --color-victim: #ff3366;
    --color-wall: #1e293b;
    --color-safe: #334155;
    --color-search: rgba(255, 215, 0, 0.6);
    --color-path: #00e5ff;
    
    --glow-base: 0 0 10px rgba(0, 255, 136, 0.5);
    --glow-victim: 0 0 10px rgba(255, 51, 102, 0.5);
    --glow-path: 0 0 15px rgba(0, 229, 255, 0.6);
    --glow-text: 0 0 10px rgba(0, 229, 255, 0.8);
    
    --cell-size: 26px;
    --grid-gap: 2px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Network Background */
.network-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    opacity: 0.4;
}

/* Layout */
.wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 30px 0 20px;
    animation: fadeInDown 0.8s ease-out;
}

.glow-title {
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: var(--glow-text);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Dashboard Layout */
.dashboard {
    display: grid;
    grid-template-columns: 320px 1fr 300px;
    gap: 25px;
    align-items: start;
}

@media (max-width: 1200px) {
    .dashboard {
        grid-template-columns: 280px 1fr 280px;
        gap: 15px;
    }
}

@media (max-width: 992px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    .left-panel, .right-panel, .center-panel {
        width: 100%;
    }
}

/* Glass Cards */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
}

h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: #fff;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 10px;
}

h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

/* Controls */
.control-group {
    margin-bottom: 24px;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.glow-select {
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    color: #fff;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    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='%2394a3b8' 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 12px center;
    background-size: 16px;
}

.glow-select:focus, .glow-select:hover {
    border-color: var(--color-path);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.2);
}

.glow-select option {
    background: #0f172a;
    color: #fff;
}

/* Tool Buttons */
.element-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tool-btn {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 15px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.tool-btn.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.05);
}

.dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 12px;
    display: inline-block;
}

.base-dot { background: var(--color-base); box-shadow: var(--glow-base); }
.victim-dot { background: var(--color-victim); box-shadow: var(--glow-victim); }
.wall-dot { background: var(--color-wall); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 4px; }
.safe-dot { background: var(--color-safe); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 4px; }
.clear-dot { background: transparent; border: 1px dashed rgba(255, 255, 255, 0.3); border-radius: 4px; }

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 30px;
}

.action-btn {
    padding: 14px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.primary-btn {
    background: linear-gradient(135deg, #00b4db, #0083b0);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 180, 219, 0.3);
}

.primary-btn:hover {
    background: linear-gradient(135deg, #00c6ff, #0072ff);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 198, 255, 0.4);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.danger-btn {
    background: rgba(255, 51, 102, 0.1);
    color: #ff3366;
    border: 1px solid rgba(255, 51, 102, 0.3);
}

.danger-btn:hover {
    background: rgba(255, 51, 102, 0.2);
    box-shadow: 0 0 15px rgba(255, 51, 102, 0.3);
}

/* Grid Map */
.simulator {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
    padding: 30px;
}

.map-container {
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    overflow: auto;
    max-width: 100%;
}

#grid-map {
    display: grid;
    /* 20x20 grid, set via JS or CSS. Assuming 20 columns */
    grid-template-columns: repeat(20, var(--cell-size));
    grid-template-rows: repeat(20, var(--cell-size));
    gap: var(--grid-gap);
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background-color: var(--color-safe);
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s;
    user-select: none;
}

.cell:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.cell.base {
    background-color: var(--color-base);
    box-shadow: var(--glow-base);
    animation: pulse 2s infinite;
}

.cell.victim {
    background-color: var(--color-victim);
    box-shadow: var(--glow-victim);
}

.cell.wall {
    background-color: var(--color-wall);
    border: 1px solid rgba(0, 0, 0, 0.5);
}

.cell.search {
    background-color: var(--color-search);
    animation: popIn 0.3s ease forwards;
}

.cell.path {
    background-color: var(--color-path);
    box-shadow: var(--glow-path);
    animation: pathPop 0.4s ease forwards;
    z-index: 5;
    position: relative;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-icon {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
}

.text-glow-blue {
    color: var(--color-path);
    text-shadow: var(--glow-text);
}

/* Legend */
.legend-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.legend-list li {
    display: flex;
    align-items: center;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    margin-right: 12px;
    display: inline-block;
}

.legend-base { background: var(--color-base); box-shadow: var(--glow-base); border-radius: 50%;}
.legend-victim { background: var(--color-victim); box-shadow: var(--glow-victim); border-radius: 50%;}
.legend-wall { background: var(--color-wall); }
.legend-safe { background: var(--color-safe); }
.legend-search { background: var(--color-search); }
.legend-path { background: var(--color-path); box-shadow: var(--glow-path); }

/* Explanation */
#algo-explanation h3 {
    color: #fff;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

#algo-explanation p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 15px;
}

.tree-diagram {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    justify-content: center;
}

/* Footer */
.glass-footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
    background: rgba(15, 23, 42, 0.4);
    margin-top: auto;
}

/* Animations */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(0, 255, 136, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0); }
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    80% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes pathPop {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}
