:root {
  --builder-gold: #f3c24a;
  --builder-cream: #f7edd7;
  --builder-muted: #e6d1af;
  --builder-wood: #60412c;
  --builder-wood-dark: #332318;
  --builder-red: #d44646;
  --builder-green: #76d98b;
  --builder-line: rgba(215, 155, 66, 0.38);
  --builder-line-strong: rgba(215, 155, 66, 0.52);
  --builder-panel: #60412c;
  --builder-panel-dark: #4f3625;
}

#content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

.builder-shell {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 1fr);
  grid-template-rows: minmax(170px, 0.62fr) minmax(0, 1.38fr);
  gap: 0;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  margin: 0;
  overflow: hidden;
  background: rgba(32, 23, 17, 0.82);
  border-top: 1px solid var(--builder-line-strong);
  border-bottom: 1px solid var(--builder-line);
}

.mobile-builder-view-switch {
  display: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

@media (max-width: 1400px) and (max-height: 950px) and (orientation: landscape) {
  .equipment-builder-page .page-title {
    display: none;
  }
}

.builder-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(79, 54, 37, 0.86);
  border: 0;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
}

.stats-panel {
  grid-column: 2 / 3;
  grid-row: 2 / 3;
  border-top: 1px solid var(--builder-line-strong);
  border-left: 1px solid var(--builder-line-strong);
}

.loadout-panel {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  border-left: 1px solid var(--builder-line-strong);
}

.loadout-panel .panel-body {
  background: rgba(73, 49, 34, 0.84);
}

.filters-panel {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  border-top: 1px solid var(--builder-line-strong);
}

.equipment-panel {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

.panel-head {
  padding: 7px 10px;
  border-bottom: 1px solid var(--builder-line-strong);
  background: rgba(51, 35, 24, 0.96);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--builder-gold);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.panel-head-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-head-with-action>span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-actions {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
}

.panel-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--builder-line);
  border-radius: 4px;
  background: rgba(32, 23, 17, 0.52);
  color: var(--builder-cream);
  cursor: pointer;
}

.loadout-slot-button {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.panel-icon-button:hover {
  border-color: var(--builder-gold);
  color: var(--builder-gold);
}

.panel-icon-button.is-active {
  border-color: var(--builder-gold);
  background: rgba(243, 194, 74, 0.18);
  color: var(--builder-gold);
  box-shadow: 0 0 0 1px rgba(243, 194, 74, 0.24);
}

.panel-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.stats-panel .panel-body {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px;
  display: block;
}

.panel-filter-row {
  flex: 0 0 auto;
  z-index: 10;
  background: rgba(51, 35, 24, 0.96);
  border-bottom: 1px solid var(--builder-line);
  min-height: 28px;
}

.set-filter-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  padding: 0;
}

.equipment-filter-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  padding: 0;
}

.set-filter-controls .input-group,
.set-filter-controls .form-select,
.set-filter-controls .form-control,
.set-filter-controls .btn,
.equipment-filter-controls .form-select {
  min-height: 0;
}

.builder-panel .custom-select,
.builder-panel .custom-input {
  min-height: 28px;
  height: 28px;
  padding-top: 1px;
  padding-bottom: 1px;
  border-radius: 0;
  border-width: 1px;
  font-size: 12px;
  line-height: 1.1;
}

.filters-panel .panel-body {
  background: rgba(79, 54, 37, 0.86);
}

.filters-panel .panel-filter-row {
  background: rgba(51, 35, 24, 0.96);
  border-bottom: 1px solid var(--builder-line);
}

.equipment-panel .panel-filter-row {
  padding: 0;
}

.equipment-panel .panel-filter-row .custom-select {
  border-radius: 0;
}

.stats-groups {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(42, 31, 23, 0.38);
  padding: 4px;
}

.stat-category {
  --category-color: #f3c24a;
  border: 1px solid rgba(67, 51, 38, 0.86);
  border-radius: 2px;
  overflow: hidden;
  background: #ead0aa;
  color: #3b2b20;
}

.stat-category-1 {
  --category-color: #55c9ff;
}

.stat-category-2 {
  --category-color: #ffd129;
}

.stat-category-3 {
  --category-color: #ff5e4d;
}

.stat-category-4 {
  --category-color: #f08c2f;
}

.stat-category-5 {
  --category-color: #55d86a;
}

.stat-category-6 {
  --category-color: #9b5cff;
}

.stat-category-7 {
  --category-color: #ffb45c;
}

