.visualizer-panel {
  min-height: 420px;
  padding: 1rem;
}

.bars-container {
  width: 100%;
  height: 380px;
  min-height: 380px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem;
  border-radius: 0.85rem;
  background:
    linear-gradient(180deg, rgba(17, 26, 50, 0.6), rgba(8, 12, 24, 0.7)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.02),
      rgba(255, 255, 255, 0.02) 10px,
      transparent 10px,
      transparent 20px
    );
  overflow: hidden;
}

.bar {
  position: relative;
  width: clamp(8px, 2.4vw, 20px);
  border-radius: 0.35rem 0.35rem 0.1rem 0.1rem;
  background: #3b82f6;
  transition: height 220ms ease, background-color 220ms ease, transform 220ms ease;
  transform-origin: bottom;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.bar-label {
  position: absolute;
  left: 50%;
  top: 0.18rem;
  transform: translateX(-50%) scale(1);
  transform-origin: center;
  font-size: clamp(9px, 0.95vw, 12px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f8fafc;
  opacity: 0.88;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  background: rgba(2, 6, 23, 0.48);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 999px;
  padding: 1px 4px;
  white-space: nowrap;
  transition:
    color 220ms ease,
    opacity 220ms ease,
    transform 220ms ease,
    background-color 220ms ease,
    border-color 220ms ease;
  pointer-events: none;
  user-select: none;
}

.bar.default {
  background: #3b82f6;
}

.bar.comparing {
  background: #facc15;
}

.bar.comparing .bar-label {
  color: #1f2937;
  opacity: 1;
  background: rgba(254, 240, 138, 0.92);
  border-color: rgba(161, 98, 7, 0.42);
  transform: translateX(-50%) translateY(-2px) scale(1.08);
}

.bar.swapping {
  background: #ef4444;
}

.bar.swapping .bar-label {
  color: #ffffff;
  opacity: 1;
  background: rgba(153, 27, 27, 0.72);
  border-color: rgba(254, 205, 211, 0.35);
  transform: translateX(-50%) translateY(-2px) scale(1.08);
}

.bar.sorted {
  background: #22c55e;
}

.bar.sorted .bar-label {
  color: #052e16;
  opacity: 1;
  background: rgba(187, 247, 208, 0.92);
  border-color: rgba(20, 83, 45, 0.35);
  transform: translateX(-50%) scale(1);
}

@media (max-width: 700px) {
  .visualizer-panel {
    min-height: 340px;
  }

  .bars-container {
    height: 300px;
    min-height: 300px;
    gap: 0.22rem;
    padding: 0.4rem;
  }

  .bar {
    width: clamp(5px, 1.9vw, 10px);
  }

  .bar-label {
    font-size: 8px;
    top: 0.12rem;
    opacity: 0.85;
    padding: 1px 3px;
  }
}
