/* Маркет подарков, вариант B: без сайдбара — коллекции лентой, фильтры в строку, 5 карточек в ряд */
.marketplace.mpb {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: #8794a1;
}
.mpb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Шапка */
.mpb-head { display: flex; align-items: flex-end; gap: 24px; order: 1; }
.mpb-head > div { flex: 1; min-width: 0; }
.mpb-head h1 { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 700; color: #fff; }
.mpb-head p { margin: 6px 0 0; font-size: 13px; line-height: 1.5; }
.mpb-head a { color: #4db2ff; text-decoration: none; }
.mpb-head a:hover { color: #248bda; }
.mpb-sell {
  padding: 12px 20px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border-radius: 10px;
  color: #fff !important;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
.mpb-sell:hover { filter: brightness(1.08); }

/* Лента коллекций */
.mpb-rail { order: 2; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.mpb-rail::-webkit-scrollbar { display: none; }
.mpb-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 6px 14px 6px 6px;
  border: 0;
  border-radius: 12px;
  background: #212a33;
  color: #fff;
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.mpb-chip:hover { background: #293440; }
.mpb-chip img, .mpb-chip i { width: 32px; height: 32px; border-radius: 8px; background: #293440; object-fit: cover; flex-shrink: 0; display: block; }
.mpb-chip span { color: #6d8394; }
.mpb-chip.active { background: #4db2ff; font-weight: 600; }
.mpb-chip.active span { color: rgba(255, 255, 255, .8); font-weight: 400; }
.mpb-chip.active img, .mpb-chip.active i { background: rgba(255, 255, 255, .25); }
.mpb-chip-all { padding: 8px 14px; min-height: 44px; font-weight: 600; }
.mpb-chip-all span { font-weight: 400; color: #8794a1; }
.mpb-chip-all.active { background: #293440; }
.mpb-chip-all.active span { color: #8794a1; }

/* Строка фильтров: поиск стоит в ней первым (на телефоне — отдельной строкой над лентой) */
.mpb-search { order: 3; width: 260px; margin-bottom: -60px; position: relative; z-index: 1; }
.mpb-search input {
  width: 100%;
  height: 44px;
  box-sizing: border-box;
  padding: 0 12px;
  background: #212a33;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #fff;
  font: inherit;
  font-size: 14px;
  outline: none;
}
.mpb-search input::placeholder { color: #6d8394; }
.mpb-search input:focus { border-color: #4db2ff; }
.mpb-bar { order: 4; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; color: #fff; padding-left: 268px; min-height: 44px; }
.mpb-spacer { flex: 1; }
.mpb-count { color: #8794a1; white-space: nowrap; }
.mpb-sort {
  order: 99;
  height: 44px;
  padding: 0 34px 0 14px;
  background: #212a33 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 0;
  border-radius: 10px;
  color: #fff;
  font: inherit;
  font-size: 14px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.mpb-reset { height: 44px; padding: 0 12px; border: 0; background: none; color: #8794a1; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.mpb-reset:hover { color: #fff; }
.mpb-reset[hidden] { display: none; }

/* Выпадающие фильтры */
.mpb-dd { position: relative; }
.mpb-dd summary {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  box-sizing: border-box;
  padding: 0 14px;
  background: #212a33;
  border-radius: 10px;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  user-select: none;
}
.mpb-dd summary::-webkit-details-marker { display: none; }
.mpb-dd summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); opacity: .8; }
.mpb-dd summary:hover { background: #293440; }
.mpb-dd[open] summary { background: #293440; }
.mpb-dd.is-active summary { background: rgba(77, 178, 255, .12); color: #4db2ff; font-weight: 600; }
.mpb-dd.is-active summary::after { display: none; }
.mpb-dd-clear { border: 0; background: none; color: inherit; font: inherit; padding: 0 2px; margin-right: -4px; cursor: pointer; min-width: 24px; min-height: 24px; }
.mpb-dd-clear[hidden] { display: none; }
.mpb-dd-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 240px;
  max-height: 340px;
  overflow-y: auto;
  padding: 8px;
  background: #212a33;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
  font-weight: 400;
  color: #fff;
}
.mpb-dd-list > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 12px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.mpb-dd-list > div:hover { background: #293440; }
.mpb-dd-list > div.active { background: rgba(77, 178, 255, .12); color: #4db2ff; font-weight: 600; }
.mpb-dd-list > div span:last-child { color: #6d8394; font-weight: 400; }
.mpb-dd-hint { margin: 0; padding: 10px 12px; font-size: 13px; color: #6d8394; }
.mpb-dd-hint[hidden] { display: none; }
.mpb-dd-range { display: flex; align-items: center; gap: 8px; padding: 6px; font-size: 13px; color: #8794a1; white-space: nowrap; }
.mpb-dd-range label { display: flex; align-items: center; gap: 6px; }
.mpb-dd-range input { width: 88px; height: 40px; box-sizing: border-box; padding: 0 10px; background: #242e38; border: 1px solid transparent; border-radius: 8px; color: #fff; font: inherit; font-size: 14px; outline: none; }
.mpb-dd-range input:focus { border-color: #4db2ff; }
.mpb-chip:focus-visible, .mpb-dd summary:focus-visible, .mpb-card:focus-visible, .mpb-sort:focus-visible, .mpb-sell:focus-visible { outline: 2px solid #4db2ff; outline-offset: 2px; }

/* Сетка и карточки */
.mpb-grid { order: 5; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.mpb-grid > .mp-loading, .mpb-grid > .mp-empty, .mpb-grid > .mp-error { grid-column: 1 / -1; }
.mpb .mp-load-more { order: 6; }
.mpb-card { background: #212a33; border-radius: 14px; overflow: hidden; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.mpb-card.is-own { cursor: default; }
@media (hover: hover) {
  .mpb-card:not(.is-own):hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
}
.mpb-card-art { position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.mpb-card-art.gradient-default { background: linear-gradient(135deg, #3a4a5c, #232d38); }
/* Превью и анимация подарка идут со своим фоном и узором — занимают картинку целиком.
   Меньше размером только одиночная картинка без фона (старые подарки без превью). */
.mpb-card-art > img:not(.db-gift-poster) { width: 78%; height: 78%; object-fit: contain; }
.mpb-card-art > lottie-player { width: 100%; height: 100%; }
.mpb-card-rarity { position: absolute; top: 10px; left: 10px; padding: 4px 8px; background: rgba(0, 0, 0, .75); border-radius: 6px; font-size: 11px; font-weight: 600; color: #a78bfa; }
.mpb-card-price { position: absolute; bottom: 10px; right: 10px; padding: 6px 10px; background: rgba(0, 0, 0, .8); border-radius: 8px; font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; }
.mpb-card-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.mpb-card-title { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 600; color: #fff; }
.mpb-card-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mpb-card-title small { color: #6d8394; font-weight: 400; font-size: 14px; flex-shrink: 0; }
.mpb-card-sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Модалка покупки */
.mpb-modal { width: 420px; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); overflow-y: auto; background: #212a33; border-radius: 16px; color: #8794a1; }
.mpb-modal .mp-loading, .mpb-modal .mp-error { padding: 48px 24px; }
.mpb-modal-art { position: relative; height: 220px; background: radial-gradient(circle at 50% 45%, #3a4a5c, #232d38); display: flex; align-items: center; justify-content: center; }
/* У анимации свой квадратный фон: растворяем его края в фоне шапки, чтобы не было видно рамки */
.mpb-modal-art lottie-player, .mpb-modal-art img {
  width: 220px;
  height: 220px;
  object-fit: contain;
  -webkit-mask-image: radial-gradient(circle at center, #000 52%, transparent 70%);
  mask-image: radial-gradient(circle at center, #000 52%, transparent 70%);
}
.mpb-modal-close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .4); color: #fff; font-size: 16px; cursor: pointer; }
.mpb-modal-close:hover { background: rgba(0, 0, 0, .6); }
.mpb-modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.mpb-modal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.mpb-modal-head h2 { margin: 0; font-size: 20px; font-weight: 600; color: #fff; }
.mpb-modal-head h2 small { color: #6d8394; font-weight: 400; font-size: 15px; }
.mpb-modal-head > span { font-size: 13px; }
.mpb-modal-attrs { background: #242e38; border-radius: 10px; padding: 4px 14px; font-size: 13px; color: #fff; }
.mpb-modal-attrs > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; }
.mpb-modal-attrs > div + div { border-top: 1px solid rgba(255, 255, 255, .04); }
.mpb-modal-attrs > div > span:first-child { color: #6d8394; }
.mpb-modal-attrs em { font-style: normal; padding: 2px 6px; background: rgba(155, 124, 229, .15); border-radius: 4px; font-size: 10px; font-weight: 600; color: #9b7ce5; }
.mpb-modal-sum { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.mpb-modal-sum > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.mpb-modal-sum .price b { font-size: 28px; font-weight: 700; color: #5ebd72; }
.mpb-modal-sum .white { color: #fff; }
.mpb-modal-sum .missing { padding: 10px 14px; border-radius: 10px; background: rgba(255, 153, 83, .08); color: #ff9953; }
.mpb-modal-sum .missing b { font-weight: 700; }
.mpb-modal-actions { display: flex; gap: 12px; }
.mpb-modal-actions button { padding: 14px 20px; border: 0; border-radius: 10px; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.mpb-modal-actions .mp-btn-cancel { flex: 1; background: #242e38; color: #8794a1; }
.mpb-modal-actions .mp-btn-cancel:hover { background: #293440; }
.mpb-modal-actions .mp-btn-buy { flex: 2; background: #4db2ff; color: #fff; }
.mpb-modal-actions .mp-btn-buy:hover { background: #248bda; }
.mpb-modal-actions .mp-btn-buy:disabled { opacity: .6; cursor: default; }
.mpb-modal-topup { padding: 14px 20px; border-radius: 10px; font-size: 15px; font-weight: 600; text-align: center; background: #5ebd72; color: #fff !important; text-decoration: none; }
.mpb-modal-topup:hover { background: #4fae63; }
.mpb-modal-note { margin: 0; font-size: 12px; line-height: 1.45; text-align: center; color: #6d8394; }

@media (max-width: 1180px) { .mpb-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 900px) { .mpb-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

@media (max-width: 760px) {
  .marketplace.mpb { padding: 16px 0 32px 16px; gap: 12px; }
  .mpb-head { padding-right: 16px; flex-direction: column; align-items: stretch; gap: 12px; }
  .mpb-head h1 { font-size: 20px; }
  .mpb-sell { text-align: center; }
  /* Порядок как в макете: поиск, лента коллекций, строка фильтров, сетка */
  .mpb-search { order: 2; width: auto; margin: 0 16px 0 0; }
  .mpb-rail { order: 3; padding-right: 16px; }
  .mpb-chip { height: 44px; box-sizing: border-box; padding: 0 12px 0 6px; }
  .mpb-chip-all { padding: 0 14px; }
  .mpb-bar { padding: 2px 16px 2px 2px; margin: -2px 0 -2px -2px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; font-size: 13px; }
  .mpb-bar::-webkit-scrollbar { display: none; }
  .mpb-sort { order: -1; font-size: 13px; padding: 0 30px 0 12px; flex-shrink: 0; }
  .mpb-dd { position: static; flex-shrink: 0; }
  .mpb-dd summary { padding: 0 12px; }
  .mpb-spacer { display: none; }
  .mpb-count { order: 100; padding-right: 4px; }
  /* Панель фильтра — шторкой снизу: в прокручиваемой строке выпадающий список обрезался бы */
  .mpb-dd-panel { position: fixed; top: auto; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); max-height: 60vh; z-index: 120; padding: 12px; border-radius: 16px; }
  .mpb-dd-list > div { min-height: 44px; box-sizing: border-box; align-items: center; }
  .mpb-dd-range { flex-wrap: wrap; }
  .mpb-dd-range input { height: 44px; width: 110px; }
  .mpb-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-right: 16px; }
  .mpb .mp-load-more { margin-right: 16px; }
  .mpb-card-rarity { top: 8px; left: 8px; }
  .mpb-card-price { bottom: 8px; right: 8px; }
  .mpb-modal { border-radius: 16px 16px 0 0; max-width: 100vw; width: 100vw; align-self: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .mpb-card { transition: none; }
}
