html,
body {
  background: #121212 !important;
}

:root {
  --mobile-top-rect-h: calc(18px + env(safe-area-inset-top, 0px));
  --mobile-bottom-rect-h: calc(82px + env(safe-area-inset-bottom, 0px));
}

body.mobile-standalone {
  --mobile-bottom-rect-h: 52px;
}

#mobileTopRect {
  display: block !important;
  visibility: visible !important;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: var(--mobile-top-rect-h);
  padding-top: env(safe-area-inset-top, 0px);
  background: #121212;
  border-radius: 0 0 28px 28px;
  box-shadow: none !important;
  filter: none !important;
  border: 0 !important;
  outline: 0 !important;
  z-index: 60;
  display: flex !important;
  align-items: flex-end;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 16px;
}

#mobileTopRect .mobile-top-level {
  height: 18px;
  display: inline-flex;
  align-items: center;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

#mobileTopRect .mobile-top-currency {
  height: 18px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

#mobileTopRect .mobile-top-keys {
  height: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

#mobileTopRect .mobile-top-keys__icon {
  font-size: 14px;
  line-height: 1;
}

#mobileTopRect .mobile-top-diamonds {
  height: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

#mobileTopRect .mobile-top-diamonds__icon {
  font-size: 14px;
  line-height: 1;
}

#mobileCenterVinyl {
  display: grid !important;
  visibility: visible !important;
  position: fixed;
  left: 50%;
  top: 44vh;
  top: 44dvh;
  transform: translate(-50%, -50%);
  animation: mobile-center-vinyl-spin 3.6s linear infinite !important;
  z-index: 30;
  pointer-events: none;
}

#mobileCenterVinyl.is-pulling {
  animation-duration: 0.32s !important;
}

