/* Mobile layout: keep the primary actions visible and give the upgrade flow
   a readable, single-column order instead of squeezing the desktop header. */

/* The wheel must remain visibly present before a skin and target are chosen.
   The empty state uses a neutral ring instead of disappearing into the page. */
.upgrade-core > #wheel {
  display: grid !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.upgrade-core > #wheel.no-chance::after {
  background: conic-gradient(
    from 180deg,
    #303842 0deg 25%,
    #242a32 25% 50%,
    #303842 50% 75%,
    #242a32 75% 100%
  ) !important;
}

.upgrade-core > #wheel.no-chance::before {
  border-color: #414b58 !important;
  background: #20252c !important;
}

/* Keep both chance value and caption white for a clear neutral readout. */
.upgrade-core > #wheel .wheel-center strong,
.upgrade-core > #wheel .wheel-center small {
  color: #f7f7f4 !important;
  -webkit-text-fill-color: #f7f7f4 !important;
  text-shadow: none !important;
}

/* Keep the full live activity rail inside the viewport on desktop without an
   extra scrollbar. Cards share the available height so the feed has a clear
   bottom edge even on shorter 2K-height viewports. */
@media (min-width: 1151px) {
  .recent-rail {
    top: 70px !important;
    bottom: auto !important;
    height: calc(100dvh - 70px) !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  .recent-rail .rail-inner {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: hidden !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }

  .recent-rail .rail-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
    height: 100% !important;
    min-height: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden !important;
  }

  .recent-rail .rail-inner::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }

  .recent-rail .rail-card {
    flex: 0 0 144px !important;
    grid-template-columns: 132px minmax(0, 1fr) !important;
    min-height: 144px !important;
    height: 144px !important;
  }

  .recent-rail .rail-media {
    min-width: 0 !important;
    padding: 2px !important;
  }

  .recent-rail .rail-media img {
    width: 128px !important;
  }

  .recent-rail .rail-copy {
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .recent-rail .rail-media img {
    height: 100% !important;
    max-height: 122px !important;
  }
}

/* At tablet widths the rail is part of the page flow, so show every card
   instead of clipping the tail of the feed. */
@media (min-width: 721px) and (max-width: 1150px) {
  .recent-rail,
  .recent-rail .rail-inner,
  .recent-rail .rail-list {
    height: auto !important;
    overflow: visible !important;
  }

  .recent-rail .rail-list > .rail-card:nth-of-type(n + 5) {
    display: flex !important;
  }
}

