.main-content {
  display: flex;
  gap: 24px;  /* Creates margin between columns */
  flex: 1;
  background: #f5f5f5;
  border-radius: 8px;
  margin-top: 2em;
  padding: 1em;
  border: 1px solid #eee;
  align-items: flex-start;
  position: relative;
}

.left-column {
  flex: 2;  /* Takes up 2/3 of the space */
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100%;
  padding-bottom: 35vh;
}

.right-column {
  flex: 1;  /* Takes up 1/3 of the space */
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 1em;
  align-self: flex-start;
  max-height: calc(100vh - 2em);
}

/* Add responsiveness for smaller screens */
@media (max-width: 1024px) {
  .right-column {
    top: 0.75em;
    max-height: calc(100vh - 1.5em);
  }
  
  .left-column {
    padding-bottom: 35vh;
  }
}

@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }
  
  .left-column {
    min-height: auto;
    padding-bottom: 0;
  }
  
  .right-column {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

.resource-pack-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px; /* Space between all grid items (tiles and categories) */
}

.category-section {
  grid-column: 1 / -1; /* Span full width */
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 6px 0; /* Space above title/buttons, below to border */
  margin-bottom: -6px; /* Offset to make border-to-tiles spacing = 16px (grid gap 16px + padding 6px - margin 6px = 16px) */
  border-bottom: 1px solid rgba(76, 150, 179, 0.25);
}

.category-section:first-child {
  padding-top: 0; /* No extra space above first category */
}

.category-title {
  font-size: 15px;
  font-weight: 600;
  color: #4c96b3;
  margin: 0;
  line-height: 1;
  padding: 5px 0;
}

.category-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.category-action-btn {
  font-size: 11px;
  padding: 5px 10px;
  background: rgba(76, 150, 179, 0.12);
  border: 1px solid rgba(76, 150, 179, 0.25);
  border-radius: 4px;
  color: #4c96b3;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
  line-height: 1;
}

.category-action-btn:hover {
  background: rgba(76, 150, 179, 0.22);
  border-color: rgba(76, 150, 179, 0.4);
}

.resource-pack-item {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: visible;
  border-radius: 8px;
  animation: twoColorPulse 1s ease-in-out infinite;
  pointer-events: none;
  cursor: default;
  transition: box-shadow 0.2s ease;
  outline: 2px solid transparent;
  outline-offset: -2px;
}

.resource-pack-item.loaded {
  animation: none;
  background-color: transparent;
  pointer-events: auto;
  cursor: pointer;
}

.resource-pack-item.loaded:hover:not(.selected) {
  box-shadow: 0 2px 8px rgba(55, 156, 210, 0.25);
}

.resource-pack-item-square {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 1:1 Aspect Ratio */
}

/* Add backdrop positioning */
.resource-pack-item-square .backdrop {
  position: absolute;
  border-radius: 8px 8px 0 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #4c96b3;
  z-index: 0;
  pointer-events: none;
}

/* Two-color pulse animation */
@keyframes twoColorPulse {
  0%, 100% {
    background-color: #cce4ee; /* Even lighter blue */
  }
  50% {
    background-color: #dceef6; /* Slightly darker light blue */
  }
}

/* Hide all tile content during loading */
.resource-pack-item:not(.loaded) .content,
.resource-pack-item:not(.loaded) .pack-title,
.resource-pack-item:not(.loaded) .backdrop,
.resource-pack-complex-item:not(.loaded) .content,
.resource-pack-complex-item:not(.loaded) .pack-title,
.resource-pack-complex-item:not(.loaded) .backdrop,
.resource-pack-complex-item:not(.loaded) .complex-left-button,
.resource-pack-complex-item:not(.loaded) .complex-right-button,
.resource-pack-complex-item:not(.loaded) .arrow {
  opacity: 0;
}

/* Fade in all content when loaded */
.resource-pack-item.loaded .content,
.resource-pack-item.loaded .pack-title,
.resource-pack-item.loaded .backdrop,
.resource-pack-complex-item.loaded .content,
.resource-pack-complex-item.loaded .pack-title,
.resource-pack-complex-item.loaded .backdrop,
.resource-pack-complex-item.loaded .complex-left-button,
.resource-pack-complex-item.loaded .complex-right-button,
.resource-pack-complex-item.loaded .arrow {
  opacity: 1;
  transition: opacity 0.8s ease-out;
}

/* Update backdrop opacity for selected state */
.resource-pack-item.selected .backdrop, .resource-pack-complex-item.selected .backdrop {
  opacity: 0.30 !important;
}

.resource-pack-item.loaded:hover .backdrop, 
.resource-pack-complex-item.loaded:hover .backdrop {
  opacity: 0.75;
  transition: opacity 0.2s ease;
}

