body {
    font-family: sans-serif;
    margin: 20px;
    background-color: #f4f4f4;
}

h1, h2 {
    color: #333;
    text-align: center;
}

.controls {
    margin-bottom: 20px;
    text-align: center;
    /* Use flexbox for alignment */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on medium screens if needed */
    gap: 10px; /* Space between elements */
}

/* Ensure input also uses border-box for consistent height calculation */
.controls input[type="text"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    color: #000;
    background-color: #fff;
    min-width: 200px; /* Minimum width for larger screens */
    height: 36px; /* Match dropdown height */
    box-sizing: border-box; /* Crucial for consistent height */
    font-size: 1rem; /* Match dropdown */
    line-height: normal; /* Match dropdown */
    flex-grow: 1; /* Allow input to grow */
    max-width: 300px; /* Prevent getting too wide */
}


/* --- Styling for Choices.js dropdown --- */
/* Make the Choices dropdown fit better */
.controls .choices {
  margin: 0 5px;
  min-width: 200px; /* Minimum width for larger screens */
  font-size: 1rem;  /* Match potential default input font size */
  line-height: normal; /* Reset line-height */
  flex-grow: 1; /* Allow dropdown to grow */
  max-width: 300px; /* Prevent getting too wide */
}

/* Style the visible part of the dropdown (the trigger) */
.choices__inner {
  padding: 7px 7.5px 6px; /* Top, Right/Left, Bottom - Adjusted for visual alignment */
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  color: #000; /* Text color for the selected item */
  min-height: auto; /* Reset min-height that might make it too tall */
  height: 36px; /* Explicitly match typical input height */
  box-sizing: border-box; /* Include padding and border in the element's total width and height */
  display: flex; /* Use flex to center content vertically */
  align-items: center; /* Center content vertically */
}

/* Style the dropdown list itself */
.choices__list--dropdown {
    z-index: 100; /* Set z-index higher than tag markers */
    border-radius: 4px; /* Optional: round corners */
    /* Ensure list container has no padding restricting item width */
    padding-left: 0;
    padding-right: 0;
}

/* Style the items within the dropdown list */
.choices__list--dropdown .choices__item--selectable {
  color: #333; /* Ensure option text is dark */
  background-color: #fff; /* Ensure option background is white */
  padding-top: 6px; /* Vertical padding */
  padding-bottom: 6px;
  padding-left: 10px; /* Horizontal padding */
  padding-right: 10px;
  line-height: 1.4; /* Improve readability */
  white-space: normal;   /* Allow text wrapping (default) */
  word-wrap: break-word; /* Allow long words to break nicely */
  overflow: visible;     /* Ensure text isn't hidden (default) */
  text-overflow: clip;   /* Default text overflow */
}

/* Style the highlighted item in the list */
.choices__list--dropdown .choices__item--selectable.is-highlighted {
  background-color: #f2f2f2; /* Highlight color on hover/focus */
  color: #000; /* Text color for highlighted item */
}
/* --- End Choices.js styling --- */


#inventoryList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.inventory-item {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.image-container {
    position: relative;
    width: 100%;
    height: auto;
    background-color: #eee;
    overflow: hidden;
}

.inventory-item img {
    display: block;
    width: 100%;
    height: auto;
}

/* Tag markers */
.tag-marker {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: rgba(255, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: transform 0.1s ease-in-out;
    z-index: 10;
    pointer-events: auto;
    touch-action: manipulation;
}
.tag-marker:hover {
    transform: translate(-50%, -50%) scale(1.5);
}

.item-details {
    padding: 10px 15px 15px 15px;
    flex-grow: 1;
}

.item-details h2 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2em;
    text-align: left;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.item-details h3 {
    font-size: 0.9em;
    color: #555;
    margin-top: 10px;
    margin-bottom: 5px;
    font-weight: bold;
}

.item-tag-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85em;
    max-height: 100px;
    overflow-y: auto;
}
.item-tag-list li {
    padding: 2px 0;
    color: #333;
}

/* Tooltip styling */
.custom-tooltip {
    position: fixed;
    background: #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.75em;
    white-space: nowrap;
    z-index: 999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.custom-tooltip::after {
    content: "";
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.custom-tooltip.show {
    opacity: 1;
}

.hidden {
    display: none;
}


/* --- Responsive adjustments for smaller screens --- */
@media (max-width: 600px) { /* Styles apply below 600px viewport width */

  .controls {
    flex-direction: column; /* Stack controls vertically */
    align-items: stretch;   /* Stretch items to fill available width */
    gap: 15px;              /* Increase gap for vertical layout */
  }

  /* Adjust input and dropdown for vertical stacking */
  .controls input[type="text"],
  .controls .choices {
    min-width: unset; /* IMPORTANT: Remove fixed minimum width */
    width: 90%;       /* Set width relative to container */
    max-width: none;  /* Remove max-width if needed, or adjust */
    margin-left: auto;  /* Center the elements within the flex column */
    margin-right: auto;
    flex-grow: 0;     /* Prevent growing in column layout */
  }

  /* Ensure dropdown list doesn't become too wide */
  .choices__list--dropdown {
      /* You might want to limit its width on mobile too */
      /* max-width: 90vw; */ /* Example: limit to 90% of viewport width */
  }

  /* Adjust grid for inventory items on small screens */
  #inventoryList {
     /* Make items slightly smaller */
     grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
     gap: 15px;
  }

   /* Adjust general spacing for mobile */
   body {
       margin: 10px; /* Reduce body margin */
   }

   h1 {
       font-size: 1.5em; /* Slightly smaller heading */
   }

}