.stat-category-8 {
  --category-color: #b9dd55;
}

.stat-effect-group-title {
  position: relative;
  display: flex;
  align-items: center;
  line-height: 1.3;
  padding: 6px 30px 6px 9px !important;
  min-height: 30px;
  background: #ead0aa;
  color: #3b2b20;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.stat-category-title {
  position: relative;
  display: flex;
  align-items: center;
  line-height: 1.1;
  min-height: 25px;
  padding: 4px 8px 4px 16px;
  background: #96663f;
  color: #f7edd7;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.stat-category-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--category-color);
}

.stat-effect-group-title::after {
  content: "";
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 9px solid #3b2b20;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.stat-effect-group-title[aria-expanded="true"]::after {
  transform: translateY(-50%) rotate(90deg);
}

.stat-effect-group-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stat-category-body {
  display: flex;
  flex-direction: column;
}

.stat-effect-group {
  border-top: 1px solid rgba(67, 51, 38, 0.84);
  background: #ead0aa;
  border-bottom: 0.5px solid rgba(67, 51, 38, 0.84);
}

.stat-row {
  display: flex;
  align-items: flex-start;
  min-height: 30px;
  padding: 6px 8px;
  border-top: 1px solid rgba(67, 51, 38, 0.84);
  background: #ead0aa;
  color: #3b2b20;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.3;
  overflow-wrap: break-word;
  position: relative;
}

.stat-row-single {
  background: #e2bc95;
}

.stat-row-child {
  padding-left: 12px;
  background: #e2bc95;
}

.stat-common-cap {
  padding: 7px 12px 3px;
  border-top: 1px solid rgba(67, 51, 38, 0.84);
  background: #e2bc95;
  color: #3b2b20;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}

.stat-row-common-cap {
  padding-left: 30px;
}

.set-filter-list {
  display: grid;
  grid-auto-rows: 30px;
  align-content: start;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
}

.set-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  height: 30px;
  padding: 5px 7px;
  border: 0;
  border-bottom: 1px solid rgba(215, 155, 66, 0.22);
  border-radius: 0;
  background: rgba(79, 54, 37, 0.86);
  color: var(--builder-cream);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
}

.set-filter-row:nth-child(even) {
  background: rgba(73, 49, 34, 0.84);
}

.set-filter-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set-filter-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--builder-gold);
  cursor: pointer;
}

.set-filter-row input:disabled {
  cursor: not-allowed;
}

.set-preview-link {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  color: var(--builder-cream);
  font-size: 15px;
  text-decoration: none;
}

.set-preview-link:hover,
.set-preview-link:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  color: var(--builder-gold);
}

.equipment-board {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.slot-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(50px, 72px));
  grid-template-rows: repeat(2, minmax(54px, 76px));
  gap: 8px;
  place-content: center;
  place-items: center;
  height: 100%;
  min-height: 100%;
  padding: 8px;
}

.equip-slot,
.equipment-tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  width: 100%;
  overflow: hidden;
}

.equip-slot {
  padding: 0;
  border: 2px solid #4a3a28;
  border-radius: 2px;
  background: #2a261f;
  box-shadow: inset 0 0 0 2px rgba(20, 17, 13, 0.75), 0 0 0 1px rgba(126, 100, 67, 0.35);
  cursor: pointer;
}

.slot-helmet {
  grid-column: 1;
  grid-row: 1;
}

.slot-armor {
  grid-column: 2;
  grid-row: 1;
}

.slot-sword {
  grid-column: 3;
  grid-row: 1;
}

.slot-artifact {
  grid-column: 4;
  grid-row: 1;
}

.slot-hero {
  grid-column: 6;
  grid-row: 1 / 3;
  align-self: center;
}

.slot-extra-artifact {
  grid-column: 5;
  grid-row: 1;
}

.slot-gem-1 {
  grid-column: 1;
  grid-row: 2;
}

.slot-gem-2 {
  grid-column: 2;
  grid-row: 2;
}

.slot-gem-3 {
  grid-column: 3;
  grid-row: 2;
}

.slot-gem-4 {
  grid-column: 4;
  grid-row: 2;
}

.slot-gem-5 {
  grid-column: 5;
  grid-row: 2;
}

.equip-slot.can-place {
  border-color: var(--builder-gold);
  box-shadow: 0 0 0 2px rgba(243, 194, 74, 0.28), 0 0 14px rgba(243, 194, 74, 0.38);
}

.equip-slot.is-locked {
  opacity: 0.42;
  cursor: default;
}

