.inventory-main {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: var(--space-16);
}

/* 인벤토리 전체 카드는 흰색 표면으로 유지 */
.inventory-card {
  max-width: var(--container-max);
  padding: var(--space-16);
  border: 0;
  border-radius: 0;
  background: var(--color-surface);
  box-shadow: none;
}

/* profile-main.css의 .profile-card::before 배경이 inventory-card에 깔리는 문제 차단 */
.inventory-card::before {
  display: none;
}

.inventory-intro {
  margin-bottom: var(--space-8);
}

.inventory-title {
  text-align: center;
  padding-bottom: 0;
}

.inventory-desc {
  text-align: center;
  margin-top: var(--space-12);
}

.inventory-card .profile-section + .profile-section {
  margin-top: var(--space-12);
  padding-top: 0;
  border-top: 0;
}

/* =========================
  INVENTORY PROFILE PREVIEW
  - 배경 이미지는 여기 안에만 들어감
========================= */
.inventory-profile-preview {
  position: relative;
  isolation: isolate;
  overflow: visible;
  width: 100%;
  max-width: 760px;
  min-height: 520px;
  margin: 0 auto var(--space-16);
  padding: var(--space-24);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.inventory-profile-preview::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: var(--profile-bg-desktop, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
}

.inventory-profile-preview.has-profile-background::before {
  opacity: 1;
}

/* =========================
  INVENTORY PROFILE FRAME
  - 장착한 경우에만 미리보기 표시
========================= */

.inventory-profile-preview.has-profile-frame {
  --inventory-frame-top: -6%;
  --inventory-frame-right: -8.3%;
  --inventory-frame-bottom: -5%;
  --inventory-frame-left: -8.3%;
}

.inventory-profile-preview.has-profile-frame::after {
  content: '';
  position: absolute;
  top: var(--inventory-frame-top);
  right: var(--inventory-frame-right);
  bottom: var(--inventory-frame-bottom);
  left: var(--inventory-frame-left);
  z-index: 3;
  background-image: var(--profile-frame-desktop);
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: inherit;
  pointer-events: none;
}

.inventory-profile-preview.has-profile-frame--mallin-shiny::after {
  top: -50px;
  right: -50px;
  bottom: -50px;
  left: -50px;
  background-image: none;
  border: 50px solid transparent;
  border-image-source: var(--profile-frame-desktop);
  border-image-slice: 110 103 109 103;
  border-image-width: 50px;
  border-image-repeat: stretch;
}

@media (max-width: 700px) {
  .inventory-profile-preview.has-profile-frame {
    --inventory-frame-top: -8%;
    --inventory-frame-right: -22.8%;
    --inventory-frame-bottom: -6.8%;
    --inventory-frame-left: -22.8%;
  }

  .inventory-profile-preview.has-profile-frame::after {
    background-image: var(--profile-frame-mobile, var(--profile-frame-desktop));
  }

  .inventory-profile-preview.has-profile-frame--mallin-shiny::after {
    top: -42px;
    right: -42px;
    bottom: -42px;
    left: -42px;
    background-image: none;
    border-width: 42px;
    border-image-source: var(
      --profile-frame-mobile,
      var(--profile-frame-desktop)
    );
    border-image-slice: 111 119 104 117;
    border-image-width: 42px;
  }
}

@media (max-width: 700px) {
  .profile-card::before {
    background-image: var(--profile-bg-mobile, var(--profile-bg-desktop, none));
  }
}

.inventory-profile-preview__content {
  position: relative;
  z-index: 1;
  min-height: 472px;
}

/* profile-main.css의 .profile-character-preview 중앙정렬을 인벤토리 미리보기 안에서만 무력화 */
.inventory-profile-preview .inventory-character-preview {
  position: absolute;
  left: 50%;
  bottom: 20px;
  width: auto;
  margin: 0;
  display: inline-flex;
  transform: translateX(-50%);
}

.inventory-profile-preview .inventory-preview-actions {
  position: absolute;
  left: 50%;
  bottom: -15px;
  width: auto;
  margin: 0;
  transform: translateX(-50%);
}

.inventory-profile-preview .profile-character-image {
  width: 180px;
}

.inventory-profile-preview .profile-inventory-link {
  white-space: nowrap;
}

.inventory-msg {
  min-height: 1.5em;
  margin-top: var(--space-12);
  margin-bottom: 0;
}

/* =========================
  INVENTORY LIST AREA
  - 캐릭터/스킨/효과/BGM 영역은 흰색 카드로 분리
========================= */
.inventory-main .profile-character-inventory {
  width: 100%;
  padding: 0;
  border-radius: var(--radius-card);
  background: var(--color-surface);
}

.inventory-main .profile-character-inventory .profile-character-preview {
  margin-bottom: var(--space-12);
}

@media (max-width: 700px) {
  .inventory-main {
    padding: var(--space-8)
      max(var(--space-8), env(safe-area-inset-right))
      max(var(--space-8), env(safe-area-inset-bottom))
      max(var(--space-8), env(safe-area-inset-left));
  }

  .inventory-card {
    margin: 0;
    padding: var(--space-8);
  }

  .inventory-main .profile-character-inventory {
    gap: var(--space-8);
  }

  .profile-character-grid {
    gap: var(--space-6);
  }

  .profile-character-card {
    min-width: 0;
    gap: var(--space-4);
    padding: var(--space-6);
  }

  .profile-character-card__name,
  .profile-character-card__meta {
    width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .profile-character-card__name {
    font-size: 11px;
    line-height: 1.25;
  }

  .profile-character-card__meta {
    font-size: 10px;
    line-height: 1.25;
  }

  .profile-bgm-card__thumb {
    width: 64px;
    height: 64px;
  }

  .profile-bgm-card__thumb-image {
    width: 32px;
    height: 32px;
  }

  .inventory-profile-preview {
    max-width: 100%;
    min-height: 560px;
    padding: 20px;
  }

  .inventory-profile-preview::before {
    background-image: var(--profile-bg-mobile, var(--profile-bg-desktop, none));
    background-position: center;
  }

  .inventory-profile-preview__content {
    min-height: 520px;
  }

  .inventory-profile-preview .inventory-character-preview {
    bottom: 40px;
  }

  .inventory-profile-preview .profile-character-image {
    width: 120px;
  }

  .inventory-profile-preview .inventory-preview-actions {
    bottom: -10px;
  }
}

/* =========================
  EFFECT INVENTORY
========================= */
.profile-character-grid--effects {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

.profile-character-effect-card__thumb {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 96px;
}

@media (max-width: 700px) {
  .profile-character-grid--effects {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profile-character-effect-card__thumb {
    min-height: 56px;
  }

}

/* =========================
  INVENTORY ANCHOR / BGM SCROLL
========================= */
#bgm-inventory {
  scroll-margin-top: 140px;
}

#emoticon-inventory {
  scroll-margin-top: 140px;
}

@media (max-width: 700px) {
  #bgm-inventory,
  #emoticon-inventory {
    scroll-margin-top: 120px;
  }
}

.inventory-anchor {
  display: block;
  position: relative;
  top: -84px;
  width: 1px;
  height: 1px;
  pointer-events: none;
  visibility: hidden;
}

.inventory-item-hidden {
  display: none !important;
}

/* =========================
  FEATURED BGM CONTROLS
========================= */
.profile-bgm-card__selection {
  display: flex;
  width: 100%;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.profile-bgm-card__selection:focus-visible,
.profile-bgm-card__featured-action:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}

.profile-bgm-card__featured-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: var(--space-6) var(--space-12);
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: var(--color-text);
  font-size: 12px;
  font-weight: 800;
}

