:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --grid-bg: #0f172a;
    --cell-bg: #334155;
    --cell-border: #475569;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --start-color: #3b82f6;
    /* Blue for start */
    --end-color: #22c55e;
    /* Green for end */
    --obstacle-color: #64748b;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.container {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    max-width: 800px;
    width: 100%;
}

header h1 {
    margin: 0;
    font-size: 2rem;
    background: linear-gradient(to right, #3b82f6, #2dd4bf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}

header p {
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.5rem;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    width: 100%;
}

button {
    background: var(--cell-bg);
    color: var(--text-primary);
    border: 1px solid var(--cell-border);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

button:hover {
    background: var(--cell-border);
}

button.active {
    background: var(--accent);
    border-color: var(--accent);
}

.solve-btn {
    background: linear-gradient(to right, #3b82f6, #8b5cf6);
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

.solve-btn.reset-btn {
    background: linear-gradient(to right, #64748b, #475569);
}

.solve-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.view-toggles {
    display: flex;
    gap: 1rem;
    background: var(--grid-bg);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
}

.grid-container {
    display: grid;
    gap: 0.5rem;
    background: var(--grid-bg);
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--cell-border);
    max-width: 90vw;
    max-height: 70vh;
    overflow: auto;
}

.cell {
    width: 60px;
    height: 60px;
    background: var(--cell-bg);
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.05);
}

.cell:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

.cell.start {
    background: var(--start-color) !important;
    color: white;
}

.cell.end {
    background: var(--end-color) !important;
    color: white;
}

.cell.obstacle {
    background: var(--obstacle-color) !important;
}

.cell.path-cell {
    border: 3px solid #fbbf24;
    box-shadow: inset 0 0 10px rgba(251, 191, 36, 0.4), 0 0 15px rgba(251, 191, 36, 0.8);
    z-index: 5;
}

.val-text {
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 2;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    position: absolute;
    top: 5px;
}

.arrow {
    font-size: 1.5rem;
    z-index: 2;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    margin-top: 5px;
}

.legend {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.cell-preview {
    width: 20px;
    height: 20px;
    border-radius: 0.25rem;
}

.cell-preview.start {
    background: var(--start-color);
}

.cell-preview.end {
    background: var(--end-color);
}

.cell-preview.obstacle {
    background: var(--obstacle-color);
}