.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 27px 21px;
  align-items: start;
}

.item-card {
  position: relative;
  display: block;
  min-width: 0;
  padding: 0;
  cursor: pointer;
  background: transparent;
  color: inherit;
  text-align: left;
}

.item-card.is-tutorial-target {
  box-shadow: inset 0 0 0 1px rgba(224, 203, 112, 0.8), 0 0 0 1px rgba(0, 0, 0, 0.28);
}

.tutorial-item-marker {
  position: absolute;
  z-index: 8;
  top: 7px;
  right: 7px;
  padding: 3px 5px 1px;
  background: rgba(28, 27, 21, 0.82);
  color: #e5d68e;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.09em;
}

.item-visual {
  position: relative;
  content-visibility: auto;
  contain-intrinsic-size: auto 110px;
  display: block;
  width: 100%;
  aspect-ratio: 1.41 / 1;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(218, 218, 214, 0.19), transparent 57%),
    linear-gradient(157deg, rgba(88, 87, 84, 0.9), rgba(154, 153, 149, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18),
    0 3px 8px rgba(0, 0, 0, 0.13);
  transition: filter 100ms ease, outline-color 100ms ease, background-color 100ms ease;
}

.item-visual::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  content: "";
  opacity: 0.17;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.045) 1px, transparent 1px);
  background-size: 14px 14px;
  mix-blend-mode: soft-light;
}

.item-image {
  position: absolute;
  z-index: 1;
  top: 0;
  left: -8%;
  width: 116%;
  height: 92%;
  object-fit: contain;
  filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.24));
  transform: translateY(0) scale(1);
  transition: transform 105ms ease, filter 105ms ease;
}

.item-card.kind-knife .item-image,
.item-card.kind-glove .item-image {
  top: 0;
  left: -5%;
  width: 110%;
  height: 93%;
}

.item-card.kind-agent .item-image,
.item-card.kind-container .item-image,
.item-card.kind-display .item-image,
.item-card.kind-graphic .item-image {
  top: 4%;
  left: 4%;
  width: 92%;
  height: 84%;
}

.item-card.kind-agent .item-image {
  top: 1%;
  height: 90%;
}

.image-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-content: center;
  color: rgba(255, 255, 255, 0.3);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.image-fallback[hidden] {
  display: none;
}

.favorite-indicator {
  position: absolute;
  z-index: 7;
  top: 7px;
  left: 7px;
  width: 17px;
  height: 17px;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(83%) sepia(83%) saturate(1041%) hue-rotate(351deg) brightness(101%) contrast(93%) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.74));
}

.storage-unit-count {
  position: absolute;
  z-index: 7;
  top: 7px;
  right: 7px;
  padding: 3px 6px 1px;
  background: rgba(20, 22, 21, 0.72);
  color: rgba(240, 241, 235, 0.78);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 11px;
}

.rarity-bar {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  height: 4px;
  background: var(--rarity, #b0c3d9);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.06);
}

.sticker-row {
  position: absolute;
  z-index: 4;
  bottom: 7px;
  left: 6px;
  display: flex;
  max-width: calc(100% - 12px);
  align-items: center;
  gap: 1px;
}

.sticker-icon {
  width: clamp(17px, 1.28vw, 22px);
  height: clamp(17px, 1.28vw, 22px);
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.66));
}

.charm-icon {
  position: absolute;
  right: 5px;
  bottom: 7px;
  z-index: 4;
  width: clamp(21px, 1.5vw, 27px);
  height: clamp(21px, 1.5vw, 27px);
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.55));
}

.special-flags {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
}

.trade-lock-indicator {
  position: relative;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(102, 174, 205, 0.82);
  border-radius: 50%;
  background: rgba(37, 52, 58, 0.54);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.trade-lock-indicator::before {
  position: absolute;
  top: 3px;
  left: 6px;
  width: 1px;
  height: 5px;
  content: "";
  background: rgba(212, 237, 246, 0.9);
}

.trade-lock-indicator::after {
  position: absolute;
  top: 7px;
  left: 6px;
  width: 4px;
  height: 1px;
  content: "";
  background: rgba(212, 237, 246, 0.9);
  transform: rotate(22deg);
  transform-origin: left center;
}

.trade-lock-tooltip {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: -6px;
  width: max-content;
  max-width: 240px;
  padding: 7px 9px 6px;
  transform: translateY(-3px);
  border-left: 2px solid rgba(102, 174, 205, 0.9);
  background: rgba(18, 21, 21, 0.97);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.42);
  color: rgba(235, 244, 247, 0.9);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 11px;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transition: opacity 80ms ease, transform 80ms ease;
  white-space: nowrap;
}

.trade-lock-indicator:hover .trade-lock-tooltip,
.trade-lock-indicator:focus-visible .trade-lock-tooltip {
  transform: translateY(0);
  opacity: 1;
}

.item-labels {
  display: block;
  min-height: 35px;
  padding-top: 5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.72);
}

