:root {
  --bg: #0b1120;
  --bg-soft: #111c33;
  --panel: #16233d;
  --line: #24354f;
  --text: #e6edf7;
  --muted: #93a4bf;
  --idle: #3f5573;
  --cmp: #fbbf24;
  --swap: #f472b6;
  --done: #34d399;
  --accent: #38bdf8;
  --accent-2: #a78bfa;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #17233c 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

/* ---------- üst bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 17, 32, 0.8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: 0.3px; }
.tag { color: var(--muted); font-size: 13px; }

.logo {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.35);
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.tabs { display: flex; gap: 6px; background: var(--bg-soft); padding: 4px; border-radius: 10px; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 18px; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 600;
}
.tab.is-active { background: var(--panel); color: var(--text); box-shadow: 0 1px 0 var(--line); }

.langs { display: flex; gap: 4px; background: var(--bg-soft); padding: 4px; border-radius: 10px; }
.lang {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 11px; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 700; letter-spacing: 0.6px;
}
.lang.is-active { background: var(--panel); color: var(--accent); }

/* ---------- düzen ---------- */
main { padding: 24px 28px 8px; }
.view { display: none; gap: 22px; }
.view.is-active { display: grid; grid-template-columns: 280px 1fr; }

@media (max-width: 900px) {
  .view.is-active { grid-template-columns: 1fr; }
  main { padding: 16px; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  height: fit-content;
  display: grid;
  gap: 16px;
}

.field { display: grid; gap: 7px; }
.field label { font-size: 13px; color: var(--muted); }
.field label b { color: var(--text); }

select {
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; font-size: 13px; width: 100%;
}

input[type="range"] { width: 100%; accent-color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  flex: 1 1 auto;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #08101f; border-color: transparent;
}

/* ---------- sahne ---------- */
.stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}

canvas { width: 100%; height: auto; display: block; border-radius: 8px; background: var(--bg-soft); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.stats > div {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px;
  display: grid; gap: 2px;
}
.stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.stats b { font-size: 17px; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; color: var(--muted); font-size: 12px; margin: 14px 0 0; }
.legend > span { display: inline-flex; align-items: center; }
.dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.dot-idle { background: var(--idle); }
.dot-cmp { background: var(--cmp); }
.dot-swap { background: var(--swap); }
.dot-done { background: var(--done); }
.dot-start { background: #22c55e; }
.dot-end { background: #ef4444; }
.dot-wall { background: #46577a; }
.dot-weight { background: #b45309; }
.dot-visit { background: #1d4ed8; }
.dot-route { background: #facc15; }

.explain { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 12px 0 0; }
.explain b { color: var(--text); }

/* ---------- ızgara ---------- */
.grid {
  display: grid;
  gap: 1px;
  background: var(--line);
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}
.cell { background: #16223a; aspect-ratio: 1; }
.cell.wall { background: #46577a; }
.cell.weight { background: #b45309; }
.cell.visited { background: #1d4ed8; animation: pop 0.25s ease-out; }
.cell.frontier { background: #60a5fa; }
.cell.route { background: #facc15; animation: pop 0.25s ease-out; }
.cell.start { background: #22c55e; }
.cell.end { background: #ef4444; }

@keyframes pop {
  0% { transform: scale(0.35); border-radius: 50%; }
  100% { transform: scale(1); border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cell.visited, .cell.route { animation: none; }
}

footer { color: var(--muted); font-size: 12px; text-align: center; padding: 22px; }
footer a { color: var(--accent); }
