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

    /* ---- Animated Background ---- */
    body {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      min-height: 100vh;
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 20px;
      background: #0a0b1a;
      position: relative;
      overflow-x: hidden;
    }

    body::before {
      content: '';
      position: fixed;
      top: 0; left: 0; width: 100%; height: 100%;
      background:
        radial-gradient(ellipse 80% 60% at 20% 80%, rgba(99, 102, 241, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 20%, rgba(168, 85, 247, 0.10) 0%, transparent 50%),
        radial-gradient(ellipse 50% 40% at 50% 50%, rgba(236, 72, 153, 0.06) 0%, transparent 50%);
      z-index: 0;
      animation: bgShift 12s ease-in-out infinite alternate;
    }

    @keyframes bgShift {
      0% { transform: scale(1) rotate(0deg); }
      100% { transform: scale(1.1) rotate(3deg); }
    }

    /* Floating grid lines */
    body::after {
      content: '';
      position: fixed;
      top: 0; left: 0; width: 100%; height: 100%;
      background-image:
        linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
      background-size: 60px 60px;
      z-index: 0;
      pointer-events: none;
    }

    /* Glowing orbs */
    .orb {
      position: fixed;
      border-radius: 50%;
      filter: blur(80px);
      z-index: 0;
      pointer-events: none;
      animation: orbFloat 15s ease-in-out infinite alternate;
    }

    .orb-1 {
      width: 400px; height: 400px;
      background: rgba(99, 102, 241, 0.08);
      top: -100px; right: -100px;
    }

    .orb-2 {
      width: 350px; height: 350px;
      background: rgba(168, 85, 247, 0.07);
      bottom: -80px; left: -80px;
      animation-delay: -5s;
    }

    .orb-3 {
      width: 250px; height: 250px;
      background: rgba(236, 72, 153, 0.06);
      top: 50%; left: 50%;
      animation-delay: -10s;
    }

    @keyframes orbFloat {
      0% { transform: translate(0, 0) scale(1); }
      100% { transform: translate(40px, -30px) scale(1.15); }
    }

    /* ---- Container ---- */
    .container {
      background: rgba(12, 14, 30, 0.75);
      backdrop-filter: blur(24px);
      -webkit-backdrop-filter: blur(24px);
      border: 1px solid rgba(255, 255, 255, 0.07);
      border-radius: 28px;
      padding: 32px;
      width: 100%;
      max-width: 960px;
      box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
      position: relative;
      z-index: 1;
    }

    .header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 20px;
      flex-wrap: wrap;
      gap: 12px;
    }

    .header-left h1 {
      color: #e8e8ff;
      font-weight: 700;
      font-size: 1.6rem;
      letter-spacing: -0.5px;
      background: linear-gradient(135deg, #e8e8ff 0%, #a5b4fc 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .header-left h2 {
      color: #a5b4fc;
      font-weight: 600;
      font-size: 1rem;
      letter-spacing: -0.3px;
      margin-top: 2px;
    }

    .header-left .subtitle {
      color: rgba(255, 255, 255, 0.3);
      font-size: 0.8rem;
      margin-top: 2px;
    }

    .algo-select {
      background:
        linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(168, 85, 247, 0.06)),
        rgba(12, 14, 36, 0.7);
      border: 1px solid rgba(129, 140, 248, 0.2);
      border-radius: 12px;
      padding: 11px 40px 11px 18px;
      color: #c8c8ff;
      font-size: 0.9rem;
      font-weight: 600;
      letter-spacing: 0.2px;
      cursor: pointer;
      outline: none;
      appearance: none;
      -webkit-appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' stop-color='%236366f1'/%3E%3Cstop offset='100%25' stop-color='%23a855f7'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath fill='url(%23g)' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 14px center;
      background-size: 12px 8px;
      box-shadow: 0 2px 12px rgba(99, 102, 241, 0.08);
      transition: all 0.25s ease;
    }

    .algo-select:hover {
      border-color: rgba(129, 140, 248, 0.5);
      box-shadow: 0 2px 20px rgba(99, 102, 241, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05);
      background:
        linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(168, 85, 247, 0.08)),
        rgba(12, 14, 36, 0.8);
    }

    .algo-select:focus {
      border-color: rgba(129, 140, 248, 0.6);
      box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15), 0 2px 20px rgba(99, 102, 241, 0.1);
    }

    .algo-select option {
      background: #14163a;
      color: #d0d0ff;
      padding: 8px 12px;
      font-weight: 500;
    }

    .algo-select optgroup {
      background: #0e1030;
      color: rgba(255, 255, 255, 0.35);
      font-weight: 600;
      font-size: 0.75rem;
      letter-spacing: 0.5px;
      text-transform: uppercase;
      padding: 6px 12px;
    }

    .algo-select:disabled {
      opacity: 0.35;
      cursor: not-allowed;
      box-shadow: none;
    }

    /* ---- Legend ---- */
    .legend {
      display: flex;
      flex-wrap: wrap;
      gap: 14px;
      justify-content: center;
      margin-bottom: 12px;
      padding: 10px 16px;
      background: rgba(0, 0, 0, 0.2);
      border-radius: 12px;
      border: 1px solid rgba(255, 255, 255, 0.04);
    }

    .legend-item {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 0.75rem;
      color: rgba(255, 255, 255, 0.45);
    }

    .legend-swatch {
      width: 14px; height: 14px;
      border-radius: 3px;
      flex-shrink: 0;
    }

    /* ---- Status Bar ---- */
    .status-bar {
      background: rgba(0, 0, 0, 0.35);
      border-radius: 12px;
      padding: 14px 20px;
      margin-bottom: 12px;
      border: 1px solid rgba(255, 255, 255, 0.05);
      min-height: 52px;
      display: flex;
      align-items: center;
    }

    .status-text {
      color: #c8c8e8;
      font-size: 0.95rem;
      font-weight: 400;
      line-height: 1.5;
      width: 100%;
    }

    .status-text strong { color: #a5b4fc; font-weight: 600; }
    .status-text .hl-blue { color: #60a5fa; }
    .status-text .hl-amber { color: #fbbf24; }
    .status-text .hl-red { color: #f87171; }
    .status-text .hl-green { color: #34d399; }
    .status-text .hl-purple { color: #c084fc; }
    .status-text .hl-pink { color: #f472b6; }

    /* ---- Visualizer ---- */
    .visualizer-wrap {
      position: relative;
      margin-bottom: 8px;
    }

    .visualizer {
      display: flex;
      align-items: flex-end;
      justify-content: center;
      height: 340px;
      background: rgba(0, 0, 0, 0.35);
      border-radius: 18px;
      padding: 24px 8px 0;
      gap: 3px;
      border: 1px solid rgba(255, 255, 255, 0.05);
      position: relative;
      overflow: hidden;
    }

    .visualizer::before {
      content: '';
      position: absolute;
      top: 0; left: 0; right: 0; bottom: 0;
      background: radial-gradient(ellipse at 50% 100%, rgba(99,102,241,0.04) 0%, transparent 60%);
      pointer-events: none;
    }

    .bar-wrapper {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: flex-end;
      height: 100%;
      position: relative;
      min-width: 0;
    }

    .bar {
      width: 100%;
      border-radius: 3px 3px 0 0;
      transition: background 0.15s ease, height 0.15s ease, opacity 0.3s ease, box-shadow 0.2s ease;
      background: linear-gradient(to top, #4f46e5, #818cf8);
      min-width: 4px;
      box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
      position: relative;
    }

    .bar.dimmed { opacity: 0.2; }
    .bar-value {
      color: rgba(255, 255, 255, 0.4);
      font-size: 0.6rem;
      font-weight: 500;
      margin-top: 2px;
      text-align: center;
      line-height: 1;
      white-space: nowrap;
    }
    .bar-index {
      color: rgba(255, 255, 255, 0.12);
      font-size: 0.5rem;
      margin-top: 1px;
      text-align: center;
      line-height: 1;
    }

    .bar.comparing {
      background: linear-gradient(to top, #d97706, #fbbf24);
      box-shadow: 0 0 20px rgba(245, 158, 11, 0.45);
    }
    .bar.swapping {
      background: linear-gradient(to top, #dc2626, #f87171);
      box-shadow: 0 0 24px rgba(239, 68, 68, 0.5);
    }
    .bar.sorted {
      background: linear-gradient(to top, #059669, #34d399);
      box-shadow: 0 0 16px rgba(16, 185, 129, 0.35);
    }
    .bar.pivot {
      background: linear-gradient(to top, #9333ea, #c084fc);
      box-shadow: 0 0 24px rgba(168, 85, 247, 0.5);
    }
    .bar.left-pointer {
      background: linear-gradient(to top, #2563eb, #60a5fa);
      box-shadow: 0 0 18px rgba(59, 130, 246, 0.4);
    }
    .bar.right-pointer {
      background: linear-gradient(to top, #db2777, #f472b6);
      box-shadow: 0 0 18px rgba(236, 72, 153, 0.4);
    }
    .bar.found {
      background: linear-gradient(to top, #059669, #6ee7b7);
      box-shadow: 0 0 30px rgba(16, 185, 129, 0.6), 0 0 60px rgba(16, 185, 129, 0.2);
    }
    .bar.miss {
      background: linear-gradient(to top, #4b5563, #9ca3af);
      box-shadow: 0 0 6px rgba(156, 163, 175, 0.15);
    }

    .pointer-label {
      position: absolute;
      top: -18px;
      left: 50%;
      transform: translateX(-50%);
      font-size: 0.55rem;
      font-weight: 700;
      color: rgba(255, 255, 255, 0.7);
      background: rgba(0, 0, 0, 0.5);
      padding: 1px 5px;
      border-radius: 4px;
      white-space: nowrap;
      letter-spacing: 0.3px;
    }
    .pointer-label.i { color: #60a5fa; background: rgba(59, 130, 246, 0.2); border: 1px solid rgba(59, 130, 246, 0.3); }
    .pointer-label.j { color: #f472b6; background: rgba(236, 72, 153, 0.2); border: 1px solid rgba(236, 72, 153, 0.3); }
    .pointer-label.pivot-label { color: #c084fc; background: rgba(168, 85, 247, 0.2); border: 1px solid rgba(168, 85, 247, 0.3); }
    .pointer-label.swap-label { color: #f87171; background: rgba(239, 68, 68, 0.2); border: 1px solid rgba(239, 68, 68, 0.3); }
    .pointer-label.lo { color: #60a5fa; background: rgba(59, 130, 246, 0.2); border: 1px solid rgba(59, 130, 246, 0.3); }
    .pointer-label.mid { color: #c084fc; background: rgba(168, 85, 247, 0.2); border: 1px solid rgba(168, 85, 247, 0.3); }
    .pointer-label.hi { color: #f472b6; background: rgba(236, 72, 153, 0.2); border: 1px solid rgba(236, 72, 153, 0.3); }
    .pointer-label.target { color: #34d399; background: rgba(16, 185, 129, 0.2); border: 1px solid rgba(16, 185, 129, 0.3); }

    .range-indicator {
      display: flex;
      justify-content: space-between;
      padding: 0 8px;
      margin-top: 3px;
      font-size: 0.55rem;
      color: rgba(255, 255, 255, 0.18);
      font-weight: 500;
      letter-spacing: 0.5px;
    }
    .range-indicator span {
      background: rgba(255, 255, 255, 0.03);
      padding: 1px 8px;
      border-radius: 4px;
    }

    /* ---- Controls ---- */
    .controls {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: center;
      justify-content: center;
      margin-top: 16px;
    }

    .controls button {
      padding: 10px 22px;
      border: none;
      border-radius: 12px;
      font-size: 0.9rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s ease;
      letter-spacing: 0.3px;
    }
    .controls button:active { transform: scale(0.96); }

    .btn-play {
      background: linear-gradient(135deg, #6366f1, #8b5cf6);
      color: #fff;
      box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
      min-width: 110px;
    }
    .btn-play:hover:not(:disabled) {
      box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5);
      transform: translateY(-1px);
    }
    .btn-play:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

    .btn-play.paused {
      background: linear-gradient(135deg, #d97706, #f59e0b);
      box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
    }
    .btn-play.paused:hover:not(:disabled) {
      box-shadow: 0 6px 24px rgba(245, 158, 11, 0.5);
    }
    .btn-play.search {
      background: linear-gradient(135deg, #059669, #10b981);
      box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
    }
    .btn-play.search:hover:not(:disabled) {
      box-shadow: 0 6px 24px rgba(16, 185, 129, 0.5);
    }
    .btn-play.completed {
      background: linear-gradient(135deg, #059669, #34d399);
      box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
    }
    .btn-play.restart {
      background: linear-gradient(135deg, #7c3aed, #6366f1);
      box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
    }
    .btn-play.restart:hover:not(:disabled) {
      box-shadow: 0 6px 24px rgba(124, 58, 237, 0.5);
    }

    .btn-stop {
      background: rgba(239, 68, 68, 0.12);
      color: rgba(255, 255, 255, 0.5);
      border: 1px solid rgba(239, 68, 68, 0.15);
    }
    .btn-stop:hover:not(:disabled) {
      background: rgba(239, 68, 68, 0.25);
      color: #fca5a5;
    }
    .btn-stop:disabled { opacity: 0.25; cursor: not-allowed; }

    .btn-reset {
      background: rgba(255, 255, 255, 0.05);
      color: rgba(255, 255, 255, 0.6);
      border: 1px solid rgba(255, 255, 255, 0.08);
    }
    .btn-reset:hover:not(:disabled) {
      background: rgba(255, 255, 255, 0.1);
      color: #fff;
    }
    .btn-reset:disabled { opacity: 0.25; cursor: not-allowed; }

    /* Target input for search */
    .target-group {
      display: flex;
      align-items: center;
      gap: 8px;
      background: rgba(255, 255, 255, 0.04);
      padding: 6px 12px 6px 16px;
      border-radius: 12px;
      border: 1px solid rgba(255, 255, 255, 0.06);
      transition: border-color 0.2s, opacity 0.3s;
    }
    .target-group label {
      color: rgba(255, 255, 255, 0.4);
      font-size: 0.75rem;
      font-weight: 500;
      letter-spacing: 0.5px;
      text-transform: uppercase;
      white-space: nowrap;
    }
    .target-group input {
      width: 64px;
      padding: 5px 8px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.1);
      background: rgba(0, 0, 0, 0.3);
      color: #e0e0ff;
      font-size: 0.85rem;
      font-weight: 600;
      outline: none;
      text-align: center;
      transition: border-color 0.2s;
    }
    .target-group input:focus {
      border-color: rgba(129, 140, 248, 0.5);
    }
    .target-group input:disabled {
      opacity: 0.3;
      cursor: not-allowed;
    }
    .target-group.hidden { display: none; }
    .hidden { display: none !important; }

    .control-group {
      display: flex;
      align-items: center;
      gap: 10px;
      background: rgba(255, 255, 255, 0.04);
      padding: 6px 16px;
      border-radius: 12px;
      border: 1px solid rgba(255, 255, 255, 0.06);
    }
    .control-group label {
      color: rgba(255, 255, 255, 0.4);
      font-size: 0.75rem;
      font-weight: 500;
      letter-spacing: 0.5px;
      text-transform: uppercase;
      white-space: nowrap;
    }
    .control-group input[type="range"] {
      -webkit-appearance: none;
      width: 80px;
      height: 4px;
      background: rgba(255, 255, 255, 0.12);
      border-radius: 2px;
      outline: none;
    }
    .control-group input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 16px; height: 16px;
      border-radius: 50%;
      background: #818cf8;
      cursor: pointer;
      box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
    }
    .control-group .value {
      color: rgba(255, 255, 255, 0.6);
      font-size: 0.85rem;
      font-weight: 600;
      min-width: 24px;
      text-align: center;
    }

    /* ---- Stats ---- */
    .stats {
      display: flex;
      gap: 28px;
      justify-content: center;
      margin-top: 14px;
      color: rgba(255, 255, 255, 0.2);
      font-size: 0.8rem;
    }
    .stats span {
      color: rgba(255, 255, 255, 0.5);
      font-weight: 600;
    }
    .stats .stat-label {
      color: rgba(255, 255, 255, 0.25);
      font-weight: 400;
    }

    .result-badge {
      display: none;
      margin-left: 8px;
      padding: 2px 12px;
      border-radius: 20px;
      font-size: 0.75rem;
      font-weight: 700;
      letter-spacing: 0.3px;
    }
    .result-badge.found {
      display: inline;
      background: rgba(16, 185, 129, 0.15);
      color: #6ee7b7;
      border: 1px solid rgba(16, 185, 129, 0.2);
    }
    .result-badge.not-found {
      display: inline;
      background: rgba(239, 68, 68, 0.15);
      color: #fca5a5;
      border: 1px solid rgba(239, 68, 68, 0.2);
    }