.player-avatar {
  display: inline-block;
  flex: none;
  width: var(--avatar-size, 32px);
  height: var(--avatar-size, 32px);
  background: url('./player-portraits.webp') 0 0 / 800% 400% no-repeat;
  image-rendering: pixelated;
}
.player-avatar[data-uploaded] { background-position: center; background-size: 100% 100%; image-rendering: auto; }
.player-avatar.avatar-round { border-radius: 50%; }
.profile-dialog {
  --stage-panel-width: 650px;
  padding: 20px;
  overflow: auto;
}
.profile-dialog form { display: grid; gap: 10px; margin: 0; }
.profile-dialog header p { margin: 0 0 0 auto; color: var(--stage-mist); font-size: 12px; }
.profile-content { display: grid; grid-template-columns: clamp(96px, 24vw, 130px) minmax(0, 1fr); gap: 14px; }
.profile-preview {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  min-height: 108px; padding: 16px 10px;
  border: 1px solid #eed987; border-radius: 18px;
  background: var(--stage-selected); text-align: center;
}
.profile-preview strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-medallion {
  display: grid; place-items: center; width: 56px; height: 56px;
  border: 2px solid #fffdf7; border-radius: 50%; background: #fffdf7; box-shadow: 0 3px 8px #553e1e14;
}
.profile-medallion .player-avatar { width: 38px; height: 38px; }
.profile-fields, .profile-name-field { display: grid; gap: 4px; min-width: 0; }
.profile-fields { gap: 8px; align-content: start; }
.profile-name-field .profile-name-note { color: var(--stage-mist, #677087); font-size: 11px; }
.profile-name-field input[readonly] { opacity: .75; cursor: default; }
.profile-dialog fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.profile-dialog legend { margin-bottom: 4px; padding: 0; }
.profile-choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 8px;
  max-height: clamp(100px, calc(var(--stage-height) - 151px), 218px);
  padding: 2px 2px 4px;
  overflow: auto;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}
.profile-choice, .profile-file { position: relative; min-width: 0; }
.profile-choices input, .profile-file input {
  position: absolute; top: 50%; left: 50%; width: 1px; height: 1px; min-height: 0; margin: 0; padding: 0; opacity: 0; pointer-events: none;
}
.profile-choices label {
  box-sizing: border-box;
  display: grid;
  min-width: 0;
  height: 46px;
  place-items: center;
  border: 1px solid var(--stage-border);
  border-radius: 12px;
  background: var(--stage-tile);
  cursor: pointer;
}
.profile-file { margin-right: auto; }
.profile-upload {
  display: inline-flex; align-items: center; gap: 5px; min-height: 44px; padding-inline: 10px;
  border: 1px solid var(--stage-border); border-radius: 999px;
  background: var(--stage-tile); color: var(--stage-highlight); white-space: nowrap; cursor: pointer;
}
.profile-choices input:checked + label, .profile-upload[data-selected] { border: 2px solid #cfae24; background: var(--stage-selected); }
.profile-choices input:focus-visible + label, .profile-file input:focus-visible + label { outline: 2px solid var(--stage-highlight); outline-offset: -2px; }
.profile-dialog .profile-error { margin: 0; color: var(--stage-error); }
.profile-actions { display: flex; gap: 8px; justify-content: flex-end; }
.profile-dialog button { min-width: 88px; min-height: 44px; padding-inline: 12px; cursor: pointer; font: inherit; }
.profile-dialog button:disabled { opacity: .55; cursor: default; }
@media (max-height: 350px) {
  .profile-dialog { padding: 12px 14px; }
  .profile-preview { min-height: 80px; padding-block: 4px 8px; }
  .profile-medallion { width: 46px; height: 46px; }
  .profile-medallion .player-avatar { width: 32px; height: 32px; }
}
