* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
/* Mobile-First Base Styles */
:root {
  --primary-blue: #007bff;
  --danger-red: #dc3545;
  --card-bg: #ffffff;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",
    "Cantarell", sans-serif;
  background: #111827;
  min-height: 100vh;
  color: #fff;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
}

/* Navbar */
.navbar {
  background: #1f2937;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.add-timer-btn {
  background: var(--primary-blue);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.add-timer-btn:hover {
  background: #2563eb;
}

.add-timer-btn:active {
  transform: scale(0.98);
}

/* Main content */
.main-content {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 2.5rem 1rem;
}

.timers-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  max-width: 28rem;
  width: 100%;
}

/* Timer card */
.timer-card {
  background: #1f2937;
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  position: relative;
  transition:
    transform 0.1s,
    box-shadow 0.2s;
  cursor: pointer;
  border: 3px solid transparent;
  touch-action: manipulation;
}

.timer-card:active {
  transform: scale(0.96);
}

.timer-card.running {
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.1); /* Subtielere schaduw */
}

.timer-card.menu-open {
  box-shadow:
    0 0 0 3px #fbbf24,
    0 4px 12px rgba(0, 0, 0, 0.3);
}

.timer-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #9ca3af;
  text-align: center;
  width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timer-name.empty {
  color: #4b5563;
  font-style: italic;
}

.chronometer-display {
  font-family: "Courier New", monospace;
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
}

.lap-indicator {
  font-size: 0.65rem;
  color: #6b7280;
  min-height: 0.8rem;
}

.lap-indicator.active {
  color: #3b82f6;
  font-weight: 500;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: #1f2937;
  padding: 2rem;
  border-radius: 1rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

.modal-content input {
  width: 100%;
  padding: 0.75rem;
  background: #111827;
  border: 2px solid #374151;
  border-radius: 0.5rem;
  color: #fff;
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.modal-content input:focus {
  outline: none;
  border-color: #3b82f6;
}

.modal-buttons {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.btn-primary,
.btn-secondary {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #3b82f6;
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  background: #374151;
  color: white;
}

.btn-secondary:hover {
  background: #4b5563;
}

/* Dropdown menu */
.dropdown-menu {
  position: fixed;
  background: #1f2937;
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 200;
  min-width: 280px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.dropdown-menu.hidden {
  display: none;
}

.dropdown-header {
  padding: 1rem;
  border-bottom: 1px solid #374151;
}
.edit-name-input {
  width: 100%;
  padding: 0.75rem;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 0.5rem;
  color: #fff;
}

.edit-name-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.dropdown-section {
  padding: 0.5rem;
  border-bottom: 1px solid #374151;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  cursor: pointer;
  border-bottom: 1px solid #374151;
}

.dropdown-item:hover {
  background: #374151;
}

.dropdown-item.danger {
  color: #ef4444;
}

.dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.dropdown-item svg {
  flex-shrink: 0;
}

.history-section {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #1a222f;
}

.history-header {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.history-list-dropdown {
  padding: 0 0.5rem 0.5rem 0.5rem;
}

.lap-item-dropdown {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem;
  background: #111827;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.lap-item-dropdown .lap-number {
  color: #9ca3af;
  font-weight: 500;
  min-width: 50px;
}

.lap-item-dropdown .lap-times {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-end;
}

.lap-item-dropdown .lap-time {
  color: #3b82f6;
  font-family: "Courier New", monospace;
  font-weight: 600;
}

.lap-item-dropdown .lap-split {
  color: #10b981;
  font-family: "Courier New", monospace;
  font-size: 0.8rem;
}

.lap-item-dropdown .lap-total {
  color: #6b7280;
  font-family: "Courier New", monospace;
  font-size: 0.75rem;
}

.history-empty {
  text-align: center;
  color: #6b7280;
  padding: 1.5rem;
  font-size: 0.85rem;
}

/* Scrollbar styling */
.dropdown-menu::-webkit-scrollbar,
.history-section::-webkit-scrollbar {
  width: 6px;
}

.dropdown-menu::-webkit-scrollbar-track,
.history-section::-webkit-scrollbar-track {
  background: transparent;
}

.dropdown-menu::-webkit-scrollbar-thumb,
.history-section::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 3px;
}

.dropdown-menu::-webkit-scrollbar-thumb:hover,
.history-section::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

/* Responsive */
@media (max-width: 640px) {
  .timers-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .timer-card {
    padding: 1rem;
  }

  .chronometer-display {
    font-size: 1.5rem;
  }
}

@media (max-width: 400px) {
  .timers-grid {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

.latest-split {
  font-size: 0.85rem;
  color: #10b981; /* Green for logged splits */
  font-family: monospace;
  height: 1.2rem;
}

.running .latest-split {
  color: #eee; /* Lighten text if card background becomes dark while running */
}

/* Dropdown menu - Mobile Bottom Sheet */
@media (max-width: 768px) {
  .dropdown-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1f2937;
    border-radius: 1.5rem 1.5rem 0 0;
    z-index: 500;
    transform: translateY(0);
    transition: transform 0.3s ease-out;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.5);
  }

  .dropdown-menu.hidden {
    transform: translateY(100%);
    display: flex;
  }
}

@media (min-width: 769px) {
  .dropdown-menu {
    position: absolute;
    width: 280px;
    border-radius: 1rem;
    background: #1f2937;
  }
  .dropdown-menu.hidden {
    display: none;
  }
}

.timer-card {
  -webkit-tap-highlight-color: transparent;
}

button,
.timer-card,
.dropdown-item {
  touch-action: manipulation;
}

.color-selector {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.color-selector input[type="color"] {
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
