.profile-details {
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
}

.profile-details[hidden] {
  display: none !important;
}

.profile-details__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  font-size: 0.8125rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.profile-details__row:last-child {
  border-bottom: none;
}

.profile-details__label {
  color: rgba(255, 255, 255, 0.55);
  font-weight: 600;
}

.profile-details__value {
  color: #fff;
  font-weight: 700;
  text-align: right;
}

/* Profile setup + team picker */
.profile-modal {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 24px);
}

.profile-modal[hidden] {
  display: none;
}

.profile-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(4px);
}

.profile-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 380px);
  max-height: min(92vh, 640px);
  overflow: auto;
  padding: clamp(1.5rem, 4vw, 2rem) clamp(1.35rem, 4vw, 1.75rem) 1.5rem;
  background: linear-gradient(180deg, #1a1a1a 0%, #121212 100%);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.profile-modal__close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.profile-modal__close:hover {
  background: rgba(212, 0, 0, 0.35);
  color: #fff;
}

.profile-modal__logout {
  display: block;
  width: 100%;
  margin: 0.15rem 0 0.5rem;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.profile-modal__logout:hover {
  border-color: var(--color-red);
  color: #fff;
}

.profile-modal__logout[hidden] {
  display: none;
}

.profile-modal__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 2.75rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  text-align: center;
  color: #fff;
  margin-bottom: 1.25rem;
}

.profile-modal__subtitle {
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  margin: -0.75rem 0 1rem;
  text-transform: lowercase;
}

.profile-avatar {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
  cursor: pointer;
}

.profile-avatar__stack {
  position: relative;
  display: inline-block;
  width: 120px;
  height: 120px;
}

.profile-avatar__circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.08);
}

.profile-avatar__circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar__plus {
  font-size: 2.5rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1;
}

.profile-avatar__team-badge {
  position: absolute;
  right: -4px;
  bottom: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: contain;
  background: #141414;
  border: 2px solid rgba(255, 255, 255, 0.35);
  padding: 4px;
  box-sizing: border-box;
  pointer-events: none;
}

.profile-avatar__team-badge[hidden] {
  display: none;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.profile-field--pick {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.profile-field__label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
  text-transform: capitalize;
}

.profile-field__input,
.profile-field__value {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.1rem;
  background: #2a2a2a;
  color: rgba(255, 255, 255, 0.9);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  outline: none;
}

.profile-field__value {
  display: block;
  color: rgba(255, 255, 255, 0.45);
}

.profile-field__value.is-selected {
  color: rgba(255, 255, 255, 0.88);
}

.profile-field__input:focus {
  box-shadow: 0 0 0 2px rgba(212, 0, 0, 0.45);
}

.profile-form__error {
  font-size: 0.75rem;
  font-weight: 600;
  color: #fecaca;
  text-align: center;
  margin-bottom: 0.75rem;
  padding: 0.45rem 0.65rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
}

.profile-form__error[hidden] {
  display: none;
}

.profile-form__success {
  font-size: 0.75rem;
  font-weight: 600;
  color: #86efac;
  text-align: center;
  margin-bottom: 0.75rem;
  padding: 0.45rem 0.65rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
}

.profile-form__success[hidden] {
  display: none;
}

.profile-password {
  margin-top: 1.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.profile-password__title {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 0.75rem;
  text-align: center;
}

.profile-password__submit {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 0.75rem 1rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.profile-password__submit:hover {
  border-color: var(--color-red);
  color: #fff;
}

.profile-password__submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

.profile-modal__dialog--edit {
  width: min(100%, 420px);
  max-height: min(94vh, 820px);
}

.profile-modal__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
}

.profile-modal__skip {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.5rem 0.25rem;
}

.profile-modal__save {
  flex: 1;
  max-width: 200px;
  margin-left: auto;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.5rem;
  background: var(--color-red);
  color: #fff;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.profile-modal__save:hover {
  filter: brightness(1.08);
}

.profile-modal__save:disabled {
  opacity: 0.65;
  cursor: wait;
}

.profile-modal__back {
  display: block;
  width: 100%;
  margin-top: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 0.65rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.profile-modal__dialog--picker {
  width: min(100%, 540px);
  max-height: min(94vh, 760px);
  padding: clamp(1.35rem, 3vw, 1.75rem) clamp(1.25rem, 3.5vw, 2rem) 1.35rem;
}

.profile-modal__dialog--picker .profile-league-list {
  max-height: min(68vh, 560px);
  gap: 0.65rem;
  padding-right: 0.15rem;
}

.profile-modal__dialog--picker .profile-league-item {
  padding: 0.8rem 1rem;
  font-size: 0.875rem;
  border-radius: 16px;
}

.profile-modal__dialog--picker .profile-league-item img {
  width: 44px;
  height: 44px;
}

.profile-modal__dialog--picker .profile-team-grid {
  max-height: min(68vh, 560px);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

.profile-league-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: min(50vh, 380px);
  overflow: auto;
}

.profile-league-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 0.65rem 0.85rem;
  background: #2a2a2a;
  color: #fff;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.profile-league-item:hover {
  background: #333;
}

.profile-league-item img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.profile-team-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  max-height: min(52vh, 400px);
  overflow: auto;
  padding: 0.15rem;
}

.profile-team-item {
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  background: #2a2a2a;
  padding: 0.55rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.profile-team-item:hover {
  transform: scale(1.04);
  box-shadow: 0 0 0 2px rgba(212, 0, 0, 0.45);
}

.profile-team-item.is-selected {
  box-shadow: 0 0 0 2px var(--color-red);
}

.profile-team-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.profile-view[hidden] {
  display: none;
}

.profile-crop__frame {
  width: 260px;
  height: 260px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  overflow: hidden;
  background: #1a1a1a;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
  touch-action: none;
  cursor: grab;
}

.profile-crop__frame.is-dragging {
  cursor: grabbing;
}

#profileCropCanvas {
  display: block;
  width: 260px;
  height: 260px;
}

.profile-crop__zoom {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.55);
}

.profile-crop__zoom input {
  flex: 1;
  accent-color: var(--color-red);
}

.profile-crop__pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.profile-crop__pad-row {
  display: flex;
  gap: 2.5rem;
}

.profile-crop__nudge {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: #2a2a2a;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.profile-crop__hint {
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 0.75rem;
}

.profile-modal__actions--crop {
  margin-top: 0.25rem;
}

body.profile-modal-open {
  overflow: hidden;
}

.auth-success {
  text-align: center;
  padding: 1.5rem 0.5rem 2rem;
}

.auth-success__icon {
  color: #4ade80;
  margin-bottom: 1rem;
}

.auth-success__title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.5rem;
}

.auth-success__text {
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.5;
}

@media (max-width: 520px) {
  .profile-modal__dialog--picker .profile-team-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 400px) {
  .profile-team-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
