* {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 1rem;
  font-weight: 500;
  text-transform: none;
  box-sizing: border-box;
}

button:focus,
input[type=range]:focus {
  outline: 2px solid #1976d2;
  outline-offset: 2px;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  flex-wrap: wrap;
}

nav.light-theme {
  background: #f5f5f5;
  color: #222;
}
nav.dark-theme {
  background: #333;
  color: #eee;
}

nav .array-inputs {
  display: flex;
  gap: 1rem;
}

nav .array-inputs #stop_button {
  background-color: #f44336;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 5px;
}
nav .array-inputs #stop_button:hover {
  background-color: #d32f2f;
  cursor: pointer;
}

nav .array-inputs #a_generate {
  background-color: #4CAF50;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  transition: background-color 0.3s ease;
}
nav .array-inputs #a_generate:hover {
  background-color: #45a049;
  cursor: pointer;
}

nav .array-inputs input[type=range] {
  cursor: pointer;
}

nav .header_right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

nav .header_right .nav-heading {
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  letter-spacing: 1px;
}

nav .header_right .algos {
  display: grid;
  grid-template-columns: repeat(6, auto);
  gap: 0.5rem;
}

nav .header_right .algos button {
  background-color: transparent;
  border: 1px solid;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: 0.3s;
}

nav.dark-theme .algos button {
  color: white;
  border-color: white;
}
nav.light-theme .algos button {
  color: black;
  border-color: black;
}

nav .header_right .algos button:hover {
  background-color: #1976d2;
  color: white;
  cursor: pointer;
}

nav .header_right .algos .butt_selected {
  background-color: white;
  color: green;
}
nav .header_right .algos .butt_selected:hover {
  background-color: white;
  cursor: pointer;
}

section {
  display: grid;
  grid-template-columns: 20% 60% 20%;
  padding: 2rem 0;
}

section .Complexity_Containers .Pair_Definitions {
  margin: 1.5rem 0;
}
section .Complexity_Containers .Pair_Definitions p {
  display: inline;
}
section .Complexity_Containers .Pair_Definitions p.Sub_Heading {
  font-size: 0.9rem;
  text-transform: none;
}

section #Info_Cont1,
section #Info_Cont2 {
  padding: 2rem;
}
section #Info_Cont1 h3,
section #Info_Cont2 h3 {
  text-decoration: underline;
  margin-bottom: 0.5rem;
}

section #array_container {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  width: 100%;
  height: 60vh;
  align-items: flex-end;
  padding: 1rem 0;
}

section #array_container > div {
  position: relative;
  margin: 0 2px;
  min-width: 20px; /* FIXED for responsiveness */
  flex: 0 0 auto;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  align-items: center;
  transition: height 0.3s ease, background-color 0.3s ease;
}

section #array_container > div span {
  color: black;
  font-size: 0.7rem;
  font-weight: bold;
  margin-bottom: 4px;
  position: static;
}

#array_container div.light-theme {
  background-color: green;
}
#array_container div.dark-theme {
  background-color: #4caf5088;
}

.hide {
  display: none;
}

.speed-controls {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}

.speed-controls button {
  background-color: #555;
  color: white;
  padding: 0.3rem 0.6rem;
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
}
.speed-controls button:hover {
  background-color: #1976d2;
  cursor: pointer;
}

.speed-controls button.active-speed {
  background-color: #1976d2;
  color: white;
}

body.light-theme {
  background: white;
  color: black;
}
body.dark-theme {
  background: #121212;
  color: #eee;
}

/* Responsive */
@media (max-width: 1024px) {
  nav {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }

  nav .header_right {
    align-items: center;
  }

  nav .header_right .algos {
    grid-template-columns: repeat(3, auto);
    justify-content: center;
  }

  .speed-controls {
    justify-content: center;
    flex-wrap: wrap;
  }

  section {
    grid-template-columns: 100%;
    text-align: center;
  }

  section #array_container {
    height: 50vh;
    padding: 1rem;
  }

  .main-footer {
    font-size: 0.8rem;
    padding: 0.8rem;
  }
}

@media (max-width: 600px) {
  nav .header_right .nav-heading {
    font-size: 1.4rem;
    text-align: center;
  }

  nav .array-inputs {
    flex-direction: column;
    align-items: center;
  }

  nav .array-inputs input,
  nav .array-inputs button {
    width: 100%;
    max-width: 200px;
  }

  .speed-controls {
    flex-direction: column;
    align-items: center;
  }

  .speed-controls button {
    width: 100%;
    max-width: 100px;
  }

  .main-footer {
    padding: 0.6rem;
    font-size: 0.75rem;
  }
}

/* Footer */
.main-footer {
  background-color: #222;
  color: #eee;
  text-align: center;
  padding: 1rem 0;
  font-size: 0.9rem;
  border-top: 1px solid #444;
  margin-top: 2rem;
}

body.light-theme .main-footer {
  background-color: #f2f2f2;
  color: #111;
  border-top: 1px solid #ccc;
}
