.profile-screen {
  width: var(--mobile-panel-width);
  max-width: 100%;
  min-width: 0;
  display: grid;
  gap: 12px;
  margin: 0 auto;
  padding: 8px 0 18px;
}

.app-top-bar--profile .top-bar__tile-title {
  --tile-title-size: 30px;
  --tile-title-height: 37px;
  --tile-title-gap: 3px;
  --tile-title-word-gap: 10px;
  --tile-title-font-size: 1.16rem;
}

.profile-screen > * {
  min-width: 0;
  max-width: 100%;
}

.profile__header {
  display: grid;
  min-width: 0;
  align-items: center;
  justify-items: center;
  gap: 7px;
  padding: 18px 16px 16px;
  border-radius: var(--radius-panel);
  background: var(--surface-panel);
  border: var(--surface-border);
  box-shadow: var(--shadow-game-panel);
  text-align: center;
}

.profile__avatar {
  position: relative;
  width: clamp(92px, 28vw, 130px);
  height: clamp(92px, 28vw, 130px);
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
}

.profile__avatar--editable {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 140ms ease, filter 140ms ease;
}

.profile__avatar--editable:active {
  transform: scale(.97);
}

.profile__avatar .avatar--xl {
  width: 100%;
  height: 100%;
  box-shadow: var(--brand-tile-shadow);
}

.profile__avatar .avatar--picture {
  width: 100%;
  height: 100%;
}

.profile__level-badge {
  position: absolute;
  right: 0;
  bottom: 1px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--gradient-secondary);
  color: #fff;
  border: 3px solid rgba(255,255,255,.92);
  box-shadow: 0 8px 16px rgba(42, 63, 98, .18), inset 0 3px 0 rgba(255,255,255,.3);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 900;
}

.profile__edit-cue {
  position: absolute;
  right: -5px;
  top: 4px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  color: #fff;
  border: 3px solid rgba(255,255,255,.92);
  box-shadow: 0 8px 16px rgba(42, 63, 98, .18), inset 0 3px 0 rgba(255,255,255,.26);
}

.profile__edit-cue .app-icon {
  width: 17px;
  height: 17px;
}

.profile__name-button {
  max-width: 100%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.profile__name-button:active {
  transform: scale(.98);
}

.profile__name {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
  color: #1d2a41;
  font-family: var(--font-heading);
  font-size: clamp(1.55rem, 7vw, 2.3rem);
  font-weight: 900;
  line-height: 1;
}

.profile__name-edit-cue {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,.76);
  color: #526079;
  box-shadow: inset 0 -2px 0 rgba(36, 51, 70, .08);
}

.profile__name-edit-cue .app-icon {
  width: 15px;
  height: 15px;
}

.profile__discriminator {
  max-width: 100%;
  min-width: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.68);
  color: #435371;
  box-shadow: inset 0 -2px 0 rgba(36, 51, 70, .06);
  font-family: var(--font-heading);
  font-size: .82rem;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
}

.profile__rank {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  max-width: 100%;
  min-width: 0;
  margin-top: 2px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: rgba(255, 244, 173, .86);
  color: #754414;
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}

.profile__rank-icon,
.profile__guest-banner-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.profile__rank-icon .app-icon,
.profile__guest-banner-icon .app-icon {
  width: 18px;
  height: 18px;
}

.profile__xp-bar {
  width: 100%;
  max-width: min(100%, 22.5rem);
  margin-top: 8px;
}

.profile__xp-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  color: #435371;
  font-size: var(--text-xs);
  font-weight: 800;
}

.profile__xp-label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.profile__stat {
  min-width: 0;
  min-height: 116px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 13px 10px 12px;
  border-radius: var(--radius-control);
  background: var(--surface-card-strong);
  border: var(--surface-border);
  box-shadow: var(--shadow-game-control);
  text-align: center;
}

.profile__stat--action {
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease;
}

.profile__stat--action:active {
  transform: scale(.98);
}

.profile__stat--action:hover {
  filter: brightness(1.03);
}

.profile__stat-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-icon-badge);
  background: var(--gradient-action-alt);
  border: 2px solid var(--brand-tile-border);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.26);
}

.profile__stat-icon .app-icon {
  width: 18px;
  height: 18px;
  color: #fff8db;
}

.profile__stat-value {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1d2a41;
  font-family: var(--font-heading);
  font-size: clamp(1.35rem, 6vw, 2rem);
  font-weight: 900;
  line-height: .98;
}

.profile__stat-label {
  max-width: 100%;
  min-width: 0;
  margin-top: 2px;
  color: #455774;
  font-family: var(--font-heading);
  font-size: .76rem;
  font-weight: 900;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.profile__iq-card {
  padding: var(--space-lg);
  border-radius: var(--radius-panel);
  background: var(--gradient-dark);
  color: #fff;
  box-shadow: var(--shadow-game-panel);
  text-align: center;
}

.profile__iq-label {
  font-size: var(--text-sm);
  opacity: .88;
}

.profile__iq-value {
  margin: var(--space-sm) 0;
  font-size: var(--text-4xl);
  font-weight: 900;
}

.profile__iq-rank {
  font-size: var(--text-sm);
  opacity: .88;
}

.profile__section-title {
  margin: 6px 0 0;
  color: #1d2a41;
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 900;
}

.profile__history-list {
  overflow: hidden;
  border-radius: var(--radius-panel);
  background: var(--surface-panel);
  border: var(--surface-border);
  box-shadow: var(--shadow-game-panel);
}

.profile__history-item {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: var(--space-md);
  border-bottom: 1px solid rgba(36, 51, 70, .08);
}

.profile__history-item > div:first-child,
.profile__history-right {
  min-width: 0;
}

.profile__history-item:last-child {
  border-bottom: 0;
}

.profile__history-mode {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1d2a41;
  font-size: var(--text-sm);
  font-weight: 900;
}

.profile__history-date {
  color: #526079;
  font-size: var(--text-xs);
  font-weight: 700;
}

.profile__history-score {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #166b9a;
  font-family: var(--font-heading);
  font-weight: 900;
}

.profile__history-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 0 1 auto;
}