/* Selected state styling - prominent visual indicator */
.resource-pack-item.selected,
.resource-pack-complex-item.selected {
  border-radius: 8px;
  outline: 3px solid #379cd2 !important;
  outline-offset: 0px;
  box-shadow: 0 3px 12px rgba(55, 156, 210, 0.4);
}

/* Green checkmark in top left corner for selected items */
.resource-pack-item.selected::before,
.resource-pack-complex-item.selected::before {
  content: '✓';
  position: absolute;
  top: 4px;
  left: 6px;
  color: #4caf50;
  font-size: 20px;
  font-weight: bold;
  z-index: 10;
  text-shadow: 
    -1px -1px 0 rgba(0, 0, 0, 0.8),
    1px -1px 0 rgba(0, 0, 0, 0.8),
    -1px 1px 0 rgba(0, 0, 0, 0.8),
    1px 1px 0 rgba(0, 0, 0, 0.8),
    0 0 2px rgba(0, 0, 0, 0.5);
}

/* Change backdrop to light blue for selected items */
.resource-pack-item.selected .backdrop,
.resource-pack-complex-item.selected .complex-bottom-row .backdrop {
  background-color: #d6edf8 !important;
}

/* Also handle selected/hover on title */
.resource-pack-item.selected .pack-title, 
.resource-pack-complex-item.selected .pack-title {
  background: linear-gradient(135deg, #379cd2 0%, #4db3e0 100%);
  color: white;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Hover effect on title for non-selected items */
.resource-pack-item.loaded:hover:not(.selected) .pack-title,
.resource-pack-complex-item.loaded:hover:not(.selected) .pack-title {
  background: rgba(42, 99, 129, 1);
}

/* Content image styling */
.content {
  position: absolute;
  top: 50%;
  left: 50%;
  /* transform applied via JavaScript for visual centering */
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.4));
  object-fit: contain;
  font-size: 0; /* Hide alt text before image loads */
  z-index: 1;
}

/* Image content should be pixelated */
.content[src] {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
}

/* Canvas content should be smooth (antialiased) */
canvas.content {
  image-rendering: auto;
}

.resource-pack-item-square .content {
  width: 80%;
  height: 80%;
}

.resource-pack-complex-item .content {
  width: 75%;
  height: 75%;
}

/* Pack title styling */
.pack-title {
  background: rgba(42, 99, 129, 0.92);
  color: white;
  font-size: 10px;
  font-weight: 500;
  padding: 4px 6px;
  text-align: center;
  border-radius: 0 0 8px 8px;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  transition: all 0.2s ease;
}

/* Sidebar preview container */
.sidebar-preview-container {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  flex-grow: 0;
}

/* Sidebar preview box */
.sidebar-preview-box {
  background: rgba(164, 202, 216, 0.3);
  border: 1px solid rgba(76, 150, 179, 0.3);
  border-radius: 8px 8px 0 0;
  border-bottom: none;
  padding: 8px;
  min-height: 200px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  align-content: center;
  align-items: center;
  overflow: visible;
}

/* Each comparison column has fixed width */
.sidebar-preview-box .preview-comparison-col {
  width: 62px;
  flex-shrink: 0;
  flex-grow: 0;
}

/* Limit to 4 columns by calculating max-width */
.sidebar-preview-box {
  max-width: 100%;
}

.sidebar-preview-box > * {
  transition: opacity 0.2s ease;
}

.sidebar-preview-box.fading > * {
  opacity: 0;
}

/* Comparison column container */
.preview-comparison-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Arrow between textures */
.preview-arrow {
  color: #4c96b3;
  font-size: 16px;
  font-weight: bold;
  line-height: 1;
  flex-shrink: 0;
}

/* Preview texture wrapper - fixes size for both img and canvas */
.preview-texture-wrapper {
  width: 56px !important;
  height: 56px !important;
  min-width: 56px;
  min-height: 56px;
  max-width: 56px;
  max-height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.preview-texture-wrapper img {
  display: block !important;
  width: 56px !important;
  height: 56px !important;
  min-width: 56px !important;
  min-height: 56px !important;
  max-width: 56px !important;
  max-height: 56px !important;
  object-fit: contain !important;
  image-rendering: pixelated !important;
  image-rendering: -moz-crisp-edges !important;
  image-rendering: crisp-edges !important;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.3)) !important;
  font-size: 0;
}

.preview-texture-wrapper canvas {
  display: block !important;
  width: 56px !important;
  height: 56px !important;
  min-width: 56px !important;
  min-height: 56px !important;
  max-width: 56px !important;
  max-height: 56px !important;
  object-fit: contain !important;
  image-rendering: auto !important; /* Allow antialiasing for 3D renders */
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.3)) !important;
  font-size: 0;
}

