* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1b2740 0, #050814 55%, #05060d 100%);
  color: #f5f5f5;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.shop-root {
  width: 100%;
  max-width: 1400px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  background: #050814;
  border-radius: 14px;
  border: 1px solid #1a283b;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

/* Header */

.shop-header {
  padding: 10px 18px;
  border-bottom: 1px solid #1a283b;
  background: linear-gradient(90deg, #06111f, #0a1624);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.shop-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shop-header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f7e9b5;
}

.shop-header-subtitle {
  font-size: 11px;
  color: #8ba0c7;
}

.shop-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-select {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #8ba0c7;
}

.header-select-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.header-select select {
  background: #050814;
  border-radius: 6px;
  border: 1px solid #283553;
  padding: 4px 8px;
  font-size: 11px;
  color: #cbd4eb;
}

/* Layout */

.shop-main {
  flex: 1;
  display: grid;
  grid-template-columns: 220px minmax(0, 1.8fr) minmax(0, 1.2fr);
  gap: 0;
  overflow: hidden;
}

.shop-panel {
  padding: 10px;
  border-right: 1px solid #1a283b;
  background: radial-gradient(circle at top left, #121c30 0, #050814 55%);
  overflow: hidden;
}

.shop-panel:last-child {
  border-right: none;
}

.panel-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8ba0c7;
  margin-bottom: 6px;
}

/* Categories */

.shop-categories {
  display: flex;
  flex-direction: column;
}

.category-list {
  margin-top: 4px;
  overflow-y: auto;
  padding-right: 4px;
}

.category-block {
  margin-bottom: 8px;
  border-radius: 6px;
  background: linear-gradient(135deg, #090f1d, #050814);
  border: 1px solid #141f33;
  padding: 6px 6px 4px;
}

.category-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #d7dfef;
  margin-bottom: 4px;
}

.category-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.category-tag {
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid #283553;
  background: rgba(12, 20, 38, 0.9);
  color: #cbd4eb;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}

.category-tag:hover {
  background: rgba(34, 55, 92, 0.95);
  border-color: #3e547e;
}

.category-tag.active {
  background: linear-gradient(135deg, #1f364f, #2f5688);
  border-color: #f7e9b5;
  color: #f7e9b5;
  box-shadow: 0 0 8px rgba(247, 233, 181, 0.35);
  transform: translateY(-1px);
}

/* Items panel */

.shop-items {
  display: flex;
  flex-direction: column;
  border-left: 1px solid #000;
  border-right: 1px solid #000;
}

.shop-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

#search-input {
  flex: 1;
  background: #050814;
  border-radius: 6px;
  border: 1px solid #283553;
  padding: 6px 8px;
  font-size: 13px;
  color: #f5f5f5;
}

#search-input:focus {
  outline: none;
  border-color: #f7e9b5;
  box-shadow: 0 0 0 1px rgba(247, 233, 181, 0.3);
}

#map-select {
  background: #050814;
  border-radius: 6px;
  border: 1px solid #283553;
  padding: 6px 8px;
  font-size: 12px;
  color: #cbd4eb;
}

.result-count {
  min-width: 80px;
  text-align: right;
  font-size: 11px;
  color: #7c93bc;
}

.item-grid {
  flex: 1;
  overflow-y: auto;
  padding: 2px 2px 2px 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px;

  /* NEW: prevent rows from stretching items vertically */
  align-content: flex-start;
  align-items: flex-start;
}

.item-card {
  background: radial-gradient(circle at top, #141c30 0, #050814 80%);
  border-radius: 6px;
  border: 1px solid #283553;
  padding: 5px 5px 4px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.05s, background 0.12s;

  /* NEW: ensure each card uses only content height */
  align-self: flex-start;
}


.item-card:hover {
  border-color: #f7e9b5;
  box-shadow: 0 0 12px rgba(247, 233, 181, 0.25);
  background: radial-gradient(circle at top, #1c2538 0, #050814 80%);
  transform: translateY(-1px);
}

.item-card.selected {
  border-color: #f7e9b5;
  box-shadow: 0 0 12px rgba(247, 233, 181, 0.4);
}

.item-icon-wrapper {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 3px;
}

.item-icon {
  display: block;
  width: 100%;
  height: auto;
}

.item-cost {
  position: absolute;
  bottom: 0;
  right: 0;
  background: rgba(4, 7, 14, 0.95);
  padding: 1px 4px;
  border-top-left-radius: 4px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.item-cost-gold {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffdf6f, #b37c24 75%);
  box-shadow: 0 0 5px rgba(247, 233, 181, 0.7);
}

.item-cost-value {
  color: #f7e9b5;
}

.item-name {
  font-size: 11px;
  font-weight: 600;
  color: #e4edff;
  line-height: 1.2;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.item-tag {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(14, 24, 45, 0.9);
  border: 1px solid #283553;
  color: #aab7d7;

  /* NEW: prevent overflowing outside card */
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  margin-top: 12px;
  font-size: 12px;
  color: #7c93bc;
}

/* Details */

.shop-details {
  display: flex;
  flex-direction: column;
}

.detail-efficiency {
  margin-top: 6px;
  font-size: 11px;
  color: #f7e9b5;
  opacity: 0.85;
}


.detail-placeholder {
  font-size: 12px;
  color: #7c93bc;
  margin-top: 4px;
}

.item-detail {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.detail-icon {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  border: 1px solid #f7e9b5;
  background: #000;
}

.detail-header-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-name {
  font-size: 16px;
  font-weight: 700;
  color: #f7e9b5;
}

.detail-gold {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #f7e9b5;
}

.detail-gold-value {
  font-weight: 600;
}

.detail-gold-label {
  font-size: 11px;
  color: #c1c7da;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.detail-tag-pill {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid #283553;
  background: rgba(14, 24, 45, 0.95);
  color: #cbd4eb;
}

.detail-plaintext {
  font-size: 12px;
  color: #cbd4eb;
  margin-bottom: 8px;
}

.detail-section {
  margin-top: 6px;
}

.detail-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8ba0c7;
  margin-bottom: 4px;
}

.detail-description {
  font-size: 12px;
  color: #d3ddff;
  line-height: 1.35;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Slight HTML-tag styling inside description */

.detail-description attention {
  color: #f7e9b5;
  font-weight: 600;
}

.detail-description passive {
  color: #f4c56a;
  font-weight: 600;
}

.detail-description magicDamage {
  color: #93c5ff;
}

.detail-description trueDamage {
  color: #ffb3b3;
}

.detail-description flavorText {
  color: #b1a1ff;
  font-style: italic;
}

.detail-description rules {
  color: #7c93bc;
}

/* Build paths */

.build-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8ba0c7;
  margin-bottom: 3px;
}

.build-icon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.build-icon-wrapper {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #283553;
  cursor: pointer;
  background: #000;
}

.build-icon-wrapper img {
  width: 100%;
  height: 100%;
  display: block;
}

/* Generic */

.hidden {
  display: none;
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #050814;
}

::-webkit-scrollbar-thumb {
  background: #283553;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3e547e;
}

/* Responsive */

@media (max-width: 1100px) {
  .shop-main {
    grid-template-columns: 190px minmax(0, 1.7fr) minmax(0, 1.3fr);
  }
}

@media (max-width: 900px) {
  .shop-root {
    height: auto;
    max-height: none;
  }

  .shop-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .shop-panel {
    border-right: none;
    border-bottom: 1px solid #1a283b;
  }

  .shop-panel:last-child {
    border-bottom: none;
  }

  .shop-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .shop-header-right {
    align-self: stretch;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