.profile__history-arrow {
  color: #526079;
  font-size: var(--text-xl);
  line-height: 1;
}

.profile__history-item--clickable {
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.profile__history-item--clickable:active {
  background: rgba(255,255,255,.38);
  transform: scale(.99);
}

.profile-word-stats {
  width: min(100%, 34rem);
  max-height: min(68vh, 38rem);
  overflow-y: auto;
  padding-right: 2px;
}

.profile-word-stats__list {
  display: grid;
  gap: 10px;
}

.profile-word-stats__row {
  display: grid;
  gap: 7px;
  padding: 12px;
  border-radius: var(--radius-control);
  background: rgba(255,255,255,.78);
  box-shadow: inset 0 -3px 0 rgba(36, 51, 70, .08);
}

.profile-word-stats__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.profile-word-stats__language {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.profile-word-stats__code {
  flex: 0 0 auto;
  min-width: 34px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(45, 198, 161, .16);
  color: #166b5a;
  font-family: var(--font-heading);
  font-size: .78rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.profile-word-stats__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1d2a41;
  font-family: var(--font-heading);
  font-size: .98rem;
  font-weight: 900;
  white-space: nowrap;
}

.profile-word-stats__count {
  flex: 0 0 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #21314a;
  font-family: var(--font-heading);
  font-size: clamp(.82rem, 3.4vw, .96rem);
  font-weight: 900;
  white-space: nowrap;
}

.profile-word-stats__bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(49, 69, 100, .12);
  box-shadow: inset 0 1px 2px rgba(36, 51, 70, .12);
}

.profile-word-stats__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2dc6a1, #1b9bd7);
}

.profile-word-stats__percent {
  justify-self: end;
  color: #526079;
  font-size: .76rem;
  font-weight: 900;
}

.profile__actions,
.profile__friend-action {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  min-width: 0;
}

.profile__actions .btn,
.profile__friend-action .btn {
  min-width: min(100%, 9.5rem);
  flex: 1 1 9.5rem;
}

.profile__back {
  margin-top: var(--space-lg);
}

.profile-edit-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.profile-avatar-modal {
  display: grid;
  gap: var(--space-md);
}

.profile-avatar-picker {
  display: grid;
  gap: 10px;
  margin-top: var(--space-md);
}

.profile-avatar-picker__label {
  margin-bottom: 0;
}

.profile-avatar-picker__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.profile-avatar-choice {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  padding: 4px;
  border-radius: var(--radius-icon-badge);
  background: rgba(255,255,255,.68);
  border: 3px solid transparent;
  box-shadow: inset 0 -2px 0 rgba(36, 51, 70, .08), 0 8px 16px rgba(42, 63, 98, .1);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.profile-avatar-choice .avatar__image {
  border-radius: 50%;
}

.profile-avatar-choice--custom {
  color: #2f5f77;
}

.profile-avatar-choice__upload {
  display: grid;
  place-items: center;
  width: 74%;
  height: 74%;
  border-radius: 50%;
  background: linear-gradient(135deg, #dcfbff, #fff1a8);
  border: 3px solid rgba(255,255,255,.86);
  box-shadow: inset 0 -4px 0 rgba(36, 51, 70, .08);
}

.profile-avatar-choice__upload .app-icon {
  width: 42%;
  height: 42%;
}

.profile-avatar-picker__file {
  display: none;
}

.profile-avatar-choice--active {
  border-color: #fff5a8;
  box-shadow:
    0 0 0 4px rgba(255, 245, 168, .38),
    inset 0 -2px 0 rgba(36, 51, 70, .08),
    0 12px 22px rgba(42, 63, 98, .16);
}

.profile-avatar-choice:active {
  transform: scale(.96);
}

.profile__guest-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-panel);
  background: rgba(255, 248, 225, .88);
  border: 1px solid rgba(255, 224, 130, .9);
  box-shadow: var(--shadow-game-control);
  text-align: center;
  min-width: 0;
}

.profile__guest-banner-text {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  min-width: 0;
  max-width: 100%;
  color: #435371;
  font-size: var(--text-sm);
  font-weight: 800;
}

.profile__guest-banner-text span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (min-width: 640px) {
  .app-top-bar--profile .top-bar__tile-title {
    --tile-title-size: 30px;
    --tile-title-height: 37px;
    --tile-title-gap: 4px;
    --tile-title-word-gap: 11px;
    --tile-title-font-size: 1.18rem;
  }

  .profile-screen {
    padding: 12px 0 24px;
  }

  .profile__name {
    font-size: clamp(2rem, 4vw, 2.6rem);
  }

  .profile__stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-md);
  }

  .profile__stat-value {
    font-size: clamp(1.55rem, 3vw, 2.25rem);
  }

  .profile__stat-label {
    font-size: .86rem;
  }

  .profile__iq-card {
    padding: var(--space-xl);
  }

  .profile__iq-value {
    font-size: var(--text-5xl);
  }

  .profile__history-mode {
    font-size: var(--text-base);
  }
}

@media (min-width: 1024px) {
  .profile-screen {
    padding: 14px 0 28px;
  }

  .profile__avatar {
    width: 140px;
    height: 140px;
  }

  .profile__level-badge {
    width: 38px;
    height: 38px;
    font-size: var(--text-sm);
  }
}