.profile-bgm-card__featured-action {
  width: 100%;
  min-height: 40px;
  padding: var(--space-8) var(--space-12);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-pill);
  background: rgba(170, 208, 94, 0.14);
  color: var(--color-text);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.profile-bgm-card.is-featured {
  box-shadow: 0 0 0 3px rgba(170, 208, 94, 0.24);
}

.profile-bgm-card.is-featured .profile-bgm-card__featured-action {
  background: var(--color-primary);
}

.profile-bgm-card__featured-action:disabled {
  cursor: wait;
  opacity: 0.62;
}

@media (max-width: 700px) {
  .profile-bgm-card__selection {
    gap: var(--space-4);
  }

  .profile-bgm-card__featured-badge {
    min-height: 22px;
    padding: var(--space-4) var(--space-6);
    font-size: 9px;
    line-height: 1.2;
  }

  .profile-bgm-card__featured-action {
    min-height: 32px;
    padding: var(--space-4) var(--space-6);
    font-size: 10px;
    line-height: 1.2;
  }
}

/* =========================
  MORE BUTTON
========================= */
.inventory-more-area {
  display: flex;
  justify-content: center;
  margin-top: var(--space-16);
}

.inventory-more-btn {
  appearance: none;
  min-height: 44px;
  padding: 10px 18px;
  border: 2px solid var(--color-primary);
  border-radius: 999px;
  background: rgba(170, 208, 94, 0.14);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-small);
  font-weight: 800;
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.15s ease,
    opacity 0.15s ease;
}

.inventory-more-btn:hover {
  background: rgba(170, 208, 94, 0.24);
  transform: translateY(-1px);
}

.inventory-more-btn:active {
  transform: translateY(0);
}

@media (max-width: 700px) {
  .inventory-anchor {
    top: -72px;
  }

  .inventory-more-area {
    margin-top: var(--space-12);
  }

  .inventory-more-btn {
    width: 100%;
    min-height: 48px;
  }
}

/* =========================
  PROFILE BACKGROUND INVENTORY
========================= */
.profile-character-grid--profile-background {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.profile-background-card__thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
  background: #f5f5f5;
}

.profile-background-card__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 700px) {
  .profile-character-grid--profile-background {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* =========================
  PROFILE FRAME INVENTORY
  - 프로필배경 카드 크기와 동일하게 정리
========================= */
.profile-character-grid--profile-frame {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.profile-character-grid--profile-frame .profile-character-card {
  min-height: auto;
}

.profile-character-grid--profile-frame .profile-background-card__thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
  background: #f5f5f5;
}

.profile-character-grid--profile-frame .profile-background-card__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: var(--space-8);
}

@media (max-width: 700px) {
  .profile-character-grid--profile-frame {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profile-character-grid--profile-frame .profile-background-card__image {
    padding: var(--space-4);
  }
}

/* =========================
  EMOTICON INVENTORY
========================= */
.profile-character-grid--emoticons {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.profile-emoticon-card__thumb {
  width: 72px;
  height: 72px;
}

@media (max-width: 700px) {
  .profile-character-grid--emoticons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profile-emoticon-card__thumb {
    width: 52px;
    height: 52px;
  }
}
