body {
  font-family: Arial, sans-serif;
  text-align: center;
  margin: 20px;
  background-color: #121212;
  color: #e0e0e0;
  max-width: 80%; /* Set max width to 80% of the page */
  margin: 20px auto; /* Center the site horizontally */
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background-color: #1e1e1e;
  border-bottom: 1px solid #333;
  width: inherit; /* Inherit width from the body */
  margin: 0 auto; /* Center the navbar horizontally */
}

.navbar h1 {
  margin: 0;
  font-size: 2em;
  color: #e0e0e0;
}

.navbar-buttons {
  display: flex;
  gap: 10px;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropbtn {
  background-color: #1e88e5;
  color: white;
  padding: 10px 20px;
  font-size: 16px;
  border: none;
  cursor: pointer;
  border-radius: 5px;
}

.dropbtn:hover {
  background-color: #1565c0;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #1e1e1e;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
  border-radius: 5px;
  width: inherit; /* Inherit width */
}

.dropdown-content button {
  color: white;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  background: none;
  border: none;
  text-align: left;
  width: 100%;
  cursor: pointer;
  box-sizing: border-box; /* Ensure padding is included in width */
  margin: 0; /* Remove any margin */
}

.dropdown-content button:hover {
  background-color: #333;
  box-sizing: border-box; /* Ensure padding is included in width */
}

.dropdown:hover .dropdown-content {
  display: block;
}

h1 {
  margin-bottom: 40px; /* Increase the bottom margin to separate the title */
  font-size: 2.5em;
  color: #e0e0e0;
  text-align: center;
}

button {
  padding: 10px 20px;
  font-size: 16px;
  margin: 20px 10px; /* Move Add Counter button slightly below and add space between buttons */
  cursor: pointer;
  border: none;
  border-radius: 5px;
  background-color: #1e88e5;
  color: white;
  transition: background-color 0.3s;
}

button:hover {
  background-color: #1565c0;
}

.reset-button {
  background-color: #e53935; /* Red background for reset button */
}

.reset-button:hover {
  background-color: #c62828; /* Darker red on hover */
}

.export-button {
  background-color: #1e88e5; /* Blue background for export button */
}

.export-button:hover {
  background-color: #1565c0; /* Darker blue on hover */
}

#export-list {
  background-color: #4caf50; /* Green background for export list button */
}

#export-list:hover {
  background-color: #388e3c; /* Darker green on hover */
}

#counter {
  font-size: 48px;
  margin: 20px;
  color: #e0e0e0;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.counter-module {
  position: relative;
  border: 1px solid #333;
  padding: 20px;
  border-radius: 8px;
  background-color: #1e1e1e;
  display: flex;
  flex-direction: column;
  justify-content: space-between; /* Ensure content is spaced out */
  text-align: center; /* Center the title horizontally */
}

.counter-module .title {
  margin: 10px 0;
  font-size: 1.5em;
  color: #e0e0e0;
  display: inline-block;
  white-space: normal; /* Allow text to wrap */
  overflow: hidden;
  max-width: 80%; /* Ensure the title does not exceed 80% of the container width */
  text-align: center; /* Center the title text */
  margin: 0 auto; /* Center the title horizontally */
}

.counter-module .counter-value {
  font-size: 10em; /* Increase the font size of the counter number */
  margin: 20px 0;
  color: #e0e0e0;
}

.counter-module .counter-unit {
  font-size: 1em;
  margin-bottom: 10px; /* Set bottom margin to 10px */
  color: #e0e0e0;
}

.counter-module .buttons {
  display: flex;
  justify-content: space-between;
  margin-top: auto; /* Push buttons to the bottom */
}

.counter-module button {
  flex: 1;
  margin: 5px 2px; /* Adjust margin to create space between buttons */
  padding: 10px;
  font-size: 2em; /* Increase the font size for circled symbols */
  background-color: #1e88e5;
  color: white;
  border: none;
  border-radius: 5px; /* Keep buttons rectangular */
  transition: background-color 0.3s;
}

.counter-module button:hover {
  background-color: #1565c0;
}

.counter-module .menu-button {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent; /* Set background to transparent */
  border: none;
  color: #e0e0e0;
  font-size: 1.5em;
  cursor: pointer;
}

.counter-module .menu-dropdown {
  display: none;
  position: absolute;
  top: 40px;
  right: 10px;
  background-color: #333;
  border: 1px solid #444;
  border-radius: 5px;
  z-index: 1;
  width: auto; /* Make width dynamic */
  min-width: 150px; /* Set a minimum width */
}

.counter-module .menu-dropdown.show {
  display: block;
  overflow: hidden; /* Ensure no overflow */
}

.counter-module .menu-dropdown button {
  display: block;
  width: 100%; /* Ensure buttons fill the entire width */
  padding: 10px;
  background: none;
  border: none;
  color: #e0e0e0;
  text-align: left;
  cursor: pointer;
  font-size: 0.9em; /* Make text smaller */
  box-sizing: border-box; /* Ensure padding is included in width */
  margin: 0; /* Remove any margin */
}

.counter-module .menu-dropdown button:hover {
  background-color: #444;
  width: 100%; /* Ensure buttons fill the entire width */
  box-sizing: border-box; /* Ensure padding is included in width */
  margin: 0; /* Remove any margin */
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 2;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: #1e1e1e;
  margin: 15% auto;
  padding: 20px;
  border: 1px solid #888;
  width: auto; /* Make width dynamic */
  max-width: 500px; /* Increased from 400px for wider inputs */
  border-radius: 8px;
  color: #e0e0e0;
  overflow: hidden; /* Ensure no overflow */
  text-align: center; /* Center content */
}

.modal-content .tips,
.modal-content .example,
.modal-content .result {
  font-size: 0.9em;
  color: #888;
  margin: 5px 0;
}

.modal-content .example {
  font-style: italic;
}

.modal-content .result {
  color: #4caf50;
  margin-bottom: 15px;
}

.modal-content input,
.modal-content textarea {
  width: 100%;
  padding: 10px; /* Add padding to modal input */
  margin: 10px 0;
  border: 1px solid #444;
  border-radius: 5px;
  background-color: #333;
  color: #e0e0e0;
  box-sizing: border-box; /* Ensure padding is included in width */
}

.modal-content button {
  padding: 10px 20px;
  margin: 5px;
  border: none;
  border-radius: 5px;
  background-color: #1e88e5;
  color: white;
  cursor: pointer;
}

.modal-content button:hover {
  background-color: #1565c0;
}

.copy-button {
  background-color: #4caf50; /* Green background for copy button */
}

.copy-button:hover {
  background-color: #388e3c; /* Darker green on hover */
}

.top-right-buttons {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
}

.import-button {
  background-color: #4caf50; /* Green background for import button */
}

.import-button:hover {
  background-color: #388e3c; /* Darker green on hover */
}

.add-title-button {
  background-color: #ff9800; /* Orange background for add title button */
}

.add-title-button:hover {
  background-color: #e68900; /* Darker orange on hover */
}

#counters-container {
  width: 100%; /* Set width to 100% of the container */
  max-width: 100%; /* Ensure it doesn't exceed the container width */
  display: grid; /* Ensure it uses grid layout */
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* Use minmax to ensure columns stretch evenly */
  gap: 20px; /* Add gap between grid items */
  margin-top: 20px; /* Add top margin */
}

.switch-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
  margin-right: 10px; /* Add space between switch and label */
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #1e88e5;
}

input:checked + .slider:before {
  transform: translateX(26px);
}

/* Removed .dragging style as SortableJS handles drag visuals */