.item-primary,
.item-secondary {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-primary {
  color: rgba(255, 255, 255, 0.95);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 15px;
}

.item-secondary {
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.015em;
  line-height: 14px;
}

.item-card:hover .item-visual {
  filter: brightness(1.08) contrast(1.015);
}

.item-card:hover .item-image {
  filter: drop-shadow(0 7px 5px rgba(0, 0, 0, 0.28));
  transform: translateY(-2px) scale(1.018);
}



.context-menu {
  position: fixed;
  z-index: 90;
  width: 218px;
  padding: 5px 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(27, 28, 27, 0.97);
  box-shadow: 0 13px 32px rgba(0, 0, 0, 0.48);
}

.context-menu-header {
  overflow: hidden;
  padding: 8px 12px 7px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.46);
  font-size: 10px;
  letter-spacing: 0.065em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-action {
  width: 100%;
  min-height: 34px;
  padding: 2px 13px 0;
  cursor: pointer;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-align: left;
}

.context-action:hover,
.context-action:focus-visible {
  outline: 0;
  color: #d7edf6;
  background: rgba(63, 128, 155, 0.58);
}

.context-separator {
  height: 1px;
  margin: 4px 0;
  background: rgba(255, 255, 255, 0.08);
}

@media (min-width: 2300px) {
  .inventory-grid { grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); }
}

@media (max-width: 1500px) {
  .inventory-grid { gap: 25px 18px; }
  .item-primary { font-size: 11.5px; }
  .item-secondary { font-size: 10.5px; }
}

/* CS2-style inventory hover information card. */
.inventory-hover-tooltip {
  position: absolute;
  z-index: 120;
  top: -8px;
  left: calc(100% + 12px);
  width: 356px;
  max-height: min(590px, calc(100vh - 24px));
  overflow: auto;
  padding: 12px 14px 13px;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  background: rgba(9, 10, 12, 0.985);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.025);
  color: rgba(238, 238, 236, 0.94);
  font-family: Arial, sans-serif;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-4px);
  transition: opacity 80ms ease, transform 80ms ease, visibility 80ms linear;
  scrollbar-width: none;
}

.inventory-hover-tooltip::-webkit-scrollbar { display: none; }

.item-card.tooltip-left .inventory-hover-tooltip {
  right: calc(100% + 12px);
  left: auto;
  transform: translateX(4px);
}

.item-card:hover .inventory-hover-tooltip,
.item-card:focus-visible .inventory-hover-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.inventory-hover-tooltip[aria-hidden="true"] {
  opacity: 0 !important;
  visibility: hidden !important;
}

.inventory-hover-header,
.inventory-hover-identity,
.inventory-hover-meta,
.inventory-hover-collection-list {
  display: flex;
}

.inventory-hover-header {
  min-height: 50px;
  align-items: center;
  gap: 10px;
}

.inventory-hover-collection-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.55));
}

.inventory-hover-identity {
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.inventory-hover-name {
  overflow: hidden;
  color: rgba(249, 249, 247, 0.97);
  font-size: 14px;
  font-weight: 700;
  line-height: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-hover-collection-name {
  overflow: hidden;
  color: rgba(229, 229, 225, 0.74);
  font-size: 11px;
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-hover-rule {
  display: block;
  height: 1px;
  margin: 9px 0;
  background: rgba(255, 255, 255, 0.105);
}

.inventory-hover-meta {
  flex-direction: column;
  gap: 3px;
}

.inventory-hover-meta-row {
  display: flex;
  min-height: 16px;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
  line-height: 15px;
}

.inventory-hover-meta-label {
  flex: 0 0 58px;
  color: rgba(224, 224, 220, 0.56);
}

.inventory-hover-meta-value {
  min-width: 0;
  color: rgba(236, 236, 233, 0.9);
}

.inventory-hover-meta-value.is-rarity {
  color: var(--tooltip-rarity, #b0c3d9);
}

.inventory-hover-description,
.inventory-hover-flavour {
  display: block;
  color: rgba(235, 235, 232, 0.86);
  font-size: 11px;
  line-height: 15px;
}

.inventory-hover-description { margin-top: 1px; }

.inventory-hover-flavour {
  margin-top: 8px;
  color: rgba(225, 225, 220, 0.72);
  font-style: italic;
}

.inventory-hover-collection-title {
  display: block;
  margin: 0 0 5px;
  color: rgba(235, 235, 232, 0.9);
  font-size: 11px;
  font-weight: 400;
}

.inventory-hover-collection-list {
  flex-direction: column;
  gap: 0;
}

.inventory-hover-collection-item {
  display: flex;
  min-height: 15px;
  align-items: baseline;
  color: var(--collection-item-rarity, #b0c3d9);
  font-size: 11px;
  line-height: 14px;
}

.inventory-hover-collection-item.is-current {
  font-weight: 700;
}

.inventory-hover-owned {
  width: 14px;
  flex: 0 0 14px;
  color: rgba(239, 239, 235, 0.92);
  font-size: 11px;
  font-weight: 700;
}

.inventory-hover-collection-item:not(.is-owned) .inventory-hover-owned {
  opacity: 0;
}

.inventory-hover-collection-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .inventory-hover-tooltip { display: none; }
}
}
