/* ═══════════════════════════════════════════════════════════
   Кейсы: витрина и полноэкранное окно кейса.
   Подключается после screens.css и переопределяет старые правила.
   ═══════════════════════════════════════════════════════════ */

/* ── Витрина ───────────────────────────────────────────────── */

.cases-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }

.case {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "art art" "title title" "sub price";
  min-width: 0;
  align-items: center;
  row-gap: 2px;
  padding: var(--sp-2) var(--sp-2) var(--sp-3);
  background: var(--surface-1);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  text-align: left;
  transition: transform .15s ease, border-color .15s ease;
}
.case:active { transform: scale(.97); }
.case__art {
  grid-area: art;
  width: 100%; aspect-ratio: 1; display: block;
  border-radius: var(--r-md);
  margin-bottom: var(--sp-2);
}
.case__title {
  grid-area: title;
  padding: 0 var(--sp-1);
  font-size: 15px; font-weight: 800; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.case__sub {
  grid-area: sub;
  padding-left: var(--sp-1);
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.case__price {
  grid-area: price;
  display: inline-flex; align-items: center; gap: 3px;
  height: 26px; padding: 0 10px;
  border-radius: var(--r-pill);
  background: rgba(245, 161, 31, .14);
  color: var(--gold-soft);
  font-size: 13px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.case__price svg { width: 12px; height: 12px; color: var(--gold); }
.case__price--free { background: rgba(36, 201, 138, .14); color: var(--ok); }
.case.is-locked .case__price--free { background: var(--surface-3); color: var(--text-dim); }
.case.is-locked .case__art { filter: saturate(.55) brightness(.8); }

/* ── Окно кейса ────────────────────────────────────────────── */

.cv {
  position: fixed; inset: 0; z-index: 61;
  width: 100%; max-width: 100vw; overflow: hidden;
  pointer-events: auto;
  display: flex; flex-direction: column;
  background: var(--bg);
  opacity: 0; transform: translateY(16px);
  transition: opacity .2s ease, transform .2s ease;
}
.cv.is-open { opacity: 1; transform: none; }

.cv__head {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: var(--sp-2);
  padding: calc(var(--safe-top) + var(--ui-top-gap) + var(--sp-2)) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--stroke);
}
.cv__back {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: var(--r-sm); background: var(--surface-2); color: var(--text);
}
.cv__back svg { width: 20px; height: 20px; }
.cv__title { font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv__bal {
  display: inline-flex; align-items: center; gap: 4px;
  height: 32px; padding: 0 12px; border-radius: var(--r-pill);
  background: var(--surface-2); font-weight: 800; font-variant-numeric: tabular-nums;
}
.cv__bal svg { width: 14px; height: 14px; color: var(--gold); }
.cv.is-busy .cv__back { opacity: .4; pointer-events: none; }

.cv__body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-7) + var(--safe-bottom));
  overflow-x: hidden;
}

/* Сцена: кейс и лента, лента — главная */
.cv-stage { position: relative; display: grid; justify-items: center; margin-bottom: var(--sp-4); }
.cv-stage__case {
  width: 104px; height: 104px; object-fit: cover; border-radius: 22px;
  margin-bottom: calc(var(--sp-3) * -1);
  position: relative; z-index: 1;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .5));
}
.cv .reel {
  width: 100%;
  margin: 0;
  padding: var(--sp-4) 0;
  border-radius: var(--r-lg);
  background:
    radial-gradient(60% 120% at 50% 50%, rgba(47, 123, 255, .14), transparent 70%),
    var(--surface-1);
  border: 1px solid var(--stroke-2);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12%, #000 88%, transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 12%, #000 88%, transparent 100%);
}
.cv .reel__mark {
  width: 3px; border-radius: 2px;
  background: var(--gold-soft);
  box-shadow: 0 0 14px rgba(255, 211, 107, .9);
}
.cv .reel__strip { gap: 10px; }
.cv .reel-card {
  flex: 0 0 86px; height: 110px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.cv .reel-card[data-tone="legend"] { background: linear-gradient(180deg, rgba(245, 161, 31, .16), var(--surface-2)); }
.cv .reel-card.is-landed {
  transform: scale(1.08);
  border-color: var(--gold-soft);
  box-shadow: 0 0 22px rgba(255, 211, 107, .45);
}

/* Действие */
.cv-action { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-6); }
.cv-open { height: 54px; font-size: 17px; }
.cv-open svg { width: 16px; height: 16px; }
.cv-open:disabled { opacity: .45; box-shadow: none; }
.cv-note { text-align: center; color: var(--text-dim); font-size: 14px; line-height: 1.4; }
.cv-link { color: var(--blue-400); font-weight: 700; padding: 2px 0; }
.cv-promo { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2); }
.cv-promo .field { text-transform: uppercase; height: 50px; }
.cv-promo .btn { height: 50px; }

