/* PlayChukka v2.6.4.2 — mobile prestige profile layout correction */

@media (max-width: 820px) {
  /* Keep all profile content clear of the fixed app navigation and iPhone toolbar. */
  body .page-content {
    padding-bottom: calc(165px + env(safe-area-inset-bottom)) !important;
  }

  #page-profile {
    padding-bottom: calc(45px + env(safe-area-inset-bottom));
    overflow: visible;
  }

  /* Keep the rank/tier seal inside the profile card instead of above the advert. */
  #page-profile .profile-hero {
    position: relative !important;
    inset: auto !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: start !important;
    gap: 18px !important;
    width: 100% !important;
    min-height: 0 !important;
    padding: 22px 18px !important;
    overflow: hidden !important;
  }

  #page-profile .profile-identity {
    display: grid !important;
    grid-template-columns: 66px minmax(0, 1fr) !important;
    gap: 15px !important;
    align-items: center !important;
    min-width: 0;
  }

  #page-profile .profile-avatar-large {
    width: 66px !important;
    height: 66px !important;
    font-size: 25px !important;
  }

  #page-profile .profile-identity > div {
    min-width: 0;
  }

  #page-profile .profile-identity h2 {
    margin: 3px 0 7px !important;
    font-size: 29px !important;
    line-height: 1.05 !important;
    overflow-wrap: anywhere;
  }

  #page-profile .profile-identity p {
    margin: 0 !important;
    font-size: 15px !important;
  }

  #page-profile .prestige-badges {
    margin-top: 10px !important;
    gap: 7px !important;
  }

  #page-profile .prestige-badge {
    padding: 6px 9px !important;
    font-size: 10px !important;
  }

  #page-profile .profile-rank-seal {
    position: static !important;
    inset: auto !important;
    transform: none !important;
    z-index: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    aspect-ratio: auto !important;
    min-height: 58px !important;
    display: grid !important;
    grid-template-columns: auto auto minmax(0, 1fr) !important;
    justify-content: start !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 11px 14px !important;
    border-radius: 15px !important;
    text-align: left !important;
  }

  #page-profile .profile-rank-seal small {
    font-size: 9px !important;
    letter-spacing: .12em !important;
  }

  #page-profile .profile-rank-seal strong {
    font-size: 25px !important;
    line-height: 1 !important;
  }

  #page-profile .profile-rank-seal span {
    font-size: 11px !important;
    line-height: 1.25 !important;
  }

  /* Maintain a clean two-column statistics grid on phones. */
  #page-profile .profile-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 11px !important;
    margin: 14px 0 !important;
  }

  #page-profile .profile-stats .stat-card {
    min-height: 112px !important;
    padding: 15px 13px !important;
  }

  #page-profile .profile-stats .stat-card small {
    font-size: 9px !important;
    line-height: 1.35 !important;
  }

  #page-profile .profile-stats .stat-card strong {
    font-size: 25px !important;
    line-height: 1.1 !important;
  }

  /* Trophy and race cards must stack vertically on mobile. */
  #page-profile .content-grid.equal {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }

  #page-profile .content-grid.equal > .card {
    width: 100% !important;
    min-width: 0 !important;
    padding: 18px 16px !important;
    overflow: hidden !important;
  }

  /* Restore the heading and place the Trophy Room button beneath it. */
  #page-profile .card-heading:has(+ #profile-trophies) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: start !important;
    gap: 14px !important;
    margin-bottom: 14px !important;
  }

  #page-profile .card-heading:has(+ #profile-trophies) > div {
    display: block !important;
    min-width: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  #page-profile .card-heading:has(+ #profile-trophies) .eyebrow,
  #page-profile .card-heading:has(+ #profile-trophies) h3 {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  #page-profile .card-heading:has(+ #profile-trophies) h3 {
    margin: 4px 0 0 !important;
    font-size: 25px !important;
    line-height: 1.08 !important;
  }

  #page-profile #pc250-open-trophy-room {
    position: static !important;
    inset: auto !important;
    transform: none !important;
    width: 100% !important;
    max-width: none !important;
    min-height: 49px !important;
    margin: 0 !important;
    padding: 12px 16px !important;
    white-space: normal !important;
    font-size: 16px !important;
    line-height: 1.25 !important;
  }

  #page-profile #profile-trophies {
    width: 100% !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
  }

  #page-profile #profile-trophies .trophy-item {
    width: 100% !important;
    min-height: 72px !important;
    padding: 13px !important;
    gap: 12px !important;
  }

  #page-profile #profile-trophies .trophy-item > span {
    width: 42px !important;
    height: 42px !important;
    flex: 0 0 42px !important;
  }

  #page-profile #profile-trophies .trophy-item strong {
    font-size: 15px !important;
    line-height: 1.3 !important;
  }

  #page-profile #profile-trophies .trophy-item small {
    margin-top: 4px !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
  }

  /* Compact the race-record section while preserving readability. */
  #page-profile #profile-race-record {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    justify-items: center !important;
    gap: 14px !important;
    width: 100% !important;
  }

  #page-profile .race-record-crown {
    width: 112px !important;
    min-width: 112px !important;
    height: 112px !important;
  }

  #page-profile .race-record-crown > strong {
    font-size: 34px !important;
  }

  #page-profile .race-record-crown > span {
    font-size: 8px !important;
  }

  #page-profile .race-record-lines {
    width: 100% !important;
    font-size: 14px !important;
    line-height: 1.55 !important;
  }

  #page-profile .race-record-lines p {
    margin: 0 0 9px !important;
  }

  #page-profile .race-record-lines .btn,
  #page-profile #profile-race-record .btn {
    min-height: 46px !important;
    padding: 11px 15px !important;
    font-size: 15px !important;
  }

  #page-profile .info-banner {
    margin-bottom: calc(22px + env(safe-area-inset-bottom)) !important;
  }

  /* Keep the existing bottom navigation above the device safe area. */
  .mobile-nav {
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
  }
}

@media (max-width: 390px) {
  #page-profile .profile-identity {
    grid-template-columns: 58px minmax(0, 1fr) !important;
    gap: 12px !important;
  }

  #page-profile .profile-avatar-large {
    width: 58px !important;
    height: 58px !important;
    font-size: 23px !important;
  }

  #page-profile .profile-identity h2 {
    font-size: 27px !important;
  }

  #page-profile .profile-stats .stat-card {
    min-height: 106px !important;
    padding: 13px 11px !important;
  }
}
