.account-chip .brain-avatar-art {
  display: block;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #33233e;
}

#dialog.profile-dialog {
  width: calc(100% - 28px);
  max-width: 640px;
  max-height: min(88dvh, 810px);
  padding: 0;
  background: #17121f;
  border: 1px solid #523d66;
  overscroll-behavior: contain;
}
.profile-dialog .dialog-head {
  position: sticky;
  z-index: 2;
  top: 0;
  margin: 0;
  padding: 14px 20px;
  border-bottom: 1px solid #382a46;
  background: #1a1422;
}
.player-profile { padding: 18px 20px 24px; }
.profile-nav {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid #382a46;
  border-radius: 14px;
  background: #120e1a;
}
.profile-nav button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #bfb2cd;
  font-size: 13px;
  font-weight: 700;
}
.profile-nav button[aria-pressed="true"] {
  background: #352549;
  color: #f7edff;
  border-color: #654681;
}
.profile-count {
  min-width: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #d1aafa;
  color: #21142f;
  font-size: 10px;
}
.profile-hero {
  display: grid;
  grid-template-columns: minmax(150px, .9fr) minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
  min-height: 230px;
  border: 1px solid #5b4274;
  border-radius: 20px;
  background: radial-gradient(ellipse at 23% 35%, #492d61 0%, #24192f 56%, #191323 100%);
}
.profile-brain-portrait { min-width: 0; }
.profile-brain-portrait .personal-brain { display: block; width: 100%; }
.profile-identity { min-width: 0; padding: 18px 22px 18px 4px; }
.profile-arena { color: #d4a9f4; font-size: 11px; font-weight: 750; }
.profile-identity h3 { margin: 5px 0 8px; font-size: clamp(22px, 4vw, 35px); letter-spacing: -.035em; overflow-wrap: anywhere; }
.profile-handle { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 10px; color: #c8bbd1; }
.profile-handle code { font-size: 12px; overflow-wrap: anywhere; }
.profile-handle button { color: #dab9f8; min-height: 24px; }
.profile-brain-level {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid #563d67;
  font-size: 12px;
}
.profile-brain-level b { color: #edcfff; font-size: 19px; white-space: nowrap; }
.profile-brain-level small { font-size: 11px; font-weight: 550; color: #b4a2c0; }
.profile-identity progress {
  display: block;
  appearance: none;
  width: 100%;
  height: 6px;
  margin-top: 5px;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: #362944;
}
.profile-identity progress::-webkit-progress-bar { background: #362944; }
.profile-identity progress::-webkit-progress-value { background: #c296ee; }
.profile-identity progress::-moz-progress-bar { background: #c296ee; }
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  margin: 13px 0 0;
  border: 1px solid #423251;
  border-radius: 13px;
  background: #1c1625;
}
.profile-stats > div { padding: 10px 9px; text-align: center; }
.profile-stats > div + div { border-left: 1px solid #423251; }
.profile-stats dt { color: #bdb0cb; font-size: 11px; }
.profile-stats dd { margin: 0; font-size: clamp(17px,4vw,23px); font-weight: 800; font-variant-numeric: tabular-nums; }
.profile-stats dd small { font-size: 11px; color: #d5aefa; }
.friend-discovery, .profile-account {
  padding: 16px;
  border: 1px solid #493858;
  border-radius: 15px;
  background: #21172b;
}
.friend-discovery h3, .profile-account h3 { margin-bottom: 9px; font-size: 18px; }
#friend-request-form label { color: #c2b5ce; font-size: 12px; }
.friend-search-field { display: flex; gap: 8px; align-items: stretch; margin-top: 4px; }
.friend-search-field input { min-width: 0; min-height: 43px; font-size: 14px; }
.friend-search-field button { flex: 0 0 auto; min-height: 43px; padding: 6px 13px; font-size: 12px; }
.friend-invite-entry { margin-top: 13px; border-top: 1px solid #463452; }
.friend-invite-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 44px; padding: 6px 0; border: 0; background: transparent; color: #dfbbff; font-weight: 700; font-size: 13px; text-align: left; }
.friend-invite-trigger:hover { color: #f4e2ff; }
.friend-invite-details { display: grid; gap: 8px; padding-top: 3px; }
.friend-invite-details[hidden], .friend-invite-actions button[hidden] { display: none; }
.friend-invite-details p { color: #c2b5ce; font-size: 12px; }
.friend-invite-details input { width: 100%; min-width: 0; font-size: 12px; }
.friend-invite-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.friend-invite-actions button { min-height: 42px; padding: 6px 11px; font-size: 12px; }
.friend-feedback:empty { display: none; }
.friend-feedback { margin-top: 8px; color: #bfe6cf; font-size: 12px; }
.friend-feedback[data-error="true"] { color: #ffadba; }
.friend-section { margin-top: 17px; }
.friend-section h3 { margin: 0 0 8px; font-size: 15px; }
.friend-section h3 > span { margin-left: 3px; color: #d9aef8; font-size: 11px; }
.friend-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.friend-row {
  display: grid;
  grid-template-columns: 38px minmax(0,1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 9px;
  border: 1px solid #42334f;
  border-radius: 12px;
  background: #1d1627;
}
.friend-avatar { border: 1px solid #694d83; border-radius: 10px; background: #30213e; }
.friend-avatar .brain-avatar-art { display: block; width: 100%; }
.friend-identity { display: grid; gap: 1px; overflow-wrap: anywhere; line-height: 1.3; }
.friend-identity b { font-size: 13px; }
.friend-identity > span, .friend-identity small { color: #c2b3cd; font-size: 11px; }
.friend-actions { display: flex; gap: 5px; flex-wrap: wrap; justify-content: end; }
.friend-actions button { min-height: 34px; border-radius: 7px; padding: 4px 7px; font-size: 11px; font-weight: 700; }
.friend-primary { border: 1px solid #d3b0f9; background: #cba5f0; color: #211331; }
.friend-secondary { border: 1px solid #594268; background: #2a2034; color: #e7d8ed; }
.friend-empty, .profile-muted { color: #bfb1cc; font-size: 12px; }
.friend-empty { padding: 16px; border: 1px dashed #544161; border-radius: 12px; }
#profile-friends-data > .profile-muted { margin-top: 12px; }
.profile-account .logout-button { margin-top: 16px; min-height: 42px; }
@media (max-width: 500px) {
  #dialog.profile-dialog { max-height: 91dvh; }
  .profile-dialog .dialog-head { padding-inline: 13px; }
  .player-profile { padding: 12px 12px 18px; }
  .profile-hero { grid-template-columns: minmax(88px,.75fr) minmax(0,1fr); min-height: 175px; }
  .profile-identity { padding: 12px 10px 12px 3px; }
  .profile-brain-level { margin-top: 8px; font-size: 11px; }
  .friend-discovery, .profile-account { padding: 11px; }
  .friend-search-field { flex-wrap: wrap; }
  .friend-search-field input { flex: 1 1 130px; width: auto; }
  .friend-actions { max-width: 100px; }
}
@media (max-width: 365px) {
  .friend-row { grid-template-columns: 33px minmax(0,1fr); gap: 7px; }
  .friend-actions { grid-column: 2; justify-content: start; max-width: none; }
}

.profile-stats{grid-template-columns:repeat(4,minmax(0,1fr))}
@media(max-width:480px){.profile-stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}.profile-stats>div+div{border-left:0}.profile-stats>div{border:1px solid #423251;border-radius:9px}.friend-identity small{overflow-wrap:anywhere}}
