.profile-view {
  position: fixed;
  z-index: 7;
  top: 0;
  right: max(0px, calc((100vw - 460px) / 2));
  bottom: 0;
  left: max(0px, calc((100vw - 460px) / 2));
  display: flex;
  width: min(100%, 460px);
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: calc(64px + max(10px, env(safe-area-inset-top)) + var(--telegram-fullscreen-top-gap, 0px)) var(--pvp-content-gutter) max(98px, calc(90px + env(safe-area-inset-bottom)));
  overflow-y: auto;
  background: var(--profile-page-background);
  overscroll-behavior: contain;
}

.profile-view[hidden] { display: none; }

.profile-header {
  display: grid;
  min-height: 36px;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 0;
}

.profile-header h1 { margin: 0; font-size: 16px; font-weight: 800; text-align: center; }
.profile-view:not(.profile-collection-view) .profile-header h1 { transform: translateY(-48px); }

.profile-header--collection { grid-template-columns: 36px 1fr 36px; gap: 8px; }

.profile-back {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
  background: #242427;
  color: #fff;
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}

.profile-collection-topbar { display: flex; min-height: 54px; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid rgba(255,255,255,.06); border-radius: 16px; background: linear-gradient(135deg, rgba(44,44,49,.96), rgba(29,29,32,.96)); }
.profile-collection-player { display: flex; min-width: 0; align-items: center; gap: 9px; }
.profile-collection-avatar { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; overflow: hidden; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; background: linear-gradient(145deg, #597a3e, #28452c); color: #fff; font-size: 14px; font-weight: 800; }
.profile-collection-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-collection-player > strong { max-width: 150px; overflow: hidden; color: #f7f5fa; font-size: 11px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.profile-collection-balance { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.profile-collection-balance > span { color: #aaa9ae; font-size: 8px; font-weight: 700; }
.profile-collection-balance > strong { display: flex; align-items: center; gap: 4px; color: #fff; font-size: 11px; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.profile-collection-balance img { width: 14px; height: 14px; border-radius: 50%; }

.profile-identity {
  display: flex;
  min-height: 86px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 1px;
}

.profile-photo {
  display: grid;
  width: 70px;
  height: 70px;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.2);
  border-radius: 50%;
  background: linear-gradient(145deg, #597a3e, #28452c);
  color: white;
  font-size: 26px;
  font-weight: 800;
}

.profile-photo img { width: 100%; height: 100%; object-fit: cover; }
.profile-identity > strong { max-width: 100%; overflow: hidden; font-size: 16px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }

.profile-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.profile-stat-card {
  display: flex;
  min-height: 113px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.035);
  border-radius: 22px;
  background: linear-gradient(140deg, #242427, #19191b);
}

.profile-stat-icon { font-size: 18px; }
.profile-stat-label { color: #aaa9ae; font-size: 12px; font-weight: 700; }
.profile-stat-card > strong { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }

.profile-shortcuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.profile-inventory {
  display: flex;
  min-width: 0;
  min-height: 66px;
  align-items: center;
  padding: 7px;
  border: 1px solid rgba(255,255,255,.055);
  border-radius: 16px;
  background: linear-gradient(140deg, #242427, #19191b);
}

.profile-inventory-toggle { display: flex; width: 100%; min-width: 0; align-items: center; gap: 5px; padding: 0; border: 0; background: transparent; color: #fff; text-align: left; cursor: pointer; }
.profile-inventory-toggle:focus-visible { outline: 2px solid #81d7ff; outline-offset: 4px; border-radius: 8px; }
.profile-inventory-icon { flex: 0 0 auto; font-size: 16px; }
.profile-inventory-toggle-copy { display: flex; min-width: 0; flex: 1; align-items: center; gap: 3px; }
.profile-inventory-toggle-copy strong { overflow: hidden; font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.profile-inventory-count { flex: 0 0 auto; padding: 4px 5px; border-radius: 999px; background: #ed1760; color: #fff; font-size: 8px; font-weight: 900; line-height: 1; white-space: nowrap; }
.profile-inventory-toggle-arrow { flex: 0 0 auto; font-size: 17px; transition: transform .2s ease; }
.profile-inventory-toggle[aria-expanded="true"] .profile-inventory-toggle-arrow { transform: rotate(90deg); }
.profile-inventory-empty { margin: 0; color: #99979d; font-size: 10px; line-height: 1.5; }
.profile-inventory-refresh { align-self: flex-start; padding: 0; border: 0; background: transparent; color: #bdaaff; font: inherit; font-size: 9px; font-weight: 800; cursor: pointer; }
.profile-inventory-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.profile-inventory-item { display: flex; min-width: 0; flex-direction: column; align-items: stretch; gap: 6px; padding: 7px; overflow: hidden; border: 1px solid rgba(255,255,255,.07); border-radius: 13px; background: rgba(255,255,255,.045); color: #fff; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.profile-inventory-item:disabled { cursor: default; }
.profile-inventory-item:active { background: rgba(255,255,255,.09); }
.profile-inventory-item:focus-visible { outline: 2px solid #bdaaff; outline-offset: 2px; }
.profile-inventory-item-icon { display: block; width: 100%; aspect-ratio: 1; border-radius: 9px; background: rgba(255,255,255,.04); object-fit: contain; }
.profile-inventory-item-copy { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.profile-inventory-item-copy strong { overflow: hidden; font-size: 9px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.profile-inventory-item-copy small { overflow: hidden; color: #65e4b4; font-size: 9px; font-weight: 850; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 0 10px rgba(64,226,168,.2); }
.profile-inventory-item-status { display: inline-flex; min-width: 0; align-items: center; gap: 4px; overflow: hidden; color: #bcb9c4; font-size: 8px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.profile-inventory-item-status[hidden] { display: none; }
.profile-inventory-item-status--processing { color: #ffd45c; }
.profile-inventory-item-status--completed { color: #62dfa0; }
.profile-inventory-item-status .profile-gift-status-spinner { width: 9px; height: 9px; flex-basis: 9px; }
.profile-collection-view--gift-modal-open { z-index: 20; }
.profile-gift-modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; width: 100%; place-items: center; padding: 22px; background: rgba(5,5,8,.78); backdrop-filter: blur(8px); }
.profile-gift-modal-backdrop[hidden] { display: none; }
.profile-gift-modal { position: relative; display: flex; width: min(100%, 340px); max-height: 85vh; flex-direction: column; align-items: center; gap: 10px; padding: 22px 18px 18px; overflow-y: auto; border: 1px solid rgba(255,255,255,.1); border-radius: 22px; background: linear-gradient(150deg, #28282e, #17171b); box-shadow: 0 18px 60px rgba(0,0,0,.5); text-align: center; }
.profile-gift-modal-close { position: absolute; top: 8px; right: 8px; display: grid; width: 32px; height: 32px; place-items: center; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); color: #fff; font-size: 23px; cursor: pointer; }
.profile-gift-modal-image { width: min(58vw, 180px); aspect-ratio: 1; border-radius: 16px; background: rgba(255,255,255,.035); object-fit: contain; }
.profile-gift-modal h2 { max-width: 100%; margin: 0; overflow-wrap: anywhere; font-size: 16px; font-weight: 850; }
.profile-gift-modal-price { margin: 0; padding: 8px 13px; border: 1px solid rgba(75,226,170,.24); border-radius: 999px; background: rgba(25,154,111,.14); color: #77f0bd; font-size: 14px; font-weight: 900; font-variant-numeric: tabular-nums; box-shadow: 0 0 18px rgba(53,213,157,.08); }
.profile-gift-modal-status, .profile-gift-modal-message { margin: 0; color: #bdb9c6; font-size: 11px; line-height: 1.45; }
.profile-gift-modal-message { color: #ffd27b; }
.profile-gift-modal-actions { display: grid; width: 100%; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.profile-gift-modal-actions[hidden] { display: none; }
.profile-gift-modal-actions .profile-gift-action { min-height: 42px; font-size: 11px; }
.profile-gift-action { min-height: 32px; flex: 1; padding: 5px 7px; border: 1px solid rgba(255,255,255,.1); border-radius: 9px; color: #fff; font: inherit; font-size: 9px; font-weight: 800; cursor: pointer; }
.profile-gift-action--sell { border-color: rgba(58,210,161,.25); background: rgba(21,131,95,.26); }
.profile-gift-action--withdraw { border-color: rgba(151,119,255,.28); background: rgba(100,70,174,.28); }
.profile-gift-action:disabled { opacity: .5; cursor: not-allowed; }
.profile-gift-status { display: inline-flex; grid-column: 1 / -1; align-items: center; gap: 6px; color: #bcb9c4; font-size: 9px; font-weight: 700; }
.profile-gift-status--processing { color: #ffd45c; }
.profile-gift-status--completed { color: #62dfa0; }
.profile-gift-status-spinner { width: 11px; height: 11px; flex: 0 0 11px; border: 2px solid rgba(255,212,92,.28); border-top-color: #ffd45c; border-radius: 50%; animation: profile-gift-status-spin .8s linear infinite; }
@keyframes profile-gift-status-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .profile-gift-status-spinner { animation: none; } }

.profile-referrals {
  display: flex;
  min-width: 0;
  min-height: 66px;
  align-items: center;
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(255,255,255,.035);
  border-radius: 16px;
  background: linear-gradient(140deg, #242427, #19191b);
  color: #fff;
  text-align: left;
  cursor: pointer;
}

.profile-referral-icon { flex: 0 0 auto; font-size: 17px; }
.profile-referral-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 3px; }
.profile-referral-copy strong { overflow: hidden; font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.profile-referral-copy small { overflow: hidden; color: #aaa9ae; font-size: 8px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.profile-chevron { flex: 0 0 auto; font-size: 17px; line-height: 1; }

.profile-referral-note {
  margin: -5px 2px 0;
  color: #99979d;
  font-size: 10px;
  line-height: 1.5;
}

.avatar-profile-photo { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

.profile-view ~ .bottom-nav { z-index: 18; }

@media (max-width: 360px) {
  .profile-view { padding-right: 11px; padding-left: 11px; }
  .profile-stat-card { min-height: 105px; padding: 12px; }
  .profile-stat-card > strong { font-size: 14px; }
}