/* Keep reveal readable on mobile */
.reveal.opened .reveal__info {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

.reveal.opened .reveal__track,
.reveal.opened .reveal__artist,
.reveal.opened .reveal__rarity {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Never let vinyl overlap opened result card */
.reveal.opened .reveal__crate,
.reveal.exploded .reveal__crate {
  opacity: 0 !important;
  pointer-events: none !important;
}

.reveal.opened .vinyl,
.reveal.exploded .vinyl {
  opacity: 0 !important;
  transform: scale(0.92) !important;
}

/* Hard override: always show reveal card popup on mobile when reveal is active */
.reveal.active .reveal__info {
  display: flex !important;
  position: fixed !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  z-index: 2102 !important;
  width: min(74vw, 268px) !important;
  max-width: 268px !important;
  min-height: min(74vw, 268px) !important;
  border-radius: 22px !important;
  padding: 12px 12px 10px !important;
  background: rgba(12, 16, 24, 0.92) !important;
  border: 2px solid var(--mobile-card-outline, rgba(255, 255, 255, 0.22)) !important;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42) !important;
}

.reveal.opened .reveal__actions,
.reveal.opened .reveal__actions.reveal-actions--mobile-floating {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

.reveal.opened .source-badge,
.reveal.opened .source-badge.reveal-source--mobile-floating,
.reveal.opened #revealSource {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

@media (max-width: 900px) {
  .reveal,
  .reveal.active {
    z-index: 4000 !important;
  }

  .reveal.active .reveal__crate {
    z-index: 4001 !important;
  }

  /* Desktop card styling on mobile reveal */
  .reveal .reveal__info {
    width: min(304px, 82vw) !important;
    max-width: 304px !important;
    min-height: 0 !important;
    padding: 16px !important;
    gap: 8px !important;
    border-radius: 18px !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    background: rgba(12, 16, 24, 0.92) !important;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.45) !important;
    text-align: center !important;
    align-items: center !important;
    overflow: visible !important;
  }

  .reveal .reveal__info::before,
  .reveal .reveal__info::after {
    content: none !important;
    display: none !important;
  }

  .reveal .reveal__info > * {
    position: static !important;
    z-index: auto !important;
  }

  .reveal.active .reveal__info {
    display: flex !important;
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: 4002 !important;
  }

  .reveal.opened .reveal__info {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .reveal.opened .reveal__info > * {
    opacity: 1 !important;
    visibility: visible !important;
  }

  .reveal .reveal__info .cover {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: auto !important;
    border-radius: 16px !important;
  }

  .reveal .reveal__info .reveal__rarity {
    font-size: 14px !important;
    letter-spacing: 1px !important;
    text-transform: uppercase !important;
    display: block !important;
    width: auto !important;
    border: 0 !important;
    background: transparent !important;
    padding: 0 !important;
  }

  .reveal .reveal__info .reveal__track {
    font-size: 21px !important;
    line-height: 1.12 !important;
    text-align: center !important;
  }

  .reveal .reveal__info .reveal__artist {
    font-size: 14px !important;
    line-height: 1.2 !important;
    text-align: center !important;
    color: var(--muted) !important;
    font-weight: 500 !important;
  }

  .reveal .reveal__info .genre-badge--reveal {
    align-self: center !important;
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: center !important;
  }

  .reveal .reveal__info .reveal__preview {
    width: 100% !important;
    margin-top: 6px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .reveal .reveal__info #revealSource {
    position: static !important;
    margin-top: 6px !important;
    align-self: flex-start !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .reveal.active .reveal__actions,
  .reveal.opened .reveal__actions {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .reveal.active #revealSource,
  .reveal.opened #revealSource {
    display: inline-flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
}

@keyframes mobile-center-vinyl-spin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

#mobileCrateBtn {
  display: inline-flex !important;
  visibility: visible !important;
  position: fixed;
  top: calc(50vh - 186px);
  top: calc(50dvh - 186px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 0;
  height: auto;
  border: 0;
  outline: 0;
  border-radius: 0;
  background: transparent;
  color: #66f2b6;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 1.6px;
  line-height: 1;
  text-transform: uppercase;
  padding: 0;
  align-items: center;
  justify-content: center;
  width: min(92vw, 360px);
  z-index: 50;
}

#mobileAutoSpinRow {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  position: fixed;
  top: calc(50vh - 116px);
  top: calc(50dvh - 116px);
  left: 50%;
  transform: translateX(-50%);
  align-items: center;
  gap: 8px;
  width: min(92vw, 360px);
  justify-content: center;
  z-index: 50;
}

#mobileSpinBtn.mobile-spin-btn {
  display: inline-flex !important;
  visibility: visible !important;
  position: fixed;
  left: 50%;
  top: calc(50vh + 82px);
  top: calc(50dvh + 82px);
  transform: translateX(-50%);
  width: auto !important;
  min-width: 0 !important;
  max-width: calc(100vw - 24px) !important;
  padding-left: 18px !important;
  padding-right: 18px !important;
  justify-content: center;
  align-items: center;
  z-index: 50;
}

#mobileAutoSpinRow .mobile-auto-spin-row__label {
  color: #9aa5b1;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  line-height: 1;
}

#mobileAutoSpinToggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

#mobileAutoSpinRow .mobile-auto-spin-row__track {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(12, 18, 28, 0.86);
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
}

#mobileAutoSpinRow .mobile-auto-spin-row__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.18s ease;
}

#mobileAutoSpinToggle:checked + .mobile-auto-spin-row__track {
  background: rgba(102, 242, 182, 0.35);
  border-color: rgba(86, 227, 255, 0.7);
}

#mobileAutoSpinToggle:checked + .mobile-auto-spin-row__track::after {
  transform: translateX(16px);
}

#mobileBottomRect {
  display: block !important;
  visibility: visible !important;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--mobile-bottom-rect-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #121212;
  border-radius: 24px 24px 0 0;
  box-shadow: none;
  z-index: 60;
}

#mobileBottomRect .mobile-bottom-nav {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  justify-items: center;
  gap: 10px;
  padding: 0 12px 0;
}