/* Sidebar description box */
.sidebar-description-box {
  background: rgba(164, 202, 216, 0.15);
  border: 1px solid rgba(76, 150, 179, 0.3);
  border-radius: 0 0 8px 8px;
  border-top: none;
  padding: 8px;
  height: 54px;
  color: rgba(0, 0, 0, 0.8);
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-description-box::before {
  content: attr(data-text);
  transition: opacity 0.2s ease;
}

.sidebar-description-box.fading::before {
  opacity: 0;
}

/* Common button styles */
.base-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    padding: 0 12px;
    border: 1px solid #4c96b3;
    border-radius: 4px;
    color: #4c96b3;
    background-color: #e7f3f7;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.base-button:hover {
    background-color: #d3e7eb;
    color: #4d92a3;
}

.base-button:active {
    background-color: #c1dce1;
    color: #4d92a3;
}

/* Download section wrapper */
.download-section {
  flex-shrink: 0;
  flex-grow: 0;
}

/* Download button - prominent when enabled */
.download-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 16px;
    border: none;
    border-radius: 5px;
    color: white;
    background-color: #2a6381;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.download-button:hover:not([disabled]) {
    background-color: #1e455a;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
}

.download-button:active:not([disabled]) {
    background-color: #163649;
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Download button disabled state */
.download-button[disabled],
.download-button:disabled {
    opacity: 0.6;
    cursor: not-allowed !important;
    background-color: #e0e0e0 !important;
    border: 1px solid #ccc !important;
    color: #999 !important;
    pointer-events: none !important;
    box-shadow: none !important;
    transform: none !important;
}

/* top buttons container */
.top-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.button-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: inherit;
  font-weight: 500;
}

.selected-packs-list {
  flex: 1; /* Take up ALL remaining space */
  width: 100%;
  box-sizing: border-box;
  background: white;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid #eee;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  overflow-y: auto; /* Allow scrolling if content overflows */
  overflow-x: hidden;
  align-content: start;
  min-height: 0; /* Allow shrinking */
}

.selected-pack-item {
  display: flex;
  align-items: center;
  padding: 3px 6px;
  background: #f5f8fa;
  border: 1px solid #e0e6eb;
  border-radius: 3px;
  min-height: 20px;
  height: auto;
}

.selected-pack-item img,
.selected-pack-item canvas {
  display: none;
}

.selected-pack-item span {
  font-size: 11px;
  color: #4a4a4a;
  line-height: 1.2;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.resource-pack-complex-item {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: visible;
    border-radius: 8px;
    animation: twoColorPulse 1s ease-in-out infinite;
    pointer-events: none;
    cursor: default;
    transition: box-shadow 0.2s ease;
    outline: 2px solid transparent;
    outline-offset: -2px;
}

.resource-pack-complex-item.loaded {
    animation: none;
    background-color: transparent;
    pointer-events: auto;
    cursor: pointer;
}

.resource-pack-complex-item.loaded:hover:not(.selected) {
    box-shadow: 0 2px 8px rgba(55, 156, 210, 0.25);
}

.resource-pack-complex-item-square {
    width: 100%;
    aspect-ratio: 1/1;
    display: grid;
    grid-template-rows: 1.5fr 6.5fr;
    gap: 2px;
    border-radius: 8px 8px 0 0;
    position: relative;
}

.complex-top-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
}

.complex-bottom-row {
    position: relative;
}

.complex-bottom-row .backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background-color: #4c96b3;
  z-index: 0;
  pointer-events: none;
}

.complex-left-button,
.complex-right-button {
    background: rgba(42, 99, 129, 0.92);
    border: none;
    padding: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.complex-left-button {
    border-radius: 8px 0 0 0;
}

.complex-right-button {
    border-radius: 0 8px 0 0;
}

.resource-pack-complex-item:not(.selected) .complex-left-button:hover,
.resource-pack-complex-item:not(.selected) .complex-right-button:hover {
    background: rgba(42, 99, 129, 1);
}

.resource-pack-complex-item.loaded:hover:not(.selected) .complex-left-button,
.resource-pack-complex-item.loaded:hover:not(.selected) .complex-right-button {
    background: rgba(42, 99, 129, 1);
}

.complex-left-button:active,
.complex-right-button:active {
    background: rgba(30, 69, 90, 1);
}

.arrow {
    font-size: 9px;
    font-weight: normal;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.complex-left-button:hover .arrow,
.complex-right-button:hover .arrow {
    color: white;
}

/* Selected state for complex item buttons */
.resource-pack-complex-item.selected .complex-left-button,
.resource-pack-complex-item.selected .complex-right-button {
    background: linear-gradient(135deg, #379cd2 0%, #4db3e0 100%);
}