/* Loja e inventário */

:root {
  --badge-ink: #d0d0d0;
  --shop-emblem-base:
    linear-gradient(#efefea, #efefea) 50% 94% / 64% 11% no-repeat,
    linear-gradient(90deg, #a44208 24%, #3b2520 24% 76%, #a44208 76%) 50% 93% / 73% 58% no-repeat;
  --shop-emblem-awning: repeating-linear-gradient(90deg, var(--accent-border) 0 20%, #fff0cc 20% 39%);
  --shop-radar-ink: #ffbe66;
  --shop-wave-ink: #c6c6ca;
  --shop-card-fill: radial-gradient(ellipse at 50% 24%, #2a2a2e, #161619 52%, #161619);
  --shop-locked-edge: linear-gradient(160deg, #ffda89, #b47a3f 53%, #ffc363);
  --shop-favorite-edge: linear-gradient(148deg, #fff1c3, #ffae3b 27%, #b36223 66%, #ffc46d);
  --shop-favorite-glow: #ff9e395c;
  --shop-favorite-badge-line: #b77b38;
  --shop-favorite-badge-fill: #39271c;
  --shop-favorite-badge-ink: #ffdb9a;
  --shop-card-empty-edge: #454547;
  --shop-card-empty-fill: #1a1a1d;
  --shop-card-divider: #4b4b50;
  --shop-card-name: #f5f4f2;
  --shop-card-kind: #b9b9be;
  --shop-card-kind-divider: #85858b;
  --shop-card-tier-default: #d1cbd0;
  --shop-card-tag: #ffad3b;
  --shop-card-flavor: #b3b3b8;
  --shop-lock-ink: #e7e7eb;
  --shop-attrs-edge: linear-gradient(145deg, #d8d8dd, #66666b 28%, #545458 63%, #aaaab0);
  --shop-attrs-fill: linear-gradient(150deg, #202024, #161619);
  --shop-attrs-divider: #515155;
  --shop-attrs-heading: #b9b9bf;
  --shop-attrs-stat-divider: #414147;
  --shop-attrs-stat-hover: #3a3a40;
  --shop-attrs-help-ink: #d7d7db;
  --shop-tooltip-line: #bbb9be;
  --shop-tooltip-fill: #141418;
  --shop-tooltip-ink: #efeff4;
  --shop-footer-divider: #505054;
  --inventory-heading: #d6d6da;
  --inventory-slot-edge: #515159;
  --inventory-slot-fill: linear-gradient(145deg, #2a2a2e, #18181b);
  --inventory-popover-edge: linear-gradient(145deg, var(--accent-highlight), var(--accent-border) 35%, #8a4a14 78%, var(--accent-bright));
  --inventory-popover-fill: linear-gradient(165deg, #1c1c20f2, #101014f5 55%, #0c0c10f7);
  --inventory-popover-ink: #f2f2f5;
  --inventory-popover-divider: #3f3f46;
  --inventory-popover-art-line: #5a5a62;
  --inventory-popover-art-fill: radial-gradient(ellipse at 40% 35%, #3a3a42, #17171b 70%);
  --inventory-popover-heading: #fff;
  --inventory-popover-meta: #b8b8c0;
  --inventory-popover-label: #d4d4da;
  --inventory-popover-value: #f5f5f7;
  --inventory-cancel-ink: #c8c8ce;
  --shop-notice-ink: #ffc76d;
}

#screen-shop {
  --shop-gutter: clamp(8px, calc(var(--stage-w) * 0.013), 22px);
  --shop-gap: clamp(5px, calc(var(--stage-w) * 0.008), 13px);
  --shop-copy: clamp(10px, calc(var(--stage-w) * 0.012), 20px);
  --shop-slot: clamp(26px, calc(var(--stage-w) * 0.044), 67px);
}

.shop-panel {
  display: grid;
  grid-template:
    "header attrs" auto
    "offers attrs" minmax(min-content, 1fr)
    "footer footer" auto
    / minmax(0, 1fr) clamp(126px, 18.5%, 295px);
  gap: var(--shop-gap);
  height: 100%;
  min-height: 0;
  padding: var(--shop-gutter);
  overflow-y: auto;
}

.shop-header {
  grid-area: header;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--shop-gap);
  min-width: 0;
  padding-block: 3px;
}

.shop-title-block {
  min-width: 0;
  text-align: center;
}

.shop-title-block h2 {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35em;
  margin: 0;
  color: var(--ink-heading);
  font-size: clamp(20px, calc(var(--stage-w) * 0.037), 61px);
  letter-spacing: -0.05em;
  line-height: 1.15;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 #0a0a0d;
}

.shop-emblem {
  position: relative;
  width: 1.14em;
  height: 0.92em;
  flex: 0 0 auto;
  background: var(--shop-emblem-base);
  filter: drop-shadow(0 3px 0 #0c0c0f);
}

.shop-emblem::before {
  content: "";
  position: absolute;
  inset: 0 0 47%;
  background: var(--shop-emblem-awning);
  clip-path: polygon(14% 0, 86% 0, 100% 81%, 88% 100%, 12% 100%, 0 81%);
}

.shop-tagline,
.shop-radar {
  margin-top: 0.3em;
  color: var(--ink-secondary);
  font-size: var(--shop-copy);
  font-weight: 600;
  line-height: 1.25;
}

.shop-radar {
  color: var(--shop-radar-ink);
}

.shop-wave,
.shop-money,
.shop-reroll,
.shop-buy,
.shop-lock,
.shop-inv-btn,
.shop-go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 2em;
  padding: 0.28em 0.72em;
  border: 0;
  color: var(--ink);
  font: inherit;
  font-size: var(--shop-copy);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.shop-wave {
  color: var(--shop-wave-ink);
}

.shop-wave strong {
  color: var(--ink);
}

.shop-wallet {
  display: flex;
  gap: var(--shop-gap);
}

.shop-money {
  font-variant-numeric: tabular-nums;
}

.shop-wallet .asset-img,
.shop-buy .asset-img {
  width: 1.15em;
  height: 1.15em;
}

.shop-reroll,
.shop-buy,
.shop-lock,
.shop-inv-btn,
.shop-go {
  cursor: pointer;
}

.shop-panel button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.shop-offers {
  grid-area: offers;
  min-width: 0;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(min-content, 1fr);
  min-height: 100%;
  gap: var(--shop-gap);
}

.shop-card {
  --bevel-cut: clamp(7px, calc(var(--stage-w) * 0.013), 22px);
  --bevel-stroke: clamp(2px, calc(var(--stage-w) * 0.0027), 5px);
  --bevel-edge: var(--tier-shop-edge);
  --bevel-fill: var(--shop-card-fill);
  --catalog-stat-size: var(--shop-copy);
  display: flex;
  flex-direction: column;
  gap: clamp(4px, calc(var(--stage-h) * 0.008), 8px);
  min-width: 0;
  padding: clamp(8px, calc(var(--stage-h) * 0.019), 18px) clamp(8px, calc(var(--stage-w) * 0.015), 25px);
}

.shop-card:has([aria-pressed="true"]) {
  --bevel-edge: var(--shop-locked-edge);
}

.shop-card.is-build-favorite {
  --bevel-edge: var(--shop-favorite-edge);
}

.shop-card.is-build-favorite::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: var(--bevel-stroke);
  clip-path: inherit;
  box-shadow: inset 0 0 17px var(--shop-favorite-glow);
  pointer-events: none;
  animation: shop-build-glow 3s ease-in-out infinite alternate;
}

.shop-build-badge {
  position: absolute;
  z-index: 1;
  top: max(5px, var(--bevel-stroke));
  right: calc(var(--bevel-cut) + 2px);
  padding: 0.18em 0.48em;
  border: 1px solid var(--shop-favorite-badge-line);
  border-radius: 3px;
  background: var(--shop-favorite-badge-fill);
  color: var(--shop-favorite-badge-ink);
  font-size: clamp(9px, calc(var(--stage-w) * 0.009), 15px);
  font-weight: 700;
  line-height: 1.2;
  text-align: right;
  text-transform: uppercase;
  pointer-events: none;
}

@keyframes shop-build-glow {
  from { opacity: 0.36; }
  to { opacity: 0.86; }
}

@media (prefers-reduced-motion: reduce) {
  .shop-card.is-build-favorite::after {
    animation: none;
    opacity: 0.58;
  }
}

.shop-card-empty {
  --bevel-edge: var(--shop-card-empty-edge);
  --bevel-fill: var(--shop-card-empty-fill);
  display: grid;
  place-items: center;
  min-height: 100px;
  color: var(--muted);
  font-size: var(--shop-copy);
}

.shop-card-head {
  display: grid;
  justify-items: center;
  gap: clamp(4px, calc(var(--stage-h) * 0.009), 8px);
  text-align: center;
}

.card-art {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: min(73%, clamp(38px, calc(var(--stage-h) * 0.126), 116px));
  aspect-ratio: 1;
  color: var(--ink);
}

.card-art::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -8%;
  background: repeating-conic-gradient(from 7deg, #9696a078 0deg 3deg, transparent 4deg 27deg, #9696a078 28deg 30deg);
  mask-image: radial-gradient(ellipse, transparent 28%, #000 46%, transparent 71%);
}

.card-art .asset-img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  filter: drop-shadow(0 2px 0 var(--ink-shadow)) drop-shadow(0 0 2px #a1a1a2);
}

.card-art .emoji {
  font-size: clamp(24px, calc(var(--stage-w) * 0.043), 62px);
}

.shop-card-title {
  width: 100%;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--shop-card-divider);
}

.shop-card-title .name {
  margin: 0 0 0.15em;
  color: var(--shop-card-name);
  font-size: clamp(12px, calc(var(--stage-w) * 0.016), 27px);
  line-height: 1.12;
  overflow-wrap: anywhere;
  text-wrap: balance;
  text-shadow: 1px 2px 0 #101013;
}

.card-kind {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.15em 0.45em;
  color: var(--shop-card-kind);
  font-size: clamp(8px, calc(var(--stage-w) * 0.0095), 16px);
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.card-kind > * + *::before {
  content: "·";
  margin-right: 0.45em;
  color: var(--shop-card-kind-divider);
}

.card-kind strong {
  color: var(--tier-color, var(--shop-card-tier-default));
}

.weapon-type {
  align-self: flex-start;
  width: fit-content;
  padding: 2px 5px;
  border: 1px solid var(--line-strong);
  background: var(--badge-fill);
  color: var(--badge-ink);
}

.card-tag {
  color: var(--shop-card-tag);
}

.card-flavor {
  margin: 0;
  color: var(--shop-card-flavor);
  font-size: calc(var(--shop-copy) * 0.85);
  line-height: 1.25;
}

.shop-stats strong {
  color: var(--effect-positive);
}

.shop-stats .stat-neg {
  color: var(--effect-negative);
}

.shop-card-actions {
  display: grid;
  gap: max(4px, calc(var(--shop-gap) * 0.62));
  margin-top: auto;
}

.shop-buy {
  min-height: 2em;
  font-size: clamp(13px, calc(var(--stage-w) * 0.019), 31px);
  color: var(--ink);
}

.shop-buy strong {
  display: flex;
  align-items: center;
  gap: 0.26em;
  font-variant-numeric: tabular-nums;
}

.shop-lock {
  color: var(--shop-lock-ink);
}

.shop-reroll,
.shop-lock {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}

.shop-panel kbd.hotkey {
  min-width: 0;
  margin: 0;
  padding: 0.05em 0.35em;
  border-radius: 3px;
  font-size: 0.78em;
  font-weight: 700;
  line-height: 1.2;
  opacity: 0.85;
}

.shop-lock-icon {
  position: relative;
  width: 0.77em;
  height: 0.58em;
  margin-top: 0.29em;
  border: 1px solid currentColor;
  border-radius: 1px;
}

.shop-lock-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 0.47em;
  height: 0.37em;
  transform: translateX(-50%);
  border: 1px solid currentColor;
  border-bottom: 0;
  border-radius: 0.25em 0.25em 0 0;
}


.shop-attrs {
  --bevel-cut: clamp(8px, calc(var(--stage-w) * 0.012), 19px);
  --bevel-stroke: clamp(2px, calc(var(--stage-w) * 0.0023), 4px);
  --bevel-edge: var(--shop-attrs-edge);
  --bevel-fill: var(--shop-attrs-fill);
  grid-area: attrs;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.4em;
  min-width: 0;
  min-height: 0;
  padding: clamp(6px, calc(var(--stage-w) * 0.01), 16px);
  font-size: clamp(9px, calc(var(--stage-w) * 0.0108), 18px);
}

.shop-attrs-head {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--shop-attrs-divider);
}

.inv-portrait {
  flex: 0 0 auto;
  width: clamp(27px, calc(var(--stage-w) * 0.044), 74px);
  aspect-ratio: 1;
}

.inv-portrait .asset-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 1px #0c0c0d);
}

.shop-attrs-head h3 {
  color: var(--shop-attrs-heading);
  font-size: 0.85em;
  font-weight: 700;
  text-transform: uppercase;
}

.inv-char-name {
  color: var(--ink-bright);
  font-size: 1.15em;
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.shop-stats {
  display: grid;
  grid-auto-rows: minmax(1.37em, 1fr);
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.stat-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
  gap: 0.24em;
  border-bottom: 1px solid var(--shop-attrs-stat-divider);
  color: var(--catalog-stat-ink);
  font-weight: 600;
  line-height: 1.15;
}

.stat-pill-main {
  display: flex;
  align-items: center;
  gap: 0.31em;
  min-width: 0;
}

.shop-stats strong {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.shop-stats .stat-pill {
  cursor: help;
}

.shop-stats .stat-pill:hover {
  background: var(--shop-attrs-stat-hover);
}

.shop-stats .stat-help {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.3em;
  height: 1.32em;
  border-radius: 2px;
  color: var(--shop-attrs-help-ink);
  font-weight: 700;
  line-height: 1;
  filter: grayscale(1);
  pointer-events: none;
}

.shop-stat-tip {
  position: absolute;
  inset: auto 0.6em 0.6em;
  z-index: 3;
  padding: 0.65em;
  border: 1px solid var(--shop-tooltip-line);
  background: var(--shop-tooltip-fill);
  color: var(--shop-tooltip-ink);
  font-size: max(11px, 0.9em);
  line-height: 1.3;
  pointer-events: none;
}

.shop-footer {
  grid-area: footer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(135px, 28%);
  align-items: center;
  gap: var(--shop-gutter);
  min-width: 0;
  padding-top: var(--shop-gap);
  border-top: 2px solid var(--shop-footer-divider);
}

.shop-bag {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr);
  align-items: start;
  gap: 0 var(--shop-gutter);
  min-width: 0;
}

.inv-block + .inv-block {
  border-left: 1px solid var(--shop-footer-divider);
  padding-left: var(--shop-gutter);
}

.inv-section-title {
  margin-bottom: 0.3em;
  color: var(--inventory-heading);
  font-size: calc(var(--shop-copy) * 0.92);
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.inv-weapons,
.inv-items {
  display: flex;
  gap: max(3px, calc(var(--shop-gap) * 0.65));
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.inv-items {
  padding-top: 3px;
  padding-right: 3px;
}

.inv-slot-wrap {
  position: relative;
  flex: 0 0 var(--shop-slot);
  width: var(--shop-slot);
  height: var(--shop-slot);
}

.inv-slot-wrap .inv-slot {
  flex: none;
  width: 100%;
  height: 100%;
}

.inv-slot {
  --slot-size: var(--shop-slot);
  --slot-padding: 0;
  --bevel-cut: clamp(4px, calc(var(--stage-w) * 0.007), 11px);
  --bevel-edge: var(--tier-color, var(--inventory-slot-edge));
  --bevel-fill: var(--inventory-slot-fill);
  --control-focus-shadow: var(--accent-picked-glow);
  position: relative;
  flex: 0 0 var(--shop-slot);
  border: 0;
  color: inherit;
}

.inv-stack-count {
  position: absolute;
  top: -2px;
  right: -2px;
  z-index: 3;
  padding: 0;
  color: #f5ebda;
  font-size: calc(var(--shop-slot) * 0.26);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  text-shadow:
    0 1px 0 #141418,
    1px 0 0 #141418,
    -1px 0 0 #141418,
    0 -1px 0 #141418;
  pointer-events: none;
}

.inv-slot .asset-img {
  width: 78%;
  height: 78%;
  object-fit: contain;
}

.inv-slot.empty {
  opacity: 0.65;
}

.inv-slot.filled {
  cursor: pointer;
}

.inv-slot[aria-pressed="true"] {
  box-shadow: var(--accent-picked-glow);
}

.inv-emoji {
  font-size: calc(var(--shop-slot) * 0.55);
  line-height: 1;
}

.shop-inv-popover {
  --bevel-cut: clamp(8px, calc(var(--stage-w) * 0.011), 16px);
  --bevel-stroke: 3px;
  --bevel-edge: var(--inventory-popover-edge);
  --bevel-fill: var(--inventory-popover-fill);
  position: fixed;
  z-index: 40;
  display: grid;
  gap: 0.55em;
  width: min(280px, calc(var(--stage-w) * 0.34));
  padding: 0.8em 0.85em 0.75em;
  color: var(--inventory-popover-ink);
  font-size: clamp(12px, calc(var(--stage-w) * 0.014), 15px);
  line-height: 1.3;
  pointer-events: auto;
  box-shadow: 0 12px 28px #000000aa, 0 0 0 1px #00000055;
}

.shop-inv-popover[hidden] {
  display: none;
}

.shop-inv-popover-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.55em;
  align-items: center;
  padding-bottom: 0.45em;
  border-bottom: 1px solid var(--inventory-popover-divider);
}

.shop-inv-popover-art {
  display: grid;
  place-items: center;
  width: clamp(42px, calc(var(--stage-w) * 0.055), 56px);
  aspect-ratio: 1;
  border: 1px solid var(--inventory-popover-art-line);
  background: var(--inventory-popover-art-fill);
}

.shop-inv-popover-art .asset-img,
.shop-inv-popover-art .inv-emoji {
  width: 78%;
  height: 78%;
  object-fit: contain;
  font-size: 1.45em;
  line-height: 1;
}

.shop-inv-popover-titles {
  min-width: 0;
}

.shop-inv-popover-titles strong {
  display: block;
  color: var(--inventory-popover-heading);
  font-size: 1.18em;
  font-weight: 800;
  line-height: 1.15;
  text-wrap: balance;
}

.shop-inv-popover-meta {
  margin: 0.2em 0 0;
  color: var(--inventory-popover-meta);
  font-size: 0.86em;
  font-weight: 600;
}

.shop-inv-popover-stats {
  display: grid;
  gap: 0.28em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shop-inv-popover-stats li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75em;
  font-weight: 700;
}

.shop-inv-popover-stats span {
  color: var(--inventory-popover-label);
}

.shop-inv-popover-stats strong {
  color: var(--inventory-popover-value);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.shop-inv-popover-actions {
  display: grid;
  gap: 0.38em;
  margin-top: 0.2em;
  padding-top: 0.45em;
  border-top: 1px solid var(--inventory-popover-divider);
}

.shop-inv-popover-actions .shop-inv-btn {
  width: 100%;
  min-height: 2.15em;
  padding-inline: 0.7em;
  font-size: 0.95em;
  font-weight: 700;
}

.shop-inv-popover-actions .shop-inv-btn[hidden] {
  display: none;
}

.shop-inv-cancel {
  color: var(--inventory-cancel-ink);
}

.shop-notice {
  grid-column: 1 / -1;
  color: var(--shop-notice-ink);
  font-size: var(--shop-copy);
}

.shop-notice:empty {
  display: none;
}

.shop-go {
  --bevel-cut: clamp(8px, calc(var(--stage-w) * 0.012), 19px);
  min-height: clamp(35px, calc(var(--stage-h) * 0.082), 80px);
  color: var(--ink);
  font-size: clamp(13px, calc(var(--stage-w) * 0.022), 37px);
  white-space: normal;
  text-align: center;
}

@media (max-height: 590px) {
  .card-flavor {
    display: none;
  }
}

@media (min-height: 620px) and (orientation: landscape) {
  .shop-header {
    min-height: calc(var(--stage-h) * 0.145);
  }

  .shop-footer {
    min-height: calc(var(--stage-h) * 0.155);
  }
}

@media (max-height: 390px) and (orientation: landscape) {
  .shop-tagline {
    display: none;
  }

  .shop-card {
    padding: 6px;
  }

  .shop-card-actions {
    gap: 3px;
  }
}

@media (max-width: 740px) and (orientation: portrait) {
  #screen-shop {
    --shop-copy: 12px;
    --shop-slot: clamp(26px, calc(var(--stage-w) * 0.078), 44px);
  }

  .shop-panel {
    grid-template: "header" max-content "offers" max-content "attrs" max-content "footer" max-content / minmax(0, 1fr);
    align-content: start;
    overflow-y: auto;
  }

  .shop-header {
    grid-template-columns: 1fr auto;
  }

  .shop-title-block {
    grid-row: 1;
    grid-column: 1 / -1;
  }

  .shop-wave {
    justify-self: start;
  }

  .shop-stats {
    overflow: visible;
  }

  .shop-grid {
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 1fr;
  }

  .shop-card-title .name {
    font-size: 14px;
  }

  .shop-card .card-art {
    width: 64px;
  }

  .shop-card {
    padding: 9px;
  }

  .shop-attrs {
    font-size: 12px;
  }

  .shop-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--shop-gap);
  }

  .shop-footer {
    grid-template-columns: minmax(0, 1fr);
  }

  .shop-go {
    min-height: 42px;
  }
}
