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

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #21262d;
    --accent-green: #39d353;
    --accent-blue: #58a6ff;
    --accent-purple: #a371f7;
    --accent-orange: #f78166;
    --accent-yellow: #e3b341;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border: #30363d;
    --node-wall: #6e7681;
    --node-visited: rgba(88, 166, 255, 0.3);
    --node-path: #39d353;
    --border-radius: 8px;
}

body {
    font-family: 'Space Grotesk', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 25px;
}

.header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    align-items: flex-end;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

select {
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    min-width: 150px;
}

select:hover, select:focus {
    border-color: var(--accent-blue);
    outline: none;
}

.control-buttons {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
    color: var(--bg-primary);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(57, 211, 83, 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Instructions */
.instructions {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.instruction {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.node-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.node-icon.start {
    background: var(--accent-green);
}

.node-icon.end {
    background: var(--accent-orange);
}

.node-icon.wall {
    background: var(--node-wall);
}

/* Grid */
.grid-container {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    overflow-x: auto;
}

.grid {
    display: grid;
    gap: 1px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    user-select: none;
}

.node {
    width: 25px;
    height: 25px;
    background: var(--bg-card);
    transition: background 0.1s;
    cursor: pointer;
}

.node:hover {
    background: var(--border);
}

.node.wall {
    background: var(--node-wall);
    animation: wallAppear 0.2s ease;
}

@keyframes wallAppear {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.node.start {
    background: var(--accent-green);
    cursor: grab;
}

.node.start:active {
    cursor: grabbing;
}

.node.end {
    background: var(--accent-orange);
    cursor: grab;
}

.node.end:active {
    cursor: grabbing;
}

.node.visited {
    background: var(--node-visited);
    animation: visitedAppear 0.3s ease;
}

@keyframes visitedAppear {
    0% {
        transform: scale(0.3);
        background: var(--accent-purple);
    }
    50% {
        background: var(--accent-blue);
    }
    100% {
        transform: scale(1);
        background: var(--node-visited);
    }
}

.node.path {
    background: var(--accent-green);
    animation: pathAppear 0.3s ease;
}

@keyframes pathAppear {
    0% {
        transform: scale(0.5);
        background: var(--accent-yellow);
    }
    100% {
        transform: scale(1);
        background: var(--accent-green);
    }
}

/* Stats */
.stats {
    display: flex;
    justify-content: center;
    gap: 50px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.stat {
    text-align: center;
}

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

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Algorithm Info */
.algorithm-info {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    text-align: center;
}

.algorithm-info h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--accent-blue);
}

.algorithm-info .guarantee {
    display: inline-block;
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 10px;
}

.algorithm-info .guarantee.yes {
    background: rgba(57, 211, 83, 0.2);
    color: var(--accent-green);
}

.algorithm-info .guarantee.no {
    background: rgba(247, 129, 102, 0.2);
    color: var(--accent-orange);
}

.algorithm-info .description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Footer */
.footer {
    text-align: center;
    padding: 15px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer a {
    color: var(--accent-blue);
    text-decoration: none;
}

.footer a:hover {
    color: var(--accent-green);
}

/* Responsive */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        width: 100%;
    }

    select {
        width: 100%;
    }

    .control-buttons {
        justify-content: center;
        flex-wrap: wrap;
    }

    .stats {
        gap: 20px;
    }

    .node {
        width: 20px;
        height: 20px;
    }
}