/* Итог */
.cv-win {
  display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: var(--sp-3); align-items: center;
  padding: var(--sp-3);
  border-radius: var(--r-lg);
  background: rgba(47, 123, 255, .08);
  border: 1px solid var(--stroke-blue);
  animation: cv-in .3s ease both;
}
.cv-win.is-gift { background: rgba(245, 161, 31, .1); border-color: rgba(255, 211, 107, .45); }
.cv-win__art { width: 76px; height: 76px; display: grid; place-items: center; }
.cv-win__art img { width: 100%; height: 100%; object-fit: contain; }
.cv-win__art .gift-img { width: 76px; height: 76px; }
.cv-win__title { font-size: 22px; font-weight: 900; line-height: 1.2; color: var(--gold-soft); overflow-wrap: anywhere; }
.cv-win.is-gift .cv-win__title { font-size: 18px; color: var(--text); }
.cv-win__sub { margin-top: 2px; font-size: 14px; color: var(--text-dim); }
.cv-win__actions { display: grid; gap: var(--sp-2); }
.cv-win__actions .btn { height: 50px; }
.cv-win__actions svg { width: 15px; height: 15px; }
@keyframes cv-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* Что внутри */
.cv-list { display: grid; gap: var(--sp-2); }
.cv-list__head {
  display: flex; justify-content: space-between;
  padding: 0 var(--sp-1) var(--sp-1);
  font-size: 15px; font-weight: 800; color: var(--text);
}
.cv-list__head span:last-child { font-size: 13px; font-weight: 600; color: var(--text-mute); }
.cv-item {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2);
  border-radius: var(--r-md);
  background: var(--surface-1);
  border: 1px solid var(--stroke);
}
.cv-item[data-tone="legend"] { border-color: rgba(255, 211, 107, .35); background: linear-gradient(90deg, rgba(245, 161, 31, .1), var(--surface-1) 60%); }
.cv-item[data-tone="epic"] { border-color: rgba(53, 210, 245, .3); }
.cv-item__art { width: 48px; height: 48px; object-fit: contain; border-radius: var(--r-sm); }
.cv-item__name { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-item__worth {
  display: inline-flex; align-items: center; gap: 3px; margin-top: 1px;
  font-size: 13px; color: var(--gold-soft); font-variant-numeric: tabular-nums;
}
.cv-item__worth svg { width: 11px; height: 11px; }
.cv-item__chance {
  min-width: 0; text-align: right; padding-left: var(--sp-2);
  font-size: 15px; font-weight: 800; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .cv, .cv-win, .cv .reel-card { transition: none; animation: none; }
}

/* Пока открыто окно кейса, шапка и нижнее меню приложения не нужны:
   они просвечивали поверх и путались с балансом окна. */
body:has(.cv.is-open) .topbar,
body:has(.cv.is-open) .tabbar { visibility: hidden; }
.cv .reel-card__art { padding: 4px; }

@media (max-width: 340px) {
  .cases-grid { gap: var(--sp-2); }
  .case { padding: 6px 6px var(--sp-2); }
  .case__price { padding: 0 7px; font-size: 12px; }
  .cv .reel-card { flex-basis: 76px; height: 98px; }
}

/* ── Правки по живому телефону ────────────────────────────── */
/* В Telegram своя кнопка «Назад» — нашей стрелки нет, колонка не нужна */
.cv__head--tg { grid-template-columns: minmax(0, 1fr) auto; }
/* Картинка кейса больше не наезжает на ленту */
.cv-stage__case { width: 88px; height: 88px; margin-bottom: var(--sp-3); }
/* Карточка звёзд выше, чем шире (100×128): рамка под её пропорции */
.cv-win { grid-template-columns: 64px minmax(0, 1fr); align-items: center; }
.cv-win__art { width: 64px; height: 82px; overflow: hidden; border-radius: 12px; }
.cv-win__art img { width: 100%; height: 100%; object-fit: contain; }
.cv-win.is-gift .cv-win__art { height: 64px; }
.cv-win__sub { font-size: 13.5px; line-height: 1.35; }
.cv-action { gap: var(--sp-3); }

/* ── Квадратные карточки ───────────────────────────────────── */
.cv .reel-card { flex: 0 0 92px; height: 92px; }
.cv .reel-card__art { padding: 0; object-fit: cover; }
.cv .reel-card[data-tone="legend"] .reel-card__art { padding: 6px; object-fit: contain; }
.cv-win__art, .cv-win.is-gift .cv-win__art { width: 64px; height: 64px; }
.cv-item__art { border-radius: 10px; }
@media (max-width: 340px) {
  .cv .reel-card { flex-basis: 80px; height: 80px; }
}
