.card-container {
  width: 250px;
  height: 375px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.card-container:hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2) !important;
  z-index: 1000 !important;
}

.card-container.dragging {
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3) !important;
  z-index: 1001 !important;
  cursor: grabbing !important;
}

.drag-over {
  border-color: #5d5cde !important;
  border-width: 3px !important;
  background-color: rgba(93, 92, 222, 0.1) !important;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50px;
  pointer-events: none;
}

.help-tooltip {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(243, 244, 246, 0.6);
  border: 1px solid rgba(156, 163, 175, 0.5);
  color: rgba(55, 65, 81, 0.8);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 50%;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(55, 65, 81, 0.1);
  z-index: 2000;
}

.help-tooltip:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(55, 65, 81, 0.15);
  background: rgba(243, 244, 246, 0.8);
}

.help-tooltip span {
  font-size: 14px;
  font-weight: 600;
  color: rgba(55, 65, 81, 0.8);
  user-select: none;
}

.help-content {
  position: fixed;
  bottom: 70px;
  right: 20px;
  background: rgba(243, 244, 246, 0.9);
  /* light gray, slightly more opaque */
  border: 1px solid rgba(156, 163, 175, 0.5);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(55, 65, 81, 0.1);
  max-width: 300px;
  z-index: 2001;
  display: none;
}

.help-content.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .card-container {
    width: 180px;
    height: 270px;
  }

  /* For mobile */
  #headerSection {
    flex-direction: column;
    align-items: flex-start;
  }

  #headerSection>div:last-child {
    margin-top: 10px;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  /* Adjust buttons for better mobile experience */
  #addCard,
  #clearAll {
    width: calc(50% - 8px);
    text-align: center;
    padding: 8px 0;
  }

  /* Make controls more touch-friendly */
  .custom-checkbox {
    width: 24px;
    height: 24px;
  }

  .custom-slider {
    width: 120px;
  }

  .custom-slider::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }

  /* Help tooltip adjustments */
  .help-tooltip {
    width: 40px;
    height: 40px;
    bottom: 15px;
    right: 15px;
  }

  .help-content {
    max-width: 260px;
  }

  /* Adjust the dark toggle switch size in mobile menu */
  #darkToggleMobile.dark-toggle {
    width: 40px;
    height: 22px;
    margin: 0;
  }

  /* Adjust ::after for the mobile dark toggle */
  #darkToggleMobile.dark-toggle::after {
    width: 18px; /* Smaller circle */
    height: 18px; /* Smaller circle */
    top: 2px; /* Keeps it vertically centered (22-18)/2 */
    left: 2px;
  }

  #darkToggleMobile.dark-toggle.active::after {
    transform: translateX(18px); 
    /* Correct translation is 40 (width) - 18 (circle) - 2 (left) - 2 (right padding) = 18 */
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  .card-container {
    width: 140px;
    height: 210px;
    border-radius: 30px;
  }

  .card-image {
    border-radius: 30px;
  }

  /* Simplified header */
  h1.text-3xl {
    font-size: 1.5rem;
  }

  .logo {
    width: 32px;
    height: 32px;
  }

  /* Full-width controls */
  #addCard,
  #clearAll {
    width: 100%;
    margin-top: 5px;
  }

  /* Ensure help content is readable */
  .help-content {
    max-width: calc(100vw - 40px);
    bottom: 65px;
  }

  /* Adjust placeholder icon size */
  .placeholder-icon svg {
    width: 40px !important;
    height: 40px !important;
  }

  .placeholder-icon p {
    font-size: 0.75rem;
  }

  /* Adjust the dark toggle switch size in mobile menu */
  #darkToggleMobile.dark-toggle {
    width: 40px;
    height: 22px;
    margin: 0;
  }

  /* Adjust ::after for the mobile dark toggle */
  #darkToggleMobile.dark-toggle::after {
    width: 18px; /* Smaller circle */
    height: 18px; /* Smaller circle */
    top: 2px; /* Keeps it vertically centered (22-18)/2 */
    left: 2px;
  }

  #darkToggleMobile.dark-toggle.active::after {
    transform: translateX(18px);
  }

  /* Made the slider more touch-friendly in mobile menu */
  .controls-panel .custom-slider {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    margin-top: 8px;
  }

  /* Improve spacing for labels */
  .control-group label {
    margin-bottom: 4px;
    display: inline-flex;
    align-items: center;
  }

  /* Offset scaled landscape checkbox label for better alignment in mobile panel */
  .controls-panel .control-group .mb-3 > label.flex {
    margin-left: 10px;
  }
}

/* Touch-specific optimizations */
@media (pointer: coarse) {

  /* Larger touch targets */
  button,
  label,
  .custom-checkbox,
  .dark-toggle {
    transform: scale(1.1);
  }

  /* Disable hover styles that can cause issues on touch devices */
  .help-tooltip:hover {
    transform: none;
  }
}

