/* The existing buttons and overlay containers own all input and scrolling. */
#overlay:is([data-screen="shop"], [data-screen="reward"], [data-screen="floor-clear"]) {
  touch-action: pan-y;
}

#overlay:is([data-screen="reward"], [data-screen="floor-clear"]) .panel {
  width: min(100%, 35rem);
  padding: clamp(10px, 3vmin, 21px);
  border: 1px solid #5c7989;
  border-radius: 3px 13px;
  background: linear-gradient(134deg, #273846, #14202b 63%);
  box-shadow: inset 0 0 0 3px #101a247a, 0 16px 36px #060a12a8;
  overflow-wrap: anywhere;
  text-align: start;
}

#overlay:is([data-screen="reward"], [data-screen="floor-clear"]) .panel-mark { display: none; }

#overlay:is([data-screen="shop"], [data-screen="reward"], [data-screen="floor-clear"]) .actions > button {
  min-block-size: 44px;
  min-inline-size: 0;
  overflow-wrap: anywhere;
  touch-action: manipulation;
}

#overlay[data-screen="reward"] .actions { justify-content: start; }
#overlay[data-screen="floor-clear"] .actions > button { width: 100%; }

.b5-label {
  color: #b6cbd6;
  font: 650 .75rem/1.25 ui-monospace, monospace;
}

