:root {
  --ln-bg: #07111f;
  --ln-panel: #0f172a;
  --ln-line: rgba(148, 163, 184, 0.22);
  --ln-text: #e8edf5;
  --ln-muted: #94a3b8;
  --ln-accent: #3b82f6;
  --ln-accent-text: #93c5fd;
  --ln-gold: #fbbf24;
  --ln-pit: #ef4444;
}

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

html, body {
  min-height: 100%;
  background: radial-gradient(ellipse at 50% 0%, #15233a 0%, var(--ln-bg) 70%);
  color: var(--ln-text);
  font-family: "Vazirmatn", sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body { min-height: 100vh; min-height: 100dvh; }

.learner-stage {
  position: relative;
  z-index: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 12px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.learner-masthead {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--ln-line);
  padding-bottom: 10px;
}

.learner-masthead h1 {
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  font-weight: 800;
}

.learner-masthead p {
  color: var(--ln-muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.learner-stats { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.learner-stat { text-align: center; min-width: 52px; }
.learner-stat .l { font-size: 0.7rem; color: var(--ln-accent-text); }
.learner-stat .v { font-size: 0.95rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.learner-frame {
  width: 100%;
  padding: 10px;
  background: linear-gradient(160deg, #15233a, var(--ln-panel));
  border-radius: 14px;
  border: 1px solid var(--ln-line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #0b1220;
}

.learner-ctrls {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dg {
  display: flex;
  gap: 6px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--ln-line);
  border-radius: 10px;
  padding: 4px;
}
.dg button {
  padding: 7px 12px;
  color: var(--ln-muted);
  border-radius: 8px;
}
.dg button.active {
  background: var(--ln-accent);
  color: #fff;
}
.dg button:not(.active):hover { color: #fff; background: rgba(59, 130, 246, 0.12); }
#algo { flex-wrap: wrap; }
#algo button { font-size: 0.78rem; padding: 7px 10px; }
.ag { display: flex; flex-wrap: wrap; gap: 8px; }

button {
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--ln-muted);
  background: transparent;
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.15s ease;
}

.bp { background: var(--ln-accent); color: #fff; }
.bp:hover, .bp.active { background: #2563eb; }
.bh { border-color: rgba(147, 197, 253, 0.35); color: var(--ln-accent-text); }
.bh:hover, .bh.active { background: rgba(59, 130, 246, 0.12); }

.speed {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ln-muted);
  font-size: 0.8rem;
}

.speed input { accent-color: var(--ln-accent); width: 110px; }

.leg {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--ln-muted);
  padding-top: 6px;
  border-top: 1px solid var(--ln-line);
}

.leg .i { display: flex; align-items: center; gap: 5px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.start { background: var(--ln-accent); }
.sw.goal { background: var(--ln-gold); }
.sw.pit { background: var(--ln-pit); }
.sw.wall { background: #334155; }
.sw.heat { background: linear-gradient(90deg, #1e3a8a, var(--ln-accent), var(--ln-gold)); }

@media (max-width: 640px) {
  .learner-masthead { flex-direction: column; align-items: flex-start; }
  .learner-stats { align-self: stretch; justify-content: space-between; }
  .learner-ctrls { flex-direction: column; align-items: stretch; }
}