.equip-slot img,
.equip-slot canvas {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 2px solid #d44646;
  border-radius: 2px;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.equip-slot .slot-placeholder-image {
  z-index: 1;
  width: 72%;
  height: 72%;
  border: 0;
  opacity: 0.72;
  box-shadow: none;
}

.equipment-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  justify-content: start;
  gap: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
}

.equipment-grid .builder-empty {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
}

.equipment-tile {
  width: 100%;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

.equipment-tile img,
.equipment-tile canvas {
  width: 80%;
  height: 80%;
  object-fit: contain;
  border: 2px solid #d44646;
  border-radius: 2px;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.equipment-tile.is-selected img,
.equipment-tile.is-selected canvas {
  border-color: var(--builder-gold);
  box-shadow: 0 0 0 2px rgba(243, 194, 74, 0.28), 0 0 14px rgba(243, 194, 74, 0.38);
}

.equipment-tile.is-equipped {
  opacity: 0.42;
}

.builder-empty {
  color: var(--builder-cream);
  font-weight: 700;
  text-align: center;
  padding: 16px;
}

@media (max-width: 992px) {
  .equipment-builder-page *::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }

  #content {
    overflow: hidden;
  }

  .mobile-builder-view-switch {
    display: flex;
    margin-top: 0;
    margin-bottom: 0;
    border-bottom: 1px solid var(--builder-line);
    background: rgba(51, 35, 24, 0.92);
  }

  .builder-shell {
    display: flex;
    flex-direction: column;
    gap: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    min-height: 0;
  }

  .stats-panel,
  .loadout-panel,
  .equipment-panel,
  .filters-panel {
    grid-column: auto;
    grid-row: auto;
    border-top: 0;
    border-left: 0;
  }

  .builder-panel {
    min-height: 0;
  }

  .stats-panel,
  .filters-panel,
  .equipment-panel,
  .loadout-panel {
    border-radius: 0;
  }

  .stats-panel .panel-body,
  .stats-groups {
    padding: 0;
  }

  .builder-shell.mobile-view-sets .filters-panel>.panel-head,
  .builder-shell.mobile-view-stats .stats-panel>.panel-head {
    display: none;
  }

  .builder-shell.mobile-view-build .filters-panel,
  .builder-shell.mobile-view-build .stats-panel,
  .builder-shell.mobile-view-sets .equipment-panel,
  .builder-shell.mobile-view-sets .loadout-panel,
  .builder-shell.mobile-view-sets .stats-panel,
  .builder-shell.mobile-view-stats .equipment-panel,
  .builder-shell.mobile-view-stats .loadout-panel,
  .builder-shell.mobile-view-stats .filters-panel {
    display: none;
  }

  .builder-shell.mobile-view-build .loadout-panel {
    order: 1;
    flex: 0 0 218px;
  }

  .builder-shell.mobile-view-build .equipment-panel {
    order: 2;
    flex: 1 1 auto;
    border-top: 1px solid var(--builder-line-strong);
  }

  .builder-shell.mobile-view-sets .filters-panel,
  .builder-shell.mobile-view-stats .stats-panel {
    order: 1;
    flex: 1 1 auto;
    min-height: 0;
  }

  .equipment-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 2px;
  }

  .equipment-tile {
    width: 100%;
    height: auto;
  }

  .equipment-tile img,
  .equipment-tile canvas {
    width: 86%;
    height: 86%;
  }
}

@media (max-width: 520px) {
  .builder-shell.mobile-view-build .loadout-panel {
    flex-basis: 188px;
  }

  .slot-board {
    grid-template-columns: repeat(6, minmax(42px, 66px));
    grid-template-rows: repeat(2, minmax(46px, 72px));
    gap: 8px;
  }
}

.equipment-builder-page .page-title h1 {
  position: static;
  top: auto;
  z-index: 50;
  width: calc(100% + 1.5rem);
  margin: 0 -0.75rem;
  padding: 6px 10px;
  background: linear-gradient(100deg, rgba(50, 35, 25, 0.96), rgba(82, 54, 35, 0.92));
  border: 0;
  border-bottom: 1px solid rgba(215, 155, 66, 0.48);
  border-radius: 0;
  color: #f3c24a;
  font-size: 1.35rem;
  font-weight: 900;
  text-align: left;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.42);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.22);
}

.equipment-builder-page .page-title h1::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 11px 2px 4px;
  border: 2px solid #d79b42;
  transform: rotate(45deg);
}
