.app {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(min-content, 1fr);
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

.shell-top {
  position: sticky;
  top: 0;
  z-index: 100;
}

/* ── Live header ── */
.header {
  height: var(--header-h);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
  padding: 0 12px;
  background: #07080e;
  border-bottom: 1px solid rgba(139, 44, 255, 0.16);
}

.header-center {
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: stretch;
}

.live-filter {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 8px 0;
}

.live-filter__btn {
  height: 32px;
  min-width: 52px;
  padding: 0 10px;
  border-radius: 0;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.live-filter__btn.is-on {
  color: #fff;
  border-color: rgba(139, 44, 255, 0.55);
  background: linear-gradient(180deg, rgba(139, 44, 255, 0.5), rgba(61, 8, 124, 0.45));
}

.live-filter__btn[data-live="rare"].is-on {
  border-color: rgba(255, 159, 28, 0.65);
  background: linear-gradient(180deg, rgba(255, 120, 20, 0.55), rgba(140, 30, 0, 0.45));
}

.live-rail {
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.live-card {
  --live-c: var(--rarity-uncommon);
  position: relative;
  flex: 0 0 196px;
  width: 196px;
  height: calc(var(--header-h) - 12px);
  margin: 6px 0;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid color-mix(in srgb, var(--live-c) 28%, rgba(255, 255, 255, 0.06));
  background:
    radial-gradient(ellipse 90% 70% at 50% 110%, color-mix(in srgb, var(--live-c) 42%, transparent), transparent 70%),
    linear-gradient(180deg, #14161f 0%, #0c0d14 55%, color-mix(in srgb, var(--live-c) 16%, #08090f) 100%);
  text-decoration: none;
  color: inherit;
}

.live-card.rarity-uncommon { --live-c: var(--rarity-uncommon); }
.live-card.rarity-rare { --live-c: var(--rarity-rare); }
.live-card.rarity-epic { --live-c: var(--rarity-epic); }
.live-card.rarity-legendary { --live-c: var(--rarity-legendary); }
.live-card.rarity-mythic { --live-c: var(--rarity-mythic); }

.live-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--live-c);
  box-shadow: 0 0 18px color-mix(in srgb, var(--live-c) 80%, transparent);
  z-index: 4;
}

.live-card.is-super {
  flex-basis: 214px;
  width: 214px;
  border-color: color-mix(in srgb, var(--live-c) 70%, #fff);
  background:
    radial-gradient(ellipse 100% 80% at 50% 120%, color-mix(in srgb, var(--live-c) 58%, transparent), transparent 68%),
    linear-gradient(180deg, color-mix(in srgb, var(--live-c) 14%, #16141c) 0%, #0c0d14 50%, color-mix(in srgb, var(--live-c) 22%, #08090f) 100%);
  box-shadow:
    inset 0 -28px 36px color-mix(in srgb, var(--live-c) 22%, transparent),
    0 0 22px color-mix(in srgb, var(--live-c) 28%, transparent);
}

.live-card.is-enter {
  animation: live-in 380ms var(--ease-out);
}

@keyframes live-in {
  from {
    transform: translateX(-40px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.live-card__gun {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) scale(1.12);
  width: 86%;
  height: 76%;
  object-fit: contain;
  object-position: center;
  z-index: 3;
  pointer-events: none;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5));
}

.live-card.is-super .live-card__gun {
  filter: brightness(1.16) saturate(1.18) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.55));
}

.live-card:hover .live-card__gun,
.live-card:focus-visible .live-card__gun,
.live-card:hover .live-card__odds,
.live-card:focus-visible .live-card__odds {
  opacity: 0;
}

.live-card__odds {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 6;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 1px 4px #000;
  pointer-events: none;
}

.live-card__hover {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 6px 22px;
  background: rgba(5, 6, 11, 0.72);
  opacity: 0;
  transition: opacity var(--dur-fast);
}

.live-card:hover .live-card__hover,
.live-card:focus-visible .live-card__hover {
  opacity: 1;
}

.live-card__case {
  width: 88%;
  height: 72px;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.65));
}

.live-card__nick {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-card__tag {
  display: none;
}

.live-card.is-buy .live-card__hover {
  gap: 3px;
  padding: 10px 8px 8px;
}

.live-card.is-buy .live-card__nick {
  position: static;
}

.live-card__action {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #c8f060;
}

.live-card__item {
  max-width: 100%;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Menubar ── */
.menubar {
  height: var(--menubar-h);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: #07080e;
  background-image: linear-gradient(180deg, rgba(61, 8, 124, 0.22), rgba(7, 8, 14, 1));
  border-bottom: 1px solid rgba(139, 44, 255, 0.22);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.menubar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  justify-self: start;
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 0 14px rgba(139, 44, 255, 0.7));
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.brand-word {
  display: flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.04em;
  line-height: 0.9;
  color: #fff;
  text-transform: uppercase;
  text-shadow: 0 2px 0 #000, 0 0 18px rgba(0, 0, 0, 0.5);
}

.brand-word span {
  color: var(--accent-purple-light);
  text-shadow: 0 0 18px rgba(184, 76, 255, 0.75);
}

.brand-bolt {
  width: 11px;
  height: 22px;
  flex-shrink: 0;
  margin: 0 1px;
  filter: drop-shadow(0 0 8px rgba(139, 44, 255, 0.9));
}

.brand-tag {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-purple-light);
  white-space: nowrap;
}

.menubar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  justify-self: center;
  overflow-x: auto;
  scrollbar-width: none;
}

.menubar-nav::-webkit-scrollbar { display: none; }

.nav-link {
  display: grid;
  place-items: center;
  width: 72px;
  height: 46px;
  padding: 0;
  border-radius: 0;
  color: var(--text-secondary);
  border: 1px solid transparent;
  flex-shrink: 0;
  transition: background var(--dur-med), color var(--dur-med), border-color var(--dur-med), box-shadow var(--dur-med);
}

.nav-link:hover {
  color: #fff;
  background: linear-gradient(180deg, rgba(184, 76, 255, 0.38), rgba(139, 44, 255, 0.12));
  border-color: rgba(184, 76, 255, 0.55);
  box-shadow: 0 0 22px rgba(139, 44, 255, 0.45), inset 0 0 12px rgba(184, 76, 255, 0.18);
}

.nav-link.active {
  color: #fff;
  background: linear-gradient(180deg, rgba(139, 44, 255, 0.42), rgba(139, 44, 255, 0.08));
  border-color: rgba(139, 44, 255, 0.5);
  box-shadow: inset 0 -3px 0 var(--accent-purple), 0 0 24px rgba(139, 44, 255, 0.28);
}

.nav-link .ico {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: inherit;
}

.nav-link .ico svg {
  width: 24px;
  height: 24px;
  display: block;
}

.nav-link.active .ico { color: var(--accent-purple-light); }

.nav-link:hover .ico {
  color: #fff;
  filter: drop-shadow(0 0 8px rgba(184, 76, 255, 0.85));
}

.nav-badge {
  margin-left: 2px;
  padding: 2px 7px;
  border-radius: 0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #f5b942, #ff9f1c);
  color: #111;
}

.menubar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  justify-self: end;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-subtle);
  border-radius: 0;
  background: var(--bg-card);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
}

