body.stock-loadout-mode {
  background: radial-gradient(ellipse at 30% 10%, #32201a 0%, #180f11 36%, #0e0d10 75%);
  color: #f3e7d0;
  margin: 0;
  min-height: 100vh;
  color-scheme: dark;
}
.stock-loadout-mode *, .stock-loadout-mode *::before, .stock-loadout-mode *::after { box-sizing: border-box; }
.stock-loadout [hidden] { display: none; }
.loadout-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid #6d4b31;
  background: #151114;
  font: 14px "DM Sans", sans-serif;
}
.loadout-header a { color: #e9bb73; }

.stock-loadout {
  --gold: #e9bb73;
  --stone: #181315;
  --border: #6d4b31;
  font-family: "DM Sans", sans-serif;
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(18px, 4vw, 48px);
}
.stock-loadout h1, .stock-loadout h2 {
  font-family: Cinzel, Georgia, serif;
  color: var(--gold);
  letter-spacing: .015em;
  margin: 0;
}
.stock-loadout h1 { font-size: clamp(35px, 7vw, 74px); }
.stock-loadout h2 { font-size: clamp(20px, 3vw, 27px); }
.stock-loadout a { color: var(--gold); }
.loadout-heading, .loadout-actions, .loadout-fields {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.loadout-heading { justify-content: space-between; }
.loadout-heading p { margin: 6px 0 0; }
#loadout-status, #loadout-position { color: #cdb899; font-size: .9rem; }
.loadout-grid { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr); gap: 16px; }
.loadout-panel {
  border: 1px solid var(--border);
  background: var(--stone);
  box-shadow: inset 0 0 0 3px #241c1b, 0 12px 36px #0006;
  padding: clamp(14px, 3vw, 24px);
  min-width: 0;
}
.loadout-character {
  text-align: center;
  background: linear-gradient(#1b1516, #121010);
}
.loadout-art {
  display: block;
  background: transparent url("../assets/stock-loadout-transparent.webp") 0 0 / 300% 300%;
  width: 100%;
  aspect-ratio: 1;
}
.equipment-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: minmax(80px, auto) 74px 65px;
  gap: 5px;
  margin-top: 14px;
  padding: 8px;
  border: 3px ridge #756958;
  background: repeating-linear-gradient(127deg, #383535 0 4px, #333131 4px 9px);
}
.equipment-slot {
  position: relative;
  display: grid;
  place-content: center;
  border: 3px ridge #6e563a;
  background: radial-gradient(ellipse, #232224, #0c0d0e);
  color: #cbb79a;
  font-size: .68rem;
  overflow: hidden;
}
.equipment-head { grid-area: 1 / 2 / 2 / 4; gap: 4px; }
.equipment-body { grid-area: 2 / 2 / 3 / 4; }
.equipment-shield { grid-area: 1 / 4 / 3 / 5; }
#loadout-slot-weapon { grid-area: 1 / 1 / 3 / 2; }
.equipment-head strong { color: var(--gold); font-size: .95rem; }
#loadout-token-logo:empty { display: none; }
#loadout-token-logo img { width: 30px; height: 30px; object-fit: contain; }
.equipment-art { position: absolute; top: 50%; left: 50%; width: 100%; transform: translate(-50%, -50%); }
#loadout-equipped-name { color: var(--gold); margin-bottom: 0; }
.loadout-art[data-art="0"] { background-position: 50% 0; }
.loadout-art[data-art="1"] { background-position: 100% 0; }
.loadout-art[data-art="2"] { background-position: 0 50%; }
.loadout-art[data-art="3"] { background-position: 50% 50%; }
.loadout-art[data-art="4"] { background-position: 100% 50%; }
.loadout-art[data-art="5"] { background-position: 0 100%; }
.loadout-art[data-art="6"] { background-position: 50% 100%; }
.loadout-art[data-art="7"] { background-position: 100% 100%; }
.loadout-fields { margin: 14px 0; }
.loadout-fields label { flex: 1 1 140px; font-size: .85rem; color: #d6c0a2; }
.stock-loadout select, .stock-loadout input[type="date"], .stock-loadout button {
  background: #211819;
  border: 1px solid var(--border);
  color: #f3e7d0;
  padding: 9px 12px;
  min-height: 42px;
}
.stock-loadout button:not(:disabled) { cursor: pointer; }
.stock-loadout :is(button, a, select):focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.stock-loadout :is(select, input[type="date"]) { display: block; margin-top: 5px; width: 100%; }
.loadout-items { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stock-loadout .loadout-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  position: relative;
  padding: 5px 5px 9px;
  color: var(--gold);
  font-family: Georgia, serif;
}
.loadout-item small { color: #e3cfb0; font: 11px "DM Sans", sans-serif; }
.loadout-item:disabled { opacity: .45; }
.stock-loadout .loadout-item[aria-pressed="true"], .stock-loadout button:not(:disabled):hover {
  border-color: var(--gold);
  background-color: #35231d;
}
.loadout-tooltip {
  display: none;
  position: absolute;
  z-index: 3;
  bottom: calc(100% + 6px);
  width: min(230px, 60vw);
  border: 1px solid var(--gold);
  background: #110e12;
  color: #fff0d4;
  padding: 9px;
  box-shadow: 0 6px 18px #0009;
  font: 13px/1.4 "DM Sans", sans-serif;
  pointer-events: none;
}
.loadout-item:nth-child(4n+1) .loadout-tooltip { left: 0; }
.loadout-item:nth-child(4n) .loadout-tooltip { right: 0; }
.loadout-item:hover .loadout-tooltip, .loadout-item:focus-visible .loadout-tooltip { display: block; }
.loadout-contract { border-top: 1px solid var(--border); margin-top: 14px; font-size: .9rem; }
.loadout-callput { display: inline-block; margin: 8px 0 0 8px; }
.loadout-results { margin-top: 16px; }
#loadout-chart { position: relative; height: 290px; overflow: hidden; }
#loadout-remaining { color: var(--gold); }
.loadout-chart-guide {
  position: absolute;
  z-index: 2;
  inset-block: 0 25px;
  border-left: 1px dashed #9bc9dc;
  padding: 5px;
  color: #bce2ef;
  font-size: .72rem;
  white-space: nowrap;
  pointer-events: none;
}
.loadout-chart-guide[data-event="expiry"] {
  border-left: 0;
  border-right: 1px dashed #f0bd65;
  transform: translateX(-100%);
  padding-top: 23px;
  color: #f0bd65;
}
#loadout-chart:empty { height: 0; }
.loadout-results table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: .88rem; }
.loadout-results :is(th, td) { padding: 9px 5px; border-bottom: 1px solid #4d372d; text-align: left; overflow-wrap: anywhere; }
.loadout-results th { color: var(--gold); }
@media (max-width: 760px) {
  .loadout-grid { grid-template-columns: 1fr; }
}
@media (max-width: 460px) {
  .loadout-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .loadout-item:nth-child(odd) .loadout-tooltip { left: 0; right: auto; }
  .loadout-item:nth-child(even) .loadout-tooltip { right: 0; left: auto; }
}

#loadout-payoff svg { display: block; width: 100%; height: auto; min-height: 160px; }
.loadout-contract h3 { color: var(--gold); font-family: Cinzel, Georgia, serif; margin-bottom: 0; }

@media (min-width: 1000px) {
  .loadout-header { padding: 8px 20px; }
  .stock-loadout { max-width: 1700px; padding: 12px 20px; display: grid;
    grid-template-columns: minmax(190px, 0.75fr) minmax(280px, 1.1fr) minmax(410px, 1.8fr);
    gap: 10px; align-items: start; }
  .loadout-heading, #loadout-status { grid-column: 1 / -1; }
  .loadout-heading h1 { font-size: 32px; }
  #loadout-status { margin: 0; }
  .loadout-grid { display: contents; }
  .loadout-panel { padding: 12px; }
  .loadout-panel h2 { font-size: 19px; }
  .loadout-results { margin: 0; }
  .equipment-board { grid-template-rows: 70px 60px 55px; }
  .loadout-fields { margin: 8px 0; gap: 6px; }
  .loadout-fields label { flex-basis: 110px; }
  .stock-loadout select, .stock-loadout input[type="date"], .stock-loadout button { min-height: 34px; padding: 6px; }
  .loadout-items { gap: 4px; }
  .stock-loadout .loadout-item { font-size: 12px; padding: 3px; }
  .loadout-item .loadout-art { max-width: 72px; }
  .loadout-contract { margin-top: 6px; font-size: .8rem; }
  .loadout-contract p, .loadout-results p { margin: 5px 0; font-size: .76rem; }
  #loadout-payoff svg { max-height: 115px; min-height: 0; }
  #loadout-chart { height: clamp(180px, 27vh, 260px); }
}

.equipment-art[data-art="0"] { width: min(100%, 100px); }
.equipment-art[data-art="1"] { width: 85%; }
.equipment-art[data-art="2"] { width: 100%; }
.equipment-art[data-art="3"] { width: 100%; }
.equipment-art[data-art="4"], .equipment-art[data-art="5"] { width: 70%; }
.equipment-art[data-art="6"], .equipment-art[data-art="7"] { width: 85%; }

/* Keep sprite proportions inside each equipment slot. */
.equipment-art { max-width: 100%; max-height: 100%; object-fit: contain; }
#loadout-slot-weapon .equipment-art { width: 100%; aspect-ratio: 1; }
#loadout-slot-weapon .equipment-art[data-art="0"] { width: 100%; transform: translate(-50%, -50%) scaleX(1.6); }
#loadout-slot-weapon .equipment-art[data-art="1"] { width: 100%; transform: translate(-50%, -50%) scale(1.15); }
#loadout-slot-ring .equipment-art { width: 100%; }
#loadout-slot-gloves .equipment-art, #loadout-slot-belt .equipment-art { width: 100%; }


.loadout-chart-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: .8rem; }
.loadout-chart-controls label { display: flex; align-items: center; gap: 6px; }
.loadout-chart-controls select { width: auto; margin: 0; }
.loadout-chart-guide[data-event="exit"] { color: #e6a5a5; border-color: #e6a5a5; }

.bag-heading { display: flex; justify-content: space-between; align-items: center; }
.stock-loadout .bag-heading button { min-height: 28px; padding: 4px 8px; font-size: 11px; }
.loadout-items {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(4, clamp(32px, 3vw, 48px));
  gap: 2px;
  padding: 5px;
  border: 3px ridge #75634b;
  background: repeating-linear-gradient(90deg, #222022 0, #171719 1px, #171719 12%, #37302a 12.3%, #171719 12.5%);
}
.stock-loadout .loadout-item {
  min-width: 0;
  min-height: 0;
  padding: 1px;
  display: grid;
  place-items: center;
  border: 1px solid #584b39;
  background: radial-gradient(ellipse at center, #303133 0, #101114 85%);
}
.stock-loadout .loadout-item[data-item="0"] { grid-area: 1 / 1 / 4 / 2; }
.stock-loadout .loadout-item[data-item="1"] { grid-area: 1 / 2 / 3 / 3; }
.stock-loadout .loadout-item[data-item="2"] { grid-area: 1 / 3 / 3 / 6; }
.stock-loadout .loadout-item[data-item="3"] { grid-area: 1 / 6 / 3 / 8; }
.stock-loadout .loadout-item[data-item="4"] { grid-area: 1 / 8 / 2 / 9; }
.stock-loadout .loadout-item[data-item="5"] { grid-area: 2 / 8 / 3 / 9; }
.stock-loadout .loadout-item[data-item="6"] { grid-area: 3 / 2 / 5 / 4; }
.stock-loadout .loadout-item[data-item="7"] { grid-area: 3 / 4 / 4 / 7; }
.loadout-item .loadout-art { width: min(100%, 100px); max-height: 100%; }
.loadout-item .loadout-tooltip {
  bottom: auto; top: 50%; left: 50%; right: auto;
  transform: translate(-50%, -50%);
  min-width: 220px; text-align: center;
  border: 2px ridge #b69a69; background: #08080cf5;
  color: #d7c9ad; font: 12px/1.5 Georgia, serif;
}
.loadout-tooltip strong, .loadout-tooltip span { display: block; }
.loadout-tooltip strong { color: #f1cf8f; font-size: 15px; }
.loadout-tooltip span:nth-child(2) { color: #aab6ef; }
.loadout-tooltip span:last-child { margin-top: 5px; }
.loadout-item:hover, .loadout-item:focus-visible { z-index: 5; }
.loadout-method { color: #cdb899; font-size: .76rem; }
.loadout-method summary { cursor: pointer; color: #e9bb73; }
@media (max-width: 460px) {
  .loadout-items { grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(4, 40px); }
  .loadout-item:nth-child(odd) .loadout-tooltip, .loadout-item:nth-child(even) .loadout-tooltip { left: 50%; right: auto; }
}

/* Clip sprite pixels within their icon, while keeping tooltips free to overflow. */
.loadout-item .loadout-art { max-width: 100%; max-height: 100%; overflow: hidden; clip-path: inset(0); transform: none; }
.loadout-item[data-item="0"] .loadout-art {
  width: 100%; height: 100%; aspect-ratio: auto;
  background-size: 900% 300%; background-position: 50% 0;
}
#loadout-slot-weapon .equipment-art[data-art="0"],
#loadout-slot-weapon .equipment-art[data-art="1"] { transform: translate(-50%, -50%); }

/* Eight by four square cells, including the empty cells. */
.loadout-items {
  box-sizing: border-box;
  aspect-ratio: 2 / 1;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 0;
  background-color: #151416;
  background-image: linear-gradient(to right, #524639 1px, transparent 1px),
                    linear-gradient(to bottom, #524639 1px, transparent 1px);
  background-size: 12.5% 25%;
}
.stock-loadout .loadout-item { padding: 0; }
.loadout-item .loadout-art { width: 100%; height: 100%; max-width: none; max-height: none; aspect-ratio: auto; }
.loadout-item[data-item="0"] .loadout-art { background-size: 1200% 310%; background-position: 50% 0%; }
.loadout-item[data-item="1"] .loadout-art { background-size: 480% 315%; background-position: 92% 0%; }
.loadout-item[data-item="2"] .loadout-art { background-size: 330% 380%; background-position: 2% 50%; }
.loadout-item[data-item="3"] .loadout-art { background-size: 335% 320%; background-position: 50% 50%; }
.loadout-item[data-item="4"] .loadout-art { background-size: 480% 460%; background-position: 92% 50%; }
.loadout-item[data-item="5"] .loadout-art { background-size: 480% 420%; background-position: 8% 94%; }
.loadout-item[data-item="6"] .loadout-art { background-size: 390% 335%; background-position: 50% 97%; }
.loadout-item[data-item="7"] .loadout-art { background-size: 345% 490%; background-position: 97% 92%; }
@media (max-width: 460px) {
  .loadout-items { grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); }
}

/* Event badges have separate lanes so a rollover cannot cover its expiry. */
.loadout-event-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 11px; margin: 4px 0; }
.legend-entry { color: #bce2ef; }
.legend-expiry { color: #f0bd65; }
.legend-reentry { color: #a6e3b2; }
.loadout-chart-guide { width: 0; padding: 0; transform: none; border: 0; border-left: 1px dashed #8fbdcf; }
.loadout-chart-guide[data-event="expiry"] { border: 0; border-left: 1px dashed #d6a858; transform: none; padding: 0; }
.loadout-chart-guide[data-event="reentry"] { border-color: #87ca96; }
.loadout-chart-guide[data-event="exit"] { border-color: #e6a5a5; }
.loadout-guide-badge { position: absolute; top: 4px; left: 3px; padding: 1px 3px; border-radius: 2px;
  background: #151313e8; color: #bce2ef; font: 600 10px/1.2 system-ui, sans-serif; }
.loadout-chart-guide[data-event="expiry"] .loadout-guide-badge { top: auto; bottom: 4px; color: #f0bd65; }
.loadout-chart-guide[data-event="reentry"] .loadout-guide-badge { color: #a6e3b2; }
.loadout-chart-guide[data-event="exit"] .loadout-guide-badge { color: #f0aaaa; transform: translateX(-100%); left: -3px; }
