*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, sans-serif;
  background: #000;
  color: #fff;
  overflow: hidden;
}

.viewport {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 0;
  background: #000;
}

.phone {
  position: relative;
  width: min(100vw, calc(100dvh * 9 / 16));
  height: min(100dvh, calc(100vw * 16 / 9));
  aspect-ratio: 9 / 16;
  background: #000;
  overflow: hidden;
}

.phone__content {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: 88px;
}

.screen {
  display: none;
  min-height: 100%;
}

.screen--active {
  display: block;
}

.profile {
  padding: calc(52px + env(safe-area-inset-top, 0px) + var(--tg-content-safe-area-top, 48px)) 16px 0;
}

.profile__anim-item {
  opacity: 0;
  transform: translateY(18px);
}

.profile--visible .profile__header {
  animation: profile-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.profile--visible .balance-card {
  animation: profile-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.12s forwards;
}

.profile--visible .profile-menu {
  animation: profile-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.22s forwards;
}

@keyframes profile-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.profile__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.profile__avatar-wrap {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(145deg, #74c0fc, #4dabf7 45%, #228be6);
  box-shadow:
    0 0 18px rgba(77, 171, 247, 0.75),
    0 0 36px rgba(34, 139, 230, 0.35);
}

.profile__avatar,
.profile__avatar-fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.profile__avatar-fallback {
  display: none;
  align-items: center;
  justify-content: center;
  background: #1a2030;
  color: #74c0fc;
  font-size: 28px;
  font-weight: 500;
}

.profile__avatar-fallback--visible {
  display: flex;
}

.profile__name {
  margin-top: 14px;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.2;
  color: #fff;
}

.profile__username {
  margin-top: 4px;
  font-size: 13px;
  color: #6b7280;
}

.profile__username:empty {
  display: none;
}

.balance-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 32px;
  padding: 16px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(77, 171, 247, 0.18);
  background: #0a0c10;
}

.balance-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(116, 192, 252, 0.22) 0%,
    rgba(77, 171, 247, 0.08) 35%,
    rgba(10, 12, 16, 0.6) 70%,
    rgba(0, 0, 0, 0.95) 100%
  );
  pointer-events: none;
}

.balance-card__info,
.balance-card__actions {
  position: relative;
  z-index: 1;
}

.balance-card__info {
  min-width: 0;
}

.balance-card__label {
  display: block;
  font-size: 12px;
  color: #6b7280;
}

.balance-card__row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.balance-card__value {
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
  color: #74c0fc;
}

.balance-card__coin {
  width: 22px;
  height: 22px;
  color: #74c0fc;
  flex-shrink: 0;
}

.balance-card__rub {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #6b7280;
}

.balance-card__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.balance-btn {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background 0.2s ease;
}

.balance-btn svg {
  width: 22px;
  height: 22px;
}

.balance-btn--deposit {
  background: rgba(77, 171, 247, 0.28);
  color: #74c0fc;
  border: 1px solid rgba(116, 192, 252, 0.35);
}

.balance-btn--withdraw {
  background: rgba(30, 40, 55, 0.9);
  color: #74c0fc;
  border: 1px solid rgba(77, 171, 247, 0.15);
}

.balance-btn:active {
  transform: scale(0.94);
}

.profile-menu {
  margin-top: 16px;
  margin-bottom: 16px;
  background: #12161c;
  border: 1px solid #1e2530;
  border-radius: 18px;
  overflow: hidden;
}

.profile-menu__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  border-bottom: 1px solid #1a2030;
}

.profile-menu__item--last {
  border-bottom: none;
}

.profile-menu__item:active {
  background: rgba(255, 255, 255, 0.04);
}

.profile-menu__icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
  line-height: 1;
  border-radius: 8px;
}

.profile-menu__icon--gifts {
  background: rgba(255, 193, 7, 0.15);
}

.profile-menu__icon--tasks {
  background: rgba(210, 180, 140, 0.15);
}

.profile-menu__icon--referrals {
  background: rgba(77, 171, 247, 0.15);
}

.profile-menu__icon--support {
  background: rgba(81, 207, 102, 0.12);
}

.profile-menu__icon--settings {
  background: rgba(173, 181, 189, 0.12);
}

.profile-menu__label {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
}

.profile-menu__chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #6b7280;
}

.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0px));
  background: #0b0e11;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
}

body.tg-fullscreen .viewport {
  align-items: stretch;
  justify-content: stretch;
  min-height: 100dvh;
  height: 100dvh;
}

body.tg-fullscreen .phone {
  width: 100%;
  height: 100%;
  max-width: none;
  aspect-ratio: auto;
}

body.tg-fullscreen .bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px 8px;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.25s ease;
}

.bottom-nav__item--active {
  color: #fff;
}

.bottom-nav__icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
}

.bottom-nav__icon-image {
  width: 19px;
  height: 19px;
  display: block;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-mode: alpha;
  mask-mode: alpha;
}

.bottom-nav__icon-image--gift {
  -webkit-mask-image: url("../img/gift.png");
  mask-image: url("../img/gift.png");
}

.bottom-nav__icon-image--pvp {
  -webkit-mask-image: url("../img/pvp-icon.png");
  mask-image: url("../img/pvp-icon.png");
  transform-origin: center center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.bottom-nav__label {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.bottom-nav__indicator {
  width: 28px;
  height: 3px;
  border-radius: 999px;
  background: transparent;
  margin-top: 2px;
  transform-origin: center;
  transition: background 0.3s ease;
}

.bottom-nav__item--active .bottom-nav__indicator {
  background: #4dabf7;
}

.bottom-nav__item--animate .bottom-nav__icon {
  animation: nav-icon-press 0.45s ease-in-out forwards;
}

.bottom-nav__item--animate .bottom-nav__icon:has(.bottom-nav__icon-image--pvp) {
  animation: none;
}

.bottom-nav__item--animate .bottom-nav__icon-image--pvp {
  animation: nav-icon-press 0.45s ease-in-out forwards;
}

.bottom-nav__item--animate .bottom-nav__indicator {
  animation: nav-indicator-press 0.45s ease-in-out forwards;
}

@keyframes nav-icon-press {
  0% {
    transform: scale(1);
  }

  45% {
    transform: scale(0.9);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes nav-indicator-press {
  0% {
    transform: scaleX(1);
    opacity: 1;
  }

  45% {
    transform: scaleX(0.75);
    opacity: 0.75;
  }

  100% {
    transform: scaleX(1);
    opacity: 1;
  }
}
