def parse_games(text: str):
    lines = [line.strip() for line in text.splitlines() if line.strip()]
    games = []

    for line in lines:

        # ignora basquete
        if "NBA" in line.upper() or "BASQUETE" in line.upper():
            break

        # procura horário
        m = re.search(r"(\d{1,2}:\d{2})", line)
        if not m:
            continue

        time_str = m.group(1)

        # pega tudo depois do horário
        rest = line.split(time_str, 1)[-1].strip()

        # limpa lixo pesado
        rest = re.sub(r"[^a-zA-ZÀ-ÿ0-9\s\(\)]", " ", rest)
        rest = re.sub(r"\s{2,}", " ", rest)

        # força separador
        rest = rest.replace(" X ", " x ").replace(" x ", " x ")

        # tenta separar
        if " x " in rest:
            home, away = rest.split(" x ", 1)

        else:
            # fallback: divide no meio
            parts = rest.split()
            if len(parts) < 2:
                continue

            mid = len(parts) // 2
            home = " ".join(parts[:mid])
            away = " ".join(parts[mid:])

        home = clean_team_name(home)
        away = clean_team_name(away)

        # valida
        if len(home) < 3 or len(away) < 3:
            continue

        games.append((time_str, home, away))

    # remove duplicados
    unique = []
    seen = set()
    for g in games:
        if g not in seen:
            unique.append(g)
            seen.add(g)

    # ordena
    unique.sort(key=lambda x: x[0])
    return unique