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

body {
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  background-color: #1b1b1b;
  color: #ffffff;
  justify-content: center;
  align-items: center;
}

h1 {
  font-size: 60px;
  text-align: center;
  margin: 15% 50px 50px 50px;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.quick_tips {
  position: fixed;
  top: 72px;
  right: 20px;
  width: min(360px, calc(100vw - 32px));
  padding: 14px 16px 16px 16px;
  background-color: #202020;
  border: 2px solid #2f2f2f;
  border-radius: 10px;
  box-shadow:
    inset 3px 0 0 #4d50ff,
    0 18px 40px rgba(0, 0, 0, 0.38);
  z-index: 130;
  animation: tipsFadeIn 0.18s ease-out;
}

.quick_tips::before {
  content: "";
  position: absolute;
  top: -8px;
  right: 26px;
  width: 14px;
  height: 14px;
  background-color: #202020;
  border-top: 2px solid #2f2f2f;
  border-left: 2px solid #2f2f2f;
  transform: rotate(45deg);
}

.quick_tips[hidden] {
  display: none;
}

.quick_tips_header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.quick_tips_eyebrow {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #7ea0ff;
  margin-bottom: 4px;
}

#quick_tips_title {
  font-size: 18px;
  margin: 0;
}

#quick_tips_message {
  color: #d2d2d2;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 12px;
}

#quick_tips_list {
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: #f4f4f4;
  font-size: 12px;
  line-height: 1.45;
}

#quick_tips_list li::marker {
  color: #7ea0ff;
}

#sort_status,
#search_status {
  display: none;
  text-align: center;
  margin: 8px 0;
  font-size: 14px;
  color: #5d8fff;
  min-height: 20px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

body.sorting-view #sort_status,
body.searching-view #search_status {
  display: block;
}

.stats_container {
  display: none;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 14px;
  margin: 0 auto;
  max-width: 1200px;
  padding: 0 20px;
}

.stats_container > div {
  padding: 6px 12px;
  background-color: #202020;
  border: 1px solid #2f2f2f;
  border-radius: 999px;
}

#target_indicator {
  display: none;
  position: absolute;
  left: 6px;
  right: 6px;
  height: 3px;
  background-color: #00ff00;
  z-index: 10;
  pointer-events: none;
}

#target_indicator::before {
  content: "TARGET";
  position: absolute;
  right: 0;
  top: -22px;
  font-size: 11px;
  color: #00ff00;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.button_container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-bottom: 15px;
}

#sort,
#search {
  padding: 12px 24px;
  font-size: 16px;
}

button {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  border: 2px solid #333333;
  background-color: #242424;
  color: #ffffff;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  position: relative;
  min-width: 120px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

button:disabled:hover {
  border-color: #333333;
  transform: none;
}

button:hover {
  border-color: #4d50ff;
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.array_container {
  display: none;
  position: relative;
  align-items: flex-end;
  height: 415px;
  width: 85%;
  max-width: 1200px;
  margin: 15px auto;
  background-color: #0a0a0a;
  border: 2px solid #2a2a2a;
  border-radius: 8px;
}

label {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
  color: #cccccc;
  margin-right: 8px;
}

.bar {
  width: 2px;
  margin: 1px;
  background-color: #ff4da6;
  transition:
    background-color 0.15s ease,
    box-shadow 0.15s ease;
  position: relative;
}

.bar:hover::after {
  content: attr(data-height);
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a2a;
  border: 1px solid #4d50ff;
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

#sorting_btns,
#searching_btns,
#utility {
  display: none;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 15px auto;
  padding: 0 20px;
}

#speed_slider,
#arrLen,
#target,
#numbersInput {
  width: 80px;
  text-align: center;
  padding: 8px 10px;
  background-color: #2a2a2a;
  border: 2px solid #3a3a3a;
  color: #ffffff;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: border-color 0.2s ease;
}

#speed_slider {
  cursor: pointer;
  width: 150px;
}

#arrLen:focus,
#target:focus,
#numbersInput:focus {
  outline: none;
  border-color: #4d50ff;
  background-color: #242424;
}

#target::placeholder,
#numbersInput::placeholder {
  color: #666666;
  font-style: italic;
}

#home_btn {
  display: none;
  position: absolute;
  top: 20px;
  left: 20px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  border: 2px solid #333333;
  background-color: #242424;
  color: #ffffff;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  min-width: auto;
}

