:root {
  --bg: #eef2f7;
  --text: #000;
  --grid-bg: #ffffff;
}

body.dark {
  --bg: #0f172a;
  --text: #e5e7eb;
  --grid-bg: #020617;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  text-align: center;
  background: var(--bg);
  color: var(--text);
}

/* controls */
.controls {
  margin: 12px;
}

button, select {
  padding: 6px 10px;
  margin: 4px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

button {
  background: #2563eb;
  color: white;
}

button:hover {
  background: #1e40af;
}

select {
  background: #334155;
  color: white;
}

/* info */
.info {
  margin-top: 8px;
  font-size: 15px;
}

/* legend */
.legend {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 10px 0;
  flex-wrap: wrap;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.box {
  width: 14px;
  height: 14px;
  border: 1px solid #555;
}

/* grid */
#grid {
  display: grid;
  grid-template-columns: repeat(40, 22px); /* 👈 40 columns */
  justify-content: center;
  margin: 15px auto;
  padding: 14px;
  background: var(--grid-bg);
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
}

#grid {
  touch-action: none;   /* 🔥 THIS IS CRITICAL */
}


.node {
  width: 22px;   /* 👈 slightly smaller */
  height: 22px;
  border: 1px solid #334155;
  transition: transform 0.1s;
}

.node:hover {
  transform: scale(1.05);
}

.start { background: green; }
.end { background: red; }
.wall {
  background-color: #1f2933;
  border: 1px solid #64748b;
  box-shadow: inset 0 0 0 1px #0f172a;
}

.weight { background: orange; }
.visited { background: #38bdf8; }
.path { background: yellow; }



.explain {
  max-width: 800px;
  margin: 30px auto;
  text-align: left;
  padding: 20px;
  background: var(--grid-bg);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.explain h3 {
  margin-top: 0;
  color: #60a5fa;
}

.explain ul {
  padding-left: 18px;
}

.explain li {
  margin-bottom: 6px;
}