body.mobile-standalone #mobileBottomRect .mobile-bottom-nav {
  padding: 0 8px 0;
}

body.mobile-standalone #mobileBottomRect {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#mobileBottomRect .mobile-bottom-nav__btn {
  width: 100%;
  max-width: 108px;
  height: 64px;
  border: 0;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: #e9edf4;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
}

body.mobile-standalone #mobileBottomRect .mobile-bottom-nav__btn {
  height: 44px;
  justify-content: flex-end;
  gap: 2px;
  padding-bottom: 0;
}

#mobileBottomRect .mobile-bottom-nav__icon {
  font-size: 18px;
  line-height: 1;
}

#mobileBottomRect .mobile-bottom-nav__text {
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.8px;
  color: #e9edf4;
  transition: color 0.18s ease;
}

#mobileBottomRect .mobile-bottom-nav__btn.is-active .mobile-bottom-nav__text {
  color: #66f2b6;
}

#mobileGuessSongFab,
#mobileQuestsFab {
  position: fixed;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(9, 16, 30, 0.92);
  color: #eaf2ff;
  display: inline-flex !important;
  visibility: visible !important;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  z-index: 62;
}

#mobileGuessSongFab {
  bottom: calc(var(--mobile-bottom-rect-h) + 10px);
}

#mobileQuestsFab {
  bottom: calc(var(--mobile-bottom-rect-h) + 62px);
}

body.mobile-crate-picker-open #mobileCenterVinyl,
body.mobile-crate-picker-open #mobileAutoSpinRow,
body.mobile-crate-picker-open #mobileCrateBtn,
body.mobile-crate-picker-open #mobileSpinBtn {
  display: none !important;
}

body.mobile-crate-picker-open #mobileGuessSongFab,
body.mobile-crate-picker-open #mobileQuestsFab {
  display: none !important;
}