.lang-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.icon-btn:hover {
  background: var(--bg-hover);
  border-color: rgba(139, 44, 255, 0.35);
}

.user-name {
  max-width: 112px;
  padding: 0 2px;
  font-size: 13px;
  font-weight: 700;
  line-height: 38px;
  color: var(--text-secondary);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-name:hover {
  color: var(--text-primary);
}

.user-balance {
  width: auto;
  min-width: 96px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #f5c542;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1;
}

.user-balance:hover {
  color: #ffd76a;
  border-color: rgba(245, 197, 66, 0.35);
}

.avatar {
  text-decoration: none;
  color: inherit;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-purple-deep));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.daily-bonus {
  margin-top: 8px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(124, 60, 255, 0.2), var(--bg-card));
  border: 1px solid rgba(124, 60, 255, 0.28);
}

.daily-bonus h4 {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-purple-light);
  margin-bottom: 6px;
}

.daily-bonus p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.4;
}

/* ── Main ── */
.main {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  min-width: 0;
  padding: var(--main-padding);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.main > * {
  width: 100%;
  max-width: var(--content-max);
  min-width: 0;
}

@media (max-width: 991px) {
  .main {
    padding: 16px;
  }

  .brand-lockup { display: none; }

  .nav-link {
    width: 56px;
    height: 42px;
  }
}

@media (max-width: 767px) {
  .header { padding: 0 10px; gap: 8px; }
  .menubar { padding: 0 10px; gap: 8px; }
  .user-name { display: none; }
}

/* Short / landscape viewports (Yandex Games iframe, phone landscape):
   free vertical space — unstick chrome, collapse live-trade, compact menubar. */
@media (max-height: 560px), (orientation: landscape) and (max-width: 950px) {
  :root {
    --header-h: 0px;
    --menubar-h: 48px;
    --main-padding: 12px;
  }

  .shell-top {
    position: static;
  }

  .header {
    display: none;
  }

  .menubar {
    height: var(--menubar-h);
    gap: 8px;
    padding: 0 10px;
    box-shadow: none;
    backdrop-filter: none;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand-lockup {
    display: none;
  }

  .nav-link {
    width: 44px;
    height: 36px;
  }

  .nav-link .ico,
  .nav-link .ico svg {
    width: 20px;
    height: 20px;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .user-name {
    display: none;
  }

  .icon-btn.user-balance {
    width: auto;
    min-width: 96px;
    max-width: 140px;
    height: 32px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 12px;
  }

  .avatar {
    width: 32px;
    height: 32px;
    font-size: 11px;
  }

  .main {
    padding: var(--main-padding);
  }
}

@media (max-height: 420px) {
  :root {
    --menubar-h: 40px;
    --main-padding: 8px;
  }

  html {
    font-size: 13px;
  }

  .menubar {
    gap: 6px;
    padding: 0 8px;
  }

  .nav-link {
    width: 40px;
    height: 32px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
  }
}

/* ── Mobile shell: thumb-first nav, no live-trade chrome (dedicated section later) ── */
@media (max-width: 767px) {
  :root {
    --header-h: 0px;
    --menubar-h: 108px;
    --main-padding: 12px;
  }

  .header {
    display: none !important;
  }

  .shell-top {
    position: sticky;
    top: 0;
    z-index: 200;
    background: #07080e;
    isolation: isolate;
  }

  .menubar {
    height: var(--menubar-h);
    min-height: var(--menubar-h);
    max-height: var(--menubar-h);
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 44px 52px;
    align-items: center;
    gap: 0 10px;
    padding: 8px 12px 4px;
    background: #07080e;
    background-image: linear-gradient(180deg, #0c0d14 0%, #07080e 100%);
    border-bottom: 1px solid rgba(139, 44, 255, 0.28);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
    backdrop-filter: none;
  }

  .menubar-logo {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    align-self: center;
  }

  .menubar-tools {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: center;
  }

  .menubar-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    align-self: stretch;
    justify-content: flex-start;
    gap: 4px;
    padding: 0 0 4px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(90deg, #000 92%, transparent);
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-lockup {
    display: none;
  }

  .nav-link {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  .nav-link .ico,
  .nav-link .ico svg {
    width: 20px;
    height: 20px;
  }

  .icon-btn.user-balance {
    width: auto;
    min-width: 96px;
    max-width: 132px;
    height: 36px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .main {
    padding: var(--main-padding);
  }
}

/* Phone landscape: single-row nav — portrait mobile uses 108px two-row stack */
@media (orientation: landscape) and (max-height: 520px) {
  :root {
    --menubar-h: 52px;
    --main-padding: 10px;
  }

  .shell-top {
    position: sticky;
    top: 0;
    z-index: 200;
    background: #07080e;
  }

  .header {
    display: none !important;
  }

  .menubar {
    height: var(--menubar-h);
    min-height: var(--menubar-h);
    max-height: var(--menubar-h);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 1fr;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    overflow: hidden;
    background: #07080e;
    background-image: linear-gradient(180deg, #0c0d14 0%, #07080e 100%);
    border-bottom: 1px solid rgba(139, 44, 255, 0.28);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    backdrop-filter: none;
  }

  .menubar-logo {
    grid-column: 1;
    grid-row: 1;
  }

  .menubar-nav {
    grid-column: 2;
    grid-row: 1;
    justify-content: center;
    padding: 0;
    mask-image: none;
  }

  .menubar-tools {
    grid-column: 3;
    grid-row: 1;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .nav-link {
    width: 40px;
    height: 40px;
  }

  .nav-link .ico,
  .nav-link .ico svg {
    width: 18px;
    height: 18px;
  }

  .icon-btn.user-balance {
    min-width: 76px;
    max-width: 104px;
    height: 32px;
    padding: 0 8px;
    font-size: 11px;
  }
}