#help_btn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 140;
  min-width: auto;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  border-color: #333333;
}

#home_btn:hover {
  border-color: #4d50ff;
  background-color: #2a2a2a;
  transform: translateY(-1px);
}

#help_btn:hover {
  border-color: #4d50ff;
  background-color: #2a2a2a;
}

#help_btn[aria-expanded="true"] {
  border-color: #4d50ff;
}

body.sorting-view h1,
body.searching-view h1 {
  margin: 15px auto;
  font-size: 40px;
}

body.sorting-view .button_container,
body.searching-view .button_container {
  display: none;
}

body.sorting-view .array_container,
body.sorting-view .stats_container,
body.sorting-view #sorting_btns,
body.sorting-view #utility {
  display: flex;
}

body.sorting-view #home_btn {
  display: block;
}

body.searching-view .array_container,
body.searching-view .stats_container,
body.searching-view #searching_btns,
body.searching-view #utility {
  display: flex;
}

body.searching-view #home_btn {
  display: block;
}

#merge:hover::after,
#quick:hover::after,
#heap:hover::after,
#bubble:hover::after,
#selection:hover::after,
#insertion:hover::after,
#shell:hover::after,
#radix:hover::after,
#linear:hover::after,
#binary:hover::after,
#jump:hover::after,
#interpolation:hover::after {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  border: 2px solid #4d50ff;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: pre;
  pointer-events: none;
  z-index: 100;
  margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  line-height: 1.6;
}

#merge:hover::after {
  content: "Time: O(n log n) | Space: O(n)\A Best: O(n log n)\A Worst: O(n log n)";
}

#quick:hover::after {
  content: "Time: O(n log n) | Space: O(log n)\A Best: O(n log n)\A Worst: O(n^2)";
}

#heap:hover::after {
  content: "Time: O(n log n) | Space: O(1)\A Best: O(n log n)\A Worst: O(n log n)";
}

#bubble:hover::after {
  content: "Time: O(n^2) | Space: O(1)\A Best: O(n)\A Worst: O(n^2)";
  border-color: #ff6666;
}

#selection:hover::after {
  content: "Time: O(n^2) | Space: O(1)\A Best: O(n^2)\A Worst: O(n^2)";
  border-color: #ff6666;
}

#insertion:hover::after {
  content: "Time: O(n^2) | Space: O(1)\A Best: O(n)\A Worst: O(n^2)";
  border-color: #ff6666;
}

#shell:hover::after {
  content: "Time: Depends on gaps | Space: O(1)\A Best: Near O(n log n)\A Worst: O(n^2)";
}

#radix:hover::after {
  content: "Time: O(d(n + k)) | Space: O(n + k)\A Best: O(d(n + k))\A Works Best: Integer Values";
}

#linear:hover::after {
  content: "Time: O(n) | Space: O(1)\A Best: O(1)\A Worst: O(n)";
  border-color: #ff6666;
}

#binary:hover::after {
  content: "Time: O(log n) | Space: O(1)\A Requires: Sorted Array\A Best: O(1)\A Worst: O(log n)";
  border-color: #66b3ff;
}

#jump:hover::after {
  content: "Time: O(sqrt n) | Space: O(1)\A Requires: Sorted Array\A Best: O(1)\A Worst: O(sqrt n)";
  border-color: #66b3ff;
}

#interpolation:hover::after {
  content: "Time: Avg O(log log n) | Space: O(1)\A Requires: Sorted Numeric Array\A Best With: Evenly Distributed Values";
  border-color: #66b3ff;
}

@keyframes tipsFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1024px) {
  html {
    overflow: scroll;
  }
  h1 {
    padding-top: 50px;
  }
  #home_btn {
    padding-top: 5px;
  }
  .quick_tips {
    right: 12px;
    width: min(360px, calc(100vw - 24px));
  }
  #help_btn {
    right: 12px;
    top: 12px;
  }
}

@media (max-width: 700px) {
  .quick_tips {
    top: 60px;
    left: 12px;
    right: 12px;
    width: auto;
    padding: 13px 14px 14px 14px;
  }

  .quick_tips::before {
    right: 18px;
  }

  #quick_tips_title {
    font-size: 16px;
  }

  #quick_tips_message,
  #quick_tips_list {
    font-size: 12px;
  }

  .quick_tips_header {
    gap: 8px;
  }

  #help_btn {
    padding: 8px 12px;
  }
}