@media (max-width: 900px) {
  /* Keep all quest cards and their action buttons visible without scrolling. */
  #quests .quests__panel {
    width: min(96vw, 520px) !important;
    max-height: calc(100dvh - 18px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(16px + env(safe-area-inset-bottom)) !important;
    overflow-y: hidden !important;
    gap: 8px !important;
  }

  #quests .quests__grid {
    display: grid !important;
    flex-direction: initial !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    padding-right: 0 !important;
    overflow-y: visible !important;
  }

  #quests .quest__card {
    padding: 7px !important;
    gap: 5px !important;
    min-height: 0 !important;
  }

  #quests .quest__label {
    font-size: 9px !important;
    letter-spacing: 0.1em !important;
  }

  #quests .quest__title {
    font-size: 12px !important;
    line-height: 1.15 !important;
  }

  #quests .quest__row {
    padding: 7px 7px !important;
    border-radius: 9px !important;
    gap: 6px !important;
  }

  #quests .quest__progress {
    font-size: 10px !important;
    padding: 2px 6px !important;
  }

  #quests .quest__card .btn {
    min-height: 30px !important;
    height: 30px !important;
    padding: 5px 8px !important;
    font-size: 10px !important;
    letter-spacing: 0.6px !important;
  }

  #guessSongClose {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
  }

  #guessSong.guess-song--mobile {
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 !important;
    z-index: 220 !important;
  }

  #guessSong.guess-song--mobile .profile__panel.guess-song__panel {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    max-height: calc(100dvh - env(safe-area-inset-top)) !important;
    overflow-y: hidden !important;
    margin-top: 0 !important;
    border-radius: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom)) !important;
    gap: 8px !important;
  }

  #guessSong.guess-song--mobile .profile__header h2 {
    font-size: 20px !important;
  }

  #guessSong.guess-song--mobile .profile__header p {
    font-size: 12px !important;
    line-height: 1.3 !important;
  }

  #guessSong.guess-song--mobile .guess-song__artist {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 0 !important;
    border-radius: 0 !important;
  }

  #guessSong.guess-song--mobile.guess-song--in-run .guess-song__artist,
  #guessSong.guess-song--mobile.guess-song--in-run .guess-song__modes {
    display: none !important;
  }

  #guessSong.guess-song--mobile .guess-song__modes {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    align-items: stretch !important;
    padding: 0 !important;
    border-radius: 0 !important;
  }

  #guessSong.guess-song--mobile .guess-song__modes #guessSongModeDiamond,
  #guessSong.guess-song--mobile .guess-song__modes #guessSongModeFree {
    width: 100% !important;
    min-width: 0 !important;
    padding: 8px 6px !important;
    font-size: 11px !important;
    letter-spacing: 0.5px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  #guessSong.guess-song--mobile .guess-song__modes #guessSongAttemptsLabel {
    grid-column: 1 / -1 !important;
    text-align: center !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
  }

  #guessSong.guess-song--mobile .guess-song__meta {
    gap: 8px !important;
    font-size: 11px !important;
    padding: 0 !important;
    border-radius: 0 !important;
  }

  #guessSong.guess-song--mobile .guess-song__options {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
    padding-bottom: 10px !important;
  }

  #guessSong.guess-song--mobile .guess-song__option {
    padding: 5px !important;
    gap: 5px !important;
    min-height: 0 !important;
  }

  #guessSong.guess-song--mobile .guess-song__option-cover {
    border-radius: 7px !important;
  }

  #guessSong.guess-song--mobile .guess-song__option-cover img {
    object-fit: cover !important;
  }

  #guessSong.guess-song--mobile .guess-song__option-name {
    font-size: 10px !important;
    line-height: 1.15 !important;
    -webkit-line-clamp: 2 !important;
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }

  #guessSong.guess-song--mobile .guess-song__actions {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, rgba(12, 16, 24, 0) 0%, rgba(12, 16, 24, 0.96) 26%);
    padding-top: 10px;
    margin-top: 4px !important;
    border-radius: 0 !important;
  }

  #guessSong.guess-song--mobile .guess-song__cashout,
  #guessSong.guess-song--mobile .guess-song__next,
  #guessSong.guess-song--mobile #guessSongPlay,
  #guessSong.guess-song--mobile #guessSongLoad {
    width: 100% !important;
  }
}

/* Mobile-only crate picker screen between top/bottom bars */
#cratePicker {
  z-index: 55;
}

body.mobile-crate-picker-open > #cratePicker {
  display: flex !important;
  visibility: visible !important;
}

body.mobile-crate-picker-open > #cratePicker .crate-picker__panel,
body.mobile-crate-picker-open > #cratePicker .crate-picker__grid,
body.mobile-crate-picker-open > #cratePicker .crate-picker__card {
  visibility: visible !important;
}

body.mobile-crate-picker-open > #cratePicker .crate-picker__grid {
  display: grid;
}

#cratePicker .crate-picker__backdrop {
  display: none !important;
}

#cratePicker .crate-picker__panel {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(var(--mobile-top-rect-h) + 8px);
  bottom: calc(var(--mobile-bottom-rect-h) + 22px);
  width: 100%;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 0;
  border: 0;
  background: #121212;
  box-shadow: none;
  padding: 10px 10px 10px;
  overflow: hidden;
}

#cratePicker .crate-picker__header {
  padding: 0 2px 8px;
}

#cratePicker .crate-picker__grid {
  height: 100%;
  max-height: none;
  overflow-y: auto;
  padding-bottom: 28px;
  padding-right: 2px;
}

#cratePicker .crate-picker__card {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 100px;
  padding: 10px 12px;
}

#cratePicker .crate-picker__cover {
  width: 84px;
  height: 84px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

#cratePicker .crate-picker__disc {
  width: 62px;
  height: 62px;
}

#cratePicker .collection__meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

#cratePicker .collection__title {
  min-height: 0;
  -webkit-line-clamp: 1;
}

#cratePicker .collection__subtitle {
  display: block;
}

#cratePicker .crate-picker__odds {
  position: static;
  align-self: center;
}
