/* Elements library, element cards, and details */
.fusion-container {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.fusion-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fusion-section h2 {
  font-size: 14px;
  font-weight: 600;
  color: #64c8ff;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Elements Library */
.elements-library {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  justify-content: flex-start;
  /* Make the library itself the single scroll container */
  max-height: 280px;
  overflow-y: auto;
  box-sizing: border-box;
}

.element-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: linear-gradient(135deg, #0f0f1a 0%, #1a0f2e 100%);
  border: 1px solid #4a2a7f;
  cursor: pointer;
  transition: all 0.2s ease;
  align-items: center;
  text-align: center;
  flex: 0 0 auto;
  /* Constrain card width to the visual-preview size + padding so cards don't expand */
  width: 72px;
  min-width: 72px;
  max-width: 72px;
  box-shadow: 0 0 8px rgba(138, 43, 226, 0.1);
}

.element-card:hover {
  border-color: #7a5aaf;
  background: linear-gradient(135deg, #1a0f2e 0%, #2a1a4e 100%);
  box-shadow: 0 0 15px rgba(138, 43, 226, 0.2);
}

.element-card.selected {
  border-color: #64c8ff;
  background: linear-gradient(135deg, #1a2a3a 0%, #2a1a4e 100%);
  box-shadow: 0 0 20px rgba(100, 200, 255, 0.3);
}

.element-card-color {
  width: 45px;
  height: 45px;
  flex-shrink: 0;
  border: 1px solid #333;
}

.element-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  overflow: hidden;
  justify-content: center;
}

.element-card-content h4 {
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  margin: 0;
  /* Single-line centered truncation */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}

/* Add layout wrappers */
.elements-layout-wrapper,
.fusion-layout-wrapper {
  display: flex;
  flex-direction: column; /* Default stack behavior */
  gap: 12px;
}

/* Tablet: 2 columns */
@media (max-width: 1024px) {
  .elements-library {
    grid-template-columns: repeat(2, 1fr);
    max-height: 250px;
  }
}

/* Mobile: 2 columns, adjusted sizing */
@media (max-width: 768px) {
  .elements-library {
    /* keep flex wrapping behavior on mobile so items pack tightly */
    gap: 6px;
    max-height: 200px;
    justify-content: flex-start;
  }

  .element-card {
    padding: 6px;
    gap: 6px;
  }

  .element-card-color {
    width: 40px;
    height: 40px;
  }

  .element-card-content h4 {
    font-size: 11px;
  }

  .element-details-color {
    width: 50px;
    height: 50px;
  }

  .element-details-name {
    font-size: 14px;
  }

  .element-details-desc {
    font-size: 11px;
  }

  .element-details-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .details-stat {
    padding: 4px;
  }

  .details-stat-label {
    font-size: 8px;
  }

  .details-stat-value {
    font-size: 12px;
  }

  /* Small mobile: side-by-side layout for wrappers */
  @media (max-width: 480px) {
    .elements-library {
      /* keep flex wrapping behavior on mobile so items pack tightly */
      gap: 6px;
      max-height: 200px;
      justify-content: start;
    }

    .elements-layout-wrapper,
    .fusion-layout-wrapper {
      flex-direction: row;
      gap: 8px;
    }
    
    /* Ensure children take equal space */
    .elements-library,
    .element-details-panel,
    .fusion-builder,
    #fusion-panel {
      flex: 1 1 50%;
    }

    .element-details-stats {
      grid-template-columns: 1fr;
    }
  }
}

/* Small mobile: single column */
@media (max-width: 480px) {
  .elements-library {
    grid-template-columns: repeat(auto-fill, minmax(90px, 120px));
    gap: 6px;
    justify-content: start;
  }

  .element-details-stats {
    grid-template-columns: 1fr;
  }
}

/* Key stats were removed, keeping key-stat styles but they are not used in HTML now */
/* ...existing code... */
.type-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border: 1px solid #2a2a2a;
  background: #0d0d0d;
  border-radius: 12px;
  text-transform: capitalize;
}

.properties-section {
  margin-top: 0; /* Removed margin top */
}

.properties-title {
  font-size: 11px;
  color: #64c8ff;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  display: none; /* Handled by properties.css, but redundant check */
}

.properties-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.property-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(138, 43, 226, 0.1);
  border: 1px solid #4a2a7f;
  padding: 4px 5px 4px 4px;
  border-radius: 4px;
  font-size: 12px;
  transition: all 0.2s ease;
}

.property-badge:hover {
  border-color: #7a5aaf;
  box-shadow: 0 0 10px rgba(138, 43, 226, 0.2);
}

.property-name {
  color: #9db4ff;
  text-transform: capitalize;
}

.property-value {
  color: #64c8ff;
  font-weight: 600;
}

.properties-empty {
  font-size: 12px;
  color: #aaa;
}

/* Ensure the small color preview in element details is visible and matches the spell-result color sizing */
.element-details-color {
  width: 45px;
  height: 45px;
  flex-shrink: 0;
  border: 1px solid #333;
  box-shadow: none;
  background-clip: padding-box;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .element-details-color {
    width: 50px;
    height: 50px;
  }
  .element-details-name {
    font-size: 14px;
  }
  .element-details-desc {
    font-size: 11px;
  }
  .element-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }
  .element-summary-info {
    display: flex;
    gap: 10px;
    align-items: flex-start;
  }
  .element-details-controls {
    margin-top: 0;
  }
  
  /* ...existing code... */
}

/* Small mobile */
@media (max-width: 480px) {
  .element-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
  }
  .element-summary-info {
    display: flex;
    gap: 10px;
    align-items: flex-start;
  }
  .key-stat-label {
    font-size: 8px;
  }
  .type-pill {
    font-size: 10px;
    padding: 2px 6px;
  }
}

/* Styles for created spells list (fixed color square and inline label) */
.created-spell-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  width: 100%; /* ensure each item takes its own line */
  box-sizing: border-box;
}

.created-spell-color {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 1px solid #333;
  border-radius: 2px;
  box-shadow: 0 0 4px rgba(0,0,0,0.4);
}

.created-spell-label {
  display: inline-block;
  font-size: 13px;
  color: #eaf8ff;
  white-space: nowrap;
}

.created-spell-meta {
  font-size: 12px;
  color: #9db4ff;
  margin-left: 6px;
}

/* Make loadout choice cards try harder to stay side-by-side:
   - limit the width of properties-list inside loadout cards so it can't expand cards
   - allow badges to wrap and truncate long overflow
   - prefer no-wrap on the choice container so cards remain on one line if possible */
.loadout-choice-container {
  flex-wrap: nowrap;
  gap: 16px;
  justify-content: center;
}