Authorities urged people to stay cool as extreme heat threatened power grids, outdoor celebrations and World Cup matches.