@media (max-width: 720px) {
  /* Keep the desktop live rail out of the mobile flow. Earlier responsive
     layers turn it into a full-width block above the arena, which pushes the
     wheel and its controls below the first viewport. */
  .recent-rail {
    display: none !important;
  }

  html,
  body {
    min-width: 320px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-width: none !important;
  }

  html::-webkit-scrollbar,
  body::-webkit-scrollbar {
    display: none !important;
  }

  .topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 50 !important;
    display: grid !important;
    width: 100% !important;
    height: 76px !important;
    grid-template-columns: minmax(0, 1fr) auto auto !important;
    grid-template-rows: 30px 32px !important;
    gap: 5px 6px !important;
    align-items: center !important;
    padding: 5px 10px !important;
  }

  .topbar .brand {
    grid-column: 1 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
    width: max-content !important;
    max-width: 100% !important;
    gap: 7px !important;
    font-size: 17px !important;
  }

  .topbar .brand-logo {
    width: 26px !important;
    height: 26px !important;
    flex: 0 0 26px !important;
  }

  .topbar .brand-word {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .topbar .metric-balance {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
    width: auto !important;
    height: 30px !important;
    margin: 0 !important;
    padding: 0 8px !important;
    border-radius: 9px !important;
  }

  .topbar .metric-balance strong {
    font-size: 12px !important;
  }

  .topbar .top-actions {
    display: contents !important;
  }

  .topbar .language-toggle {
    grid-column: 3 !important;
    grid-row: 1 !important;
    width: 36px !important;
    height: 30px !important;
    padding: 0 !important;
    gap: 0 !important;
  }

  .topbar .language-toggle span {
    display: none !important;
  }

  .topbar .language-toggle img {
    width: 18px !important;
    height: 13px !important;
  }

  .topbar #topup {
    grid-column: 1 / 3 !important;
    grid-row: 2 !important;
    display: inline-flex !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 32px !important;
    padding: 0 12px !important;
    font-size: 10px !important;
    letter-spacing: .07em !important;
    white-space: nowrap !important;
  }

  .topbar #topup::before {
    width: 17px !important;
    height: 17px !important;
    flex-basis: 17px !important;
    margin: 0 !important;
    font-size: 15px !important;
  }

  .topbar #login.login,
  .topbar #login.account-button {
    grid-column: 3 !important;
    grid-row: 2 !important;
    width: 88px !important;
    min-width: 88px !important;
    max-width: 88px !important;
    height: 32px !important;
    padding: 0 6px !important;
    border-radius: 9px !important;
    font-size: 0 !important;
    white-space: nowrap !important;
  }

  .topbar #login.login::before {
    content: 'Войти' !important;
    color: #f1e6ff !important;
    font-size: 10px !important;
    font-weight: 850 !important;
    line-height: 1 !important;
  }

  .topbar #login.account-button > span:last-child {
    display: none !important;
  }

  main.app {
    width: 100% !important;
    margin: 0 !important;
    left: auto !important;
    transform: none !important;
    padding: 8px 12px 30px !important;
    overflow: visible !important;
  }

  main.app > .toolbar {
    display: grid !important;
    width: 100% !important;
    max-width: 360px !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 3px !important;
    margin: 0 auto 8px !important;
  }

  main.app > .toolbar .toolbar-action {
    width: auto !important;
    min-width: 0 !important;
    height: 30px !important;
  }

  main.app > .arena {
    display: grid !important;
    width: 100% !important;
    margin: 0 !important;
    transform: none !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
    align-items: stretch !important;
  }

  .upgrade-core {
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 auto !important;
    transform: none !important;
    justify-self: stretch !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
  }

  .upgrade-core::before {
    display: none !important;
  }

  .offer-panel {
    grid-row: 2 !important;
  }

  .target-panel {
    grid-row: 3 !important;
  }

  .selection-panel {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 286px !important;
    height: auto !important;
    max-height: none !important;
    padding: 17px 14px 14px !important;
  }

  .selection-panel h2 {
    font-size: 14px !important;
  }

  .selection-panel > p {
    margin-top: 6px !important;
    font-size: 10px !important;
  }

  .selection-panel .panel-items {
    min-height: 174px !important;
    max-height: none !important;
    margin-top: 10px !important;
  }

  .offer-panel #offer-items,
  .target-panel #target-preview {
    min-height: 174px !important;
  }

  .upgrade-core .wheel {
    width: min(248px, calc(100vw - 40px)) !important;
    height: min(248px, calc(100vw - 40px)) !important;
    margin: 0 auto !important;
    transform: none !important;
  }

  .upgrade-core .upgrade {
    width: min(100%, 340px) !important;
    height: 44px !important;
    font-size: 17px !important;
    margin-top: 6px !important;
    margin-right: auto !important;
    margin-left: auto !important;
  }

  .upgrade-core .quick {
    width: min(100%, 340px) !important;
    justify-content: stretch !important;
    margin-top: 6px !important;
    margin-bottom: 0 !important;
    margin-right: auto !important;
    margin-left: auto !important;
  }

  .upgrade-core .quick button {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    height: 29px !important;
  }

  .bottom {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
    margin-top: 18px !important;
  }
}

@media (max-width: 720px) and (max-height: 700px) {
  .topbar {
    height: 70px !important;
    grid-template-rows: 28px 30px !important;
    padding-block: 4px !important;
  }

  main.app {
    padding-top: 5px !important;
  }

  main.app > .toolbar {
    margin-bottom: 5px !important;
  }

  .upgrade-core .wheel {
    width: min(224px, calc(100vw - 46px)) !important;
    height: min(224px, calc(100vw - 46px)) !important;
  }
}

@media (max-width: 380px) {
  .topbar {
    gap: 7px 5px !important;
    padding-inline: 8px !important;
  }

  .topbar .brand {
    font-size: 16px !important;
  }

  .topbar #login.login,
  .topbar #login.account-button {
    width: 82px !important;
    min-width: 82px !important;
    max-width: 82px !important;
  }

  .topbar #topup {
    font-size: 9px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .topbar #topup,
  .topbar #login.login,
  .topbar #login.account-button { transition: none !important; }
}
