:root {
  --bg: #0f1220;
  --panel: #161a2b;
  --muted: #8b91a7;
  --accent: #6aa6ff;
  --accent-2: #7bffb2;
  --danger: #ff6b6b;
  --visited: #4a5aa6;
  --queued: #3452a3;
  --path: #ffd166;
  --grid-gap: 2px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 800px at 20% 0%, #12162a, #0c0f1c 60%);
  color: white;
}

.app { min-height: 100%; display: flex; flex-direction: column; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0));
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  backdrop-filter: blur(6px);
  z-index: 5;
}

.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }

button, select {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.12);
  color: white;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

button.primary {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  border: none;
}

button:disabled { opacity: 0.6; cursor: not-allowed; }

label.inline { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
input[type="range"] { accent-color: var(--accent); }

main { padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.hint { color: var(--muted); font-size: 0.9rem; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: center; color: var(--muted); margin: 2px 0 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.swatch { width: 16px; height: 16px; border-radius: 4px; display: inline-block; box-shadow: 0 0 0 1px rgba(255,255,255,0.12) inset; }
.swatch.start { background: linear-gradient(180deg, #22c55e, #16a34a); }
.swatch.end { background: linear-gradient(180deg, #ef4444, #dc2626); }
.swatch.wall { background: #0f2048; box-shadow: inset 0 0 0 2px #24488f; }
.swatch.visited { background: var(--visited); }
.swatch.queued { background: var(--queued); }
.swatch.path { background: var(--path); }

.grid {
  display: grid;
  grid-template-columns: repeat(40, 22px);
  grid-auto-rows: 22px;
  gap: var(--grid-gap);
  background: rgba(255,255,255,0.06);
  padding: 8px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), 0 8px 40px rgba(0,0,0,0.35);
}

.cell {
  width: 22px; height: 22px;
  background: #12172c;
  border-radius: 4px;
  transition: background 120ms ease, transform 120ms ease, box-shadow 120ms ease;
  position: relative;
}

.cell:hover { box-shadow: 0 0 0 1px rgba(255,255,255,0.15) inset; }

.cell.wall { background: #0f2048; box-shadow: inset 0 0 0 2px #24488f, 0 0 0 1px rgba(36,72,143,0.2); }
.cell.visited { background: var(--visited); }
.cell.queued { background: var(--queued); }
.cell.path { background: var(--path); }

.cell.start { background: linear-gradient(180deg, #22c55e, #16a34a); }
.cell.end { background: linear-gradient(180deg, #ef4444, #dc2626); }

.footer { color: var(--muted); font-size: 0.85rem; padding: 10px 16px; text-align: center; }

@media (max-width: 960px) {
  .grid { grid-template-columns: repeat(24, 22px); }
}

/* Pulsating gradient animation while animating */
@keyframes pulseQueued {
  0% { box-shadow: 0 0 0 0 rgba(106, 166, 255, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(106, 166, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(106, 166, 255, 0); }
}
@keyframes pulseVisited {
  0% { box-shadow: 0 0 0 0 rgba(123, 255, 178, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(123, 255, 178, 0); }
  100% { box-shadow: 0 0 0 0 rgba(123, 255, 178, 0); }
}

.animating .cell.queued {
  background: radial-gradient(80% 80% at 30% 25%, #6aa6ff 0%, #3452a3 60%, #223463 100%);
  animation: pulseQueued 1.2s ease-out infinite;
}
.animating .cell.visited {
  background: radial-gradient(80% 80% at 30% 25%, #7bffb2 0%, #3c7f66 60%, #244b3e 100%);
  animation: pulseVisited 1.4s ease-out infinite;
}