.b5-value {
  color: #e3f5ff;
  font: 700 1rem/1.25 ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* The wallet stays distinct from any item's price or availability. */
[data-b5-part="wallet"] {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-height: 38px;
  gap: 3px 9px;
  margin-block: 0 8px;
  padding: 5px 9px 5px 40px;
  border: 1px solid #667c7b;
  border-radius: 2px;
  background: linear-gradient(93deg, #21383e, #17242e 56%);
  position: relative;
}

[data-b5-part="wallet"]::before {
  content: "";
  position: absolute;
  inset: 50% auto auto 6px;
  width: 28px;
  height: 28px;
  transform: translateY(-50%);
  background: url("../assets/deep-space/ui/batch-five/wallet.png") center / contain no-repeat;
}

[data-b5-part="wallet"] .b5-value { color: #cbf5e5; }
.b5-message { color: #d0dce1; font-size: .75rem; }

#overlay[data-screen="shop"] .actions > [data-b5-part="product"] {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: start;
  gap: 4px 7px;
  padding: 8px 9px;
  border-inline-start-width: 3px;
  background: linear-gradient(125deg, #2b414e, #1b2935 68%);
}

#overlay[data-screen="shop"] .actions > [data-b5-part="product"]:hover:enabled {
  border-color: #a0d7e5;
  background: linear-gradient(125deg, #365561, #20333f 68%);
}

#overlay[data-screen="shop"] .actions > [data-b5-part="product"]:disabled {
  opacity: 1;
  border-color: #536571;
  background: #1b2731;
  color: #d9e5ea;
}

#overlay[data-screen="shop"] .actions > [data-b5-stock="sold"] { border-inline-start-color: #b09570; }

.b5-product-heading {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: .84rem;
  line-height: 1.25;
}

.b5-product-heading::before {
  content: "";
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  background: url("../assets/deep-space/ui/batch-five/product.png") center / contain no-repeat;
}

.b5-product-heading:has(img)::before { display: none; }
.b5-product-price { align-self: center; color: #b6e6e4; font: 650 .73rem/1.1 ui-monospace, monospace; }

#overlay[data-screen="shop"] .actions .b5-product-detail {
  grid-column: 1 / -1;
  margin: 0;
  color: #c6d5dd;
  font-size: .75rem;
  line-height: 1.25;
}

.b5-stock-label, [data-b5-part="sold"] {
  justify-self: start;
  padding: 2px 5px;
  border: 1px solid #6a7981;
  border-radius: 2px;
  color: #d0dce0;
  font: 650 .68rem/1.15 ui-monospace, monospace;
}

[data-b5-part="sold"] {
  padding-inline-start: 20px;
  border-color: #9d8060;
  color: #ffe0ac;
  background:
    url("../assets/deep-space/ui/batch-five/sold.png") 3px center / 13px auto no-repeat,
    repeating-linear-gradient(133deg, #422e25, #422e25 3px, #3a2921 3px, #3a2921 6px);
}

#overlay[data-screen="event"] .panel > [data-b5-outcome="blocked"] {
  margin: 0 0 9px;
  padding: 7px 9px 7px 34px;
  border: 1px solid #b47867;
  border-radius: 3px;
  background: url("../assets/deep-space/ui/batch-five/event.png") 6px center / 21px auto no-repeat, #352829;
  color: #ffe5db;
}

#overlay[data-screen="event"] [data-b5-outcome="blocked"] .b5-label { color: #ffc5ac; }

#status[data-b5-part="event"] {
  padding-inline-start: 17px;
  background: url("../assets/deep-space/ui/batch-five/event.png") left center / 13px auto no-repeat;
  color: #c5f3de;
  line-height: 1.05;
  white-space: normal;
  overflow-wrap: anywhere;
}

[data-b5-part="cabinet"] {
  --latch-color: #d49c74;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  margin-block-end: 9px;
  min-height: 49px;
  padding: 6px 8px 6px 49px;
  border: 1px solid var(--latch-color);
  border-radius: 3px 8px;
  background: url("../assets/deep-space/ui/batch-five/cabinet.png") 6px center / 38px auto no-repeat, #2b292c;
}

[data-b5-latch="ready"] { --latch-color: #86b8a9; background-color: #1e3436; }
[data-b5-part="cabinet"] .b5-label { color: var(--latch-color); }

[data-b5-part="transfer"] {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  border: 1px solid #648c9d;
  border-radius: 3px 8px;
  background: linear-gradient(110deg, #182832, #23404b);
}

.b5-transfer-origin, .b5-transfer-destination { padding: 7px 8px; }
.b5-transfer-origin { border-inline-end: 1px solid #648c9d; }
.b5-transfer-destination {
  padding-inline-start: 38px;
  background: url("../assets/deep-space/ui/batch-five/transfer.png") 6px center / 26px auto no-repeat;
}
[data-b5-part="transfer"] strong { display: block; color: #e3f5ff; font-size: .88rem; }

[data-b5-part="boss-supply"] {
  margin-block: 8px;
  padding: 6px 8px;
  border: 1px solid #8b8167;
  border-radius: 2px 7px;
  background: linear-gradient(118deg, #373329, #242b31 72%);
}

[data-b5-part="boss-supply"] > h3 {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 4px;
  color: #f5d4a3;
}

[data-b5-part="boss-supply"] > h3::before {
  content: "";
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  background: url("../assets/deep-space/ui/batch-five/boss-supply.png") center / contain no-repeat;
}

.b5-readings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 0;
}

.b5-reading {
  padding: 5px;
  border: 1px solid #67717a;
  background: #17232c;
}

.b5-reading dd { margin: 3px 0 0; }
.b5-before { color: #bdcbd2; font-weight: 500; }
#overlay .b5-terms, #overlay .b5-advice { margin: 4px 0 0; font-size: .75rem; }
#overlay .b5-terms { color: #f6dfb7; }

#flow[data-flow-screen="pause"] [data-b5-part="equipment"] {
  padding: 6px 7px;
  border: 1px solid #597787;
  border-radius: 3px 7px;
  background: linear-gradient(108deg, #233641, #17242e 76%);
}

[data-b5-part="equipment"] > h3 {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 4px;
  color: #d9f4fe;
}

[data-b5-part="equipment"] > h3::before {
  content: "";
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  background: url("../assets/deep-space/ui/batch-five/equipment.png") center / contain no-repeat;
}

.b5-equipment-slots { display: grid; gap: 2px; }
.b5-slot {
  display: grid;
  grid-template-columns: minmax(0, .65fr) minmax(0, 1fr);
  gap: 4px;
  padding: 5px 3px;
  border-top: 1px solid #3c5765;
}
.b5-slot-value { color: #e0edf2; font-weight: 600; }
.b5-slot-status { display: block; color: #c9ddd9; font-weight: 400; }
.b5-slot .deep-space-item-icon { --item-icon-size: 1.1em; }

[data-touch] #flow[data-flow-screen="pause"] .mf-pause-details > summary {
  min-height: 44px;
  align-content: center;
}

[data-b5-part="equipment"] .tool-equip { margin: 4px 0 0; }
[data-touch] [data-b5-part="equipment"] .tool-equip select { min-height: 44px; }

:is([data-layout="portrait"], [data-layout="landscape"][data-compact]) #overlay[data-screen="shop"] .actions > button:last-child {
  position: sticky;
  z-index: 1;
  inset-block-end: 0;
  background: #284652;
  box-shadow: 0 -2px 5px #101923;
}

:is([data-layout="portrait"], [data-layout="landscape"][data-compact]) #overlay[data-screen="shop"] .actions > button:last-child:hover {
  background: #365d69;
}

:is([data-layout="portrait"], [data-layout="landscape"][data-compact]) #overlay[data-screen="shop"] .actions > [data-b5-part="product"] {
  scroll-margin-block-end: 49px;
}

[data-layout="landscape"][data-compact] #overlay[data-screen="floor-clear"] .panel {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: 4px 6px;
  padding: 6px 8px;
}

[data-layout="landscape"][data-compact] #overlay[data-screen="floor-clear"] #title {
  grid-area: 1 / 1;
  align-self: center;
  margin: 0;
  font-size: 1.15rem;
}

[data-layout="landscape"][data-compact] #overlay[data-screen="floor-clear"] #tag {
  grid-area: 1 / 2;
  align-self: center;
  justify-self: end;
}

[data-layout="landscape"][data-compact] [data-b5-part="transfer"] {
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
}

[data-layout="landscape"][data-compact] .b5-transfer-origin {
  border-inline-end: 0;
  border-block-end: 1px solid #648c9d;
}

[data-layout="landscape"][data-compact] [data-b5-part="boss-supply"] { margin: 0; }
[data-layout="landscape"][data-compact] #overlay[data-screen="floor-clear"] .actions { grid-column: 1 / -1; }

[data-layout="landscape"][data-compact] #overlay[data-screen="floor-clear"] { padding-block: 4px; }
[data-layout="landscape"][data-compact] :is(.b5-transfer-origin, .b5-transfer-destination) { padding-block: 5px; }

[data-layout="landscape"][data-compact] [data-b5-part="boss-supply"] > h3::before {
  width: 17px;
  height: 17px;
  flex-basis: 17px;
}

[data-layout="landscape"][data-compact] .b5-reading {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 5px;
  align-items: baseline;
  padding: 3px 4px;
}

[data-layout="landscape"][data-compact] .b5-reading dd { margin: 0; font-size: .85rem; }
[data-layout="landscape"][data-compact] #overlay :is(.b5-terms, .b5-advice) {
  margin-block-start: 3px;
  line-height: 1.2;
}