.dark {
  background-color: #111827;
}

.dark .card-container {
  border-color: #374151;
  background-color: #1f2937;
}

.dark .placeholder-icon {
  color: #6b7280;
}

.dark .help-content {
  background-color: rgba(31, 41, 55, 0.95);
  border-color: #374151;
  color: #e5e7eb;
}

.dark .help-tooltip {
  background: rgba(31, 41, 55, 0.9);
  border-color: #374151;
  color: #e5e7eb;
}

.dark .help-tooltip:hover {
  background: rgba(31, 41, 55, 1);
}

.dark .help-tooltip span {
  color: #e5e7eb;
}

.logo {
  width: 40px;
  height: 40px;
  /* background: linear-gradient(135deg, #5D5CDE, #7C7CE8); */
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: "Inter", sans-serif;
  font-weight: bold;
  font-size: 18px;
}

/* Dark mode toggle */
.dark-toggle {
  position: relative;
  width: 48px;
  height: 24px;
  background: #e5e7eb;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  outline: none;
  margin: 0 10px;
}

.dark-toggle:hover {
  background: #d1d5db;
}

.dark-toggle.active {
  background: #5d5cde;
}

.dark-toggle.active:hover {
  background: #4f46e5;
}

.dark-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.dark-toggle.active::after {
  transform: translateX(24px);
}

/* Custom checkbox */
.custom-checkbox {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #d1d5db;
  border-radius: 4px;
  background: white;
  transition: all 0.2s ease;
  position: relative;
  margin-right: 8px;
  cursor: pointer;
}

.custom-checkbox:hover {
  border-color: #6366f1;
}

.custom-checkbox:checked {
  background: #6366f1;
  border-color: #6366f1;
}

.custom-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Custom slider */
.custom-slider {
  -webkit-appearance: none;
  /* remove its default styling for the slider element */
  appearance: none;
  width: 100px;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  outline: none;
  transition: background 0.2s;
  margin-left: 12px;
  margin-right: 8px;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
}

.custom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.custom-slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
  cursor: pointer;
}

.dark .help-tooltip {
  background: linear-gradient(135deg, #4338ca, #7c3aed);
  border-color: rgba(255, 255, 255, 0.1);
}

.dark .custom-checkbox {
  background: #374151;
  border-color: #6b7280;
}

.dark .custom-checkbox:checked {
  background: #6366f1;
  border-color: #6366f1;
}

.dark .custom-slider {
  background: #4b5563;
}

.dark label.text-sm {
  color: white;
  transition: all 0.2s ease;
}


/* Floating Menu and Controls Panel for Mobile */
@media (max-width: 480px) {

  /* Floating menu button */
  .controls-menu-button {
    position: fixed;
    top: 15px;
    right: 15px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5D5CDE, #4338ca);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 2001;
    border: none;
    cursor: pointer;
  }

  /* Menu button icons - consolidated here */
  .controls-menu-button svg,
  .controls-menu-button .menu-icon,
  .controls-menu-button .close-icon {
    width: 24px;
    height: 24px;
    transition: all 0.3s ease;
  }

  .controls-menu-button .hidden {
    display: none;
  }

  /* Controls panel with improved transitions */
  .controls-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 250px;
    height: 100%;
    background: white;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    padding: 20px;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
  }

  .controls-panel.show {
    transform: translateX(0) !important;
  }

  .dark .controls-panel {
    background: #1f2937;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
  }

  .controls-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
  }

  .controls-panel-title {
    font-size: 16px;
    font-weight: 600;
  }

  .controls-panel-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #6b7280;
  }

  .dark .controls-panel-close {
    color: #e5e7eb;
  }

  .control-group {
    padding: 15px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  /* Add better alignment for form controls in groups */
  .control-group .flex {
    display: flex;
    align-items: center;
    width: 100%;
  }

  /* Fix dark mode toggle alignment */
  .control-group .flex span {
    flex: 1;
  }

  /* Fix checkbox alignment */
  .mb-3 label.flex {
    display: flex;
    align-items: center;
  }

  .mb-3 label.flex input {
    margin-right: 8px;
  }

  .dark .control-group {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  /* Hide header controls on small screens */
  #headerSection>div:last-child>*:not(.logo) {
    display: none;
  }

  /* Make buttons in panel full width */
  .controls-panel button {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
  }

  /* Overlay when menu is open */
  .panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .panel-overlay.show {
    opacity: 1;
    visibility: visible;
  }
}

/* Dark mode additions for mobile menu */
@media (max-width: 480px) {
  .dark .controls-panel {
    background: #1f2937;
  }

  .dark .controls-panel-title {
    color: #f3f4f6;
  }

  .dark .control-group {
    border-color: #374151;
  }
}